Skip to contentSkip to conversation

mtd: rawnand: cortina_nand: Add Cortina CAxxxx SoC support

PATCH Superseded Alex Nemirovsky 2 participants 5 messages Dec 8, 2020 – Dec 11, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtd: rawnand: cortina_nand: Add Cortina CAxxxx SoC support

From: Kate Liu <[email protected]>

Add Cortina Access parallel Nand support for CAxxxx SOCs

---

 MAINTAINERS                         |    2 +
 drivers/mtd/nand/raw/Kconfig        |   12 +
 drivers/mtd/nand/raw/Makefile       |    1 +
 drivers/mtd/nand/raw/cortina_nand.c | 1390 +++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/cortina_nand.h |  293 ++++++++
 5 files changed, 1698 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/cortina_nand.c
 create mode 100644 drivers/mtd/nand/raw/cortina_nand.h
MAINTAINERS +2 -0
index 2625fc6..a002263 100644
@@ -197,6 +197,8 @@ F:	drivers/led/led_cortina.c
 F:	drivers/mmc/ca_dw_mmc.c
 F:	drivers/i2c/i2c-cortina.c
 F:	drivers/i2c/i2c-cortina.h
+F:	drivers/mtd/nand/raw/cortina_nand.c
+F:	drivers/mtd/nand/raw/cortina_nand.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
drivers/mtd/nand/raw/Kconfig +12 -0
index 3cf3b14..ed151ee 100644
@@ -321,6 +321,18 @@ config NAND_STM32_FMC2
 	  The controller supports a maximum 8k page size and supports
 	  a maximum 8-bit correction error per sector of 512 bytes.
 
+config CORTINA_NAND
+	bool "Support for NAND controller on Cortina-Access SoCs"
+	depends on CORTINA_PLATFORM
+	select SYS_NAND_SELF_INIT
+	select DM_MTD
+	imply CMD_NAND
+	help
+	  Enables support for NAND Flash chips on Coartina-Access SoCs platform
+	  This controller is found on Presidio/Venus SoCs.
+	  The controller supports a maximum 8k page size and supports
+	  a maximum 40-bit error correction per sector of 1024 bytes.
+
 comment "Generic NAND options"
 
 config SYS_NAND_BLOCK_SIZE
drivers/mtd/nand/raw/Makefile +1 -0
index 24c51b6..f3f0e15 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_NAND_PLAT) += nand_plat.o
 obj-$(CONFIG_NAND_SUNXI) += sunxi_nand.o
 obj-$(CONFIG_NAND_ZYNQ) += zynq_nand.o
 obj-$(CONFIG_NAND_STM32_FMC2) += stm32_fmc2_nand.o
+obj-$(CONFIG_CORTINA_NAND) += cortina_nand.o
 
 else  # minimal SPL drivers
 
drivers/mtd/nand/raw/cortina_nand.c new file +1390 -0

1,390 lines not on this page · raw message

drivers/mtd/nand/raw/cortina_nand.h new file +293 -0

293 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 board: presidio: Add Parallel NAND support

From: Kate Liu <[email protected]>

Set environment for Nand flash (U-boot 2020.04):
- add nand flash in the device tree
- add new default configuration file for G3 using parallel Nand
- set nand parameters in presidio_asic.h

---

 MAINTAINERS                                   |  1 +
 arch/arm/dts/ca-presidio-engboard.dts         | 14 +++++++++++
 configs/cortina_presidio-asic-pnand_defconfig | 34 +++++++++++++++++++++++++++
 include/configs/presidio_asic.h               |  9 +++++++
 4 files changed, 58 insertions(+)
 create mode 100644 configs/cortina_presidio-asic-pnand_defconfig
MAINTAINERS +1 -0
index a002263..a4d5f30 100644
@@ -199,6 +199,7 @@ F:	drivers/i2c/i2c-cortina.c
 F:	drivers/i2c/i2c-cortina.h
 F:	drivers/mtd/nand/raw/cortina_nand.c
 F:	drivers/mtd/nand/raw/cortina_nand.h
+F:	configs/cortina_presidio-asic-pnand_defconfig
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M:	Marek Behun <[email protected]>
arch/arm/dts/ca-presidio-engboard.dts +14 -0
index eef433e..0ab52fd 100644
@@ -52,6 +52,20 @@
 		clock-frequency = <400000>;
 	};
 
