Skip to contentSkip to conversation

MTD: LPC32xx SLC NAND driver

PATCH Applied Roland Stigge 3 participants 9 messages Jun 7, 2012 – Jun 27, 2012

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

PATCH v7 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 v6:
* Renamed lpc32xx_nand_slc.c -> lpc32xx_slc.c

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_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_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_slc.c new file +1060 -0

1,060 lines not on this page · raw message

#1 lore raw

PATCH v6 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 v5:
* Renamed: lpc32xx_nand_mlc.c -> lpc32xx_mlc.c

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                              |   11 
 drivers/mtd/nand/Makefile                             |    1 
 drivers/mtd/nand/lpc32xx_mlc.c                        |  963 ++++++++++++++++++
 4 files changed, 1025 insertions(+)
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_slc.o
+obj-$(CONFIG_MTD_NAND_MLC_LPC32XX)      += lpc32xx_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_mlc.c new file +963 -0

963 lines not on this page · raw message

#3 lore raw
In reply to Roland Stigge
Quoted 3 lines · Roland Stigge

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

Now the write_page and write_page_raw functions return an error code, see this commit in the l2 tree:

http://git.infradead.org/users/dedekind/l2-mtd.git/commit/49c8d9ab3b70732665249f2d993f734378ebbba9

I've amended your SLC driver, see below the diff. But I think it could return the real return code becuse it can fail - could you please take a look and send an incremental patch?

Please, base your work on top of the l2-mtd tree:
git://git.infradead.org/users/dedekind/l2-mtd.git

Thanks!

drivers/mtd/nand/lpc32xx_slc.c +9 -7
index 796e37b..7e2e78d 100644
@@ -673,9 +673,9 @@ static int lpc32xx_nand_read_page_raw_syndrome(struct mtd_info *mtd,
  * Write the data and OOB data to the device, use ECC with the data,
  * disable ECC for the OOB data
  */
-static void lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd,
-                                            struct nand_chip *chip,
-                                            const u8 *buf, int oob_required)
+static int lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd,
+                                           struct nand_chip *chip,
+                                           const u8 *buf, int oob_required)
 {
        struct lpc32xx_nand_host *host = chip->priv;
        u8 *pb = chip->oob_poi + chip->ecc.layout->eccpos[0];
@@ -691,20 +691,22 @@ static void lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd,
 
        /* Write ECC data to device */
        chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
+       return 0;
 }
 
 /*
  * Write the data and OOB data to the device, no ECC correction with the
  * data or OOB data
  */
-static void lpc32xx_nand_write_page_raw_syndrome(struct mtd_info *mtd,
-                                                struct nand_chip *chip,
-                                                const u8 *buf,
-                                                int oob_required)
+static int lpc32xx_nand_write_page_raw_syndrome(struct mtd_info *mtd,
+                                               struct nand_chip *chip,
+                                               const u8 *buf,
+                                               int oob_required)
 {
        /* Raw writes can just use the FIFO interface */
        chip->write_buf(mtd, buf, chip->ecc.size * chip->ecc.steps);
        chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
+       return 0;
 }
 
 static bool lpc32xx_dma_filter(struct dma_chan *chan, void *param)
Signature · 2 lines
Best Regards,
Artem Bityutskiy
#4 lore raw
Quoted 9 lines · Artem Bityutskiy
Quoted 4 lines · Roland Stigge

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

Now the write_page and write_page_raw functions return an error code, see this commit in the l2 tree:

Quoted 8 lines

http://git.infradead.org/users/dedekind/l2-mtd.git/commit/49c8d9ab3b70732665249f2d993f734378ebbba9

I've amended your SLC driver, see below the diff. But I think it
could return the real return code becuse it can fail - could you please take a look and send an incremental patch?

Please, base your work on top of the l2-mtd tree:
git://git.infradead.org/users/dedekind/l2-mtd.git

Thanks for the note! I'm sending an incremental patch. There was actually only one place in the two functions that could fail (return code of lpc32xx_xfer()).

Roland

#5 lore raw
Quoted 16 lines · Roland Stigge
Quoted 15 lines · Artem Bityutskiy
Quoted 4 lines · Roland Stigge

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

Now the write_page and write_page_raw functions return an error code, see this commit in the l2 tree:

http://git.infradead.org/users/dedekind/l2-mtd.git/commit/49c8d9ab3b70732665249f2d993f734378ebbba9

?I've amended your SLC driver, see below the diff. But I think it could return the real return code becuse it can fail - could you please take a look and send an incremental patch?

Quoted 6 lines
Quoted 2 lines

Please, base your work on top of the l2-mtd tree:
git://git.infradead.org/users/dedekind/l2-mtd.git

Thanks for the note! I'm sending an incremental patch. There was actually only one place in the two functions that could fail (return code of lpc32xx_xfer()).

I think it's best in case of *_raw to use nand base default functions, like in the MLC patch.

#6 lore raw

Hi!

Quoted 2 lines · Alexandre Pereira da Silva

I think it's best in case of *_raw to use nand base default functions, like in the MLC patch.

Problem here (specific for this SLC controller) is that it expects us to access the data register via 16bit access while the actual data is only 8bit wide.

This can't be done with the default nand functions, neither with the 8bit nor 16bit variant.

Roland

PS: Nevertheless, I will post our SLC driver update series against the l2-mtd branch.

#7 lore raw
In reply to Roland Stigge
Quoted 3 lines · Roland Stigge

Thanks for the note! I'm sending an incremental patch. There was actually only one place in the two functions that could fail (return code of lpc32xx_xfer()).

Could you please check the MCL patch as well and re-send it against the l2 tree?

I've squashed your change into the driver and pushed out, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#8 lore raw
Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · Roland Stigge

Thanks for the note! I'm sending an incremental patch. There was actually only one place in the two functions that could fail (return code of lpc32xx_xfer()).

Could you please check the MCL patch as well and re-send it against the l2 tree?

I've squashed your change into the driver and pushed out, thanks!

Yes, thanks!

Will post an updated MLC against l2-mtd later today.

Roland