devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] dmaengine: sirf: enable generic dt binding for dma channels
@ 2014-01-26  2:08 Barry Song
       [not found] ` <20140120074857.GJ26823@intel.com>
       [not found] ` <1389190369-2012-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Barry Song @ 2014-01-26  2:08 UTC (permalink / raw)
  To: vinod.koul, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak
  Cc: devicetree, dmaengine, workgroup.linux, Lars-Peter Clausen,
	Barry Song

From: Barry Song <Baohua.Song@csr.com>

move to support of_dma_request_slave_channel() and dma_request_slave_channel.
we add a xlate() to let dma clients be able to find right dma_chan by generic
"dmas" properties in dts.

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
 -v5:
 add Acked-by: vinod.koul@intel.com;
 cc devicetree guys as Acked from dt was required

 .../devicetree/bindings/dma/sirfsoc-dma.txt        |   43 ++++++++++++++++++++
 arch/arm/boot/dts/atlas6.dtsi                      |    2 +
 arch/arm/boot/dts/prima2.dtsi                      |    2 +
 drivers/dma/sirf-dma.c                             |   23 ++++++++++
 4 files changed, 70 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/dma/sirfsoc-dma.txt

diff --git a/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
new file mode 100644
index 0000000..ecbc96a
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
@@ -0,0 +1,43 @@
+* CSR SiRFSoC DMA controller
+
+See dma.txt first
+
+Required properties:
+- compatible: Should be "sirf,prima2-dmac" or "sirf,marco-dmac"
+- reg: Should contain DMA registers location and length.
+- interrupts: Should contain one interrupt shared by all channel
+- #dma-cells: must be <1>. used to represent the number of integer
+    cells in the dmas property of client device.
+- clocks: clock required
+
+Example:
+
+Controller:
+dmac0: dma-controller@b00b0000 {
+	compatible = "sirf,prima2-dmac";
+	reg = <0xb00b0000 0x10000>;
+	interrupts = <12>;
+	clocks = <&clks 24>;
+	#dma-cells = <1>;
+};
+
+
+Client:
+Fill the specific dma request line in dmas. In the below example, spi0 read
+channel request line is 9 of the 2nd dma controller, while write channel uses
+4 of the 2nd dma controller; spi1 read channel request line is 12 of the 1st
+dma controller, while write channel uses 13 of the 1st dma controller:
+
+spi0: spi@b00d0000 {
+	compatible = "sirf,prima2-spi";
+	dmas = <&dmac1 9>,
+		<&dmac1 4>;
+	dma-names = "rx", "tx";
+};
+
+spi1: spi@b0170000 {
+	compatible = "sirf,prima2-spi";
+	dmas = <&dmac0 12>,
+		<&dmac0 13>;
+	dma-names = "rx", "tx";
+};
diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi
index b63cfef..4f41f0a 100644
--- a/arch/arm/boot/dts/atlas6.dtsi
+++ b/arch/arm/boot/dts/atlas6.dtsi
@@ -260,6 +260,7 @@
 				reg = <0xb00b0000 0x10000>;
 				interrupts = <12>;
 				clocks = <&clks 24>;
+				#dma-cells = <1>;
 			};
 
 			dmac1: dma-controller@b0160000 {
@@ -268,6 +269,7 @@
 				reg = <0xb0160000 0x10000>;
 				interrupts = <13>;
 				clocks = <&clks 25>;
+				#dma-cells = <1>;
 			};
 
 			vip@b00C0000 {
diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi
index b292a5c..19e4e22 100644
--- a/arch/arm/boot/dts/prima2.dtsi
+++ b/arch/arm/boot/dts/prima2.dtsi
@@ -277,6 +277,7 @@
 				reg = <0xb00b0000 0x10000>;
 				interrupts = <12>;
 				clocks = <&clks 24>;
+				#dma-cells = <1>;
 			};
 
 			dmac1: dma-controller@b0160000 {
@@ -285,6 +286,7 @@
 				reg = <0xb0160000 0x10000>;
 				interrupts = <13>;
 				clocks = <&clks 25>;
+				#dma-cells = <1>;
 			};
 
 			vip@b00C0000 {
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index 6aec3ad..8b74c0d 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -18,6 +18,7 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/clk.h>
+#include <linux/of_dma.h>
 #include <linux/sirfsoc_dma.h>
 
 #include "dmaengine.h"
@@ -640,6 +641,18 @@ bool sirfsoc_dma_filter_id(struct dma_chan *chan, void *chan_id)
 }
 EXPORT_SYMBOL(sirfsoc_dma_filter_id);
 
