diff mbox

[07/12] mtd: gpmi: move to use generic DMA helper

Message ID 1361978748-25281-8-git-send-email-shawn.guo@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Guo Feb. 27, 2013, 3:25 p.m. UTC
With the generic DMA device tree helper supported by mxs-dma driver,
client devices only need to call dma_request_slave_channel() for
requesting a DMA channel from dmaengine.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org
---
 .../devicetree/bindings/mtd/gpmi-nand.txt          |   17 ++++---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c             |   51 +-------------------
 drivers/mtd/nand/gpmi-nand/gpmi-nand.h             |    3 +-
 3 files changed, 12 insertions(+), 59 deletions(-)

Comments

Huang Shijie Feb. 28, 2013, 8:39 a.m. UTC | #1
? 2013?02?27? 23:25, Shawn Guo ??:
> +++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> @@ -7,10 +7,12 @@ Required properties:
>    - compatible : should be "fsl,<chip>-gpmi-nand"
>    - reg : should contain registers location and length for gpmi and bch.
>    - reg-names: Should contain the reg names "gpmi-nand" and "bch"
> -  - interrupts : The first is the DMA interrupt number for GPMI.
> -                 The second is the BCH interrupt number.
> -  - interrupt-names : The interrupt names "gpmi-dma", "bch";
> -  - fsl,gpmi-dma-channel : Should contain the dma channel it uses.
> +  - interrupts : BCH interrupt number.
> +  - interrupt-names : Should be "bch".
why split out the bch interrupt? It seems no use to do it.

thanks
Huang Shijie
Shawn Guo March 1, 2013, 1:14 a.m. UTC | #2
On Thu, Feb 28, 2013 at 04:39:12PM +0800, Huang Shijie wrote:
> ? 2013?02?27? 23:25, Shawn Guo ??:
> > +++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> > @@ -7,10 +7,12 @@ Required properties:
> >    - compatible : should be "fsl,<chip>-gpmi-nand"
> >    - reg : should contain registers location and length for gpmi and bch.
> >    - reg-names: Should contain the reg names "gpmi-nand" and "bch"
> > -  - interrupts : The first is the DMA interrupt number for GPMI.
> > -                 The second is the BCH interrupt number.
> > -  - interrupt-names : The interrupt names "gpmi-dma", "bch";
> > -  - fsl,gpmi-dma-channel : Should contain the dma channel it uses.
> > +  - interrupts : BCH interrupt number.
> > +  - interrupt-names : Should be "bch".
> why split out the bch interrupt? It seems no use to do it.
> 
The real change here is to remove gpmi-dma interrupt, since we have all
dma interrupts defined in dma controller node.

Shawn
Artem Bityutskiy March 8, 2013, 1:19 p.m. UTC | #3
On Wed, 2013-02-27 at 23:25 +0800, Shawn Guo wrote:
> With the generic DMA device tree helper supported by mxs-dma driver,
> client devices only need to call dma_request_slave_channel() for
> requesting a DMA channel from dmaengine.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Artem Bityutskiy <dedekind1@gmail.com>
> Cc: linux-mtd@lists.infradead.org

It looks like this ne is rather independent and can go via the MTD tree.
So pushed this one to l2-mtd.git - let me know if I am confused. Thanks!
Arnd Bergmann March 8, 2013, 2:06 p.m. UTC | #4
On Friday 08 March 2013, Artem Bityutskiy wrote:
> On Wed, 2013-02-27 at 23:25 +0800, Shawn Guo wrote:
> > With the generic DMA device tree helper supported by mxs-dma driver,
> > client devices only need to call dma_request_slave_channel() for
> > requesting a DMA channel from dmaengine.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > Cc: Artem Bityutskiy <dedekind1@gmail.com>
> > Cc: linux-mtd@lists.infradead.org
> 
> It looks like this ne is rather independent and can go via the MTD tree.
> So pushed this one to l2-mtd.git - let me know if I am confused. Thanks!

I think you should not apply this patch on a tree that does not already
have the first three patches in the series. The easiest way would be
to keep the series together. As an alternative, Shawn could create a
git branch with those three patches and let you (and the other subsystem
maintainers) pull that branch in before applying the subsystem specific
patch.

	Arnd
