Skip to contentSkip to conversation

dma: Add Freescale eDMA engine driver support

PATCH Superseded Jingchang Lu 4 participants 10 messages Sep 18, 2013 – Dec 6, 2013

Subsystems (3)

v6 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 3/3 dma: Add Freescale eDMA engine driver support

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

---
changes in v6:
holding lock in dma_control to prevent race.

changes in v5:
config slave_id when dmaengine_slave_config intead of channel request. adding residue calculation and dma pause/resume device control.

changes in v4:
using exact compatible string in binding document.

changes in v3:
handle all pending interrupt one time.
add protect lock on dma transfer complete handling. change desc and tcd alloc flag to GFP_NOWAIT. add sanity check and error messages.

changes in v2:
using generic dma-channels property instead of fsl,dma-channel. rename the binding document to fsl-edma.txt.

 Documentation/devicetree/bindings/dma/fsl-edma.txt |  84 ++
 drivers/dma/Kconfig                                |  10 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/fsl-edma.c                             | 944 +++++++++++++++++++++
 4 files changed, 1039 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-edma.txt
 create mode 100644 drivers/dma/fsl-edma.c
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +84 -0
new file mode 100644
index 0000000..60a8cb2
@@ -0,0 +1,84 @@
+* Freescale enhanced Direct Memory Access(eDMA) Controller
+
+The eDMA engine deploys DMAMUXs routing request sources(slot) to
+eDMA controller channels.
+
+* eDMA Controller
+Required properties:
+- compatible :
+  - "fsl,vf610-edma" for eDMA used similar to that on Vybrid vf610 SoC
+- reg : Should contain eDMA registers location and length
+- interrupts : Should contain eDMA interrupt
+- interrupt-names : Should be "edma-tx" for tx interrupt and
+  "edma-err" for err interrupt
+- #dma-cells : Must be <2>.
+  The first cell specifies the DMAMUX ID. Specific request source
+  can only be routed by specific DMAMUXs.
+  the second cell specifies the request source(slot) ID.
+  See include/dt-bindings/dma/<soc>-edma.h for all the supported
+  request source IDs.
+- dma-channels : Number of channels supported by the controller
+- fsl,dma-mux : Phandle of the DMAMUXs deployed by the controller
+
+
+* DMAMUX
+Required properties:
+- reg : Should contain DMAMUX registers location and length
+- fsl,dmamux-id : DMAMUX ID. DMAMUX IDs are unique in each eDMA controller.
+  inside one eDMA controller, specific request source can only be routed by
+  one of its DMAMUXs.
+  However Specific request source may be routed to different eDMA controller,
+  thus all the DMAMUXs sharing a the same request sources have the same ID.
+- clocks : Phandle of the clock used by the DMAMUX
+- clock-names : The clock names
+
+Below is the eDMA controller and DMAMUX association, and DMAMUX IDs assignment
+On Vybrid vf610 SoC, DMAMUX0 and DMAMU3 share the same request source group,
+and DMAMUX1 and DMAMU2 share the same request source group.
+
+eDMA controller		DMAMUXs		DMAMUX ID
+-------------------------------------------------
+eDMA0			DMAMUX0		0
+			DMAMUX1		1
+
+eDMA1			DMAMUX2		1
+			DMAMUX3		0
+
+Examples:
+
+edma0: dma-controller at 40018000 {
+	#dma-cells = <2>;
+	compatible = "fsl,vf610-edma";
+	reg = <0x40018000 0x2000>;
+	interrupts = <0 8 0x04>, <0 9 0x04>;
+	interrupt-names = "edma-tx", "edma-err";
+	dma-channels = <32>;
+	fsl,edma-mux = <&dmamux0>, <&dmamux1>;
+};
+
+dmamux0: dmamux at 40024000 {
+	reg = <0x40024000 0x1000>;
+	fsl,dmamux-id = <0>;
+	clocks = <&clks VF610_CLK_DMAMUX0>;
+	clock-names = "dmamux";
+};
+
+
+* DMA clients
+DMA client drivers that uses the DMA function must use the format described
+in the dma.txt file, using a three-cell specifier for each channel: a phandle
+plus two integer cells as described above.
+
+Examples:
+
+sai2: sai at 40031000 {
+	compatible = "fsl,vf610-sai";
+	reg = <0x40031000 0x1000>;
+	interrupts = <0 86 0x04>;
+	clocks = <&clks VF610_CLK_SAI2>;
+	clock-names = "sai";
+	dma-names = "tx", "rx";
+	dmas = <&edma0 0 VF610_EDMA_MUXID0_SAI2_TX>,
+		<&edma0 0 VF610_EDMA_MUXID0_SAI2_RX>;
+	status = "disabled";
+};
drivers/dma/Kconfig +10 -0
index 526ec77..7d7604d 100644
@@ -317,6 +317,16 @@ config K3_DMA
 	  Support the DMA engine for Hisilicon K3 platform
 	  devices.
 
+config FSL_EDMA
+	tristate "Freescale eDMA engine support"
+	depends on OF
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  Support the Freescale eDMA engine with DMAMUXs managing route
+	  between request sources(slot) and eDMA engine channels.
+	  This module can be found on Freescale Vybrid and LS-1 SoCs.
+
 config DMA_ENGINE
 	bool
 
drivers/dma/Makefile +1 -0
index db89035..81f01ce 100644
@@ -41,3 +41,4 @@ obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o
 obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o
 obj-$(CONFIG_TI_CPPI41) += cppi41.o
 obj-$(CONFIG_K3_DMA) += k3dma.o
+obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
drivers/dma/fsl-edma.c new file +944 -0

944 lines not on this page · raw message

Signature · 1 line
1.8.0
#1 lore raw

Hi, Vinod,

Could you please help review this patch? Could it be merged into your next tree? Thanks!

Best Regards,
Jingchang

Quoted 46 lines

-----Original Message-----
From: Lu Jingchang-B35083
Sent: Wednesday, September 18, 2013 5:58 PM
To: vinod.koul at intel.com
Cc: shawn.guo at linaro.org; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org; devicetree at vger.kernel.org; Lu Jingchang- B35083; Wang Huan-B18965
Subject: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

---
changes in v6:
holding lock in dma_control to prevent race.

changes in v5:
config slave_id when dmaengine_slave_config intead of channel request. adding residue calculation and dma pause/resume device control.

changes in v4:
using exact compatible string in binding document.

changes in v3:
handle all pending interrupt one time.
add protect lock on dma transfer complete handling. change desc and tcd alloc flag to GFP_NOWAIT. add sanity check and error messages.

changes in v2:
using generic dma-channels property instead of fsl,dma-channel. rename the binding document to fsl-edma.txt.

 Documentation/devicetree/bindings/dma/fsl-edma.txt |  84 ++
 drivers/dma/Kconfig                                |  10 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/fsl-edma.c                             | 944
+++++++++++++++++++++
 4 files changed, 1039 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-edma.txt
 create mode 100644 drivers/dma/fsl-edma.c
#2 lore raw
Quoted 4 lines · On Thu, Oct 10, 2013 at 09:39:04AM +0000, Lu Jingchang-B35083 wrote:

Hi, Vinod,

Could you please help review this patch? Could it be merged into your next tree? Thanks!

Where is the patch 1 & 2 of the series, I dont sem to find it.
Also I need ACK from one of the DT maintainers on the binding before I can carry this

--
~Vinod

Quoted 53 lines

Best Regards,
Jingchang

Quoted 46 lines

-----Original Message-----
From: Lu Jingchang-B35083
Sent: Wednesday, September 18, 2013 5:58 PM
To: vinod.koul at intel.com
Cc: shawn.guo at linaro.org; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org; devicetree at vger.kernel.org; Lu Jingchang- B35083; Wang Huan-B18965
Subject: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

---
changes in v6:
holding lock in dma_control to prevent race.

changes in v5:
config slave_id when dmaengine_slave_config intead of channel request. adding residue calculation and dma pause/resume device control.

changes in v4:
using exact compatible string in binding document.

changes in v3:
handle all pending interrupt one time.
add protect lock on dma transfer complete handling. change desc and tcd alloc flag to GFP_NOWAIT. add sanity check and error messages.

changes in v2:
using generic dma-channels property instead of fsl,dma-channel. rename the binding document to fsl-edma.txt.

 Documentation/devicetree/bindings/dma/fsl-edma.txt |  84 ++
 drivers/dma/Kconfig                                |  10 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/fsl-edma.c                             | 944
+++++++++++++++++++++
 4 files changed, 1039 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-edma.txt
 create mode 100644 drivers/dma/fsl-edma.c
#3 lore raw

Hi, Rob,
Could you please help review the devicetree binding? Thanks!

Best Regards,
Jingchang

Quoted 78 lines

-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Thursday, October 10, 2013 11:44 PM
To: Lu Jingchang-B35083
Cc: shawn.guo at linaro.org; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org; devicetree at vger.kernel.org
Subject: Re: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Quoted 3 lines · On Thu, Oct 10, 2013 at 09:39:04AM +0000, Lu Jingchang-B35083 wrote:

Hi, Vinod,

Could you please help review this patch? Could it be merged into your

next tree?

Quoted 1 line

Thanks!

Where is the patch 1 & 2 of the series, I dont sem to find it. Also I need ACK from one of the DT maintainers on the binding before I can carry
this

--
~Vinod

Quoted 28 lines

Best Regards,
Jingchang

Quoted 22 lines

-----Original Message-----
From: Lu Jingchang-B35083
Sent: Wednesday, September 18, 2013 5:58 PM
To: vinod.koul at intel.com
Cc: shawn.guo at linaro.org; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org; devicetree at vger.kernel.org; Lu Jingchang- B35083; Wang Huan-B18965
Subject: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

---
changes in v6:
holding lock in dma_control to prevent race.

changes in v5:
config slave_id when dmaengine_slave_config intead of channel

request.

Quoted 16 lines
Quoted 16 lines

adding residue calculation and dma pause/resume device control.

changes in v4:
using exact compatible string in binding document.

changes in v3:
handle all pending interrupt one time.
add protect lock on dma transfer complete handling. change desc and tcd alloc flag to GFP_NOWAIT. add sanity check and error messages.

changes in v2:
using generic dma-channels property instead of fsl,dma-channel. rename the binding document to fsl-edma.txt.

Quoted 7 lines
Quoted 7 lines
 Documentation/devicetree/bindings/dma/fsl-edma.txt |  84 ++
 drivers/dma/Kconfig                                |  10 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/fsl-edma.c                             | 944
+++++++++++++++++++++
 4 files changed, 1039 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-

edma.txt

Quoted 2 lines
Quoted 1 line
 create mode 100644 drivers/dma/fsl-edma.c

--