+static struct dma_chan *of_dma_sirfsoc_xlate(struct of_phandle_args *dma_spec,
+	struct of_dma *ofdma)
+{
+	struct sirfsoc_dma *sdma = ofdma->of_dma_data;
+	unsigned int request = dma_spec->args[0];
+
+	if (request > SIRFSOC_DMA_CHANNELS)
+		return NULL;
+
+	return dma_get_slave_channel(&sdma->channels[request].chan);
+}
+
 static int sirfsoc_dma_probe(struct platform_device *op)
 {
 	struct device_node *dn = op->dev.of_node;
@@ -744,11 +757,20 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 	if (ret)
 		goto free_irq;
 
+	/* Device-tree DMA controller registration */
+	ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
+	if (ret) {
+		dev_err(dev, "failed to register DMA controller\n");
+		goto unreg_dma_dev;
+	}
+
 	pm_runtime_enable(&op->dev);
 	dev_info(dev, "initialized SIRFSOC DMAC driver\n");
 
 	return 0;
 
+unreg_dma_dev:
+	dma_async_device_unregister(dma);
 free_irq:
 	free_irq(sdma->irq, sdma);
 irq_dispose:
@@ -761,6 +783,7 @@ static int sirfsoc_dma_remove(struct platform_device *op)
 	struct device *dev = &op->dev;
 	struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
 
+	of_dma_controller_free(op->dev.of_node);
 	dma_async_device_unregister(&sdma->dma);
 	free_irq(sdma->irq, sdma);
 	irq_dispose_mapping(sdma->irq);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] dmaengine: sirf: enable generic dt binding for dma channels
       [not found]     ` <CAGsJ_4zcwCx0RNMNx8YaDBFtGE=02-B79+WKDGeky80X5agcuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-03-01  2:49       ` Barry Song
       [not found]         ` <CAGsJ_4zMYGTS4CyCsTAH_5PMK3v4Pr+e88YjXL=d3A=EjPf9rQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Barry Song @ 2014-03-01  2:49 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring
  Cc: dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	DL-SHA-WorkGroupLinux, Barry Song, Mark Rutland,
	Lars-Peter Clausen,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

2014-01-20 17:35 GMT+08:00 Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> 2014/1/20 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
>> On Wed, Jan 08, 2014 at 10:12:49PM +0800, Barry Song wrote:
>>> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
>>>
>>> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
>>> we add a xlate() to let dma clients be able to find right dma_chan by generic
>>> "dmas" properties in dts.
>>>
>>> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
>>> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
>>> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
>> Look okay, need an ACk from DT maintainers before I can apply...

Hi Vinod,
v5 is sent to devicetree list and there is no object.
http://www.spinics.net/lists/devicetree/msg19677.html
this patch is using general dt-binding for dma completely same with
other dma drivers, there is no special binding here.
so i think there is no reason to wait for merging since now updates
for its clients e.g. SPI, UART have been in 3.14-rc.

-barry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] dmaengine: sirf: enable generic dt binding for dma channels
       [not found]         ` <CAGsJ_4zMYGTS4CyCsTAH_5PMK3v4Pr+e88YjXL=d3A=EjPf9rQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-03-17  4:51           ` Vinod Koul
       [not found]             ` <20140317045105.GB1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Vinod Koul @ 2014-03-17  4:51 UTC (permalink / raw)
  To: Barry Song
  Cc: Rob Herring, dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	DL-SHA-WorkGroupLinux, Barry Song, Mark Rutland,
	Lars-Peter Clausen,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Sat, Mar 01, 2014 at 10:49:18AM +0800, Barry Song wrote:
