Add generic DMA DT binding support
Subsystems (3)
v4 cover Add generic DMA DT binding support
Changes since V3:
- Make dma-cells property optional as suggested by Rob Herring
- Add dma-requests and dma-channels properties to DMA controller as suggested by Arnd for future-proof
- Add Acked-by for some of the patches
Changes since V2:
- Add new filter function for DT case as suggested by Arnd
- Add xlate as static function
- Use newly added filter function in xlate.
- Add Acked-by for some of the patches
Changes since V1:
- Address the review comments by Arnd Bergmann as below
- Wording of the properties.
- Pass pdmac as third parameter to of_dma_controller_register
- Filter the dma channel based on channel number and dma_device
This patch set adds support for generic dma device tree bindings for Samsung platforms and is dependent on the following patches from Vinod Koul next branch
1)of: Add generic device tree DMA helpers
2)dmaengine: add helper function to request a slave DMA channel
This patch set is made based on Vinod Koul next branch
Padmavathi Venna (4):
DMA: PL330: Add new pl330 filter for DT case.
DMA: PL330: Add xlate function
DMA: PL330: Register the DMA controller with the generic DMA helpers
ARM: dts: pl330: Add #dma-cells for generic dma binding support
.../devicetree/bindings/dma/arm-pl330.txt | 21 +++++-- arch/arm/boot/dts/exynos5250.dtsi | 12 ++++ drivers/dma/pl330.c | 64 +++++++++++++++---- 3 files changed, 78 insertions(+), 19 deletions(-)
Signature · 1 line
1.7.4.4
PATCH v4 1/4 DMA: PL330: Add new pl330 filter for DT case.
This patch adds a new pl330_dt_filter for DT case to filter the required channel based on the new filter params and modifies the old filter only for non-DT case as suggested by Arnd Bergmann.
--- drivers/dma/pl330.c | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-)
drivers/dma/pl330.c +15 -14
@@ -606,6 +606,11 @@ struct dma_pl330_desc {struct dma_pl330_chan *pchan; }; +struct dma_pl330_filter_args { +struct dma_pl330_dmac *pdmac; +unsigned int chan_id; +}; +static inline void _callback (struct pl330_req *r,enum pl330_op_err err) {if (r && r->xfer_cb)
@@ -2352,6 +2357,16 @@ static void dma_pl330_rqcb(void *token, enum pl330_op_err err)tasklet_schedule (&pch->task); } +static bool pl330_dt_filter (struct dma_chan *chan,void *param) +{ +struct dma_pl330_filter_args *fargs = param; + +if (chan->device != &fargs->pdmac->ddma) +return false; + +return (chan->chan_id == fargs->chan_id); +} +bool pl330_filter (struct dma_chan *chan,void *param) {u8 *peri_id;
@@ -2359,20 +2374,6 @@ bool pl330_filter(struct dma_chan *chan, void *param)if (chan->device->dev->driver != &pl330_driver.drv)return false; -#ifdef CONFIG_OF -if (chan->device->dev->of_node) { -const __be32 *prop_value; -phandle phandle; -struct device_node *node; - - prop_value = ((struct property *)param)->value; - phandle =be32_to_cpup (prop_value++); - node =of_find_node_by_phandle (phandle); -return ((chan->private == node) && - (chan->chan_id ==be32_to_cpup (prop_value))); - } -#endif - peri_id = chan->private;return *peri_id == (unsigned )param; }
Signature · 1 line
1.7.4.4
PATCH v4 2/4 DMA: PL330: Add xlate function
In reply to Padmavathi VennaAdd xlate to translate the device-tree binding information into the appropriate format. The filter function requires the dma controller device and dma channel number as filter_params.
--- drivers/dma/pl330.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/dma/pl330.c +25 -0
@@ -25,6 +25,7 @@#include <linux/amba/pl330.h> #include <linux/scatterlist.h> #include <linux/of.h> +#include <linux/of_dma.h> #include "dmaengine.h" #define PL330_MAX_CHAN 8
@@ -2379,6 +2380,30 @@ bool pl330_filter(struct dma_chan *chan, void *param) }EXPORT_SYMBOL (pl330_filter); +static struct dma_chan *of_dma_pl330_xlate (struct of_phandle_args *dma_spec, +struct of_dma *ofdma) +{ +int count = dma_spec->args_count; +struct dma_pl330_dmac *pdmac = ofdma->of_dma_data; +struct dma_pl330_filter_args fargs; +dma_cap_mask_t cap; + +if (!pdmac) +return NULL ; + +if (count !=1 ) +return NULL ; + + fargs.pdmac = pdmac; + fargs.chan_id = dma_spec->args[0 ]; + +dma_cap_zero (cap); +dma_cap_set (DMA_SLAVE , cap); +dma_cap_set (DMA_CYCLIC , cap); + +return dma_request_channel (cap, pl330_dt_filter, &fargs); +} +static int pl330_alloc_chan_resources (struct dma_chan *chan) {struct dma_pl330_chan *pch =to_pchan (chan);
Signature · 1 line
1.7.4.4
PATCH v4 3/4 DMA: PL330: Register the DMA controller with the generic DMA helpers
In reply to Padmavathi VennaThis patch registers the pl330 dma controller driver with the generic device tree dma helper functions.
--- drivers/dma/pl330.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/dma/pl330.c +10 -0
@@ -2995,6 +2995,14 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pi->pcfg.data_bus_width /8 , pi->pcfg.num_chan, pi->pcfg.num_peri, pi->pcfg.num_events); + ret =of_dma_controller_register (adev->dev.of_node, + of_dma_pl330_xlate, pdmac); +if (ret) { +dev_err (&adev->dev, +"unable to register DMA to the generic DT DMA helpers\n" ); + goto probe_err2; + } +return 0 ; probe_err2:
@@ -3015,6 +3023,8 @@ static int __devexit pl330_remove(struct amba_device *adev)if (!pdmac)return 0 ; +of_dma_controller_free (adev->dev.of_node); +amba_set_drvdata (adev,NULL );/* Idle the DMAC */
Signature · 1 line
1.7.4.4
PATCH v4 4/4 ARM: dts: pl330: Add #dma-cells for generic dma binding support
In reply to Padmavathi VennaThis patch adds #dma-cells property to PL330 DMA controller nodes for supporting generic dma dt bindings on samsung exynos5250 platform.
--- .../devicetree/bindings/dma/arm-pl330.txt | 21 +++++++++++++++---- arch/arm/boot/dts/exynos5250.dtsi | 12 +++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/dma/arm-pl330.txt +16 -5
@@ -10,7 +10,11 @@ Required properties: - interrupts: interrupt number to the cpu. Optional properties: -- dma-coherent : Present if dma operations are coherent + - dma-coherent : Present if dma operations are coherent + - #dma-cells: must be <1>. used to represent the number of integer + cells in the dmas property of client device. + - dma-channels: contains the total number of DMA channels supported by the DMAC + - dma-requests: contains the total number of DMA requests supported by the DMAC Example:
@@ -18,16 +22,23 @@ Example: compatible = "arm,pl330", "arm,primecell"; reg = <0x12680000 0x1000>; interrupts = <99>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; }; Client drivers (device nodes requiring dma transfers from dev-to-mem or -mem-to-dev) should specify the DMA channel numbers using a two-value pair +mem-to-dev) should specify the DMA channel numbers and dma channel names as shown below. [property name] = <[phandle of the dma controller] [dma request id]>; + [property name] = <[dma channel name]> where 'dma request id' is the dma request number which is connected - to the client controller. The 'property name' is recommended to be - of the form <name>-dma-channel. + to the client controller. The 'property name' 'dmas' and 'dma-names' + as required by the generic dma device tree binding helpers. The dma + names correspond 1:1 with the dma request ids in the dmas property. - Example: tx-dma-channel = <&pdma0 12>; + Example: dmas = <&pdma0 12 + &pdma1 11>; + dma-names = "tx", "rx";
arch/arm/boot/dts/exynos5250.dtsi +12 -0
@@ -280,24 +280,36 @@ compatible = "arm,pl330", "arm,primecell"; reg = <0x121A0000 0x1000>; interrupts = <0 34 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; }; pdma1: pdma@121B0000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x121B0000 0x1000>; interrupts = <0 35 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; }; mdma0: mdma@10800000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x10800000 0x1000>; interrupts = <0 33 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <1>; }; mdma1: mdma@11C10000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x11C10000 0x1000>; interrupts = <0 124 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <1>; }; };
Signature · 1 line
1.7.4.4
PATCH v4 4/4 ARM: dts: pl330: Add #dma-cells for generic dma binding support
Quoted 3 lines · Padmavathi Venna
This patch adds #dma-cells property to PL330 DMA controller nodes for supporting generic dma dt bindings on samsung exynos5250 platform.
Can you comment on the following thread?
https://lists.ozlabs.org/pipermail/devicetree-discuss/2013-February/028188.html
Describing DMA controllers is part of a wider problem of how to describe bus masters in DT.
The key problem is that nobody knows what subset of the bus hierarchy is accessed by a DMA controller (or something else) in its master role. Currently I think that the PCI-oriented standard bindings in the ePAPR specification are not adequate to describe arbitrary SoC platforms, but maybe I'm missing something or being too pessimistic...
The "what does a master see" problem is mostly independent of your DMA bindings, except that coherency is not specific to DMA controllers, and ideally we would describe that in a common way for all masters. (Also, in general most devices don't power up coherent -- configuration both in the peripheral and in the bus fabric may be needed before coherency is established).
Cheers
---Dave
Quoted 102 lines
Signed-off-by Padmavathi Venna <[email protected]>Acked-by Arnd Bergmann <[email protected]>--- .../devicetree/bindings/dma/arm-pl330.txt | 21 +++++++++++++++---- arch/arm/boot/dts/exynos5250.dtsi | 12 +++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/dma/arm-pl330.txt +16
-5@@ -10,7 +10,11 @@ Required properties: - interrupts: interrupt number to the cpu. Optional properties: -- dma-coherent : Present if dma operations are coherent + - dma-coherent : Present if dma operations are coherent + - #dma-cells: must be <1>. used to represent the number of integer + cells in the dmas property of client device. + - dma-channels: contains the total number of DMA channels supported by the DMAC + - dma-requests: contains the total number of DMA requests supported by the DMAC Example:@@ -18,16 +22,23 @@ Example: compatible = "arm,pl330", "arm,primecell"; reg = <0x12680000 0x1000>; interrupts = <99>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; }; Client drivers (device nodes requiring dma transfers from dev-to-mem or -mem-to-dev) should specify the DMA channel numbers using a two-value pair +mem-to-dev) should specify the DMA channel numbers and dma channel names as shown below. [property name] = <[phandle of the dma controller] [dma request id]>; + [property name] = <[dma channel name]> where 'dma request id' is the dma request number which is connected - to the client controller. The 'property name' is recommended to be - of the form <name>-dma-channel. + to the client controller. The 'property name' 'dmas' and 'dma-names' + as required by the generic dma device tree binding helpers. The dma + names correspond 1:1 with the dma request ids in the dmas property. - Example: tx-dma-channel = <&pdma0 12>; + Example: dmas = <&pdma0 12 + &pdma1 11>; + dma-names = "tx", "rx";arch/arm/boot/dts/exynos5250.dtsi +12
-0@@ -280,24 +280,36 @@ compatible = "arm,pl330", "arm,primecell"; reg = <0x121A0000 0x1000>; interrupts = <0 34 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; }; pdma1: pdma at 121B0000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x121B0000 0x1000>; interrupts = <0 35 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; }; mdma0: mdma at 10800000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x10800000 0x1000>; interrupts = <0 33 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <1>; }; mdma1: mdma at 11C10000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x11C10000 0x1000>; interrupts = <0 124 0>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <1>; }; };Signature · 7 lines
1.7.4.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Vinod Koul
Appliedv4 cover Add generic DMA DT binding support
In reply to Padmavathi VennaOn Thu, Feb 14, 2013 at 09:10:04AM +0530, Padmavathi Venna wrote:
Logically this should have been v5 :)
Applied all, thanks
--
~Vinod
Quoted 40 lines
Changes since V3:
- Make dma-cells property optional as suggested by Rob Herring
- Add dma-requests and dma-channels properties to DMA controller as suggested by Arnd for future-proof
- Add Acked-by for some of the patchesChanges since V2:
- Add new filter function for DT case as suggested by Arnd
- Add xlate as static function
- Use newly added filter function in xlate.
- Add Acked-by for some of the patchesChanges since V1:
- Address the review comments by Arnd Bergmann as below
- Wording of the properties.
- Pass pdmac as third parameter toof_dma_controller_register
- Filter the dma channel based on channel number anddma_deviceThis patch set adds support for generic dma device tree bindings for Samsung platforms and is dependent on the following patches from Vinod Koul next branch
1)of: Add generic device tree DMA helpers
2)dmaengine: add helper function to request a slave DMA channelThis patch set is made based on Vinod Koul next branch
Padmavathi Venna (4):
DMA: PL330: Add new pl330 filter for DT case.
DMA: PL330: Add xlate function
DMA: PL330: Register the DMA controller with the generic DMA helpers
ARM: dts: pl330: Add #dma-cells for generic dma binding support.../devicetree/bindings/dma/arm-pl330.txt | 21 +++++-- arch/arm/boot/dts/exynos5250.dtsi | 12 ++++ drivers/dma/pl330.c | 64 +++++++++++++++---- 3 files changed, 78 insertions(+), 19 deletions(-)Signature · 1 line
1.7.4.4