#4 lore raw
In reply to Jingchang Lu
Quoted 44 lines · Jingchang Lu

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

---
changes in v6:
holding lock in dma_control to prevent race.

changes in v5:
config slave_id when dmaengine_slave_config intead of channel request. adding residue calculation and dma pause/resume device control.

changes in v4:
using exact compatible string in binding document.

changes in v3:
handle all pending interrupt one time.
add protect lock on dma transfer complete handling. change desc and tcd alloc flag to GFP_NOWAIT. add sanity check and error messages.

changes in v2:
using generic dma-channels property instead of fsl,dma-channel. rename the binding document to fsl-edma.txt.

 Documentation/devicetree/bindings/dma/fsl-edma.txt |  84 ++
 drivers/dma/Kconfig                                |  10 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/fsl-edma.c                             | 944 +++++++++++++++++++++
 4 files changed, 1039 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/fsl-edma.txt
 create mode 100644 drivers/dma/fsl-edma.c
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +1 -0
new file mode 100644
index 0000000..60a8cb2
@@ -0,0 +1,84 @@
+* Freescale enhanced Direct Memory Access(eDMA) Controller

Documentation/devicetree/bindings/dma/fsl-edma.txt line 11

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +10 -0
+
+The eDMA engine deploys DMAMUXs routing request sources(slot) to
+eDMA controller channels.
+
+* eDMA Controller
+Required properties:
+- compatible :
+  - "fsl,vf610-edma" for eDMA used similar to that on Vybrid vf610 SoC
+- reg : Should contain eDMA registers location and length
+- interrupts : Should contain eDMA interrupt

- interrupts: A list of interrupt-specifiers, one for each entry in interrupt-names.

Quoted 4 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +4 -0
+- interrupt-names : Should be "edma-tx" for tx interrupt and
+  "edma-err" for err interrupt
+- #dma-cells : Must be <2>.
+  The first cell specifies the DMAMUX ID. Specific request source

Documentation/devicetree/bindings/dma/fsl-edma.txt line 25

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +10 -0
+  can only be routed by specific DMAMUXs.
+  the second cell specifies the request source(slot) ID.
+  See include/dt-bindings/dma/<soc>-edma.h for all the supported
+  request source IDs.
+- dma-channels : Number of channels supported by the controller
+- fsl,dma-mux : Phandle of the DMAMUXs deployed by the controller
+
+
+* DMAMUX
+Required properties:

No compatible?

Where are DMAMUX nodes expected to live?

How to they relate to the eDMA controller in HW? Are they a subcomponent, or a logically separate unit that happens to be connected?

Documentation/devicetree/bindings/dma/fsl-edma.txt line 33

Quoted 8 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +8 -0
+- reg : Should contain DMAMUX registers location and length
+- fsl,dmamux-id : DMAMUX ID. DMAMUX IDs are unique in each eDMA controller.
+  inside one eDMA controller, specific request source can only be routed by
+  one of its DMAMUXs.
+  However Specific request source may be routed to different eDMA controller,
+  thus all the DMAMUXs sharing a the same request sources have the same ID.
+- clocks : Phandle of the clock used by the DMAMUX
+- clock-names : The clock names

_which_ clock names do you expect? From the looks of the example, you expect "dmamux".

Quoted 1 line

From the view of the DMAMUX, what is its clock input called? "dmamux"

doesn't look like what I'd expect for a clock name, but if the documentation for the eDMA doesn't provide a name for it, "dmamux" is fine.

If you're not using clock-names, it's useless. You _must_ define the set of names you expect or it's unusable. If you do define a set of names, then you should request clocks by name in the driver.

Quoted 27 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +27 -0
+
+Below is the eDMA controller and DMAMUX association, and DMAMUX IDs assignment
+On Vybrid vf610 SoC, DMAMUX0 and DMAMU3 share the same request source group,
+and DMAMUX1 and DMAMU2 share the same request source group.
+
+eDMA controller                DMAMUXs         DMAMUX ID
+-------------------------------------------------
+eDMA0                  DMAMUX0         0
+                       DMAMUX1         1
+
+eDMA1                  DMAMUX2         1
+                       DMAMUX3         0
+
+Examples:
+
+edma0: dma-controller at 40018000 {
+       #dma-cells = <2>;
+       compatible = "fsl,vf610-edma";
+       reg = <0x40018000 0x2000>;
+       interrupts = <0 8 0x04>, <0 9 0x04>;
+       interrupt-names = "edma-tx", "edma-err";
+       dma-channels = <32>;
+       fsl,edma-mux = <&dmamux0>, <&dmamux1>;
+};
+
+dmamux0: dmamux at 40024000 {
+       reg = <0x40024000 0x1000>;

Documentation/devicetree/bindings/dma/fsl-edma.txt line 70

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +10 -0
+       fsl,dmamux-id = <0>;
+       clocks = <&clks VF610_CLK_DMAMUX0>;
+       clock-names = "dmamux";
+};
+
+
+* DMA clients
+DMA client drivers that uses the DMA function must use the format described
+in the dma.txt file, using a three-cell specifier for each channel: a phandle
+plus two integer cells as described above.

Nit: the phandle isn't part of the specifier. The cells after the phandle are the specifier associated with the phandle.

[...]

Documentation/devicetree/bindings/dma/fsl-edma.txt

