Skip to contentSkip to conversation

mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

PATCH New Alex Nemirovsky 5 participants 12 messages Jun 1, 2020 – Jun 4, 2020

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

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Changes in v2:
- Cleanup code style to pass checkpatch.pl

 MAINTAINERS                    |    2 +
 drivers/mtd/nand/raw/Kconfig   |   31 +
 drivers/mtd/nand/raw/Makefile  |    1 +
 drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++
 5 files changed, 8876 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/ca_nand.c
 create mode 100644 drivers/mtd/nand/raw/ca_nand.h
MAINTAINERS +2 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:	drivers/gpio/cortina_gpio.c
 F:	drivers/watchdog/cortina_wdt.c
 F:	drivers/serial/serial_cortina.c
 F:	drivers/mmc/ca_dw_mmc.c
+F:	drivers/mtd/nand/raw/ca_nand.c
+F:	drivers/mtd/nand/raw/ca_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +31 -0
index c4d9d31..b3cbfcc 100644
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
        help
          Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+	select SYS_NAND_SELF_INIT
+        help
+          This enables the parallel RAW NAND driver for the
+	  Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.
+
+config NAND_CORTINA_ECC_HW_BCH
+     bool
+     default y
+     depends on NAND_CORTINA_ECC_LEVEL=2 \
+             || NAND_CORTINA_ECC_LEVEL=3 \
+             || NAND_CORTINA_ECC_LEVEL=4 \
+             || NAND_CORTINA_ECC_LEVEL=5
+
 config NAND_DAVINCI
 	bool "Support TI Davinci NAND controller"
 	help
drivers/mtd/nand/raw/Makefile +1 -0
index 9337f64..572e9e6 100644
@@ -42,6 +42,7 @@ obj-$(CONFIG_NAND_ECC_BCH) += nand_bch.o
 obj-$(CONFIG_NAND_ATMEL) += atmel_nand.o
 obj-$(CONFIG_NAND_ARASAN) += arasan_nfc.o
 obj-$(CONFIG_NAND_BRCMNAND) += brcmnand/
+obj-$(CONFIG_NAND_CORTINA) += ca_nand.o
 obj-$(CONFIG_NAND_DAVINCI) += davinci_nand.o
 obj-$(CONFIG_NAND_DENALI) += denali.o
 obj-$(CONFIG_NAND_DENALI_DT) += denali_dt.o
drivers/mtd/nand/raw/ca_nand.c new file +4943 -0

2,948 lines not on this page · raw message

drivers/mtd/nand/raw/ca_nand.h new file +3899 -0

3,899 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#1 lore raw

PATCH v3 2/2 board: presidio-asic: Add RAW Parallel NAND support

Add Parallel NAND CAxxxx support to Cortina Access Presidio Engineering Board support

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>

---

Changes in v3: None
Changes in v2: None

 configs/cortina_presidio-asic-bch16_defconfig | 35 ++++++++++++++++++++++++++
 configs/cortina_presidio-asic-bch24_defconfig | 36 +++++++++++++++++++++++++++
 configs/cortina_presidio-asic-bch40_defconfig | 36 +++++++++++++++++++++++++++
 configs/cortina_presidio-asic-bch8_defconfig  | 36 +++++++++++++++++++++++++++
 include/configs/presidio_asic.h               | 15 +++++++++++
 5 files changed, 158 insertions(+)
 create mode 100644 configs/cortina_presidio-asic-bch16_defconfig
 create mode 100644 configs/cortina_presidio-asic-bch24_defconfig
 create mode 100644 configs/cortina_presidio-asic-bch40_defconfig
 create mode 100644 configs/cortina_presidio-asic-bch8_defconfig