Huang Shijie March 8, 2013, 4:26 p.m. UTC | #5
On Fri, Mar 8, 2013 at 8:19 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Wed, 2013-02-27 at 23:25 +0800, Shawn Guo wrote:
>> With the generic DMA device tree helper supported by mxs-dma driver,
>> client devices only need to call dma_request_slave_channel() for
>> requesting a DMA channel from dmaengine.
>>
>> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
>> Cc: Artem Bityutskiy <dedekind1@gmail.com>
>> Cc: linux-mtd@lists.infradead.org
>
> It looks like this ne is rather independent and can go via the MTD tree.
> So pushed this one to l2-mtd.git - let me know if I am confused. Thanks!
I suggest do not apply this patch. the whole patch set is still under
review now.

Best Regards
Huang Shijie

>
> --
> Best Regards,
> Artem Bityutskiy
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Shawn Guo March 11, 2013, 3:03 a.m. UTC | #6
Artem,

On Fri, Mar 08, 2013 at 03:19:45PM +0200, Artem Bityutskiy wrote:
> On Wed, 2013-02-27 at 23:25 +0800, Shawn Guo wrote:
> > With the generic DMA device tree helper supported by mxs-dma driver,
> > client devices only need to call dma_request_slave_channel() for
> > requesting a DMA channel from dmaengine.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > Cc: Artem Bityutskiy <dedekind1@gmail.com>
> > Cc: linux-mtd@lists.infradead.org
> 
> It looks like this ne is rather independent and can go via the MTD tree.
> So pushed this one to l2-mtd.git - let me know if I am confused. Thanks!

First of all, there is a new version (v2) of the patch (series) to
address review comments.

Secondly, as Arnd pointed it out, you shouldn't apply this single
patch, because it depends on the first 3 patches in the series to
work.  Applying this single patch will result in a non-functional
gpmi driver.

As I mentioned in the cover letter, I prefer to have your ACK on
the patch to merge the series through arm-soc tree as a whole.  If
you insist that you merge the patch through your tree, I can also
create a topic branch containing the first 3 patches, as Arnd suggests.
Please just let me know.

Shawn
Artem Bityutskiy March 11, 2013, 7:32 a.m. UTC | #7
On Fri, 2013-03-08 at 14:06 +0000, Arnd Bergmann wrote:
> On Friday 08 March 2013, Artem Bityutskiy wrote:
> > On Wed, 2013-02-27 at 23:25 +0800, Shawn Guo wrote:
> > > With the generic DMA device tree helper supported by mxs-dma driver,
> > > client devices only need to call dma_request_slave_channel() for
> > > requesting a DMA channel from dmaengine.
> > > 
> > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > Cc: Artem Bityutskiy <dedekind1@gmail.com>
> > > Cc: linux-mtd@lists.infradead.org
> > 
> > It looks like this ne is rather independent and can go via the MTD tree.
> > So pushed this one to l2-mtd.git - let me know if I am confused. Thanks!
> 
> I think you should not apply this patch on a tree that does not already
> have the first three patches in the series. The easiest way would be
> to keep the series together. As an alternative, Shawn could create a
> git branch with those three patches and let you (and the other subsystem
> maintainers) pull that branch in before applying the subsystem specific
> patch.

OK, this one looked independent to me. Anyway, dropped it and for this
one:

Acked-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
index 3fb3f901..6f74e23 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
@@ -7,10 +7,12 @@  Required properties:
   - compatible : should be "fsl,<chip>-gpmi-nand"
   - reg : should contain registers location and length for gpmi and bch.
   - reg-names: Should contain the reg names "gpmi-nand" and "bch"
-  - interrupts : The first is the DMA interrupt number for GPMI.
-                 The second is the BCH interrupt number.
-  - interrupt-names : The interrupt names "gpmi-dma", "bch";
-  - fsl,gpmi-dma-channel : Should contain the dma channel it uses.
+  - interrupts : BCH interrupt number.
+  - interrupt-names : Should be "bch".
+  - dmas: DMA specifier, consisting of a phandle to DMA controller node
+    and GPMI DMA channel ID.
+    Refer to dma.txt and fsl-mxs-dma.txt for details.
+  - dma-names: Must be "gpmi".
 
 Optional properties:
   - nand-on-flash-bbt: boolean to enable on flash bbt option if not