> 2014-01-20 17:35 GMT+08:00 Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> > 2014/1/20 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
> >> On Wed, Jan 08, 2014 at 10:12:49PM +0800, Barry Song wrote:
> >>> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> >>>
> >>> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
> >>> we add a xlate() to let dma clients be able to find right dma_chan by generic
> >>> "dmas" properties in dts.
> >>>
> >>> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
> >>> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
> >>> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> >> Look okay, need an ACk from DT maintainers before I can apply...
> 
> Hi Vinod,
> v5 is sent to devicetree list and there is no object.
> http://www.spinics.net/lists/devicetree/msg19677.html
> this patch is using general dt-binding for dma completely same with
> other dma drivers, there is no special binding here.
> so i think there is no reason to wait for merging since now updates
> for its clients e.g. SPI, UART have been in 3.14-rc.
I still need the ack for DT folks... Seems still missing :(

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] dmaengine: sirf: enable generic dt binding for dma channels
       [not found]             ` <20140317045105.GB1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-03-18  2:02               ` Barry Song
  2014-03-18 12:20               ` Arnd Bergmann
  1 sibling, 0 replies; 8+ messages in thread
From: Barry Song @ 2014-03-18  2:02 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Rob Herring, dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	DL-SHA-WorkGroupLinux, Barry Song, Mark Rutland,
	Lars-Peter Clausen,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

2014-03-17 12:51 GMT+08:00 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
> On Sat, Mar 01, 2014 at 10:49:18AM +0800, Barry Song wrote:
>> 2014-01-20 17:35 GMT+08:00 Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>> > 2014/1/20 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
>> >> On Wed, Jan 08, 2014 at 10:12:49PM +0800, Barry Song wrote:
>> >>> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
>> >>>
>> >>> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
>> >>> we add a xlate() to let dma clients be able to find right dma_chan by generic
>> >>> "dmas" properties in dts.
>> >>>
>> >>> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
>> >>> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
>> >>> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
>> >> Look okay, need an ACk from DT maintainers before I can apply...
>>
>> Hi Vinod,
>> v5 is sent to devicetree list and there is no object.
>> http://www.spinics.net/lists/devicetree/msg19677.html
>> this patch is using general dt-binding for dma completely same with
>> other dma drivers, there is no special binding here.
>> so i think there is no reason to wait for merging since now updates
>> for its clients e.g. SPI, UART have been in 3.14-rc.
> I still need the ack for DT folks... Seems still missing :(

Vinod, it seems nobody in dt has noticed this change since there is
not a real change for DT binding. if we need an ack for every normal
change in dt, the maintain chain might be easily broken.it seems it is
not always a good practice?

>
> --
> ~Vinod

-barry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] dmaengine: sirf: enable generic dt binding for dma channels
       [not found]             ` <20140317045105.GB1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2014-03-18  2:02               ` Barry Song
@ 2014-03-18 12:20               ` Arnd Bergmann
  1 sibling, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2014-03-18 12:20 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Vinod Koul, Barry Song, Mark Rutland,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Lars-Peter Clausen, DL-SHA-WorkGroupLinux, Rob Herring,
	Barry Song, dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Monday 17 March 2014, Vinod Koul wrote:
