Skip to contentSkip to conversation

ARM: LPC32xx: Provide DMA filter callbacks via platform data

PATCH In review Roland Stigge 4 participants 10 messages Aug 16, 2012 – Aug 17, 2012

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: LPC32xx: Provide DMA filter callbacks via platform data

The SLC and MLC NAND drivers now need their dma_filter callbacks via platform data to make them independent of single DMA engine drivers.

(This also helps fixing build errors of the SLC and MLC drivers when building as modules because direct access to AMBA dma filter functions isn't available via export.)

---

Applies to v3.6-rc1

 arch/arm/mach-lpc32xx/phy3250.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/mach-lpc32xx/phy3250.c +14 -0
@@ -37,6 +37,8 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/clk.h>
+#include <linux/mtd/lpc32xx_slc.h>
+#include <linux/mtd/lpc32xx_mlc.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -223,6 +225,14 @@ static struct mmci_platform_data lpc32xx
 	 * gather, and the MMCI driver doesn't do it this way */
 };
 
+static struct lpc32xx_slc_platform_data lpc32xx_slc_data = {
+	.dma_filter = pl08x_filter_id,
+};
+
+static struct lpc32xx_mlc_platform_data lpc32xx_mlc_data = {
+	.dma_filter = pl08x_filter_id,
+};
+
 static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
 	OF_DEV_AUXDATA("arm,pl022", 0x20084000, "dev:ssp0", &lpc32xx_ssp0_data),
 	OF_DEV_AUXDATA("arm,pl022", 0x2008C000, "dev:ssp1", &lpc32xx_ssp1_data),
@@ -230,6 +240,10 @@ static const struct of_dev_auxdata lpc32
 	OF_DEV_AUXDATA("arm,pl080", 0x31000000, "pl08xdmac", &pl08x_pd),
 	OF_DEV_AUXDATA("arm,pl18x", 0x20098000, "20098000.sd",
 		       &lpc32xx_mmci_data),
+	OF_DEV_AUXDATA("nxp,lpc3220-slc", 0x20020000, "20020000.flash",
+		       &lpc32xx_slc_data),
+	OF_DEV_AUXDATA("nxp,lpc3220-mlc", 0x200a8000, "200a8000.flash",
+		       &lpc32xx_mlc_data),
 	{ }
 };
 
#1 lore raw

PATCH 1/1 mtd: lpc32xx_slc: Make driver independent of AMBA DMA engine driver

This patch makes the SLC NAND driver independent of the single AMBA DMA engine driver by using the platform data provided dma_filter callback.

---
 drivers/mtd/nand/lpc32xx_slc.c  |   13 +++++++++++--
 include/linux/mtd/lpc32xx_slc.h |   20 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)
drivers/mtd/nand/lpc32xx_slc.c +11 -2
@@ -37,7 +37,7 @@
 #include <linux/of.h>
 #include <linux/of_mtd.h>
 #include <linux/of_gpio.h>
-#include <linux/amba/pl08x.h>
+#include <linux/mtd/lpc32xx_slc.h>
 
 #define LPC32XX_MODNAME		"lpc32xx-nand"
 