configs/cortina_presidio-asic-bch16_defconfig new file +35 -0
new file mode 100644
index 0000000..57ef98f
@@ -0,0 +1,35 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x04000000
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x400000
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_NAND=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+CONFIG_ENV_IS_IN_NAND=y
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+# CONFIG_MMC is not set
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_NAND_CORTINA=y
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
configs/cortina_presidio-asic-bch24_defconfig new file +36 -0
new file mode 100644
index 0000000..d22eae7
@@ -0,0 +1,36 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x04000000
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x400000
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_NAND=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+CONFIG_ENV_IS_IN_NAND=y
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+# CONFIG_MMC is not set
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_NAND_CORTINA=y
+CONFIG_NAND_CORTINA_ECC_LEVEL=4
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
configs/cortina_presidio-asic-bch40_defconfig new file +36 -0
new file mode 100644
index 0000000..3c39415
@@ -0,0 +1,36 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x04000000
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x400000
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_NAND=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+CONFIG_ENV_IS_IN_NAND=y
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+# CONFIG_MMC is not set
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_NAND_CORTINA=y
+CONFIG_NAND_CORTINA_ECC_LEVEL=5
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
configs/cortina_presidio-asic-bch8_defconfig new file +36 -0
new file mode 100644
index 0000000..8cda753
@@ -0,0 +1,36 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x04000000
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x400000
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_NAND=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+CONFIG_ENV_IS_IN_NAND=y
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+# CONFIG_MMC is not set
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_NAND_CORTINA=y
+CONFIG_NAND_CORTINA_ECC_LEVEL=2
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
include/configs/presidio_asic.h +15 -0
index 51177f4..3e5030f 100644
@@ -32,6 +32,8 @@
 
 #define CONFIG_SYS_TIMER_BASE		0xf4321000
 
+#define GLOBAL_SOFTWARE2		0xf43200c4
+
 /* Use external clock source */
 #define PRESIDIO_APB_CLK		125000000
 #define CORTINA_PER_IO_FREQ		PRESIDIO_APB_CLK
@@ -68,4 +70,17 @@
 #define CONFIG_SYS_MAXARGS		64
 #define CONFIG_EXTRA_ENV_SETTINGS	"silent=y\0"
 
+/* Macros for Flash */
+#define CORTINA_FLASH_CTRL_BASE		0xf4324000
+#define CORTINA_DMA_GLB_BASE		0xf7001000
+#define CORTINA_DMA_SSP_BASE		0xf7001a00
+#define CONFIG_SYS_FLASH_BASE		0xe0000000
+
+#ifdef CONFIG_NAND_CORTINA
+	#define CONFIG_SYS_MAX_NAND_DEVICE	1
+	#define CONFIG_SYS_NAND_MAX_CHIPS	1
+	#define CONFIG_SYS_NAND_BASE		CONFIG_SYS_FLASH_BASE
+	#define CONFIG_SYS_NAND_BASE_LIST	{ CONFIG_SYS_NAND_BASE }
+#endif
+
 #endif /* __PRESIDIO_ASIC_H */
Signature · 1 line
2.7.4
maintainer
#2 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

In reply to Alex Nemirovsky

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 20 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Quoted 8 lines

Changes in v2:
- Cleanup code style to pass checkpatch.pl

 MAINTAINERS                    |    2 +
 drivers/mtd/nand/raw/Kconfig   |   31 +
 drivers/mtd/nand/raw/Makefile  |    1 +
 drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++

This is insanely big !

Quoted 22 lines
 5 files changed, 8876 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/ca_nand.c
 create mode 100644 drivers/mtd/nand/raw/ca_nand.h
MAINTAINERS +2 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:	drivers/gpio/cortina_gpio.c
 F:	drivers/watchdog/cortina_wdt.c
 F:	drivers/serial/serial_cortina.c
 F:	drivers/mmc/ca_dw_mmc.c
+F:	drivers/mtd/nand/raw/ca_nand.c
+F:	drivers/mtd/nand/raw/ca_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +0 -0
index c4d9d31..b3cbfcc 100644

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 107

Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +3 -0
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
        help
          Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+	select SYS_NAND_SELF_INIT

Alignment looks wrong

Quoted 9 lines
drivers/mtd/nand/raw/Kconfig +9 -0
+        help
+          This enables the parallel RAW NAND driver for the
+	  Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 126

Quoted 10 lines
drivers/mtd/nand/raw/Kconfig +10 -0
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.

Not sure how u-boot guys want to handle this but the current way to request for a specif correction is to pass nand-ecc-strength and nand-ecc-size DT properties. If the driver does not support the requested properties, there is a function (at least in Linux) which finds the closest correction called nand_ecc_choose_conf(), provided that you implemented a few specific hooks in your driver.

But basically, this should be the core's input, not the user, unless you have a strong reason to do so.

Quoted 12 lines
drivers/mtd/nand/raw/Kconfig +9 -0
+
+config NAND_CORTINA_ECC_HW_BCH
+     bool
+     default y
+     depends on NAND_CORTINA_ECC_LEVEL=2 \
+             || NAND_CORTINA_ECC_LEVEL=3 \
+             || NAND_CORTINA_ECC_LEVEL=4 \
+             || NAND_CORTINA_ECC_LEVEL=5
+
 config NAND_DAVINCI
 	bool "Support TI Davinci NAND controller"
 
#3 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Quoted 85 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 20 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Quoted 8 lines

