Skip to contentSkip to conversation

mtd: nand: vf610_nfc: Freescale NFC for VF610

PATCH Superseded Stefan Agner 2 participants 8 messages Mar 9, 2015

Subsystems (6)

v2 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v2 cover mtd: nand: vf610_nfc: Freescale NFC for VF610

This adds support for Freescale NAND flash controller (NFC) found on various devices such as Vybrid (VF610), MPC5125, MCF54418 (ColdFire) and Kinetis K70.

The patchset is based on the patchset by Bill Pringlemeir, see:
http://thread.gmane.org/gmane.linux.ports.arm.kernel/295419

A variant of this driver is in upstream U-Boot now. During this process, various points have been discussed and changed. Those changes are also incorporated in this patchset, including the change to the name "vf610_nfc" (discussion in first patchset).
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/192465
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/193142
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/193351
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/195441
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/195513

MTD tests worked, except mtd_nandecctest.ko: The test stopped already after changing the first bit. I guess this is due to not properly working raw page read/write implementation. However, implementing those functions is not feasible since ECC is always done on-the-fly.

Performance keypoints (slightly less for page write/reads):

[ 1782.284398] mtd_speedtest: testing eraseblock write speed
[ 1963.472907] mtd_speedtest: eraseblock write speed is 2877 KiB/s
[ 1963.478913] mtd_speedtest: testing eraseblock read speed
[ 2004.906267] mtd_speedtest: eraseblock read speed is 12586 KiB/s

The driver has only been tested on Freescale Vybrid. Tests on other platforms welcome, especially on big endian architectures...

Changes since v1:
- Nest nfc_config struct within the main nfc struct
- Use assigned clock binding to specify NFC clock
- Rebased ontop of MSCM IR patchset (driver parts have been merged)
- Split out arch Kconfig in a seperate config
- Fix module license
- Updated MAINTAINERS

Changes since RFC (Bill Pringlemeir):
- Renamed driver from fsl_nfc to vf610_nfc
- Use readl/writel for all register in accessor functions
- Optimized field accessor functions
- Implemented PM (suspend/resume) functions
- Implemented basic support for ECC strength/ECC step size from dt
- Improved performance of count_written_bits by using hweight32
- Support ECC with 60-bytes to correct up to 32 bit errors
- Changed to in-band BBT (NAND_BBT_NO_OOB) which also allows ECC modes which uses up to 60 bytes on 64 byte OOB
- Removed custom (downstream) BBT pattern since BBT table won't be compatible anyway (due to the change above)

Stefan Agner (6):
mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
mtd: nand: vf610_nfc: add hardware BCH-ECC support
mtd: nand: vf610_nfc: add device tree bindings
ARM: vf610: enable NAND Flash Controller
ARM: dts: vf610: add NAND flash controller peripherial
ARM: dts: vf-colibri: enable NAND flash controller

 .../devicetree/bindings/mtd/vf610-nfc.txt          |  39 +
 MAINTAINERS                                        |   6 +
 arch/arm/boot/dts/vf-colibri.dtsi                  |  32 +
 arch/arm/boot/dts/vf610-twr.dts                    |  44 ++
 arch/arm/boot/dts/vfxxx.dtsi                       |   8 +
 arch/arm/mach-imx/Kconfig                          |   1 +
 drivers/mtd/nand/Kconfig                           |  14 +
 drivers/mtd/nand/Makefile                          |   1 +
 drivers/mtd/nand/vf610_nfc.c                       | 856 +++++++++++++++++++++
 9 files changed, 1001 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/vf610-nfc.txt
 create mode 100644 drivers/mtd/nand/vf610_nfc.c
Signature · 1 line
2.3.1
#1 lore raw

PATCH v2 1/6 mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others

This driver supports Freescale NFC (NAND flash controller) found on Vybrid (VF610), MPC5125, MCF54418 and Kinetis K70.

Limitations:
- DMA and pipelining not used
- Pages larger than 2k are not supported
- No hardware ECC

The driver has only been tested on Vybrid (VF610).

---
 MAINTAINERS                  |   6 +
 drivers/mtd/nand/Kconfig     |  12 +
 drivers/mtd/nand/Makefile    |   1 +
 drivers/mtd/nand/vf610_nfc.c | 713 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 732 insertions(+)
 create mode 100644 drivers/mtd/nand/vf610_nfc.c
MAINTAINERS +6 -0
index eaf9996..d8cbaee 100644
@@ -10363,6 +10363,12 @@ S:	Maintained
 F:	Documentation/fb/uvesafb.txt
 F:	drivers/video/fbdev/uvesafb.*
 