@@ -27,9 +29,10 @@  gpmi-nand@8000c000 {
 	#size-cells = <1>;
 	reg = <0x8000c000 2000>, <0x8000a000 2000>;
 	reg-names = "gpmi-nand", "bch";
-	interrupts = <88>, <41>;
-	interrupt-names = "gpmi-dma", "bch";
-	fsl,gpmi-dma-channel = <4>;
+	interrupts = <41>;
+	interrupt-names = "bch";
+	dmas = <&dma_apbh 4>;
+	dma-names = "gpmi";
 
 	partition@0 {
 	...
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 717881a..64d4d61 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -36,7 +36,6 @@ 
 #define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME  "gpmi-nand"
 #define GPMI_NAND_BCH_REGS_ADDR_RES_NAME   "bch"
 #define GPMI_NAND_BCH_INTERRUPT_RES_NAME   "bch"
-#define GPMI_NAND_DMA_INTERRUPT_RES_NAME   "gpmi-dma"
 
 /* add our owner bbt descriptor */
 static uint8_t scan_ff_pattern[] = { 0xff };
@@ -420,28 +419,6 @@  static void release_bch_irq(struct gpmi_nand_data *this)
 		free_irq(i, this);
 }
 
-static bool gpmi_dma_filter(struct dma_chan *chan, void *param)
-{
-	struct gpmi_nand_data *this = param;
-	int dma_channel = (int)this->private;
-
-	if (!mxs_dma_is_apbh(chan))
-		return false;
-	/*
-	 * only catch the GPMI dma channels :
-	 *	for mx23 :	MX23_DMA_GPMI0 ~ MX23_DMA_GPMI3
-	 *		(These four channels share the same IRQ!)
-	 *
-	 *	for mx28 :	MX28_DMA_GPMI0 ~ MX28_DMA_GPMI7
-	 *		(These eight channels share the same IRQ!)
-	 */
-	if (dma_channel == chan->chan_id) {
-		chan->private = &this->dma_data;
-		return true;
-	}
-	return false;
-}
-
 static void release_dma_channels(struct gpmi_nand_data *this)
 {
 	unsigned int i;
@@ -455,36 +432,10 @@  static void release_dma_channels(struct gpmi_nand_data *this)
 static int acquire_dma_channels(struct gpmi_nand_data *this)
 {
 	struct platform_device *pdev = this->pdev;
-	struct resource *r_dma;
-	struct device_node *dn;
-	u32 dma_channel;
-	int ret;
 	struct dma_chan *dma_chan;
-	dma_cap_mask_t mask;
-
-	/* dma channel, we only use the first one. */
-	dn = pdev->dev.of_node;
-	ret = of_property_read_u32(dn, "fsl,gpmi-dma-channel", &dma_channel);
-	if (ret) {
-		pr_err("unable to get DMA channel from dt.\n");
-		goto acquire_err;
-	}
-	this->private = (void *)dma_channel;
-
-	/* gpmi dma interrupt */
-	r_dma = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
-					GPMI_NAND_DMA_INTERRUPT_RES_NAME);
-	if (!r_dma) {
-		pr_err("Can't get resource for DMA\n");
-		goto acquire_err;
-	}
-	this->dma_data.chan_irq = r_dma->start;
 
 	/* request dma channel */
-	dma_cap_zero(mask);
-	dma_cap_set(DMA_SLAVE, mask);
-
-	dma_chan = dma_request_channel(mask, gpmi_dma_filter, this);
+	dma_chan = dma_request_slave_channel(&pdev->dev, "gpmi");
 	if (!dma_chan) {
 		pr_err("Failed to request DMA channel.\n");
 		goto acquire_err;
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
index 0729477..a7685e3 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
@@ -20,7 +20,7 @@ 
 #include <linux/mtd/nand.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
-#include <linux/fsl/mxs-dma.h>
+#include <linux/dmaengine.h>
 
 #define GPMI_CLK_MAX 5 /* MX6Q needs five clocks */
 struct resources {
@@ -180,7 +180,6 @@  struct gpmi_nand_data {
 	/* DMA channels */
 #define DMA_CHANS		8
 	struct dma_chan		*dma_chans[DMA_CHANS];
-	struct mxs_dma_data	dma_data;
 	enum dma_ops_type	last_dma_type;
 	enum dma_ops_type	dma_type;
 	struct completion	dma_done;