Changes in v2:
- Cleanup code style to pass checkpatch.pl

 MAINTAINERS                    |    2 +
 drivers/mtd/nand/raw/Kconfig   |   31 +
 drivers/mtd/nand/raw/Makefile  |    1 +
 drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++

This is insanely big !

Quoted 22 lines
 5 files changed, 8876 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/ca_nand.c
 create mode 100644 drivers/mtd/nand/raw/ca_nand.h
MAINTAINERS +2 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:	drivers/gpio/cortina_gpio.c
 F:	drivers/watchdog/cortina_wdt.c
 F:	drivers/serial/serial_cortina.c
 F:	drivers/mmc/ca_dw_mmc.c
+F:	drivers/mtd/nand/raw/ca_nand.c
+F:	drivers/mtd/nand/raw/ca_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +0 -0
index c4d9d31..b3cbfcc 100644

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 107

Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +3 -0
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
        help
          Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+	select SYS_NAND_SELF_INIT

Alignment looks wrong

Quoted 18 lines
drivers/mtd/nand/raw/Kconfig +18 -0
+        help
+          This enables the parallel RAW NAND driver for the
+	  Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
Quoted 8 lines

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 126

Quoted 1 line
drivers/mtd/nand/raw/Kconfig +1 -0
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.

Not sure how u-boot guys want to handle this but the current way to request for a specif correction is to pass nand-ecc-strength and nand-ecc-size DT properties. If the driver does not support the requested properties, there is a function (at least in Linux) which finds the closest correction called nand_ecc_choose_conf(), provided that you implemented a few specific hooks in your driver.

We have drivers making use of those properties too, so this one should as well. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200602/7c1a55a4/attachment.sig>
#4 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Hi Miquel/Tom,

Quoted 94 lines
Quoted 85 lines

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 20 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Quoted 8 lines

Changes in v2:
- Cleanup code style to pass checkpatch.pl

 MAINTAINERS                    |    2 +
 drivers/mtd/nand/raw/Kconfig   |   31 +
 drivers/mtd/nand/raw/Makefile  |    1 +
 drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++

This is insanely big !

Quoted 22 lines
 5 files changed, 8876 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/ca_nand.c
 create mode 100644 drivers/mtd/nand/raw/ca_nand.h
MAINTAINERS +2 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:	drivers/gpio/cortina_gpio.c
 F:	drivers/watchdog/cortina_wdt.c
 F:	drivers/serial/serial_cortina.c
 F:	drivers/mmc/ca_dw_mmc.c
+F:	drivers/mtd/nand/raw/ca_nand.c
+F:	drivers/mtd/nand/raw/ca_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +0 -0
index c4d9d31..b3cbfcc 100644

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 107

Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +3 -0
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
        help
          Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+	select SYS_NAND_SELF_INIT

Alignment looks wrong

Quoted 18 lines
drivers/mtd/nand/raw/Kconfig +18 -0
+        help
+          This enables the parallel RAW NAND driver for the
+	  Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
Quoted 8 lines

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 126

Quoted 1 line
drivers/mtd/nand/raw/Kconfig +1 -0
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.

Not sure how u-boot guys want to handle this but the current way to request for a specif correction is to pass nand-ecc-strength and nand-ecc-size DT properties. If the driver does not support the requested properties, there is a function (at least in Linux) which finds the closest correction called nand_ecc_choose_conf(), provided that you implemented a few specific hooks in your driver.

Quoted 5 lines

We have drivers making use of those properties too, so this one should as well. Thanks!

Signature · 1 line
Tom

Since DTB is separate image from u-boot. If we put these information in DTB. What ECC algorithm should be applied when read DTB from flash? Could you guide more detail.

Thanks,
Jason

maintainer
#5 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Hi Jason,

Jason Li <[email protected]> wrote on Wed, 3 Jun 2020 01:55:22 +0000:

Quoted 99 lines

Hi Miquel/Tom,

Quoted 97 lines
Quoted 85 lines

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 20 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Quoted 8 lines

Changes in v2:
- Cleanup code style to pass checkpatch.pl

 MAINTAINERS                    |    2 +
 drivers/mtd/nand/raw/Kconfig   |   31 +
 drivers/mtd/nand/raw/Makefile  |    1 +
 drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++  

This is insanely big !

Quoted 22 lines
 5 files changed, 8876 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/ca_nand.c
 create mode 100644 drivers/mtd/nand/raw/ca_nand.h