> On Sat, Mar 01, 2014 at 10:49:18AM +0800, Barry Song wrote:
> > 2014-01-20 17:35 GMT+08:00 Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> > > 2014/1/20 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
> > >> On Wed, Jan 08, 2014 at 10:12:49PM +0800, Barry Song wrote:
> > >>> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> > >>>
> > >>> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
> > >>> we add a xlate() to let dma clients be able to find right dma_chan by generic
> > >>> "dmas" properties in dts.
> > >>>
> > >>> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
> > >>> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
> > >>> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> > >> Look okay, need an ACk from DT maintainers before I can apply...
> > 
> > Hi Vinod,
> > v5 is sent to devicetree list and there is no object.
> > http://www.spinics.net/lists/devicetree/msg19677.html
> > this patch is using general dt-binding for dma completely same with
> > other dma drivers, there is no special binding here.
> > so i think there is no reason to wait for merging since now updates
> > for its clients e.g. SPI, UART have been in 3.14-rc.
> I still need the ack for DT folks... Seems still missing :(

I thought I'd looked at it before.  The wording of the binding document
could be clarified a little, but the binding itself is absolutely
reasonable and the implementation looks correct. I would suggest you
merge it as is.

Acked-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v5] dmaengine: sirf: enable generic dt binding for dma channels
       [not found] ` <1389190369-2012-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-03-19 14:43   ` Vinod Koul
       [not found]     ` <20140319144359.GI1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Vinod Koul @ 2014-03-19 14:43 UTC (permalink / raw)
  To: Barry Song
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, workgroup.linux-kQvG35nSl+M,
	Lars-Peter Clausen, Barry Song

On Sun, Jan 26, 2014 at 10:08:45AM +0800, Barry Song wrote:
> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> 
> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
> we add a xlate() to let dma clients be able to find right dma_chan by generic
> "dmas" properties in dts.
> 
> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>

I tried applying this but it failed to apply.

Can you pls rebase quickly and resend. While at it pls add the Acks recived!

-- 
~Vinod

> ---
>  -v5:
>  add Acked-by: vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org;
>  cc devicetree guys as Acked from dt was required
> 
>  .../devicetree/bindings/dma/sirfsoc-dma.txt        |   43 ++++++++++++++++++++
>  arch/arm/boot/dts/atlas6.dtsi                      |    2 +
>  arch/arm/boot/dts/prima2.dtsi                      |    2 +
>  drivers/dma/sirf-dma.c                             |   23 ++++++++++
>  4 files changed, 70 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
> 
> diff --git a/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
> new file mode 100644
> index 0000000..ecbc96a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
> @@ -0,0 +1,43 @@
> +* CSR SiRFSoC DMA controller
> +
> +See dma.txt first
> +
> +Required properties:
> +- compatible: Should be "sirf,prima2-dmac" or "sirf,marco-dmac"
> +- reg: Should contain DMA registers location and length.
> +- interrupts: Should contain one interrupt shared by all channel
> +- #dma-cells: must be <1>. used to represent the number of integer
> +    cells in the dmas property of client device.
> +- clocks: clock required
> +
> +Example:
> +
> +Controller:
> +dmac0: dma-controller@b00b0000 {
> +	compatible = "sirf,prima2-dmac";
> +	reg = <0xb00b0000 0x10000>;
> +	interrupts = <12>;
> +	clocks = <&clks 24>;
> +	#dma-cells = <1>;
> +};
> +
> +
> +Client:
> +Fill the specific dma request line in dmas. In the below example, spi0 read
> +channel request line is 9 of the 2nd dma controller, while write channel uses
> +4 of the 2nd dma controller; spi1 read channel request line is 12 of the 1st
> +dma controller, while write channel uses 13 of the 1st dma controller:
> +
> +spi0: spi@b00d0000 {
> +	compatible = "sirf,prima2-spi";
> +	dmas = <&dmac1 9>,
> +		<&dmac1 4>;
> +	dma-names = "rx", "tx";
> +};
> +
> +spi1: spi@b0170000 {
> +	compatible = "sirf,prima2-spi";
> +	dmas = <&dmac0 12>,
> +		<&dmac0 13>;
> +	dma-names = "rx", "tx";
> +};
> diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi
> index b63cfef..4f41f0a 100644
> --- a/arch/arm/boot/dts/atlas6.dtsi
> +++ b/arch/arm/boot/dts/atlas6.dtsi
> @@ -260,6 +260,7 @@
>  				reg = <0xb00b0000 0x10000>;
>  				interrupts = <12>;
>  				clocks = <&clks 24>;
> +				#dma-cells = <1>;
>  			};
>  
>  			dmac1: dma-controller@b0160000 {
> @@ -268,6 +269,7 @@
>  				reg = <0xb0160000 0x10000>;
>  				interrupts = <13>;
>  				clocks = <&clks 25>;
> +				#dma-cells = <1>;
>  			};
>  
>  			vip@b00C0000 {
> diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi
> index b292a5c..19e4e22 100644
> --- a/arch/arm/boot/dts/prima2.dtsi
> +++ b/arch/arm/boot/dts/prima2.dtsi
> @@ -277,6 +277,7 @@
>  				reg = <0xb00b0000 0x10000>;
>  				interrupts = <12>;
>  				clocks = <&clks 24>;
> +				#dma-cells = <1>;
>  			};
>  
>  			dmac1: dma-controller@b0160000 {
> @@ -285,6 +286,7 @@
>  				reg = <0xb0160000 0x10000>;
>  				interrupts = <13>;
>  				clocks = <&clks 25>;
> +				#dma-cells = <1>;
>  			};
>  
>  			vip@b00C0000 {
> diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
> index 6aec3ad..8b74c0d 100644
> --- a/drivers/dma/sirf-dma.c
> +++ b/drivers/dma/sirf-dma.c
> @@ -18,6 +18,7 @@
>  #include <linux/of_device.h>
>  #include <linux/of_platform.h>
>  #include <linux/clk.h>
> +#include <linux/of_dma.h>
>  #include <linux/sirfsoc_dma.h>
>  
>  #include "dmaengine.h"
> @@ -640,6 +641,18 @@ bool sirfsoc_dma_filter_id(struct dma_chan *chan, void *chan_id)
>  }
>  EXPORT_SYMBOL(sirfsoc_dma_filter_id);
>  
> +static struct dma_chan *of_dma_sirfsoc_xlate(struct of_phandle_args *dma_spec,
> +	struct of_dma *ofdma)
> +{
> +	struct sirfsoc_dma *sdma = ofdma->of_dma_data;
> +	unsigned int request = dma_spec->args[0];
> +
> +	if (request > SIRFSOC_DMA_CHANNELS)
> +		return NULL;
> +
> +	return dma_get_slave_channel(&sdma->channels[request].chan);
> +}
> +
>  static int sirfsoc_dma_probe(struct platform_device *op)
>  {
>  	struct device_node *dn = op->dev.of_node;
> @@ -744,11 +757,20 @@ static int sirfsoc_dma_probe(struct platform_device *op)
>  	if (ret)
>  		goto free_irq;
>  
> +	/* Device-tree DMA controller registration */
> +	ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
> +	if (ret) {
> +		dev_err(dev, "failed to register DMA controller\n");
> +		goto unreg_dma_dev;
> +	}
> +
>  	pm_runtime_enable(&op->dev);
>  	dev_info(dev, "initialized SIRFSOC DMAC driver\n");
>  
>  	return 0;
>  
> +unreg_dma_dev:
> +	dma_async_device_unregister(dma);
>  free_irq:
>  	free_irq(sdma->irq, sdma);
>  irq_dispose:
> @@ -761,6 +783,7 @@ static int sirfsoc_dma_remove(struct platform_device *op)
>  	struct device *dev = &op->dev;
>  	struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
>  
> +	of_dma_controller_free(op->dev.of_node);
>  	dma_async_device_unregister(&sdma->dma);
>  	free_irq(sdma->irq, sdma);
>  	irq_dispose_mapping(sdma->irq);
> -- 
> 1.7.5.4
> 
> 

-- 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v5] dmaengine: sirf: enable generic dt binding for dma channels
       [not found]     ` <20140319144359.GI1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-03-27  8:03       ` Barry Song
       [not found]         ` <CAGsJ_4yVXN2pT-QCjWLx7bCM7rau=UAnkCY8k9QqEPOkMAcrXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Barry Song @ 2014-03-27  8:03 UTC (permalink / raw)
  To: Vinod Koul
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, Pawel Moll, Mark Rutland,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, Kumar Gala,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	DL-SHA-WorkGroupLinux, Lars-Peter Clausen, Barry Song