Quoted 8 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +8 -0
+static bool fsl_edma_filter_fn(struct dma_chan *chan, void *mux_id)
+{
+       struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
+
+       if (fsl_chan->edmamux->mux_id != (u32)mux_id)
+               return false;
+
+       return true;

Why not:

return fsl_chan->edmamux->mux_id == (u32)mux_id;

[...]

Documentation/devicetree/bindings/dma/fsl-edma.txt

Quoted 6 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +6 -0
+static int
+fsl_init_edmamux(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma)
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct fsl_edma_dmamux *fsl_edmamux;
+       struct device_node *phandle;

That's confusing, a node is not a phandle. Why not mux_np?

Documentation/devicetree/bindings/dma/fsl-edma.txt

Quoted 13 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +13 -0
+       const void *prop;
+       struct resource res;
+       int len, n_muxes, chans_per_mux, ch_off;
+       int i, j;
+       int ret;
+
+       prop = of_get_property(np, "fsl,dma-mux", &len);
+       if (!prop) {
+               dev_err(&pdev->dev, "Can't get DMAMUX.\n");
+               return -EINVAL;
+       }
+
+       n_muxes = len / sizeof(u32);

It would be nicer if we had a variant of of_count_phandle_with_args that cound handle a fixed count of 0 args for this sort of thing.

Quoted 12 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +12 -0
+       chans_per_mux = fsl_edma->n_chans / n_muxes;
+       fsl_edmamux = devm_kzalloc(&pdev->dev,
+                       sizeof(struct fsl_edma_dmamux) * n_muxes, GFP_KERNEL);
+       if (!fsl_edmamux)
+               return -ENOMEM;
+
+       fsl_edma->n_muxes = 0;
+       fsl_edma->edmamux = fsl_edmamux;
+       for (i = 0; i < n_muxes; i++) {
+               phandle = of_parse_phandle(np, "fsl,dma-mux", i);
+               ret = of_address_to_resource(phandle, 0, &res);
+               if (ret)

Documentation/devicetree/bindings/dma/fsl-edma.txt

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +10 -0
+                       return ret;
+               fsl_edmamux->membase = devm_ioremap_resource(&pdev->dev, &res);
+               if (IS_ERR(fsl_edmamux->membase))
+                       return PTR_ERR(fsl_edmamux->membase);
+
+               fsl_edmamux->clk = of_clk_get(phandle, 0);
+               if (IS_ERR(fsl_edmamux->clk)) {
+                       dev_err(&pdev->dev, "Missing DMAMUX clock.\n");
+                       return PTR_ERR(fsl_edmamux->clk);
+               }

Please acquire the clock by name:

fsl_edmamux->clk = of_clk_get_byname(phandle, "dmamux");

Documentation/devicetree/bindings/dma/fsl-edma.txt

Quoted 9 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +9 -0
+
+               ret = clk_prepare_enable(fsl_edmamux->clk);
+               if (ret) {
+                       dev_err(&pdev->dev, "DMAMUX clk enable failed.\n");
+                       return ret;
+               }
+
+               ret = of_property_read_u32_index(phandle, "fsl,dmamux-id", 0,
+                               &fsl_edmamux->mux_id);

Why not just of_property_read_u32?

Quoted 14 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +14 -0
+               if (ret) {
+                       dev_err(&pdev->dev, "Can't get dmamux-id.\n");
+                       return ret;
+               }
+
+               ch_off = fsl_edma->n_muxes * chans_per_mux;
+               for (j = 0; j < chans_per_mux; j++)
+                       fsl_edma->chans[ch_off + j].edmamux = fsl_edmamux;
+
+               fsl_edmamux++;
+               fsl_edma->n_muxes++;
+       }
+       return 0;
+}

[...]