MAINTAINERS +2 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:	drivers/gpio/cortina_gpio.c
 F:	drivers/watchdog/cortina_wdt.c
 F:	drivers/serial/serial_cortina.c
 F:	drivers/mmc/ca_dw_mmc.c
+F:	drivers/mtd/nand/raw/ca_nand.c
+F:	drivers/mtd/nand/raw/ca_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +0 -0
index c4d9d31..b3cbfcc 100644

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 107

Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +3 -0
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
        help
          Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+	select SYS_NAND_SELF_INIT  

Alignment looks wrong

Quoted 18 lines
drivers/mtd/nand/raw/Kconfig +18 -0
+        help
+          This enables the parallel RAW NAND driver for the
+	  Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
Quoted 8 lines

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 126

Quoted 1 line
drivers/mtd/nand/raw/Kconfig +1 -0
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.  

Not sure how u-boot guys want to handle this but the current way to request for a specif correction is to pass nand-ecc-strength and nand-ecc-size DT properties. If the driver does not support the requested properties, there is a function (at least in Linux) which finds the closest correction called nand_ecc_choose_conf(), provided that you implemented a few specific hooks in your driver.

We have drivers making use of those properties too, so this one should as well. Thanks!

Quoted 7 lines
Quoted 2 lines
Signature · 1 line
Tom  

Since DTB is separate image from u-boot. If we put these information in DTB. What ECC algorithm should be applied when read DTB from flash? Could you guide more detail.

I guess your upper layer is in charge. Maybe you can check OF_SEPARATE / OF_HOSTFILE. If you're in trouble at SPL level, maybe you can check sunxi_nand_spl.c too.

#6 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

In reply to Jason Li

Hi Jason,

Quoted 100 lines · Jason Li

Hi Miquel/Tom,

Quoted 97 lines
Quoted 85 lines

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 20 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Quoted 8 lines

Changes in v2:
- Cleanup code style to pass checkpatch.pl

 MAINTAINERS                    |    2 +
 drivers/mtd/nand/raw/Kconfig   |   31 +
 drivers/mtd/nand/raw/Makefile  |    1 +
 drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++

This is insanely big !

Quoted 22 lines
 5 files changed, 8876 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/ca_nand.c
 create mode 100644 drivers/mtd/nand/raw/ca_nand.h
MAINTAINERS +2 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:     drivers/gpio/cortina_gpio.c
 F:        drivers/watchdog/cortina_wdt.c
 F:        drivers/serial/serial_cortina.c
 F:        drivers/mmc/ca_dw_mmc.c
+F:        drivers/mtd/nand/raw/ca_nand.c
+F:        drivers/mtd/nand/raw/ca_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:        Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +0 -0
index c4d9d31..b3cbfcc 100644

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 107

Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +3 -0
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
        help
          Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+  select SYS_NAND_SELF_INIT

Alignment looks wrong

Quoted 18 lines
drivers/mtd/nand/raw/Kconfig +18 -0
+        help
+          This enables the parallel RAW NAND driver for the
+    Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
Quoted 8 lines

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 126

Quoted 1 line
drivers/mtd/nand/raw/Kconfig +1 -0
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.

Not sure how u-boot guys want to handle this but the current way to request for a specif correction is to pass nand-ecc-strength and nand-ecc-size DT properties. If the driver does not support the requested properties, there is a function (at least in Linux) which finds the closest correction called nand_ecc_choose_conf(), provided that you implemented a few specific hooks in your driver.

We have drivers making use of those properties too, so this one should as well. Thanks!

Quoted 7 lines
Quoted 2 lines

--
Tom

Since DTB is separate image from u-boot. If we put these information in DTB. What ECC algorithm should be applied when read DTB from flash? Could you guide more detail.

Typically DTB is packaged with U-Boot and they are loaded together. So they should use the same ECC algorithm.

If you have a complicated image, take a look at binman.

Regards,
Simon

#7 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

In reply to Miquel Raynal
Quoted 32 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 23 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Changes in v2:
- Cleanup code style to pass checkpatch.pl

Quoted 7 lines
Quoted 5 lines
MAINTAINERS                    |    2 +
drivers/mtd/nand/raw/Kconfig   |   31 +
drivers/mtd/nand/raw/Makefile  |    1 +
drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++

This is insanely big !

Hi Miquel, could you clarify? Is there a change request?

Quoted 74 lines
Quoted 23 lines
5 files changed, 8876 insertions(+)

create mode 100644 drivers/mtd/nand/raw/ca_nand.c
create mode 100644 drivers/mtd/nand/raw/ca_nand.h

