Skip to contentSkip to conversation

MTD: LPC32xx SLC NAND driver

PATCH Superseded Roland Stigge 3 participants 8 messages Jun 6, 2012 – Jun 7, 2012

Subsystems (4)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 MTD: LPC32xx SLC NAND driver

This patch adds support for the SLC NAND controller inside the LPC32xx SoC.

---
Applies to 3.5-rc1

Changes since v5:
* Configurable as "tristate" in Kconfig (was "bool")

Changes since v4:
* Dropped superfluous error handling of dmaengine_submit()
* Added unmapping of dma sg buffers

Changes since v3:
* Adjusted to mtd API changes

Changes since v2:
* Fixed dma data direction and dma transfer direction differences
* Removed dma_sync_sg_for_cpu() - not necessary due to unmap
* Removed dma_set_mask()

Changes since v1:
* Fixed busy wait DMA timeout with cpu_relax() - unexpected condition anyway
* Fixed comment of dma_setup function
* Minor cleanup

Thanks to Artem Bityutskiy, Huang Shijie and Russell King for reviewing!

 Documentation/devicetree/bindings/mtd/lpc32xx-slc.txt |   52 
 drivers/mtd/nand/Kconfig                              |   11 
 drivers/mtd/nand/Makefile                             |    1 
 drivers/mtd/nand/lpc32xx_nand_slc.c                   | 1060 ++++++++++++++++++
 4 files changed, 1124 insertions(+)
Documentation/devicetree/bindings/mtd/lpc32xx-slc.txt new file +52 -0
@@ -0,0 +1,52 @@
+NXP LPC32xx SoC NAND SLC controller
+
+Required properties:
+- compatible: "nxp,lpc3220-slc"
+- reg: Address and size of the controller
+- nand-on-flash-bbt: Use bad block table on flash
+- gpios: GPIO specification for NAND write protect
+
+The following required properties are very controller specific. See the LPC32xx
+User Manual:
+- nxp,wdr-clks: Delay before Ready signal is tested on write (W_RDY)
+- nxp,rdr-clks: Delay before Ready signal is tested on read (R_RDY)
+(The following values are specified in Hz, to make them independent of actual
+clock speed:)
+- nxp,wwidth: Write pulse width (W_WIDTH)
+- nxp,whold: Write hold time (W_HOLD)
+- nxp,wsetup: Write setup time (W_SETUP)
+- nxp,rwidth: Read pulse width (R_WIDTH)
+- nxp,rhold: Read hold time (R_HOLD)
+- nxp,rsetup: Read setup time (R_SETUP)
+
+Optional subnodes:
+- Partitions, see Documentation/devicetree/bindings/mtd/partition.txt
+
+Example:
+
+	slc: flash at 20020000 {
+		compatible = "nxp,lpc3220-slc";
+		reg = <0x20020000 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		nxp,wdr-clks = <14>;
+		nxp,wwidth = <40000000>;
+		nxp,whold = <100000000>;
+		nxp,wsetup = <100000000>;
+		nxp,rdr-clks = <14>;
+		nxp,rwidth = <40000000>;
+		nxp,rhold = <66666666>;
+		nxp,rsetup = <100000000>;
+		nand-on-flash-bbt;
+		gpios = <&gpio 5 19 1>; /* GPO_P3 19, active low */
+
+		mtd0 at 00000000 {
+			label = "phy3250-boot";
+			reg = <0x00000000 0x00064000>;
+			read-only;
+		};
+
+		...
+
+	};
drivers/mtd/nand/Kconfig +11 -0
@@ -454,6 +454,17 @@ config MTD_NAND_PXA3xx
 	  This enables the driver for the NAND flash device found on
 	  PXA3xx processors
 
+config MTD_NAND_SLC_LPC32XX
+	tristate "NXP LPC32xx SLC Controller"
+	depends on ARCH_LPC32XX
+	help
+	  Enables support for NXP's LPC32XX SLC (i.e. for Single Level Cell
+	  chips) NAND controller. This is the default for the PHYTEC 3250
+	  reference board which contains a NAND256R3A2CZA6 chip.
+
+	  Please check the actual NAND chip connected and its support
+	  by the SLC NAND controller.
+
 config MTD_NAND_CM_X270
 	tristate "Support for NAND Flash on CM-X270 modules"
 	depends on MACH_ARMCORE
drivers/mtd/nand/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_MTD_NAND_ORION)		+= orion_n
 obj-$(CONFIG_MTD_NAND_FSL_ELBC)		+= fsl_elbc_nand.o
 obj-$(CONFIG_MTD_NAND_FSL_IFC)		+= fsl_ifc_nand.o
 obj-$(CONFIG_MTD_NAND_FSL_UPM)		+= fsl_upm.o