+VF610 NAND DRIVER
+M:	Stefan Agner <[email protected]>
+L:	linux-mtd at lists.infradead.org
+S:	Supported
+F:	drivers/mtd/nand/vf610_nfc.c
+
 VFAT/FAT/MSDOS FILESYSTEM
 M:	OGAWA Hirofumi <[email protected]>
 S:	Maintained
drivers/mtd/nand/Kconfig +12 -0
index 5b76a17..1be30a6 100644
@@ -455,6 +455,18 @@ config MTD_NAND_MPC5121_NFC
 	  This enables the driver for the NAND flash controller on the
 	  MPC5121 SoC.
 
+config HAVE_NAND_VF610_NFC
+	bool
+
+config MTD_NAND_VF610_NFC
+	tristate "Support for Freescale NFC for VF610/MPC5125"
+	depends on HAVE_NAND_VF610_NFC
+	help
+	  Enables support for NAND Flash Controller on some Freescale
+	  processors like the VF610, MPC5125, MCF54418 or Kinetis K70.
+	  The driver supports a maximum 2k page size. The driver
+	  currently does not support hardware ECC.
+
 config MTD_NAND_MXC
 	tristate "MXC NAND support"
 	depends on ARCH_MXC
drivers/mtd/nand/Makefile +1 -0
index 582bbd05..e97ca7b 100644
@@ -45,6 +45,7 @@ obj-$(CONFIG_MTD_NAND_SOCRATES)		+= socrates_nand.o
 obj-$(CONFIG_MTD_NAND_TXX9NDFMC)	+= txx9ndfmc.o
 obj-$(CONFIG_MTD_NAND_NUC900)		+= nuc900_nand.o
 obj-$(CONFIG_MTD_NAND_MPC5121_NFC)	+= mpc5121_nfc.o
+obj-$(CONFIG_MTD_NAND_VF610_NFC)	+= vf610_nfc.o
 obj-$(CONFIG_MTD_NAND_RICOH)		+= r852.o
 obj-$(CONFIG_MTD_NAND_JZ4740)		+= jz4740_nand.o
 obj-$(CONFIG_MTD_NAND_GPMI_NAND)	+= gpmi-nand/
drivers/mtd/nand/vf610_nfc.c new file +713 -0

713 lines not on this page · raw message

Signature · 1 line
2.3.1
#2 lore raw

PATCH v2 2/6 mtd: nand: vf610_nfc: add hardware BCH-ECC support

In reply to Stefan Agner

This adds hardware ECC support using the BCH encoder in the NFC IP. The ECC encoder supports up to 32-bit correction by using 60 error correction bytes. There is no sub-page ECC step, ECC is calculated always accross the whole page (up to 2k pages).

---
 drivers/mtd/nand/Kconfig     |   6 +-
 drivers/mtd/nand/vf610_nfc.c | 193 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 172 insertions(+), 27 deletions(-)
drivers/mtd/nand/Kconfig +4 -2
index 1be30a6..0fb97b3 100644
@@ -464,8 +464,10 @@ config MTD_NAND_VF610_NFC
 	help
 	  Enables support for NAND Flash Controller on some Freescale
 	  processors like the VF610, MPC5125, MCF54418 or Kinetis K70.
-	  The driver supports a maximum 2k page size. The driver
-	  currently does not support hardware ECC.
+	  The driver supports a maximum 2k page size. With 2k pages and
+	  64 bytes or more of OOB, hardware ECC with up to 32-bit error
+	  correction is supported. Hardware ECC is only enabled through
+	  device tree.
 
 config MTD_NAND_MXC
 	tristate "MXC NAND support"
drivers/mtd/nand/vf610_nfc.c +168 -25

267 lines not on this page · raw message

Signature · 1 line
2.3.1
#3 lore raw

PATCH v2 3/6 mtd: nand: vf610_nfc: add device tree bindings

In reply to Stefan Agner
---
 .../devicetree/bindings/mtd/vf610-nfc.txt          | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/vf610-nfc.txt