+	nand: nand-controller at f4324000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "cortina,ca-nand";
+		reg = <0 0xf4324000 0x3b0>, /* NAND controller */
+		      <0 0xf7001000 0xb4>, /* DMA_GLOBAL */
+		      <0 0xf7001a00 0x80>; /* DMA channel0 for FLASH */
+		status = "okay";
+		nand-ecc-mode = "hw";
+		nand-ecc-strength = <16>;
+		nand-ecc-step-size = <1024>;    /* Must be 1024 */
+		nand_flash_base_addr = <0xe0000000>;
+	};
+
 	sflash: sflash-controller at f4324000 {
 		#address-cells = <2>;
 		#size-cells = <1>;
configs/cortina_presidio-asic-pnand_defconfig new file +34 -0
new file mode 100644
index 0000000..ed83da1
@@ -0,0 +1,34 @@
+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_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="earlycon=serial,0xf4329148 console=ttyS0,115200 root=/dev/ram0"
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+# CONFIG_MMC is not set
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
+
+CONFIG_CMD_MTD=y
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_CORTINA_NAND=y
include/configs/presidio_asic.h +9 -0
index 34235b5..710731e 100644
@@ -67,4 +67,13 @@
 #define CONFIG_SYS_MAXARGS		64
 #define CONFIG_EXTRA_ENV_SETTINGS	"silent=y\0"
 
+/* nand driver parameters */
+#ifdef CONFIG_TARGET_PRESIDIO_ASIC
+	#define CONFIG_SYS_NAND_ONFI_DETECTION
+	#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
#2 lore raw

PATCH 2/2 board: presidio: Add Parallel NAND support

Quoted 7 lines · Alex Nemirovsky

From: Kate Liu <[email protected]>

Set environment for Nand flash (U-boot 2020.04):
- add nand flash in the device tree
- add new default configuration file for G3 using parallel Nand
- set nand parameters in presidio_asic.h

Quoted 8 lines

---

 MAINTAINERS                                   |  1 +
 arch/arm/dts/ca-presidio-engboard.dts         | 14 +++++++++++
 configs/cortina_presidio-asic-pnand_defconfig | 34 +++++++++++++++++++++++++++

A small thing, the defconfig being added here (and aside, I gather we can't have a single defconfig for all variants?) needs to be re-generated with savedefconfig. There's a blank line in it which implies that it wasn't. 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/20201211/022d3769/attachment.sig>
#3 lore raw

PATCH 2/2 board: presidio: Add Parallel NAND support

Hi Tom,
after this NAND driver is in master, we can look at reducing the number of defconfigs for this board and send out a new patch.

Thanks
-Alex

Quoted 27 lines · Tom Rini
Quoted 7 lines · Alex Nemirovsky

From: Kate Liu <[email protected]>

Set environment for Nand flash (U-boot 2020.04):
- add nand flash in the device tree
- add new default configuration file for G3 using parallel Nand
- set nand parameters in presidio_asic.h

Quoted 8 lines

---

MAINTAINERS                                   |  1 +
arch/arm/dts/ca-presidio-engboard.dts         | 14 +++++++++++
configs/cortina_presidio-asic-pnand_defconfig | 34 +++++++++++++++++++++++++++

A small thing, the defconfig being added here (and aside, I gather we can't have a single defconfig for all variants?) needs to be re-generated with savedefconfig. There's a blank line in it which implies that it wasn't. Thanks.

Signature · 1 line
Tom
#4 lore raw

PATCH 1/2 mtd: rawnand: cortina_nand: Add Cortina CAxxxx SoC support

In reply to Alex Nemirovsky
Quoted 8 lines · Alex Nemirovsky

From: Kate Liu <[email protected]>

Add Cortina Access parallel Nand support for CAxxxx SOCs

A one small things:

[snip]

Quoted 11 lines
drivers/mtd/nand/raw/cortina_nand.h new file +11 -0
+struct nand_ctlr {
+	/* Cortina NAND controller register */
+	u32 flash_id;		     // offset 0x000
+	u32 flash_timeout;		// offset 0x004
+	u32 flash_status;		 // offset 0x008
+	u32 flash_type;		   // offset 0x00c
+	u32 flash_flash_access_start;     // offset 0x010
+	u32 flash_flash_interrupt;	// offset 0x014
+	u32 flash_flash_mask;	     // offset 0x018
+	u32 flash_fifo_control;	   // offset 0x01c
+	u32 flash_fifo_status;	    // offset 0x020

drivers/mtd/nand/raw/cortina_nand.h line 153

Quoted 10 lines
drivers/mtd/nand/raw/cortina_nand.h new file +10 -0
+	u32 flash_fifo_address;	   // offset 0x024
+	u32 flash_fifo_match_address;     // offset 0x028
+	u32 flash_fifo_data;	      // offset 0x02c
+	u32 flash_sf_access;	      // offset 0x030
+	u32 flash_sf_ext_access;	  // offset 0x034
+	u32 flash_sf_address;	     // offset 0x038
+	u32 flash_sf_data;		// offset 0x03c
+	u32 flash_sf_timing;	      // offset 0x040
+	u32 resv[3];
+	u32 flash_pf_access;	      // offset 0x050

We don't need the offset commented on every member. Typically it's not done (which is annoying in debug / verification), but it is nice to see after a reserved block. Can you remove most of them so it's just showing the post-resv offsets? 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/20201211/fa0e5d30/attachment.sig>