+obj-$(CONFIG_MTD_NAND_SLC_LPC32XX)      += lpc32xx_nand_slc.o
 obj-$(CONFIG_MTD_NAND_SH_FLCTL)		+= sh_flctl.o
 obj-$(CONFIG_MTD_NAND_MXC)		+= mxc_nand.o
 obj-$(CONFIG_MTD_NAND_SOCRATES)		+= socrates_nand.o
drivers/mtd/nand/lpc32xx_nand_slc.c new file +1060 -0

1,060 lines not on this page · raw message

#1 lore raw

PATCH v5 1/1 MTD: LPC32xx MLC NAND driver

This patch adds a driver for the MLC NAND controller of the LPC32xx SoC.

---
Applies to v3.5-rc1 + LPC32xx SLC NAND driver (Kconfig + Makefile)

Changes since v4:
* This patch erroneously changed Kconfig of the _other_ NAND (SLC) driver from "bool" to "tristate". Moved this fix to the actual SLC driver patch.

Changes since v3:
* Dropped superfluous error handling of dmaengine_submit()
* Added unmapping of dma sg buffers

Changes since v2:
* Adjusted to mtd API changes

Changes since v1:
* Factored out dmaengine_slave_config() to dma_setup() function in probe()
* Fixed dma data direction and dma transfer direction differences
* Removed dma_sync_sg_for_cpu() - not necessary due to unmap
* Removed dma_set_mask()

Thanks to Russell King for reviewing!

 Documentation/devicetree/bindings/mtd/lpc32xx-mlc.txt |   50 
 drivers/mtd/nand/Kconfig                              |   13 
 drivers/mtd/nand/Makefile                             |    1 
 drivers/mtd/nand/lpc32xx_nand_mlc.c                   |  963 ++++++++++++++++++
 4 files changed, 1026 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mtd/lpc32xx-mlc.txt new file +50 -0
@@ -0,0 +1,50 @@
+NXP LPC32xx SoC NAND MLC controller
+
+Required properties:
+- compatible: "nxp,lpc3220-mlc"
+- reg: Address and size of the controller
+- interrupts: The NAND interrupt specification
+- gpios: GPIO specification for NAND write protect
+
+The following required properties are very controller specific. See the LPC32xx
+User Manual 7.5.14 MLC NAND Timing Register (the values here are specified in
+Hz, to make them independent of actual clock speed and to provide for good
+accuracy:)
+- nxp,tcea_delay: TCEA_DELAY
+- nxp,busy_delay: BUSY_DELAY
+- nxp,nand_ta: NAND_TA
+- nxp,rd_high: RD_HIGH
+- nxp,rd_low: RD_LOW
+- nxp,wr_high: WR_HIGH
+- nxp,wr_low: WR_LOW
+
+Optional subnodes:
+- Partitions, see Documentation/devicetree/bindings/mtd/partition.txt
+
+Example:
+
+	mlc: flash at 200A8000 {
+		compatible = "nxp,lpc3220-mlc";
+		reg = <0x200A8000 0x11000>;
+		interrupts = <11 0>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		nxp,tcea-delay = <333333333>;
+		nxp,busy-delay = <10000000>;
+		nxp,nand-ta = <18181818>;
+		nxp,rd-high = <31250000>;
+		nxp,rd-low = <45454545>;
+		nxp,wr-high = <40000000>;
+		nxp,wr-low = <83333333>;
+		gpios = <&gpio 5 19 1>; /* GPO_P3 19, active low */
+
+		mtd0 at 00000000 {
+			label = "boot";
+			reg = <0x00000000 0x00064000>;
+			read-only;
+		};
+
+		...
+
+	};
drivers/mtd/nand/Kconfig +11 -0
@@ -465,6 +465,17 @@ config MTD_NAND_SLC_LPC32XX
 	  Please check the actual NAND chip connected and its support
 	  by the SLC NAND controller.
 
+config MTD_NAND_MLC_LPC32XX
+       tristate "NXP LPC32xx MLC Controller"
+       depends on ARCH_LPC32XX
+       help
+         Uses the LPC32XX MLC (i.e. for Multi Level Cell chips) NAND
+         controller. This is the default for the WORK92105 controller
+         board.
+
+         Please check the actual NAND chip connected and its support
+         by the MLC NAND controller.
+
 config MTD_NAND_CM_X270
 	tristate "Support for NAND Flash on CM-X270 modules"
 	depends on MACH_ARMCORE
drivers/mtd/nand/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_MTD_NAND_FSL_ELBC)		+= fsl_
 obj-$(CONFIG_MTD_NAND_FSL_IFC)		+= fsl_ifc_nand.o
 obj-$(CONFIG_MTD_NAND_FSL_UPM)		+= fsl_upm.o
 obj-$(CONFIG_MTD_NAND_SLC_LPC32XX)      += lpc32xx_nand_slc.o