@@ -199,6 +199,7 @@ struct lpc32xx_nand_cfg_slc {
 
 struct lpc32xx_nand_host {
 	struct nand_chip	nand_chip;
+	struct lpc32xx_slc_platform_data *pdata;
 	struct clk		*clk;
 	struct mtd_info		mtd;
 	void __iomem		*io_base;
@@ -714,9 +715,15 @@ static int lpc32xx_nand_dma_setup(struct
 	struct mtd_info *mtd = &host->mtd;
 	dma_cap_mask_t mask;
 
+	if (!host->pdata || !host->pdata->dma_filter) {
+		dev_err(mtd->dev.parent, "no DMA platform data\n");
+		return -ENOENT;
+	}
+
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
-	host->dma_chan = dma_request_channel(mask, pl08x_filter_id, "nand-slc");
+	host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter,
+					     "nand-slc");
 	if (!host->dma_chan) {
 		dev_err(mtd->dev.parent, "Failed to request DMA channel\n");
 		return -EBUSY;
@@ -814,6 +821,8 @@ static int __devinit lpc32xx_nand_probe(
 	}
 	lpc32xx_wp_disable(host);
 
+	host->pdata = pdev->dev.platform_data;
+
 	mtd = &host->mtd;
 	chip = &host->nand_chip;
 	chip->priv = host;
include/linux/mtd/lpc32xx_slc.h new file +20 -0
@@ -0,0 +1,20 @@
+/*
+ * Platform data for LPC32xx SoC SLC NAND controller
+ *
+ * Copyright (C) 2012 Roland Stigge
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MTD_LPC32XX_SLC_H
+#define __LINUX_MTD_LPC32XX_SLC_H
+
+#include <linux/dmaengine.h>
+
+struct lpc32xx_slc_platform_data {
+	bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
+};
+
+#endif  /* __LINUX_MTD_LPC32XX_SLC_H */
#2 lore raw

PATCH 1/1 mtd: lpc32xx_mlc: Make driver independent of AMBA DMA engine driver

In reply to Roland Stigge

This patch makes the MLC NAND driver independent of the single AMBA DMA engine driver by using the platform data provided dma_filter callback.

---
 drivers/mtd/nand/lpc32xx_mlc.c  |   13 +++++++++++--
 include/linux/mtd/lpc32xx_mlc.h |   20 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)
drivers/mtd/nand/lpc32xx_mlc.c +11 -2
@@ -37,7 +37,7 @@
 #include <linux/of.h>
 #include <linux/of_mtd.h>
 #include <linux/of_gpio.h>
-#include <linux/amba/pl08x.h>
+#include <linux/mtd/lpc32xx_mlc.h>
 #include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
@@ -171,6 +171,7 @@ static struct nand_bbt_descr lpc32xx_nan
 
 struct lpc32xx_nand_host {
 	struct nand_chip	nand_chip;
+	struct lpc32xx_mlc_platform_data *pdata;
 	struct clk		*clk;
 	struct mtd_info		mtd;
 	void __iomem		*io_base;
@@ -581,9 +582,15 @@ static int lpc32xx_dma_setup(struct lpc3
 	struct mtd_info *mtd = &host->mtd;
 	dma_cap_mask_t mask;
 
+	if (!host->pdata || !host->pdata->dma_filter) {
+		dev_err(mtd->dev.parent, "no DMA platform data\n");
+		return -ENOENT;
+	}
+
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
-	host->dma_chan = dma_request_channel(mask, pl08x_filter_id, "nand-mlc");
+	host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter,
+					     "nand-mlc");
 	if (!host->dma_chan) {
 		dev_err(mtd->dev.parent, "Failed to request DMA channel\n");
 		return -EBUSY;
@@ -703,6 +710,8 @@ static int __devinit lpc32xx_nand_probe(
 	}
 	lpc32xx_wp_disable(host);
 
+	host->pdata = pdev->dev.platform_data;
+
 	nand_chip->priv = host;		/* link the private data structures */
 	mtd->priv = nand_chip;
 	mtd->owner = THIS_MODULE;
include/linux/mtd/lpc32xx_mlc.h new file +20 -0
@@ -0,0 +1,20 @@
+/*
+ * Platform data for LPC32xx SoC MLC NAND controller
+ *
+ * Copyright (C) 2012 Roland Stigge
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MTD_LPC32XX_MLC_H
+#define __LINUX_MTD_LPC32XX_MLC_H
+
+#include <linux/dmaengine.h>
+
+struct lpc32xx_mlc_platform_data {
+	bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
+};
+
+#endif  /* __LINUX_MTD_LPC32XX_MLC_H */
Acked-by on v1 1/1
#3 lore raw
In reply to Roland Stigge
Quoted 8 lines · Roland Stigge

The SLC and MLC NAND drivers now need their dma_filter callbacks via platform data to make them independent of single DMA engine drivers.

(This also helps fixing build errors of the SLC and MLC drivers when building as modules because direct access to AMBA dma filter functions isn't available via export.)

Yes, this looks right.

Once we have proper DT bindings for the DMA channels, we can hopefully get rid of the auxdata again.

Arnd

#4 lore raw
In reply to Roland Stigge
Quoted 8 lines · Roland Stigge

The SLC and MLC NAND drivers now need their dma_filter callbacks via platform data to make them independent of single DMA engine drivers.

(This also helps fixing build errors of the SLC and MLC drivers when building as modules because direct access to AMBA dma filter functions isn't available via export.)

Pushed the 3 patches to l2-mtd.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#5 lore raw
Quoted 5 lines · Artem Bityutskiy
Quoted 4 lines · Roland Stigge

The SLC and MLC NAND drivers now need their dma_filter callbacks via platform data to make them independent of single DMA engine drivers.

Quoted 7 lines
Quoted 5 lines

(This also helps fixing build errors of the SLC and MLC drivers when building as modules because direct access to AMBA dma filter functions isn't available via export.)

Pushed the 3 patches to l2-mtd.git, thanks!

To later avoid collisions on subsystem merge, can you please leave the patch with arch/arm/mach-lpc32xx/phy3250.c for arm-soc.git? (I will provide a pull request for Arnd and Olof, as usual.)

Thanks,

Roland

#6 lore raw
Quoted 10 lines · Roland Stigge
Quoted 9 lines · Artem Bityutskiy
Quoted 8 lines · Roland Stigge

The SLC and MLC NAND drivers now need their dma_filter callbacks via platform data to make them independent of single DMA engine drivers.

(This also helps fixing build errors of the SLC and MLC drivers when building as modules because direct access to AMBA dma filter functions isn't available via export.)

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Pushed the 3 patches to l2-mtd.git, thanks!

To later avoid collisions on subsystem merge, can you please leave the patch with arch/arm/mach-lpc32xx/phy3250.c for arm-soc.git? (I will provide a pull request for Arnd and Olof, as usual.)

Only if Arnd insists. Otherwise I'd prefer to resolve collisions (they cannot be hard with this patch) than pulling the soc tree to the mtd tree.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#7 lore raw
Quoted 7 lines · Artem Bityutskiy
Quoted 3 lines

To later avoid collisions on subsystem merge, can you please leave the patch with arch/arm/mach-lpc32xx/phy3250.c for arm-soc.git? (I will provide a pull request for Arnd and Olof, as usual.)

Only if Arnd insists. Otherwise I'd prefer to resolve collisions (they cannot be hard with this patch) than pulling the soc tree to the mtd tree.

Actually the mtd patches do not compile-depend on it, sorry, I am dropping it from the MTD tree. Thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#8 lore raw
Quoted 6 lines · Artem Bityutskiy

Show Details

Quoted 4 lines · Artem Bityutskiy
Quoted 3 lines

To later avoid collisions on subsystem merge, can you please leave the patch with arch/arm/mach-lpc32xx/phy3250.c for arm-soc.git? (I will provide a pull request for Arnd and Olof, as usual.)

Quoted 6 lines
Quoted 3 lines

Only if Arnd insists. Otherwise I'd prefer to resolve collisions (they cannot be hard with this patch) than pulling the soc tree to the mtd tree.

Actually the mtd patches do not compile-depend on it, sorry, I am dropping it from the MTD tree. Thanks!

For reference, I'm fine with either outcome, I don't mind seeing an occasional collision with subsystem trees, as they tend to be trivial to resolve.

If you split a series to go through multiple git trees, you have to ensure that both halves are actually regression free by themselves, which typically ends up being much harder than fixing a small merge conflict.

Arnd

#9 lore raw
Quoted 9 lines · Arnd Bergmann
Quoted 2 lines

Actually the mtd patches do not compile-depend on it, sorry, I am dropping it from the MTD tree. Thanks!

For reference, I'm fine with either outcome, I don't mind seeing an occasional collision with subsystem trees, as they tend to be trivial to resolve.

If you split a series to go through multiple git trees, you have to ensure that both halves are actually regression free by themselves,

Of course. But in this very case, they are. So I'd prefer pushing them via different trees because I have other patches for mach-lpc32xx in the queue and would like to minimize work for you. :-)

Roland