MAINTAINERS +0 -0
index 8add9d4..6da2ad8 100644
@@ -181,6 +181,8 @@ F:	drivers/gpio/cortina_gpio.c

F: drivers/watchdog/cortina_wdt.c
F: drivers/serial/serial_cortina.c
F: drivers/mmc/ca_dw_mmc.c

MAINTAINERS +2 -0
+F:	drivers/mtd/nand/raw/ca_nand.c
+F:	drivers/mtd/nand/raw/ca_nand.h

ARM/CZ.NIC TURRIS MOX SUPPORT
M: Marek Behun <[email protected]>

drivers/mtd/nand/raw/Kconfig +0 -0
index c4d9d31..b3cbfcc 100644

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 107

Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +3 -0
@@ -102,6 +102,37 @@ config NAND_BRCMNAND_63158
       help
         Enable support for broadcom nand driver on bcm63158.
 
+config NAND_CORTINA
+        tristate "Support Cortina-Access Parallel NAND cntlr."
+	select SYS_NAND_SELF_INIT

Alignment looks wrong

Quoted 9 lines
drivers/mtd/nand/raw/Kconfig +9 -0
+        help
+          This enables the parallel RAW NAND driver for the
+	  Cortina-Access CAxxxx Family of SoCs.
+
+config NAND_CORTINA_ECC_LEVEL
+        int "Cortina-Access Parallel Nand driver HW ECC algorithm"
+        default 3
+        range 0 5
+        depends on NAND_CORTINA

drivers/mtd/nand/raw/Kconfig config NAND_BRCMNAND_63158 · line 126

Quoted 10 lines
drivers/mtd/nand/raw/Kconfig +10 -0
+        help
+          NAND Flash ECC algorithm. Value range from 0 to 5.
+          The default value is 3.
+
+          0: Hamming algorithm. Correct 3 bad bits in 256 btyes.
+          1: Hamming algorithm. Correct 3 bad bits in 512 btyes.
+          2: BCH algorithm. Correct 8 bad bits in 1K btyes.
+          3: BCH algorithm. Correct 16 bad bits in 1K btyes.
+          4: BCH algorithm. Correct 24 bad bits in 1K btyes.
+          5: BCH algorithm. Correct 40 bad bits in 1K btyes.

Not sure how u-boot guys want to handle this but the current way to request for a specif correction is to pass nand-ecc-strength and nand-ecc-size DT properties. If the driver does not support the requested properties, there is a function (at least in Linux) which finds the closest correction called nand_ecc_choose_conf(), provided that you implemented a few specific hooks in your driver.

But basically, this should be the core's input, not the user, unless you have a strong reason to do so.

Quoted 12 lines
drivers/mtd/nand/raw/Kconfig +9 -0
+
+config NAND_CORTINA_ECC_HW_BCH
+     bool
+     default y
+     depends on NAND_CORTINA_ECC_LEVEL=2 \
+             || NAND_CORTINA_ECC_LEVEL=3 \
+             || NAND_CORTINA_ECC_LEVEL=4 \
+             || NAND_CORTINA_ECC_LEVEL=5
+

config NAND_DAVINCI
bool "Support TI Davinci NAND controller"

maintainer
#8 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Wed, 3 Jun 2020 00:25:53 +0000:

Quoted 36 lines
Quoted 36 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 28 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Changes in v2:
- Cleanup code style to pass checkpatch.pl

MAINTAINERS                    |    2 +
drivers/mtd/nand/raw/Kconfig   |   31 +
drivers/mtd/nand/raw/Makefile  |    1 +
drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++  
Quoted 3 lines
Quoted 1 line

This is insanely big !

Hi Miquel, could you clarify? Is there a change request?

9000 lines for a single NAND driver? You bet I do :)