Documentation/devicetree/bindings/mtd/vf610-nfc.txt new file +39 -0
new file mode 100644
index 0000000..312c872
@@ -0,0 +1,39 @@
+Freescale's NAND flash controller (NFC)
+
+This variant of the Freescale NAND flash controller (NFC) is on Vybrid (vf610),
+MPC5125, MCF54418 and Kinetis K70.
+
+Required properties:
+- compatible: "fsl,vf610-nfc"
+- reg: Address range of the mtd chip
+- interrupts: Should contain the STMMAC interrupts
+- nand-bus-width: see nand.txt
+- nand-ecc-mode: see nand.txt
+- nand-on-flash-bbt: see nand.txt
+- clock-frequency : Optional clock rate to NFC in Hz
+- #address-cells, #size-cells : Must be present if the device has sub-nodes
+  representing partitions.
+
+Required properties for hardware ECC:
+- nand-ecc-strength: supported strengths are 24 and 32 (see nand.txt)
+- nand-ecc-step-size: step size equals page size, currently only 2k pages are
+  supported
+
+Example:
+
+	nfc: nand at 400e0000 {
+		compatible = "fsl,vf610-nfc";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x400e0000 0x4000>;
+		interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clks VF610_CLK_NFC>;
+		clock-names = "nfc";
+		assigned-clocks = <&clks VF610_CLK_NFC>;
+		assigned-clock-rates = <33000000>;
+		nand-bus-width = <8>;
+		nand-ecc-mode = "hw";
+		nand-on-flash-bbt;
+		nand-ecc-strength = <32>;
+		nand-ecc-step-size = <2048>;
+	};
Signature · 1 line
2.3.1
#5 lore raw

PATCH v2 4/6 ARM: vf610: enable NAND Flash Controller

In reply to Stefan Agner

Enable the NAND Flash Controller driver which is part of the Vybrid SoC by default.

---
 arch/arm/mach-imx/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-imx/Kconfig +1 -0
index c8dffce..182e30e 100644
@@ -635,6 +635,7 @@ config SOC_VF610
 	select ARM_GIC
 	select PINCTRL_VF610
 	select PL310_ERRATA_769419 if CACHE_L2X0
+	select HAVE_NAND_VF610_NFC
 
 	help
 	  This enable support for Freescale Vybrid VF610 processor.
Signature · 1 line
2.3.1
#6 lore raw

PATCH v2 5/6 ARM: dts: vf610: add NAND flash controller peripherial

In reply to Stefan Agner

This adds the NAND flash controller (NFC) peripherial. The driver supports the SLC NAND chips found on Freescale's Vybrid Tower System Module. The Micron NAND chip on the module needs 4-bit ECC per 512 byte page. Use 24-bit ECC per 2k page, which is supported by the driver.

---
 arch/arm/boot/dts/vf610-twr.dts | 44 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/vfxxx.dtsi    |  8 ++++++++
 2 files changed, 52 insertions(+)
arch/arm/boot/dts/vf610-twr.dts +44 -0
index f64fddc..f42d155 100644
@@ -287,6 +287,50 @@
 	status = "okay";
 };
 
+&iomuxc {
+	vf610-twr {
+		pinctrl_nfc_1: nfcgrp_1 {
+			fsl,pins = <
+			VF610_PAD_PTD31__NF_IO15	0x28df
+			VF610_PAD_PTD30__NF_IO14	0x28df
+			VF610_PAD_PTD29__NF_IO13	0x28df
+			VF610_PAD_PTD28__NF_IO12	0x28df
+			VF610_PAD_PTD27__NF_IO11	0x28df
+			VF610_PAD_PTD26__NF_IO10	0x28df
+			VF610_PAD_PTD25__NF_IO9		0x28df
+			VF610_PAD_PTD24__NF_IO8		0x28df
+			VF610_PAD_PTD23__NF_IO7		0x28df
+			VF610_PAD_PTD22__NF_IO6		0x28df
+			VF610_PAD_PTD21__NF_IO5		0x28df
+			VF610_PAD_PTD20__NF_IO4		0x28df
+			VF610_PAD_PTD19__NF_IO3		0x28df
+			VF610_PAD_PTD18__NF_IO2		0x28df
+			VF610_PAD_PTD17__NF_IO1		0x28df
+			VF610_PAD_PTD16__NF_IO0		0x28df
+			VF610_PAD_PTB24__NF_WE_B	0x28c2
+			VF610_PAD_PTB25__NF_CE0_B	0x28c2
+			VF610_PAD_PTB27__NF_RE_B	0x28c2
+			VF610_PAD_PTC26__NF_RB_B	0x283d
+			VF610_PAD_PTC27__NF_ALE		0x28c2
+			VF610_PAD_PTC28__NF_CLE		0x28c2
+			>;
+		};
+	};
+};
+
+&nfc {
+	assigned-clocks = <&clks VF610_CLK_NFC>;
+	assigned-clock-rates = <33000000>;
+	nand-bus-width = <16>;
+	nand-ecc-mode = "hw";
+	nand-on-flash-bbt;
+	nand-ecc-strength = <24>;
+	nand-ecc-step-size = <2048>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_nfc_1>;
+	status = "okay";
+};
+
 &uart1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_uart1>;
arch/arm/boot/dts/vfxxx.dtsi +8 -0
index 32de809..8c85972 100644
@@ -507,6 +507,14 @@
 				status = "disabled";
 			};
 