[-- Attachment #1: Type: text/plain, Size: 818 bytes --]

2014-03-19 22:43 GMT+08:00 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
> On Sun, Jan 26, 2014 at 10:08:45AM +0800, Barry Song wrote:
>> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
>>
>> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
>> we add a xlate() to let dma clients be able to find right dma_chan by generic
>> "dmas" properties in dts.
>>
>> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
>> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
>> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
>
> I tried applying this but it failed to apply.
>
> Can you pls rebase quickly and resend. While at it pls add the Acks recived!

Hi Vinod,
attached see the rebased version for master.

-barry

[-- Attachment #2: 0001-dmaengine-sirf-enable-generic-dt-binding-for-dma-cha.patch --]
[-- Type: text/x-patch, Size: 5144 bytes --]

From 3b720f21783f1df32ceaed35aa01ee2da1d2d26a Mon Sep 17 00:00:00 2001
From: Barry Song <Baohua.Song@csr.com>
Date: Thu, 27 Mar 2014 15:49:31 +0800
Subject: [PATCH] dmaengine: sirf: enable generic dt binding for dma channels

move to support of_dma_request_slave_channel() and dma_request_slave_channel.
we add a xlate() to let dma clients be able to find right dma_chan by generic
"dmas" properties in dts.

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
---
 .../devicetree/bindings/dma/sirfsoc-dma.txt        |   43 ++++++++++++++++++++
 arch/arm/boot/dts/atlas6.dtsi                      |    2 +
 arch/arm/boot/dts/prima2.dtsi                      |    2 +
 drivers/dma/sirf-dma.c                             |   23 ++++++++++
 4 files changed, 70 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/dma/sirfsoc-dma.txt

diff --git a/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
new file mode 100644
index 0000000..ecbc96a
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
@@ -0,0 +1,43 @@
+* CSR SiRFSoC DMA controller
+
+See dma.txt first
+
+Required properties:
+- compatible: Should be "sirf,prima2-dmac" or "sirf,marco-dmac"
+- reg: Should contain DMA registers location and length.
+- interrupts: Should contain one interrupt shared by all channel
+- #dma-cells: must be <1>. used to represent the number of integer
+    cells in the dmas property of client device.
+- clocks: clock required
+
+Example:
+
+Controller:
+dmac0: dma-controller@b00b0000 {
+	compatible = "sirf,prima2-dmac";
+	reg = <0xb00b0000 0x10000>;
+	interrupts = <12>;
+	clocks = <&clks 24>;
+	#dma-cells = <1>;
+};
+
+
+Client:
+Fill the specific dma request line in dmas. In the below example, spi0 read
+channel request line is 9 of the 2nd dma controller, while write channel uses
+4 of the 2nd dma controller; spi1 read channel request line is 12 of the 1st
+dma controller, while write channel uses 13 of the 1st dma controller:
+
+spi0: spi@b00d0000 {
+	compatible = "sirf,prima2-spi";
+	dmas = <&dmac1 9>,
+		<&dmac1 4>;
+	dma-names = "rx", "tx";
+};
+
+spi1: spi@b0170000 {
+	compatible = "sirf,prima2-spi";
+	dmas = <&dmac0 12>,
+		<&dmac0 13>;
+	dma-names = "rx", "tx";
+};
diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi
index f8674bc..ec23b5c 100644
--- a/arch/arm/boot/dts/atlas6.dtsi
+++ b/arch/arm/boot/dts/atlas6.dtsi
@@ -269,6 +269,7 @@
 				reg = <0xb00b0000 0x10000>;
 				interrupts = <12>;
 				clocks = <&clks 24>;
+				#dma-cells = <1>;
 			};
 
 			dmac1: dma-controller@b0160000 {
@@ -277,6 +278,7 @@
 				reg = <0xb0160000 0x10000>;
 				interrupts = <13>;
 				clocks = <&clks 25>;
+				#dma-cells = <1>;
 			};
 
 			vip@b00C0000 {
diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi
index 0e21993..3a15dee 100644
--- a/arch/arm/boot/dts/prima2.dtsi
+++ b/arch/arm/boot/dts/prima2.dtsi
@@ -286,6 +286,7 @@
 				reg = <0xb00b0000 0x10000>;
 				interrupts = <12>;
 				clocks = <&clks 24>;
+				#dma-cells = <1>;
 			};
 
 			dmac1: dma-controller@b0160000 {
@@ -294,6 +295,7 @@
 				reg = <0xb0160000 0x10000>;
 				interrupts = <13>;
 				clocks = <&clks 25>;
+				#dma-cells = <1>;
 			};
 
 			vip@b00C0000 {
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index d4d3a31..a1bd829 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -18,6 +18,7 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/clk.h>
+#include <linux/of_dma.h>
 #include <linux/sirfsoc_dma.h>
 
 #include "dmaengine.h"
@@ -659,6 +660,18 @@ static int sirfsoc_dma_device_slave_caps(struct dma_chan *dchan,
 	return 0;
 }
 
+static struct dma_chan *of_dma_sirfsoc_xlate(struct of_phandle_args *dma_spec,
+	struct of_dma *ofdma)
+{
+	struct sirfsoc_dma *sdma = ofdma->of_dma_data;
+	unsigned int request = dma_spec->args[0];
+
+	if (request > SIRFSOC_DMA_CHANNELS)
+		return NULL;
+
+	return dma_get_slave_channel(&sdma->channels[request].chan);
+}
+
 static int sirfsoc_dma_probe(struct platform_device *op)
 {
 	struct device_node *dn = op->dev.of_node;
@@ -764,11 +777,20 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 	if (ret)
 		goto free_irq;
 
+	/* Device-tree DMA controller registration */
+	ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
+	if (ret) {
+		dev_err(dev, "failed to register DMA controller\n");
+		goto unreg_dma_dev;
+	}
+
 	pm_runtime_enable(&op->dev);
 	dev_info(dev, "initialized SIRFSOC DMAC driver\n");
 
 	return 0;
 
+unreg_dma_dev:
+	dma_async_device_unregister(dma);
 free_irq:
 	free_irq(sdma->irq, sdma);
 irq_dispose:
@@ -781,6 +803,7 @@ static int sirfsoc_dma_remove(struct platform_device *op)
 	struct device *dev = &op->dev;
 	struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
 
+	of_dma_controller_free(op->dev.of_node);
 	dma_async_device_unregister(&sdma->dma);
 	free_irq(sdma->irq, sdma);
 	irq_dispose_mapping(sdma->irq);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v5] dmaengine: sirf: enable generic dt binding for dma channels
       [not found]         ` <CAGsJ_4yVXN2pT-QCjWLx7bCM7rau=UAnkCY8k9QqEPOkMAcrXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-03-29 13:51           ` Vinod Koul
  0 siblings, 0 replies; 8+ messages in thread
From: Vinod Koul @ 2014-03-29 13:51 UTC (permalink / raw)
  To: Barry Song
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, Pawel Moll, Mark Rutland,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, Kumar Gala,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	DL-SHA-WorkGroupLinux, Lars-Peter Clausen, Barry Song

On Thu, Mar 27, 2014 at 04:03:31PM +0800, Barry Song wrote:
> 2014-03-19 22:43 GMT+08:00 Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>:
> > On Sun, Jan 26, 2014 at 10:08:45AM +0800, Barry Song wrote:
> >> From: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> >>
> >> move to support of_dma_request_slave_channel() and dma_request_slave_channel.
> >> we add a xlate() to let dma clients be able to find right dma_chan by generic
> >> "dmas" properties in dts.
> >>
> >> Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
> >> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
> >> Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
> >
> > I tried applying this but it failed to apply.
> >
> > Can you pls rebase quickly and resend. While at it pls add the Acks recived!
> 
> Hi Vinod,
> attached see the rebased version for master.
Applied, thanks

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-29 13:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-26  2:08 [PATCH v5] dmaengine: sirf: enable generic dt binding for dma channels Barry Song
     [not found] ` <20140120074857.GJ26823@intel.com>
     [not found]   ` <CAGsJ_4zcwCx0RNMNx8YaDBFtGE=02-B79+WKDGeky80X5agcuw@mail.gmail.com>
     [not found]     ` <CAGsJ_4zcwCx0RNMNx8YaDBFtGE=02-B79+WKDGeky80X5agcuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-01  2:49       ` [PATCH v4] " Barry Song
     [not found]         ` <CAGsJ_4zMYGTS4CyCsTAH_5PMK3v4Pr+e88YjXL=d3A=EjPf9rQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-17  4:51           ` Vinod Koul
     [not found]             ` <20140317045105.GB1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-18  2:02               ` Barry Song
2014-03-18 12:20               ` Arnd Bergmann
     [not found] ` <1389190369-2012-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-03-19 14:43   ` [PATCH v5] " Vinod Koul
     [not found]     ` <20140319144359.GI1976-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-27  8:03       ` Barry Song
     [not found]         ` <CAGsJ_4yVXN2pT-QCjWLx7bCM7rau=UAnkCY8k9QqEPOkMAcrXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-29 13:51           ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).