$ wc -l drivers/mtd/nand/raw/*.c | grep -v spl
  1273 drivers/mtd/nand/raw/arasan_nfc.c
  1511 drivers/mtd/nand/raw/atmel_nand.c
   838 drivers/mtd/nand/raw/davinci_nand.c
  1376 drivers/mtd/nand/raw/denali.c
   171 drivers/mtd/nand/raw/denali_dt.c
   810 drivers/mtd/nand/raw/fsl_elbc_nand.c
  1064 drivers/mtd/nand/raw/fsl_ifc_nand.c
   184 drivers/mtd/nand/raw/fsl_upm.c
   518 drivers/mtd/nand/raw/fsmc_nand.c
   133 drivers/mtd/nand/raw/kb9202_nand.c
    91 drivers/mtd/nand/raw/kirkwood_nand.c
   122 drivers/mtd/nand/raw/kmeter1_nand.c
   765 drivers/mtd/nand/raw/lpc32xx_nand_mlc.c
   583 drivers/mtd/nand/raw/lpc32xx_nand_slc.c
  1307 drivers/mtd/nand/raw/mxc_nand.c
  1421 drivers/mtd/nand/raw/mxs_nand.c
    94 drivers/mtd/nand/raw/mxs_nand_dt.c
  5316 drivers/mtd/nand/raw/nand_base.c
  1373 drivers/mtd/nand/raw/nand_bbt.c
   231 drivers/mtd/nand/raw/nand_bch.c
   175 drivers/mtd/nand/raw/nand.c
   174 drivers/mtd/nand/raw/nand_ecc.c
   213 drivers/mtd/nand/raw/nand_ids.c
    64 drivers/mtd/nand/raw/nand_plat.c
   334 drivers/mtd/nand/raw/nand_timings.c
   904 drivers/mtd/nand/raw/nand_util.c
   193 drivers/mtd/nand/raw/omap_elm.c
  1037 drivers/mtd/nand/raw/omap_gpmc.c
  1933 drivers/mtd/nand/raw/pxa3xx_nand.c
  1061 drivers/mtd/nand/raw/stm32_fmc2_nand.c
  1850 drivers/mtd/nand/raw/sunxi_nand.c
  1002 drivers/mtd/nand/raw/tegra_nand.c
   815 drivers/mtd/nand/raw/vf610_nfc.c
  1254 drivers/mtd/nand/raw/zynq_nand.c

So this driver would be almost twice bigger than the NAND core itself (nand_base.c). I did not check in details but I am pretty sure you duplicate a lot of code.

Thanks,
Miqu?l

#9 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Hi Miquel,

still not clear what you would like us to do about the length of the driver.

Quoted 91 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Wed, 3 Jun 2020 00:25:53 +0000:

Quoted 36 lines
Quoted 36 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 28 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Changes in v2:
- Cleanup code style to pass checkpatch.pl

MAINTAINERS                    |    2 +
drivers/mtd/nand/raw/Kconfig   |   31 +
drivers/mtd/nand/raw/Makefile  |    1 +
drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++  
Quoted 3 lines
Quoted 1 line

This is insanely big !

Hi Miquel, could you clarify? Is there a change request?

9000 lines for a single NAND driver? You bet I do :)

$ wc -l drivers/mtd/nand/raw/*.c | grep -v spl
 1273 drivers/mtd/nand/raw/arasan_nfc.c
 1511 drivers/mtd/nand/raw/atmel_nand.c
  838 drivers/mtd/nand/raw/davinci_nand.c
 1376 drivers/mtd/nand/raw/denali.c
  171 drivers/mtd/nand/raw/denali_dt.c
  810 drivers/mtd/nand/raw/fsl_elbc_nand.c
 1064 drivers/mtd/nand/raw/fsl_ifc_nand.c
  184 drivers/mtd/nand/raw/fsl_upm.c
  518 drivers/mtd/nand/raw/fsmc_nand.c
  133 drivers/mtd/nand/raw/kb9202_nand.c
   91 drivers/mtd/nand/raw/kirkwood_nand.c
  122 drivers/mtd/nand/raw/kmeter1_nand.c
  765 drivers/mtd/nand/raw/lpc32xx_nand_mlc.c
  583 drivers/mtd/nand/raw/lpc32xx_nand_slc.c
 1307 drivers/mtd/nand/raw/mxc_nand.c
 1421 drivers/mtd/nand/raw/mxs_nand.c
   94 drivers/mtd/nand/raw/mxs_nand_dt.c
 5316 drivers/mtd/nand/raw/nand_base.c
 1373 drivers/mtd/nand/raw/nand_bbt.c
  231 drivers/mtd/nand/raw/nand_bch.c
  175 drivers/mtd/nand/raw/nand.c
  174 drivers/mtd/nand/raw/nand_ecc.c
  213 drivers/mtd/nand/raw/nand_ids.c
   64 drivers/mtd/nand/raw/nand_plat.c
  334 drivers/mtd/nand/raw/nand_timings.c
  904 drivers/mtd/nand/raw/nand_util.c
  193 drivers/mtd/nand/raw/omap_elm.c
 1037 drivers/mtd/nand/raw/omap_gpmc.c
 1933 drivers/mtd/nand/raw/pxa3xx_nand.c
 1061 drivers/mtd/nand/raw/stm32_fmc2_nand.c
 1850 drivers/mtd/nand/raw/sunxi_nand.c
 1002 drivers/mtd/nand/raw/tegra_nand.c
  815 drivers/mtd/nand/raw/vf610_nfc.c
 1254 drivers/mtd/nand/raw/zynq_nand.c

So this driver would be almost twice bigger than the NAND core itself (nand_base.c). I did not check in details but I am pretty sure you duplicate a lot of code.

Thanks,
Miqu?l

maintainer
#10 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Wed, 3 Jun 2020 07:23:23 +0000:

Quoted 3 lines

Hi Miquel,

still not clear what you would like us to do about the length of the driver.

Stop duplicating the whole logic present in the core:
- nand reset
- nand identification
- bad block handling
- ca_nand_command{,_lp}()
- ca_nand_scan_tail()

Plus:
- ca_nand_read/write_page_hwecc is overly complicated and 100 lines to assign chip->oob_poi is very suspicious.
- your endless set of definitions in the header is really strange, could be reduced to a smaller number of defines (the ones of interest, that you use).

Hope this helps.

Quoted 93 lines
Quoted 92 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Wed, 3 Jun 2020 00:25:53 +0000:

Quoted 36 lines
Quoted 36 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 28 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Changes in v2:
- Cleanup code style to pass checkpatch.pl

MAINTAINERS                    |    2 +
drivers/mtd/nand/raw/Kconfig   |   31 +
drivers/mtd/nand/raw/Makefile  |    1 +
drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++  
Quoted 3 lines
Quoted 1 line

This is insanely big !

Hi Miquel, could you clarify? Is there a change request?

9000 lines for a single NAND driver? You bet I do :)

$ wc -l drivers/mtd/nand/raw/*.c | grep -v spl
 1273 drivers/mtd/nand/raw/arasan_nfc.c
 1511 drivers/mtd/nand/raw/atmel_nand.c
  838 drivers/mtd/nand/raw/davinci_nand.c
 1376 drivers/mtd/nand/raw/denali.c
  171 drivers/mtd/nand/raw/denali_dt.c
  810 drivers/mtd/nand/raw/fsl_elbc_nand.c
 1064 drivers/mtd/nand/raw/fsl_ifc_nand.c
  184 drivers/mtd/nand/raw/fsl_upm.c
  518 drivers/mtd/nand/raw/fsmc_nand.c
  133 drivers/mtd/nand/raw/kb9202_nand.c
   91 drivers/mtd/nand/raw/kirkwood_nand.c
  122 drivers/mtd/nand/raw/kmeter1_nand.c
  765 drivers/mtd/nand/raw/lpc32xx_nand_mlc.c
  583 drivers/mtd/nand/raw/lpc32xx_nand_slc.c
 1307 drivers/mtd/nand/raw/mxc_nand.c
 1421 drivers/mtd/nand/raw/mxs_nand.c
   94 drivers/mtd/nand/raw/mxs_nand_dt.c
 5316 drivers/mtd/nand/raw/nand_base.c
 1373 drivers/mtd/nand/raw/nand_bbt.c
  231 drivers/mtd/nand/raw/nand_bch.c
  175 drivers/mtd/nand/raw/nand.c
  174 drivers/mtd/nand/raw/nand_ecc.c
  213 drivers/mtd/nand/raw/nand_ids.c
   64 drivers/mtd/nand/raw/nand_plat.c
  334 drivers/mtd/nand/raw/nand_timings.c
  904 drivers/mtd/nand/raw/nand_util.c
  193 drivers/mtd/nand/raw/omap_elm.c
 1037 drivers/mtd/nand/raw/omap_gpmc.c
 1933 drivers/mtd/nand/raw/pxa3xx_nand.c
 1061 drivers/mtd/nand/raw/stm32_fmc2_nand.c
 1850 drivers/mtd/nand/raw/sunxi_nand.c
 1002 drivers/mtd/nand/raw/tegra_nand.c
  815 drivers/mtd/nand/raw/vf610_nfc.c
 1254 drivers/mtd/nand/raw/zynq_nand.c

So this driver would be almost twice bigger than the NAND core itself (nand_base.c). I did not check in details but I am pretty sure you duplicate a lot of code.

Thanks,
Miqu?l

#11 lore raw

PATCH v3 1/2 mtd: rawnand: ca_nand: add Cortina Access Parallel NAND controller support

Hi Miquel,

Quoted 18 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Wed, 3 Jun 2020 07:23:23 +0000:

Quoted 3 lines

Hi Miquel,

still not clear what you would like us to do about the length of the driver.

Stop duplicating the whole logic present in the core:
- nand reset
- nand identification
- bad block handling
- ca_nand_command{,_lp}()
- ca_nand_scan_tail()

Quoted 8 lines

Plus:
- ca_nand_read/write_page_hwecc is overly complicated and 100 lines to assign chip->oob_poi is very suspicious.
- your endless set of definitions in the header is really strange, could be reduced to a smaller number of defines (the ones of interest, that you use).

Hope this helps.

yes, I believe it does.

Jason,
please review Miquel?s feedback and lets try to modify as requested.

Thanks

Quoted 94 lines
Quoted 94 lines
Quoted 93 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Wed, 3 Jun 2020 00:25:53 +0000:

Quoted 36 lines
Quoted 36 lines · Miquel Raynal

Hi Alex,

Alex Nemirovsky <[email protected]> wrote on Mon, 1 Jun 2020 14:26:49 -0700:

Quoted 28 lines

From: Jason Li <[email protected]>

Supports all CAxxxx SoCs which support a parallel nand controller. It should be noted that some CAxxxx Soc also support an separate SPI serial NAND controller.

This driver only supports the parallel NAND controller. A different driver supports the SPI NAND interface controller.

CC Miquel Raynal <[email protected]>
CC Simon Glass <[email protected]>
CC Tom Rini <[email protected]>

---

Changes in v3:
- Include udelay.h to avoid implicit declaration of udelay()

Changes in v2:
- Cleanup code style to pass checkpatch.pl

MAINTAINERS                    |    2 +
drivers/mtd/nand/raw/Kconfig   |   31 +
drivers/mtd/nand/raw/Makefile  |    1 +
drivers/mtd/nand/raw/ca_nand.c | 4943 ++++++++++++++++++++++++++++++++++++++++
drivers/mtd/nand/raw/ca_nand.h | 3899 +++++++++++++++++++++++++++++++  
Quoted 3 lines
Quoted 1 line

This is insanely big !

Hi Miquel, could you clarify? Is there a change request?

9000 lines for a single NAND driver? You bet I do :)

$ wc -l drivers/mtd/nand/raw/*.c | grep -v spl
1273 drivers/mtd/nand/raw/arasan_nfc.c
1511 drivers/mtd/nand/raw/atmel_nand.c
 838 drivers/mtd/nand/raw/davinci_nand.c
1376 drivers/mtd/nand/raw/denali.c
 171 drivers/mtd/nand/raw/denali_dt.c
 810 drivers/mtd/nand/raw/fsl_elbc_nand.c
1064 drivers/mtd/nand/raw/fsl_ifc_nand.c
 184 drivers/mtd/nand/raw/fsl_upm.c
 518 drivers/mtd/nand/raw/fsmc_nand.c
 133 drivers/mtd/nand/raw/kb9202_nand.c
  91 drivers/mtd/nand/raw/kirkwood_nand.c
 122 drivers/mtd/nand/raw/kmeter1_nand.c
 765 drivers/mtd/nand/raw/lpc32xx_nand_mlc.c
 583 drivers/mtd/nand/raw/lpc32xx_nand_slc.c
1307 drivers/mtd/nand/raw/mxc_nand.c
1421 drivers/mtd/nand/raw/mxs_nand.c
  94 drivers/mtd/nand/raw/mxs_nand_dt.c
5316 drivers/mtd/nand/raw/nand_base.c
1373 drivers/mtd/nand/raw/nand_bbt.c
 231 drivers/mtd/nand/raw/nand_bch.c
 175 drivers/mtd/nand/raw/nand.c
 174 drivers/mtd/nand/raw/nand_ecc.c
 213 drivers/mtd/nand/raw/nand_ids.c
  64 drivers/mtd/nand/raw/nand_plat.c
 334 drivers/mtd/nand/raw/nand_timings.c
 904 drivers/mtd/nand/raw/nand_util.c
 193 drivers/mtd/nand/raw/omap_elm.c
1037 drivers/mtd/nand/raw/omap_gpmc.c
1933 drivers/mtd/nand/raw/pxa3xx_nand.c
1061 drivers/mtd/nand/raw/stm32_fmc2_nand.c
1850 drivers/mtd/nand/raw/sunxi_nand.c
1002 drivers/mtd/nand/raw/tegra_nand.c
 815 drivers/mtd/nand/raw/vf610_nfc.c
1254 drivers/mtd/nand/raw/zynq_nand.c

So this driver would be almost twice bigger than the NAND core itself (nand_base.c). I did not check in details but I am pretty sure you duplicate a lot of code.

Thanks,
Miqu?l