Documentation/devicetree/bindings/dma/fsl-edma.txt

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +10 -0
+static int fsl_edma_probe(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct fsl_edma_engine *fsl_edma;
+       struct fsl_edma_chan *fsl_chan;
+       struct resource *res;
+       int len, chans;
+       int ret, i;
+
+       ret = of_property_read_u32_index(np, "dma-channels", 0, &chans);

Use of_property_read_u32.

Thanks,
Mark.

#5 lore raw
Quoted 19 lines

-----Original Message-----
From: Mark Rutland [mailto:mark.rutland at arm.com]
Sent: Thursday, November 14, 2013 6:46 PM
To: Lu Jingchang-B35083
Cc: vinod.koul at intel.com; devicetree at vger.kernel.org; Wang Huan-B18965; linux-kernel at vger.kernel.org; shawn.guo at linaro.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Quoted 7 lines · Jingchang Lu

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

[...]

Quoted 9 lines

Documentation/devicetree/bindings/dma/fsl-edma.txt line 25

Quoted 2 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +2 -0
+* DMAMUX
+Required properties:

No compatible?

Where are DMAMUX nodes expected to live?

How to they relate to the eDMA controller in HW? Are they a subcomponent, or a logically separate unit that happens to be connected?

[Lu Jingchang-b35083]
DMAMUX is a multiplexer between dma controller channels and peripheral deivces, each DMAMUX provides 16 independently selectable DMA channel routers, and each channel router can be assigned to one of the possible peripheral DMA slots. So it's not a standalone device, it's just required by the DMA controller to connect the channels and slaves, So it's got by DMA controller's "fsl,dma-mux" property. Thanks!

Quoted 17 lines
Quoted 3 lines
+- reg : Should contain DMAMUX registers location and length
+- fsl,dmamux-id : DMAMUX ID. DMAMUX IDs are unique in each eDMA

controller.

Quoted 1 line

+ inside one eDMA controller, specific request source can only be

routed by

Review

Quoted 2 lines
(quoted diff) +2 -0
+  one of its DMAMUXs.
+  However Specific request source may be routed to different eDMA

controller,

Quoted 1 line

+ thus all the DMAMUXs sharing a the same request sources have the

same ID.

Quoted 2 lines
+- clocks : Phandle of the clock used by the DMAMUX
+- clock-names : The clock names

_which_ clock names do you expect? From the looks of the example, you expect "dmamux".

Quoted 9 lines

From the view of the DMAMUX, what is its clock input called? "dmamux" doesn't look like what I'd expect for a clock name, but if the documentation for the eDMA doesn't provide a name for it, "dmamux" is fine.

If you're not using clock-names, it's useless. You _must_ define the set of names you expect or it's unusable. If you do define a set of names, then you should request clocks by name in the driver.

[Lu Jingchang-b35083] [Lu Jingchang-b35083]
The clock here is from the platform bus clock, I will remove this property for compatible between SoCs. Thanks!

Quoted 1 line
Quoted 1 line

+

[...]

Quoted 10 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+* DMA clients
+DMA client drivers that uses the DMA function must use the format

described

Quoted 1 line

+in the dma.txt file, using a three-cell specifier for each channel: a

phandle

Quoted 1 line

+plus two integer cells as described above.

Nit: the phandle isn't part of the specifier. The cells after the phandle are the specifier associated with the phandle.

[Lu Jingchang-b35083]
I will fix this, thanks!

Quoted 13 lines

[...]

drivers/dma/fsl-edma.c line 678

Quoted 8 lines
drivers/dma/fsl-edma.c new file +8 -0
+static bool fsl_edma_filter_fn(struct dma_chan *chan, void *mux_id)
+{
+       struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
+
+       if (fsl_chan->edmamux->mux_id != (u32)mux_id)
+               return false;
+
+       return true;

Why not:

Quoted 2 lines

return fsl_chan->edmamux->mux_id == (u32)mux_id;

[Lu Jingchang-b35083]
I will replace it, thanks!

Quoted 11 lines

[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int
+fsl_init_edmamux(struct platform_device *pdev, struct fsl_edma_engine

*fsl_edma)

drivers/dma/fsl-edma.c line 730

Quoted 4 lines
drivers/dma/fsl-edma.c new file +4 -0
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct fsl_edma_dmamux *fsl_edmamux;
+       struct device_node *phandle;

That's confusing, a node is not a phandle. Why not mux_np?

[Lu Jingchang-b35083]
Ok, I will eliminate the confusing, thanks!

Quoted 17 lines
Quoted 4 lines
drivers/dma/fsl-edma.c new file +3 -0
+       const void *prop;
+       struct resource res;
+       int len, n_muxes, chans_per_mux, ch_off;

drivers/dma/fsl-edma.c line 743

Quoted 10 lines
drivers/dma/fsl-edma.c new file +10 -0
+       int i, j;
+       int ret;
+
+       prop = of_get_property(np, "fsl,dma-mux", &len);
+       if (!prop) {
+               dev_err(&pdev->dev, "Can't get DMAMUX.\n");
+               return -EINVAL;
+       }
+
+       n_muxes = len / sizeof(u32);

It would be nicer if we had a variant of of_count_phandle_with_args that cound handle a fixed count of 0 args for this sort of thing.

[Lu Jingchang-b35083]
Yes, I will do it, thanks!

Quoted 26 lines

drivers/dma/fsl-edma.c

Quoted 4 lines
drivers/dma/fsl-edma.c new file +3 -0
+       chans_per_mux = fsl_edma->n_chans / n_muxes;
+       fsl_edmamux = devm_kzalloc(&pdev->dev,
+                       sizeof(struct fsl_edma_dmamux) * n_muxes,

GFP_KERNEL);

drivers/dma/fsl-edma.c

Quoted 11 lines
drivers/dma/fsl-edma.c new file +11 -0
+       if (!fsl_edmamux)
+               return -ENOMEM;
+
+       fsl_edma->n_muxes = 0;
+       fsl_edma->edmamux = fsl_edmamux;
+       for (i = 0; i < n_muxes; i++) {
+               phandle = of_parse_phandle(np, "fsl,dma-mux", i);
+               ret = of_address_to_resource(phandle, 0, &res);
+               if (ret)
+                       return ret;
+               fsl_edmamux->membase = devm_ioremap_resource(&pdev->dev,

&res);

drivers/dma/fsl-edma.c line 765

Quoted 8 lines
drivers/dma/fsl-edma.c new file +8 -0
+               if (IS_ERR(fsl_edmamux->membase))
+                       return PTR_ERR(fsl_edmamux->membase);
+
+               fsl_edmamux->clk = of_clk_get(phandle, 0);
+               if (IS_ERR(fsl_edmamux->clk)) {
+                       dev_err(&pdev->dev, "Missing DMAMUX clock.\n");
+                       return PTR_ERR(fsl_edmamux->clk);
+               }
Quoted 1 line

Please acquire the clock by name:

[Lu Jingchang-b35083]
I will remove the node name property for reuse the driver between SoCs, for they may have different clock names. Thanks!

Quoted 16 lines

fsl_edmamux->clk = of_clk_get_byname(phandle, "dmamux");

drivers/dma/fsl-edma.c

Quoted 4 lines
drivers/dma/fsl-edma.c new file +4 -0
+
+               ret = clk_prepare_enable(fsl_edmamux->clk);
+               if (ret) {
+                       dev_err(&pdev->dev, "DMAMUX clk enable

failed.\n");

drivers/dma/fsl-edma.c

Quoted 4 lines
drivers/dma/fsl-edma.c new file +4 -0
+                       return ret;
+               }
+
+               ret = of_property_read_u32_index(phandle, "fsl,dmamux-

id", 0,

Quoted 1 line

+ &fsl_edmamux->mux_id);

Why not just of_property_read_u32?

[...]

Quoted 13 lines

drivers/dma/fsl-edma.c line 833

Quoted 11 lines
drivers/dma/fsl-edma.c new file +10 -0
+static int fsl_edma_probe(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct fsl_edma_engine *fsl_edma;
+       struct fsl_edma_chan *fsl_chan;
+       struct resource *res;
+       int len, chans;
+       int ret, i;
+
+       ret = of_property_read_u32_index(np, "dma-channels", 0, &chans);

Use of_property_read_u32.

[Lu Jingchang-b35083]
Thanks, I will do this.

Best Regards,
Jingchang

#6 lore raw
Quoted 29 lines · Jingchang Lu
Quoted 19 lines

-----Original Message-----
From: Mark Rutland [mailto:mark.rutland at arm.com]
Sent: Thursday, November 14, 2013 6:46 PM
To: Lu Jingchang-B35083
Cc: vinod.koul at intel.com; devicetree at vger.kernel.org; Wang Huan-B18965; linux-kernel at vger.kernel.org; shawn.guo at linaro.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Quoted 7 lines · Jingchang Lu

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request sources(slot) to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

[...]

Quoted 9 lines

Documentation/devicetree/bindings/dma/fsl-edma.txt line 25

Quoted 2 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +2 -0
+* DMAMUX
+Required properties:

No compatible?

Where are DMAMUX nodes expected to live?

How to they relate to the eDMA controller in HW? Are they a subcomponent, or a logically separate unit that happens to be connected?

Quoted 7 lines

[Lu Jingchang-b35083]
DMAMUX is a multiplexer between dma controller channels and peripheral deivces, each DMAMUX provides 16 independently selectable DMA channel routers, and each channel router can be assigned to one of the possible peripheral DMA slots. So it's not a standalone device, it's just required by the DMA controller to connect the channels and slaves, So it's got by DMA controller's "fsl,dma-mux" property. Thanks!

Ok.

I'm not so sure on the way this is described, from the point of view of the device, its DMA channel is wired to the MUX, not to the DMA engine directly:

                       +-------+
             /---------|DEVICE0|
             |         +-------+
+-----+   +------+
| DMA |===|DMAMUX|
+-----+   +------+
             |         +-------+
             \---------|DEVICE1|
                       +-------+

If that's the case, I'd expect the DMAMUX to have a #dma-cells and describe each device as being wired to the mux, and then the mux as being wired to the DMA. If the MUXes are sub-blocks of the DMA, then I'm not sure why they need to be described at all.

Currently, the DMA code is handling information that's specific to the MUX (i.e. the channel ID that's specific to the MUX), and that feels odd unless the MUX is a component of the DMA (which if true I'd expect it to be described differently).

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines
+- reg : Should contain DMAMUX registers location and length
+- fsl,dmamux-id : DMAMUX ID. DMAMUX IDs are unique in each eDMA

controller.

Quoted 1 line

+ inside one eDMA controller, specific request source can only be

routed by

Review

Quoted 2 lines
(quoted diff) +2 -0
+  one of its DMAMUXs.
+  However Specific request source may be routed to different eDMA

controller,

Quoted 1 line

+ thus all the DMAMUXs sharing a the same request sources have the

same ID.

Quoted 2 lines
+- clocks : Phandle of the clock used by the DMAMUX
+- clock-names : The clock names

_which_ clock names do you expect? From the looks of the example, you expect "dmamux".

From the view of the DMAMUX, what is its clock input called? "dmamux" doesn't look like what I'd expect for a clock name, but if the documentation for the eDMA doesn't provide a name for it, "dmamux" is fine.

Quoted 8 lines
Quoted 4 lines

If you're not using clock-names, it's useless. You _must_ define the set of names you expect or it's unusable. If you do define a set of names, then you should request clocks by name in the driver.

[Lu Jingchang-b35083] [Lu Jingchang-b35083]
The clock here is from the platform bus clock, I will remove this property for compatible between SoCs. Thanks!

Quoted 1 line
Quoted 1 line

+

Ok, if it's already on and you don't need it for now, nto describing it is fine.

[...]

Quoted 10 lines
Quoted 7 lines

drivers/dma/fsl-edma.c line 765

Quoted 5 lines
drivers/dma/fsl-edma.c new file +5 -0
+               fsl_edmamux->clk = of_clk_get(phandle, 0);
+               if (IS_ERR(fsl_edmamux->clk)) {
+                       dev_err(&pdev->dev, "Missing DMAMUX clock.\n");
+                       return PTR_ERR(fsl_edmamux->clk);
+               }

Please acquire the clock by name:

[Lu Jingchang-b35083]
I will remove the node name property for reuse the driver between SoCs, for they may have different clock names. Thanks!

The clock-names property describes the clock from the view of the _device_, not the _system_. The set of possible clock-names should not vary from system to system, but it may vary from generation to generation of the device.

See the last portion of
http://www.spinics.net/lists/devicetree/msg08993.html for a description of clock-names.

Thanks,
Mark.

#7 lore raw
Quoted 79 lines

-----Original Message-----
From: Mark Rutland [mailto:mark.rutland at arm.com]
Sent: Monday, November 18, 2013 7:15 PM
To: Lu Jingchang-B35083
Cc: vinod.koul at intel.com; devicetree at vger.kernel.org; Wang Huan-B18965; linux-kernel at vger.kernel.org; shawn.guo at linaro.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Quoted 7 lines · Jingchang Lu
Quoted 7 lines

-----Original Message-----
From: Mark Rutland [mailto:mark.rutland at arm.com]
Sent: Thursday, November 14, 2013 6:46 PM
To: Lu Jingchang-B35083
Cc: vinod.koul at intel.com; devicetree at vger.kernel.org; Wang Huan-

B18965;

Quoted 3 lines
Quoted 3 lines

linux-kernel at vger.kernel.org; shawn.guo at linaro.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver

support

Quoted 4 lines
Quoted 4 lines · Jingchang Lu
Quoted 2 lines

Add Freescale enhanced direct memory(eDMA) controller support. The eDMA controller deploys DMAMUXs routing DMA request

sources(slot)

Quoted 11 lines
Quoted 5 lines
Quoted 5 lines

to eDMA channels.
This module can be found on Vybrid and LS-1 SoCs.

[...]

Quoted 5 lines

Documentation/devicetree/bindings/dma/fsl-edma.txt line 25

Quoted 2 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +2 -0
+* DMAMUX
+Required properties:

No compatible?

Quoted 4 lines
Quoted 4 lines

Where are DMAMUX nodes expected to live?

How to they relate to the eDMA controller in HW? Are they a subcomponent, or a logically separate unit that happens to be

connected?

Quoted 2 lines

[Lu Jingchang-b35083]
DMAMUX is a multiplexer between dma controller channels and peripheral

deivces,

Quoted 1 line

each DMAMUX provides 16 independently selectable DMA channel routers,

and each

Quoted 1 line

channel router can be assigned to one of the possible peripheral DMA

slots.

Quoted 1 line

So it's not a standalone device, it's just required by the DMA

controller to

Quoted 1 line

connect the channels and slaves, So it's got by DMA controller's

"fsl,dma-mux" property.

Quoted 1 line

Thanks!

Ok.

I'm not so sure on the way this is described, from the point of view of the device, its DMA channel is wired to the MUX, not to the DMA engine directly:

                       +-------+
             /---------|DEVICE0|
             |         +-------+
+-----+   +------+
| DMA |===|DMAMUX|
+-----+   +------+
             |         +-------+
             \---------|DEVICE1|
                       +-------+

If that's the case, I'd expect the DMAMUX to have a #dma-cells and describe each device as being wired to the mux, and then the mux as being wired to the DMA. If the MUXes are sub-blocks of the DMA, then I'm not sure why they need to be described at all.

Quoted 5 lines

Currently, the DMA code is handling information that's specific to the MUX (i.e. the channel ID that's specific to the MUX), and that feels odd unless the MUX is a component of the DMA (which if true I'd expect it to be described differently).

Yes, the connection is as your imagination, except for each DMA has two MUX. The DMA helper looks the registered DMA engineer for DMA channel binding, and the registered DMA engineer is the eDMA node, if binding to DMAMUX, the helper will not find out the dma engineer.
The only DMAMUX configuration is programming the slave id into its corresponding register, so its code is handled by the eDMA driver, the DMAMUX is not optional.
Thanks!

Best Regards,
Jingchang

#8 lore raw
Quoted 49 lines · Jingchang Lu
Quoted 44 lines
Quoted 9 lines
Quoted 9 lines

Documentation/devicetree/bindings/dma/fsl-edma.txt line 25

Quoted 2 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +2 -0
+* DMAMUX
+Required properties:

No compatible?

Where are DMAMUX nodes expected to live?

How to they relate to the eDMA controller in HW? Are they a subcomponent, or a logically separate unit that happens to be

connected?

Quoted 2 lines

[Lu Jingchang-b35083]
DMAMUX is a multiplexer between dma controller channels and peripheral

deivces,

Quoted 1 line

each DMAMUX provides 16 independently selectable DMA channel routers,

and each

Quoted 1 line

channel router can be assigned to one of the possible peripheral DMA

slots.

Quoted 1 line

So it's not a standalone device, it's just required by the DMA

controller to

Quoted 1 line

connect the channels and slaves, So it's got by DMA controller's

"fsl,dma-mux" property.

Quoted 1 line

Thanks!

Ok.

I'm not so sure on the way this is described, from the point of view of the device, its DMA channel is wired to the MUX, not to the DMA engine directly:

                       +-------+
             /---------|DEVICE0|
             |         +-------+
+-----+   +------+
| DMA |===|DMAMUX|
+-----+   +------+
             |         +-------+
             \---------|DEVICE1|
                       +-------+

If that's the case, I'd expect the DMAMUX to have a #dma-cells and describe each device as being wired to the mux, and then the mux as being wired to the DMA. If the MUXes are sub-blocks of the DMA, then I'm not sure why they need to be described at all.

Quoted 5 lines

Currently, the DMA code is handling information that's specific to the MUX (i.e. the channel ID that's specific to the MUX), and that feels odd unless the MUX is a component of the DMA (which if true I'd expect it to be described differently).

Quoted 7 lines

Yes, the connection is as your imagination, except for each DMA has two MUX. The DMA helper looks the registered DMA engineer for DMA channel binding, and the registered DMA engineer is the eDMA node, if binding to DMAMUX, the helper will not find out the dma engineer.
The only DMAMUX configuration is programming the slave id into its corresponding register, so its code is handled by the eDMA driver, the DMAMUX is not optional.

This is fairly common representation of how DMA engines interact with slave clients via a programmable mux. Now the slave id value in this case (which we program to mux) needs to be for the client and _not_ for the dmanegine. DMA engine would have a register to configure the mux value required for the transaction.

The dma engine API provides a way to program the slave id (ie mux value) and IMO this should be a property of slave device (perhaps part of its dma resource) and used while programming channel. Making it dma driver property makes no sense here

--
~Vinod

#9 lore raw
Quoted 88 lines

-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Thursday, November 28, 2013 2:08 PM
To: Lu Jingchang-B35083
Cc: Mark Rutland; devicetree at vger.kernel.org; Wang Huan-B18965; linux- kernel at vger.kernel.org; shawn.guo at linaro.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v6 3/3] dma: Add Freescale eDMA engine driver support

Quoted 5 lines · Jingchang Lu
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Documentation/devicetree/bindings/dma/fsl-edma.txt line 25

Quoted 2 lines
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +2 -0
+* DMAMUX
+Required properties:

No compatible?

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

Where are DMAMUX nodes expected to live?

How to they relate to the eDMA controller in HW? Are they a subcomponent, or a logically separate unit that happens to be

connected?

Quoted 2 lines

[Lu Jingchang-b35083]
DMAMUX is a multiplexer between dma controller channels and

peripheral

Quoted 2 lines
Quoted 2 lines

deivces,

Quoted 1 line

each DMAMUX provides 16 independently selectable DMA channel

routers,

Quoted 2 lines
Quoted 2 lines

and each

Quoted 1 line

channel router can be assigned to one of the possible peripheral

DMA

Quoted 10 lines
Quoted 10 lines

slots.

Quoted 1 line

So it's not a standalone device, it's just required by the DMA

controller to

Quoted 1 line

connect the channels and slaves, So it's got by DMA controller's

"fsl,dma-mux" property.

Quoted 1 line

Thanks!

Ok.

I'm not so sure on the way this is described, from the point of view

of

Quoted 1 line
Quoted 1 line

the device, its DMA channel is wired to the MUX, not to the DMA

engine

Quoted 12 lines
Quoted 12 lines

directly:

                       +-------+
             /---------|DEVICE0|
             |         +-------+
+-----+   +------+
| DMA |===|DMAMUX|
+-----+   +------+
             |         +-------+
             \---------|DEVICE1|
                       +-------+
Quoted 3 lines
Quoted 3 lines

If that's the case, I'd expect the DMAMUX to have a #dma-cells and describe each device as being wired to the mux, and then the mux as being wired to the DMA. If the MUXes are sub-blocks of the DMA, then

I'm

Quoted 3 lines
Quoted 3 lines

not sure why they need to be described at all.

Currently, the DMA code is handling information that's specific to

the

Quoted 1 line
Quoted 1 line

MUX (i.e. the channel ID that's specific to the MUX), and that feels

odd

Quoted 1 line
Quoted 1 line

unless the MUX is a component of the DMA (which if true I'd expect it

to

Quoted 3 lines
Quoted 2 lines

be described differently).

Yes, the connection is as your imagination, except for each DMA has two

MUX.

Quoted 1 line

The DMA helper looks the registered DMA engineer for DMA channel

binding,

Quoted 5 lines

and the registered DMA engineer is the eDMA node, if binding to DMAMUX, the helper will not find out the dma engineer.
The only DMAMUX configuration is programming the slave id into its corresponding register, so its code is handled by the eDMA driver, the DMAMUX is not optional.

This is fairly common representation of how DMA engines interact with slave
clients via a programmable mux. Now the slave id value in this case (which we
program to mux) needs to be for the client and _not_ for the dmanegine. DMA
engine would have a register to configure the mux value required for the transaction.

Quoted 7 lines

The dma engine API provides a way to program the slave id (ie mux value) and IMO
this should be a property of slave device (perhaps part of its dma resource) and
used while programming channel. Making it dma driver property makes no sense
here

Since the DMAMUX node in DTS is not a standalone device but tightly-coupled to the eDMA controller, Would it be better integrated the DMAMUX info into the eDMA node? Just like the GIC has an dist and an cpu interface.

edma0: dma-controller at 40018000 {
	#dma-cells = <2>;
	compatible = "fsl,vf610-edma";
	reg = <0x40018000 0x2000>,
		<0x40024000 0x1000>,
		<0x40025000 0x1000>;
	interrupts = <0 8 0x04>, <0 9 0x04>;
	interrupt-names = "edma-txrx", "edma-err";
	dma-channels = <32>; 
	clocks = <&clks VF610_CLK_DMAMUX0>,
		<&clks VF610_CLK_DMAMUX1>;
};

And Vinod, I notice that there has been some discussion on the slave_id handling for the SAI audio driver , which uses the eDMA doing data transfer. Since the driver core infrastructure would automatically call the DMA engine help function requesting the channel which be done by the driver itself, reducing the work of individual device driver. So for DMA controller like our eDMA which has slave_id parameter, how about doing the slave_id configuration during the help call, this can also frees the driver configuring it, and make the driver compatible with those who has no slave_id.
Thanks!

Best Regards,
Jingchang