+			nfc: nand at 400e0000 {
+				compatible = "fsl,vf610-nfc";
+				reg = <0x400e0000 0x4000>;
+				interrupts = <83 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clks VF610_CLK_NFC>;
+				clock-names = "nfc";
+				status = "disabled";
+			};
 		};
 	};
 };
Signature · 1 line
2.3.1
#7 lore raw

PATCH v2 6/6 ARM: dts: vf-colibri: enable NAND flash controller

In reply to Stefan Agner

Enable NAND access by adding pinmux and NAND flash controller node to device tree. The NAND chips currently used on the Colibri VF61 requires 8-bit ECC per 512 byte page, hence specify 32-bit ECC strength per 2k page size.

---
 arch/arm/boot/dts/vf-colibri.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/boot/dts/vf-colibri.dtsi +32 -0
index 5c2b732..76139d7 100644
@@ -46,6 +46,19 @@
 	pinctrl-0 = <&pinctrl_i2c0>;
 };
 
+&nfc {
+	assigned-clocks = <&clks VF610_CLK_NFC>;
+	assigned-clock-rates = <33000000>;
+	nand-bus-width = <8>;
+	nand-ecc-mode = "hw";
+	nand-on-flash-bbt;
+	nand-ecc-strength = <32>;
+	nand-ecc-step-size = <2048>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_nfc_1>;
+	status = "okay";
+};
+
 &pwm0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm0>;
@@ -141,6 +154,25 @@
 			>;
 		};
 
+		pinctrl_nfc_1: nfcgrp_1 {
+			fsl,pins = <
+				VF610_PAD_PTD23__NF_IO7		0x28df
+				VF610_PAD_PTD22__NF_IO6		0x28df
+				VF610_PAD_PTD21__NF_IO5		0x28df
+				VF610_PAD_PTD20__NF_IO4		0x28df
+				VF610_PAD_PTD19__NF_IO3		0x28df
+				VF610_PAD_PTD18__NF_IO2		0x28df
+				VF610_PAD_PTD17__NF_IO1		0x28df
+				VF610_PAD_PTD16__NF_IO0		0x28df
+				VF610_PAD_PTB24__NF_WE_B	0x28c2
+				VF610_PAD_PTB25__NF_CE0_B	0x28c2
+				VF610_PAD_PTB27__NF_RE_B	0x28c2
+				VF610_PAD_PTC26__NF_RB_B	0x283d
+				VF610_PAD_PTC27__NF_ALE		0x28c2
+				VF610_PAD_PTC28__NF_CLE		0x28c2
+			>;
+		};
+
 		pinctrl_pwm0: pwm0grp {
 			fsl,pins = <
 				VF610_PAD_PTB0__FTM0_CH0		0x1182
Signature · 1 line
2.3.1
#4 lore raw

Re: [PATCH v2 3/6] mtd: nand: vf610_nfc: add device tree bindings

In reply to Stefan Agner
Quoted 13 lines · stefan at agner.ch

---
.../devicetree/bindings/mtd/vf610-nfc.txt | 39 ++++++++++++++++++++++

1 file changed, 39 insertions(+) create mode 100644

Documentation/devicetree/bindings/mtd/vf610-nfc.txt

Documentation/devicetree/bindings/mtd/vf610-nfc.txt new file +0 -0
new file mode 100644
index 0000000..312c872

[snip]

Quoted 2 lines
+- reg: Address range of the mtd chip 
+- interrupts: Should contain the STMMAC interrupts 

What is 'STMMAC'? Is that something I cribbed from another file? Ah, I see 'spear_smi.txt' which is an NAND driver with a 'clock-frequency' parameter (probably before 'assigned-clocks' support).

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mtd/spear_smi.txt

I don't think 'STMMAC' makes sense.

+- interrupts: irq to be used

Maybe? Same as mxc-nand.txt. It is not so helpful though.

Quoted 4 lines
+- nand-bus-width: see nand.txt
+- nand-ecc-mode: see nand.txt
+- nand-on-flash-bbt: see nand.txt 
+- clock-frequency : Optional clock rate to NFC in Hz

I guess this changed? We might want to put a note about what kind of impact this might have on the bus. Ie,

assigned-clocks: Input SOC clock to the NAND controller.
assigned-clock-rates: The NAND bus timing is derived from this clock
rate and should not exceed maximum timing for any NAND memory chip in a board stuffing. Typical NAND memory timings derived from this clock are found in the SOC hardware reference manual.

Originally, the reason I made this file was because the 'clock-frequency' was non-standard. I guess it is nice to have it anyways.

Fwiw,
Bill Pringlemeir.