+obj-$(CONFIG_MTD_NAND_MLC_LPC32XX)      += lpc32xx_nand_mlc.o
 obj-$(CONFIG_MTD_NAND_SH_FLCTL)		+= sh_flctl.o
 obj-$(CONFIG_MTD_NAND_MXC)		+= mxc_nand.o
 obj-$(CONFIG_MTD_NAND_SOCRATES)		+= socrates_nand.o
drivers/mtd/nand/lpc32xx_nand_mlc.c new file +963 -0

963 lines not on this page · raw message

#2 lore raw
In reply to Roland Stigge
Quoted 30 lines · Roland Stigge
drivers/mtd/nand/lpc32xx_nand_slc.c new file +30 -0
+#ifdef CONFIG_PM
+static int lpc32xx_nand_resume(struct platform_device *pdev)
+{
+	struct lpc32xx_nand_host *host = platform_get_drvdata(pdev);
+
+	/* Re-enable NAND clock */
+	clk_enable(host->clk);
+
+	/* Fresh init of NAND controller */
+	lpc32xx_nand_setup(host);
+
+	/* Disable write protect */
+	lpc32xx_wp_disable(host);
+
+	return 0;
+}
+
+static int lpc32xx_nand_suspend(struct platform_device *pdev, pm_message_t pm)
+{
+	u32 tmp;
+	struct lpc32xx_nand_host *host = platform_get_drvdata(pdev);
+
+	/* Force CE high */
+	tmp = readl(SLC_CTRL(host->io_base));
+	tmp &= ~SLCCFG_CE_LOW;
+	writel(tmp, SLC_CTRL(host->io_base));
+
+	/* Enable write protect for safety */
+	lpc32xx_wp_enable(host);
+

drivers/mtd/nand/lpc32xx_nand_slc.c line 1033

Quoted 10 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +10 -0
+	/* Disable clock */
+	clk_disable(host->clk);
+
+	return 0;
+}
+
+#else
+#define lpc32xx_nand_resume NULL
+#define lpc32xx_nand_suspend NULL
+#endif

0, not NULL.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#7 lore raw
In reply to Roland Stigge
Quoted 1 line · Roland Stigge
 drivers/mtd/nand/lpc32xx_nand_slc.c                   | 1060 ++++++++++++++++++

Can you please rename it to lpc32xx_slc.c? It is already in the "nand" sub-directory, no need to add "nand" to the file name.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#3 lore raw
In reply to Artem Bityutskiy

Hi,

Quoted 4 lines · Artem Bityutskiy
Quoted 2 lines

+#else +#define lpc32xx_nand_resume NULL +#define
lpc32xx_nand_suspend NULL +#endif

0, not NULL.

Can you please point me to an explanation for this? NULL sounds natural here, since it is used as a pointer, and other nand drivers are already doing it via NULL:

bcm_umi_nand.c
bf5xx_nand.c
pxa3xx_nand.c
r852.c
s3c2410.c
tmio_nand.c
txx9ndfmc.c

... and none is #defining as 0.

Thanks in advance,

Roland

#4 lore raw
Quoted 6 lines · Roland Stigge
Quoted 4 lines
Quoted 2 lines

+#else +#define lpc32xx_nand_resume NULL +#define
lpc32xx_nand_suspend NULL +#endif

0, not NULL.

Can you please point me to an explanation for this? NULL sounds

Right, sorry, that was incorrect.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#5 lore raw
In reply to Artem Bityutskiy
Quoted 7 lines · Artem Bityutskiy

drivers/mtd/nand/lpc32xx_nand_slc.c line 1033

Quoted 4 lines · Roland Stigge
drivers/mtd/nand/lpc32xx_nand_slc.c new file +4 -0
+#else
+#define lpc32xx_nand_resume NULL
+#define lpc32xx_nand_suspend NULL
+#endif

0, not NULL.

Err, what planet are you on there. These are _pointers_ to functions, so using a _pointer_ is more correct than using an _integer_.

#6 lore raw
Quoted 11 lines · Russell King - ARM Linux
Quoted 7 lines · Artem Bityutskiy

drivers/mtd/nand/lpc32xx_nand_slc.c line 1033

Quoted 4 lines · Roland Stigge
drivers/mtd/nand/lpc32xx_nand_slc.c new file +4 -0
+#else
+#define lpc32xx_nand_resume NULL
+#define lpc32xx_nand_suspend NULL
+#endif

0, not NULL.

Err, what planet are you on there. These are _pointers_ to functions, so using a _pointer_ is more correct than using an _integer_.

Yes, thanks, I was wrong.

Signature · 2 lines
Best Regards,
Artem Bityutskiy