Skip to contentSkip to conversation

mtd: nand: raw: Collected improvements

PATCH Applied Alexander Dahl 4 participants 19 messages Mar 20, 2024 – Apr 15, 2024

Subsystems (4)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover mtd: nand: raw: Collected improvements

Hello everyone,

while working on NAND flash support for a custom board based on the at91 SAM9X60 SoC I stumbled over some issues in the raw nand subsystem.

Four of six patches are minor fixes.

Patch 4 introduces a new subcommand for the new atmel nand controller driver. Patch 6 introduces a new subcommand for the nand command to override ONFI timing mode. Both are are for debugging purposes only and thus optional, and need to be enabled through menu. Both helped me a lot when investigating issues.

Series is based on upstream next branch, but should also apply to master cleanly.

Greets
Alex

v1:

v2:

- rebased on recent next
- collected tags
- improved patch 4 after feedback from Mihai
- added new patch 5 with another help text fix
- added new patch 6 with a new debug command
- reworded cover letter

See per patch changes in patches for more detailed changes.

Alexander Dahl (6):
mtd: nand: raw: Use macro nand_to_mtd() where appropriate
mtd: nand: raw: Port another option flag from Linux
mtd: nand: raw: Fix (most) Kconfig indentation
mtd: nand: raw: atmel: Introduce optional debug commands
mtd: nand: raw: atmel: Fix comment in timings preparation
cmd: nand: Add new optional sub-command 'onfi'

 cmd/Kconfig                                  |  10 +
 cmd/nand.c                                   |  61 ++++
 drivers/mtd/nand/raw/Kconfig                 | 115 +++----
 drivers/mtd/nand/raw/atmel/nand-controller.c | 299 ++++++++++++++++++-
 drivers/mtd/nand/raw/nand_base.c             |   8 +-
 include/linux/mtd/rawnand.h                  |   8 +
 6 files changed, 441 insertions(+), 60 deletions(-)

base-commit: f048104999db28d49362201eaebfc91adb14f47c

Signature · 1 line
2.39.2
#1 lore raw

PATCH v2 1/6 mtd: nand: raw: Use macro nand_to_mtd() where appropriate

In every other place in this file the macro is used, make it consistent.

Fixes 9d1806fadc24 ("mtd: nand: Get rid of mtd variable in function calls")

---

Notes:
v1:
- initial patch version

v2:
- collected tags

 drivers/mtd/nand/raw/nand_base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/nand_base.c +3 -3
index c40a0f23d7b..688d17ba3c2 100644
@@ -4118,7 +4118,7 @@ static int nand_get_bits_per_cell(u8 cellinfo)
  */
 void nand_decode_ext_id(struct nand_chip *chip)
 {
-	struct mtd_info *mtd = &chip->mtd;
+	struct mtd_info *mtd = nand_to_mtd(chip);
 	int extid;
 	/* The 3rd id byte holds MLC / multichip data */
 	chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]);
@@ -4185,7 +4185,7 @@ static int nand_manufacturer_init(struct nand_chip *chip)
  */
 static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type)
 {
-	struct mtd_info *mtd = &chip->mtd;
+	struct mtd_info *mtd = nand_to_mtd(chip);
 
 	mtd->erasesize = type->erasesize;
 	mtd->writesize = type->pagesize;
@@ -4265,7 +4265,7 @@ static const struct nand_manufacturer *nand_get_manufacturer_desc(u8 id)
 int nand_detect(struct nand_chip *chip, int *maf_id,
 		int *dev_id, struct nand_flash_dev *type)
 {
-	struct mtd_info *mtd = &chip->mtd;
+	struct mtd_info *mtd = nand_to_mtd(chip);
 	const struct nand_manufacturer *manufacturer_desc;
 	int busw, ret;
 	u8 *id_data = chip->id.data;
Signature · 1 line
2.39.2
#2 lore raw

PATCH v2 2/6 mtd: nand: raw: Port another option flag from Linux

In reply to Alexander Dahl

Introduced in upstream Linux with commit 7a08dbaedd365 for release v5.0.

When the new atmel nand driver was backported to U-Boot with commit 6a8dfd57220d ("nand: atmel: Add DM based NAND driver") that definition was added to the driver instead of the header file. Move it over to the other definitions with the same help text it has in Linux.

Code actually using this has not been ported over to raw nand base yet.

---

Notes:
v1:
- initial patch version

v2:
- collected tags

 drivers/mtd/nand/raw/atmel/nand-controller.c | 2 --
 include/linux/mtd/rawnand.h                  | 7 +++++++
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +0 -2
index 0e0441472b8..e06523f3298 100644
@@ -1429,8 +1429,6 @@ static int atmel_nand_setup_data_interface(struct mtd_info *mtd, int csline,
 	return nc->caps->ops->setup_data_interface(nand, csline, conf);
 }
 
-#define NAND_KEEP_TIMINGS       0x00800000
-
 static void atmel_nand_init(struct atmel_nand_controller *nc,
 			    struct atmel_nand *nand)
 {
include/linux/mtd/rawnand.h +7 -0
index fb002ae6411..4abaf4734cf 100644
@@ -249,6 +249,13 @@ enum nand_ecc_algo {
  */
 #define NAND_USE_BOUNCE_BUFFER	0x00100000
 
+/*
+ * Do not try to tweak the timings at runtime. This is needed when the
+ * controller initializes the timings on itself or when it relies on
+ * configuration done by the bootloader.
+ */
+#define NAND_KEEP_TIMINGS	0x00800000
+
 /* Options set by nand scan */
 /* bbt has already been read */
 #define NAND_BBT_SCANNED	0x40000000
Signature · 1 line
2.39.2
#3 lore raw

PATCH v2 3/6 mtd: nand: raw: Fix (most) Kconfig indentation

In reply to Alexander Dahl

One tab in general. One tab plus two spaces for help text.

---

Notes:
v1:
- initial patch version

v2:
- collected tags

 drivers/mtd/nand/raw/Kconfig | 106 +++++++++++++++++------------------
 1 file changed, 53 insertions(+), 53 deletions(-)
drivers/mtd/nand/raw/Kconfig +53 -53
index bb9994b8626..f6644899b0a 100644
@@ -1,6 +1,6 @@
-
 menuconfig MTD_RAW_NAND
 	bool "Raw NAND Device Support"
+
 if MTD_RAW_NAND
 
 config SYS_NAND_SELF_INIT
@@ -49,12 +49,12 @@ config SYS_NAND_NO_SUBPAGE_WRITE
 	depends on NAND_ARASAN || NAND_DAVINCI || NAND_KIRKWOOD
 
 config DM_NAND_ATMEL
-       bool "Support Atmel NAND controller with DM support"
-       select SYS_NAND_SELF_INIT
-       imply SYS_NAND_USE_FLASH_BBT
-       help
-         Enable this driver for NAND flash platforms using an Atmel NAND
-         controller.
+	bool "Support Atmel NAND controller with DM support"
+	select SYS_NAND_SELF_INIT
+	imply SYS_NAND_USE_FLASH_BBT
+	help
+	  Enable this driver for NAND flash platforms using an Atmel NAND
+	  controller.
 
 config NAND_ATMEL
 	bool "Support Atmel NAND controller"
@@ -133,35 +133,35 @@ config NAND_BRCMNAND_6753
 	  Enable support for broadcom nand driver on bcm6753.
 
 config NAND_BRCMNAND_68360
-       bool "Support Broadcom NAND controller on bcm68360"
-       depends on NAND_BRCMNAND && BCM6856
-       help
-         Enable support for broadcom nand driver on bcm68360.
+	bool "Support Broadcom NAND controller on bcm68360"
+	depends on NAND_BRCMNAND && BCM6856
+	help
+	  Enable support for broadcom nand driver on bcm68360.
 
 config NAND_BRCMNAND_6838
-       bool "Support Broadcom NAND controller on bcm6838"
-       depends on NAND_BRCMNAND && ARCH_BMIPS && SOC_BMIPS_BCM6838
-       help
-         Enable support for broadcom nand driver on bcm6838.
+	bool "Support Broadcom NAND controller on bcm6838"
+	depends on NAND_BRCMNAND && ARCH_BMIPS && SOC_BMIPS_BCM6838
+	help
+	  Enable support for broadcom nand driver on bcm6838.
 
 config NAND_BRCMNAND_6858
-       bool "Support Broadcom NAND controller on bcm6858"
-       depends on NAND_BRCMNAND && BCM6858
-       help
-         Enable support for broadcom nand driver on bcm6858.
+	bool "Support Broadcom NAND controller on bcm6858"
+	depends on NAND_BRCMNAND && BCM6858
+	help
+	  Enable support for broadcom nand driver on bcm6858.
 
 config NAND_BRCMNAND_63158
-       bool "Support Broadcom NAND controller on bcm63158"
-       depends on NAND_BRCMNAND && BCM63158
-       help
-         Enable support for broadcom nand driver on bcm63158.
+	bool "Support Broadcom NAND controller on bcm63158"
+	depends on NAND_BRCMNAND && BCM63158
+	help
+	  Enable support for broadcom nand driver on bcm63158.
 
 config NAND_BRCMNAND_IPROC
-       bool "Support Broadcom NAND controller on the iproc family"
-       depends on NAND_BRCMNAND
-       help
-         Enable support for broadcom nand driver on the Broadcom
-         iproc family such as Northstar (BCM5301x, BCM4708...)
+	bool "Support Broadcom NAND controller on the iproc family"
+	depends on NAND_BRCMNAND
+	help
+	  Enable support for broadcom nand driver on the Broadcom
+	  iproc family such as Northstar (BCM5301x, BCM4708...)
 
 config NAND_DAVINCI
 	bool "Support TI Davinci NAND controller"
@@ -413,10 +413,10 @@ config NAND_VF610_NFC
 if NAND_VF610_NFC
 
 config NAND_VF610_NFC_DT
-        bool "Support Vybrid's vf610 NAND controller as a DT device"
-        depends on OF_CONTROL && DM_MTD
-        help
-          Enable the driver for Vybrid's vf610 NAND flash on platforms
+	bool "Support Vybrid's vf610 NAND controller as a DT device"
+	depends on OF_CONTROL && DM_MTD
+	help
+	  Enable the driver for Vybrid's vf610 NAND flash on platforms
 	  using device tree.
 
 choice
@@ -472,11 +472,11 @@ config NAND_SUNXI
 	select SPL_NAND_SUPPORT
 	select SPL_SYS_NAND_SELF_INIT
 	imply CMD_NAND
-	---help---
-	Enable support for NAND. This option enables the standard and
-	SPL drivers.
-	The SPL driver only supports reading from the NAND using DMA
-	transfers.
+	help
+	  Enable support for NAND. This option enables the standard and
+	  SPL drivers.
+	  The SPL driver only supports reading from the NAND using DMA
+	  transfers.
 
 if NAND_SUNXI
 
@@ -577,16 +577,16 @@ config NAND_OCTEONTX
 	select SYS_NAND_SELF_INIT
 	imply CMD_NAND
 	help
-	 This enables Nand flash controller hardware found on the OcteonTX
-	 processors.
+	  This enables Nand flash controller hardware found on the OcteonTX
+	  processors.
 
 config NAND_OCTEONTX_HW_ECC
 	bool "Support Hardware ECC for OcteonTX NAND controller"
 	depends on NAND_OCTEONTX
 	default y
 	help
-	 This enables Hardware BCH engine found on the OcteonTX processors to
-	 support ECC for NAND flash controller.
+	  This enables Hardware BCH engine found on the OcteonTX processors to
+	  support ECC for NAND flash controller.
 
 config NAND_STM32_FMC2
 	bool "Support for NAND controller on STM32MP SoCs"
@@ -751,37 +751,37 @@ config SYS_NAND_BAD_BLOCK_POS
 config SYS_NAND_U_BOOT_LOCATIONS
 	bool "Define U-Boot binaries locations in NAND"
 	help
-	Enable CONFIG_SYS_NAND_U_BOOT_OFFS though Kconfig.
-	This option should not be enabled when compiling U-Boot for boards
-	defining CONFIG_SYS_NAND_U_BOOT_OFFS in their include/configs/<board>.h
-	file.
+	  Enable CONFIG_SYS_NAND_U_BOOT_OFFS though Kconfig.
+	  This option should not be enabled when compiling U-Boot for boards
+	  defining CONFIG_SYS_NAND_U_BOOT_OFFS in their include/configs/<board>.h
+	  file.
 
 config SYS_NAND_U_BOOT_OFFS
 	hex "Location in NAND to read U-Boot from"
 	default 0x800000 if NAND_SUNXI
 	depends on SYS_NAND_U_BOOT_LOCATIONS
 	help
-	Set the offset from the start of the nand where u-boot should be
-	loaded from.
+	  Set the offset from the start of the nand where u-boot should be
+	  loaded from.
 
 config SYS_NAND_U_BOOT_OFFS_REDUND
 	hex "Location in NAND to read U-Boot from"
 	default SYS_NAND_U_BOOT_OFFS
 	depends on SYS_NAND_U_BOOT_LOCATIONS
 	help
-	Set the offset from the start of the nand where the redundant u-boot
-	should be loaded from.
+	  Set the offset from the start of the nand where the redundant u-boot
+	  should be loaded from.
 
 config SPL_NAND_AM33XX_BCH
 	bool "Enables SPL-NAND driver which supports ELM based"
 	depends on SPL_NAND_SUPPORT && NAND_OMAP_GPMC && !OMAP34XX
 	default y
-        help
+	help
 	  Hardware ECC correction. This is useful for platforms which have ELM
 	  hardware engine and use NAND boot mode.
 	  Some legacy platforms like OMAP3xx do not have in-built ELM h/w engine,
 	  so those platforms should use CONFIG_SPL_NAND_SIMPLE for enabling
-          SPL-NAND driver with software ECC correction support.
+	  SPL-NAND driver with software ECC correction support.
 
 config SPL_NAND_DENALI
 	bool "Support Denali NAND controller for SPL"
@@ -810,6 +810,6 @@ config SYS_NAND_HW_ECC_OOBFIRST
 	bool "In SPL, read the OOB first and then the data from NAND"
 	depends on SPL_NAND_SIMPLE
 
-endif
+endif	# if SPL
 
-endif   # if NAND
+endif	# if MTD_RAW_NAND
Signature · 1 line
2.39.2
#4 lore raw

PATCH v2 4/6 mtd: nand: raw: atmel: Introduce optional debug commands

In reply to Alexander Dahl

For now adds one new command 'hsmc' with a single subcommand 'decode' to read and display the content of the registers of the Static Memory Controllers (SMC/HSMC) found in different at91 SoCs. Needed to get a better picture on what raw nand core and atmel nand controller driver try to set as timings based on ONFI parameters of the connected NAND chip.

Tested on SAMA5D2 and SAM9X60 based boards. Example output:

    U-Boot> hsmc decode

    MCK rate: 200 MHz

    SMC_SETUP3:     0x00000002
    SMC_PULSE3:     0x06030703
    SMC_CYCLE3:     0x00060007
    SMC_MODE3:      0x001f0003
    NCS_RD: setup: 0 (0 ns), pulse: 6 (30 ns), hold: 0 (0 ns), cycle: 6 (30 ns)
       NRD: setup: 0 (0 ns), pulse: 3 (15 ns), hold: 3 (15 ns), cycle: 6 (30 ns)
    NCS_WR: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns)
       NWE: setup: 2 (10 ns), pulse: 3 (15 ns), hold: 2 (10 ns), cycle: 7 (35 ns)
    Standard read applied
    TDF optimization enabled
    TDF cycles: 15 (75 ns)
    Data Bus Width: 8-bit bus
    NWAIT Mode: 0
    Write operation controlled by NWE signal
    Read operation controlled by NRD signal

---

Notes:
v1:
- initial patch version

v2:
- Use SMC register definitions
- Implement atmel_hsmc_print_timings()
- Improve hsmc command output
- Collected tags

 drivers/mtd/nand/raw/Kconfig                 |   9 +
 drivers/mtd/nand/raw/atmel/nand-controller.c | 295 +++++++++++++++++++
 2 files changed, 304 insertions(+)
drivers/mtd/nand/raw/Kconfig +9 -0
index f6644899b0a..43057aa6c5b 100644
@@ -50,12 +50,21 @@ config SYS_NAND_NO_SUBPAGE_WRITE
 
 config DM_NAND_ATMEL
 	bool "Support Atmel NAND controller with DM support"
+	select MFD_ATMEL_SMC
 	select SYS_NAND_SELF_INIT
 	imply SYS_NAND_USE_FLASH_BBT
 	help
 	  Enable this driver for NAND flash platforms using an Atmel NAND
 	  controller.
 
+config CMD_NAND_ATMEL_DEBUG
+	bool "Optional debug commands for Atmel NAND controller"
+	depends on DM_NAND_ATMEL
+	help
+	  Add commands for debugging internals of the Atmel NAND flash
+	  controller, for example:
+	  - Decode Static Memory Controller (SMC) registers
+
 config NAND_ATMEL
 	bool "Support Atmel NAND controller"
 	select SYS_NAND_SELF_INIT
drivers/mtd/nand/raw/atmel/nand-controller.c +295 -0

339 lines not on this page · raw message

Signature · 1 line
2.39.2
#5 lore raw

PATCH v2 5/6 mtd: nand: raw: atmel: Fix comment in timings preparation

In reply to Alexander Dahl

Introduced with commit 6a8dfd57220d ("nand: atmel: Add DM based NAND driver") when driver was initially ported from Linux. The context around this and especially the code itself suggests 'read' is meant instead of write.

The fix is the same as accepted in Linux already with mainline Linux kernel commit 1c60e027ffde ("mtd: nand: raw: atmel: Fix comment in timings preparation").

---

Notes:
v2:
- initial patch version (not present in v1)

 drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
index 75da15c157b..bbafc88e44c 100644
@@ -1271,7 +1271,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 		return ret;
 
 	/*
-	 * The write cycle timing is directly matching tWC, but is also
+	 * The read cycle timing is directly matching tRC, but is also
 	 * dependent on the setup and hold timings we calculated earlier,
 	 * which gives:
 	 *
Signature · 1 line
2.39.2
Reviewed-by on v2 5/6
#6 lore raw

Re: [PATCH v2 5/6] mtd: nand: raw: atmel: Fix comment in timings preparation

Quoted 26 lines · Alexander Dahl

Introduced with commit 6a8dfd57220d ("nand: atmel: Add DM based NAND driver") when driver was initially ported from Linux. The context around this and especially the code itself suggests 'read' is meant instead of write.

The fix is the same as accepted in Linux already with mainline Linux kernel commit 1c60e027ffde ("mtd: nand: raw: atmel: Fix comment in timings preparation").

---

Notes:
v2:
- initial patch version (not present in v1)

 drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +0 -0
index 75da15c157b..bbafc88e44c 100644

drivers/mtd/nand/raw/atmel/nand-controller.c static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,

Quoted 9 lines
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -2
@@ -1271,7 +1271,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                return ret;
 
        /*
-        * The write cycle timing is directly matching tWC, but is also
+        * The read cycle timing is directly matching tRC, but is also
         * dependent on the setup and hold timings we calculated earlier,
         * which gives:
         *
--
Quoted 2 lines

2.39.2

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#7 lore raw

PATCH v2 6/6 cmd: nand: Add new optional sub-command 'onfi'

In reply to Alexander Dahl

Override the ONFI timing mode at runtime.

---

Notes:
v2:
- initial patch version (not present in v1)

 cmd/Kconfig                      | 10 ++++++
 cmd/nand.c                       | 61 ++++++++++++++++++++++++++++++++
 drivers/mtd/nand/raw/nand_base.c |  2 +-
 include/linux/mtd/rawnand.h      |  1 +
 4 files changed, 73 insertions(+), 1 deletion(-)
cmd/Kconfig +10 -0
index 61e280fb1a4..c39cc297306 100644
@@ -1421,6 +1421,7 @@ config CMD_NAND
 	  NAND support.
 
 if CMD_NAND
+
 config CMD_NAND_TRIMFFS
 	bool "nand write.trimffs"
 	default y if ARCH_SUNXI
@@ -1437,6 +1438,15 @@ config CMD_NAND_TORTURE
 	help
 	  NAND torture support.
 
+config CMD_NAND_ONFI
+	bool "nand onfi"
+	help
+	  Set ONFI timing modes explicitly.
+	  This is a debugging command to switch to slower ONFI timing
+	  modes for testing.
+	  In normal operation determining the timing mode automatically
+	  should work fine, and you don't need this.
+
 endif # CMD_NAND
 
 config CMD_NVME
cmd/nand.c +61 -0

79 lines not on this page · raw message

drivers/mtd/nand/raw/nand_base.c +1 -1
index 688d17ba3c2..2384425a746 100644
@@ -983,7 +983,7 @@ static int nand_onfi_set_timings(struct mtd_info *mtd, struct nand_chip *chip)
  *
  * Returns 0 for success or negative error code otherwise.
  */
-static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
+int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
 {
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	int ret;
include/linux/mtd/rawnand.h +1 -0
index 4abaf4734cf..07bc4cc9051 100644
@@ -1315,6 +1315,7 @@ void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
 void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len);
 void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len);
 uint8_t nand_read_byte(struct mtd_info *mtd);
+int nand_setup_data_interface(struct nand_chip *chip, int chipnr);
 
 /* get timing characteristics from ONFI timing mode. */
 const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode);
Signature · 1 line
2.39.2
Tested-by on v2 6/6
#8 lore raw

RE: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

Hi Alex,

------------------------------------------

Override the ONFI timing mode at runtime.

---

I tested your new command on a new board/soc sam9x75-curiosity 😊 I find it very very useful !
I also rounded the master clock to 270 MHz 😊
Thanks.

=> nand info

Device 0: nand0, sector size 256 KiB
Manufacturer MACRONIX
Model MX30LF4G28AD
Device size 512 MiB
Page size 4096 b
OOB size 256 b
Erase size 262144 b
ecc strength 8 bits
ecc step size 512 b
subpagesize 4096 b
options 0x40004200
bbt options 0x00028000

=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000004
SMC_PULSE2:     0x0c070d05
SMC_CYCLE2:     0x000c000d
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 12 (36 ns), hold: 0 (0 ns), cycle: 12 (36 ns)

NRD: setup: 0 (0 ns), pulse: 7 (21 ns), hold: 5 (15 ns), cycle: 12 (36 ns)
NCS_WR: setup: 0 (0 ns), pulse: 13 (39 ns), hold: 0 (0 ns), cycle: 13 (39 ns)
NWE: setup: 4 (12 ns), pulse: 5 (15 ns), hold: 4 (12 ns), cycle: 13 (39 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> nand onfi 2
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000003
SMC_PULSE2:     0x0e090e06
SMC_CYCLE2:     0x000e000e
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 14 (42 ns), hold: 0 (0 ns), cycle: 14 (42 ns)

NRD: setup: 0 (0 ns), pulse: 9 (27 ns), hold: 5 (15 ns), cycle: 14 (42 ns)
NCS_WR: setup: 0 (0 ns), pulse: 14 (42 ns), hold: 0 (0 ns), cycle: 14 (42 ns)
NWE: setup: 3 (9 ns), pulse: 6 (18 ns), hold: 5 (15 ns), cycle: 14 (42 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> nand onfi 1
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000003
SMC_PULSE2:     0x110a1109
SMC_CYCLE2:     0x00110011
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 17 (51 ns), hold: 0 (0 ns), cycle: 17 (51 ns)

NRD: setup: 0 (0 ns), pulse: 10 (30 ns), hold: 7 (21 ns), cycle: 17 (51 ns)
NCS_WR: setup: 0 (0 ns), pulse: 17 (51 ns), hold: 0 (0 ns), cycle: 17 (51 ns)
NWE: setup: 3 (9 ns), pulse: 9 (27 ns), hold: 5 (15 ns), cycle: 17 (51 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> nand onfi 3
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000004
SMC_PULSE2:     0x0c070d05
SMC_CYCLE2:     0x000c000d
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 12 (36 ns), hold: 0 (0 ns), cycle: 12 (36 ns)

NRD: setup: 0 (0 ns), pulse: 7 (21 ns), hold: 5 (15 ns), cycle: 12 (36 ns)
NCS_WR: setup: 0 (0 ns), pulse: 13 (39 ns), hold: 0 (0 ns), cycle: 13 (39 ns)
NWE: setup: 4 (12 ns), pulse: 5 (15 ns), hold: 4 (12 ns), cycle: 13 (39 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> nand torture 0x800000 0x800000

NAND torture: device 0 offset 0x800000 size 0x800000 (block size 0x40000)
Passed: 32, failed: 0

=> clk dump

24000000              1        |       |-- mainck
 1080000000           1        |       |   |-- plla_fracck
 1080000000           1        |       |   |   |-- plla_divpmcck
 1080000000           1        |       |   |   |   `-- mck_pres
 270000000            8        |       |   |   |       `-- mck_div

Best regards,
Mihai Sain

#9 lore raw

RE: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

In reply to Alexander Dahl

Hi Alex,

--------------------------------------------------------

Override the ONFI timing mode at runtime.

---

I used the same board sam9x75-curiosity to test mode 5 😊

I forced in nfc driver the mode 5:
+ if (conf->timings.sdr.tRC_min < 20000)

And I ran the nand torture on 16 MiB:

=> nand onfi 0
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000007
SMC_PULSE2:     0x22112211
SMC_CYCLE2:     0x00220022
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 34 (102 ns), hold: 0 (0 ns), cycle: 34 (102 ns)

NRD: setup: 0 (0 ns), pulse: 17 (51 ns), hold: 17 (51 ns), cycle: 34 (102 ns)
NCS_WR: setup: 0 (0 ns), pulse: 34 (102 ns), hold: 0 (0 ns), cycle: 34 (102 ns)
NWE: setup: 7 (21 ns), pulse: 17 (51 ns), hold: 10 (30 ns), cycle: 34 (102 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> time nand torture 0x800000 0x1000000

NAND torture: device 0 offset 0x800000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 30.152 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000001
SMC_PULSE2:     0x0b060804
SMC_CYCLE2:     0x000b0008
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 11 (33 ns), hold: 0 (0 ns), cycle: 11 (33 ns)

NRD: setup: 0 (0 ns), pulse: 6 (18 ns), hold: 5 (15 ns), cycle: 11 (33 ns)
NCS_WR: setup: 0 (0 ns), pulse: 8 (24 ns), hold: 0 (0 ns), cycle: 8 (24 ns)
NWE: setup: 1 (3 ns), pulse: 4 (12 ns), hold: 3 (9 ns), cycle: 8 (24 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> time nand torture 0x800000 0x1000000

NAND torture: device 0 offset 0x800000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 15.891 seconds

Best regards,
Mihai Sain

#10 lore raw

Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

Hi

I think this command can be really useful.

Quoted 66 lines · On Wed, Mar 20, 2024 at 3:09 PM <[email protected]> wrote:

Hi Alex,

--------------------------------------------------------

Override the ONFI timing mode at runtime.

---

I used the same board sam9x75-curiosity to test mode 5 😊

I forced in nfc driver the mode 5:
+ if (conf->timings.sdr.tRC_min < 20000)

And I ran the nand torture on 16 MiB:

=> nand onfi 0
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000007
SMC_PULSE2:     0x22112211
SMC_CYCLE2:     0x00220022
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 34 (102 ns), hold: 0 (0 ns), cycle: 34 (102 ns)

NRD: setup: 0 (0 ns), pulse: 17 (51 ns), hold: 17 (51 ns), cycle: 34 (102 ns)
NCS_WR: setup: 0 (0 ns), pulse: 34 (102 ns), hold: 0 (0 ns), cycle: 34 (102 ns)
NWE: setup: 7 (21 ns), pulse: 17 (51 ns), hold: 10 (30 ns), cycle: 34 (102 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

=> time nand torture 0x800000 0x1000000

NAND torture: device 0 offset 0x800000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 30.152 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 270 MHz

SMC_SETUP2:     0x00000001
SMC_PULSE2:     0x0b060804
SMC_CYCLE2:     0x000b0008
SMC_MODE2:      0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 11 (33 ns), hold: 0 (0 ns), cycle: 11 (33 ns)

NRD: setup: 0 (0 ns), pulse: 6 (18 ns), hold: 5 (15 ns), cycle: 11 (33 ns)
NCS_WR: setup: 0 (0 ns), pulse: 8 (24 ns), hold: 0 (0 ns), cycle: 8 (24 ns)
NWE: setup: 1 (3 ns), pulse: 4 (12 ns), hold: 3 (9 ns), cycle: 8 (24 ns)
Standard read applied
TDF optimization enabled
TDF cycles: 15 (45 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal

Quoted 7 lines

=> time nand torture 0x800000 0x1000000

NAND torture: device 0 offset 0x800000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 15.891 seconds

Let try to have more testing on more boards

Michael

Quoted 2 lines

Best regards,
Mihai Sain

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#11 lore raw

RE: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

Hi Michael,

-------------------------------------------------------

I think this command can be really useful. Let try to have more testing on more boards

---------------------------------------------------------

I managed to test the command on sama7g54-curiosity board.

I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min < 20000).

=> nand onfi 0
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000004
HSMC_PULSE3:    0x140a140a
HSMC_CYCLE3:    0x00140014
HSMC_TIMINGS3:  0x880805f4
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)

NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 ns)
NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)
NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  64 (320 ns)
TAR (ALE to REN Low Delay):    5 (25 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   4 (20 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 22.638 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000001
HSMC_PULSE3:    0x07040502
HSMC_CYCLE3:    0x00070005
HSMC_TIMINGS3:  0x880402f2
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns)

NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns)
NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns)
NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  4 (20 ns)
TAR (ALE to REN Low Delay):    2 (10 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   2 (10 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 11.661 seconds

=> nand info

Device 0: nand0, sector size 256 KiB
Manufacturer MACRONIX
Model MX30LF4G28AD
Device size 512 MiB
Page size 4096 b
OOB size 256 b
Erase size 262144 b
ecc strength 8 bits
ecc step size 512 b
subpagesize 4096 b
options 0x40004200
bbt options 0x00028000

Best regards,
Mihai Sain

#12 lore raw

Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

Hello Mihai,

Am Fri, Mar 22, 2024 at 10:02:29AM +0000 schrieb [email protected]:

Quoted 10 lines

Hi Michael,

-------------------------------------------------------

I think this command can be really useful. Let try to have more testing on more boards

---------------------------------------------------------

I managed to test the command on sama7g54-curiosity board.

Thanks for that. Nice to see it works on other variants of the SoC family.

Quoted 1 line

I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min < 20000).

You did a similar thing for the sam9x75. These boards/socs seem to have a newer SMC / HSMC controller than sama5d2 or sam9x60? The driver claims all the (H)SMC incarnations do _not_ support these EDO modes 4 and 5. Maybe someone could have a deeper look at the datasheets of the newer SoCs and propose a patch to support those newer controllers in the atmel nand-controller driver? I guess the problem is the same in Linux, right?

Greets
Alex

Quoted 88 lines

=> nand onfi 0
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000004
HSMC_PULSE3:    0x140a140a
HSMC_CYCLE3:    0x00140014
HSMC_TIMINGS3:  0x880805f4
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)

NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 ns)
NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)
NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  64 (320 ns)
TAR (ALE to REN Low Delay):    5 (25 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   4 (20 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 22.638 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000001
HSMC_PULSE3:    0x07040502
HSMC_CYCLE3:    0x00070005
HSMC_TIMINGS3:  0x880402f2
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns)

NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns)
NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns)
NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  4 (20 ns)
TAR (ALE to REN Low Delay):    2 (10 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   2 (10 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 11.661 seconds

=> nand info

Device 0: nand0, sector size 256 KiB
Manufacturer MACRONIX
Model MX30LF4G28AD
Device size 512 MiB
Page size 4096 b
OOB size 256 b
Erase size 262144 b
ecc strength 8 bits
ecc step size 512 b
subpagesize 4096 b
options 0x40004200
bbt options 0x00028000

Best regards,
Mihai Sain

#13 lore raw

Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

HI

Quoted 28 lines · Alexander Dahl

Hello Mihai,

Am Fri, Mar 22, 2024 at 10:02:29AM +0000 schrieb [email protected]:

Quoted 10 lines

Hi Michael,

-------------------------------------------------------

I think this command can be really useful. Let try to have more testing on more boards

---------------------------------------------------------

I managed to test the command on sama7g54-curiosity board.

Thanks for that. Nice to see it works on other variants of the SoC family.

Quoted 1 line

I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min < 20000).

You did a similar thing for the sam9x75. These boards/socs seem to have a newer SMC / HSMC controller than sama5d2 or sam9x60? The driver claims all the (H)SMC incarnations do _not_ support these EDO modes 4 and 5. Maybe someone could have a deeper look at the datasheets of the newer SoCs and propose a patch to support those newer controllers in the atmel nand-controller driver? I guess the problem is the same in Linux, right?

Quoted 91 lines

Greets
Alex

Quoted 88 lines

=> nand onfi 0
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000004
HSMC_PULSE3:    0x140a140a
HSMC_CYCLE3:    0x00140014
HSMC_TIMINGS3:  0x880805f4
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)

NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 ns)
NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)
NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  64 (320 ns)
TAR (ALE to REN Low Delay):    5 (25 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   4 (20 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 22.638 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000001
HSMC_PULSE3:    0x07040502
HSMC_CYCLE3:    0x00070005
HSMC_TIMINGS3:  0x880402f2
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns)

NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns)
NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns)
NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  4 (20 ns)
TAR (ALE to REN Low Delay):    2 (10 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   2 (10 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 11.661 seconds

=> nand info

Device 0: nand0, sector size 256 KiB
Manufacturer MACRONIX
Model MX30LF4G28AD
Device size 512 MiB
Page size 4096 b
OOB size 256 b
Erase size 262144 b
ecc strength 8 bits
ecc step size 512 b
subpagesize 4096 b
options 0x40004200
bbt options 0x00028000

Best regards,
Mihai Sain

I'm in favor to have it even cover by one soc family. I would like to confirm on imx6 and imx8. If you are not in a rush.
Let's us test too

Michael

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#14 lore raw

Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

Hello Michael,

Am Fri, Mar 22, 2024 at 12:54:27PM +0100 schrieb Michael Nazzareno Trimarchi:

Quoted 120 lines

HI

Quoted 117 lines · Alexander Dahl

Hello Mihai,

Am Fri, Mar 22, 2024 at 10:02:29AM +0000 schrieb [email protected]:

Quoted 10 lines

Hi Michael,

-------------------------------------------------------

I think this command can be really useful. Let try to have more testing on more boards

---------------------------------------------------------

I managed to test the command on sama7g54-curiosity board.

Thanks for that. Nice to see it works on other variants of the SoC family.

Quoted 1 line

I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min < 20000).

You did a similar thing for the sam9x75. These boards/socs seem to have a newer SMC / HSMC controller than sama5d2 or sam9x60? The driver claims all the (H)SMC incarnations do _not_ support these EDO modes 4 and 5. Maybe someone could have a deeper look at the datasheets of the newer SoCs and propose a patch to support those newer controllers in the atmel nand-controller driver? I guess the problem is the same in Linux, right?

Greets
Alex

Quoted 86 lines

=> nand onfi 0
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000004
HSMC_PULSE3:    0x140a140a
HSMC_CYCLE3:    0x00140014
HSMC_TIMINGS3:  0x880805f4
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)

NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 ns)
NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)
NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  64 (320 ns)
TAR (ALE to REN Low Delay):    5 (25 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   4 (20 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 22.638 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000001
HSMC_PULSE3:    0x07040502
HSMC_CYCLE3:    0x00070005
HSMC_TIMINGS3:  0x880402f2
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns)

NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns)
NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns)
NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  4 (20 ns)
TAR (ALE to REN Low Delay):    2 (10 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   2 (10 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 11.661 seconds

=> nand info

Device 0: nand0, sector size 256 KiB
Manufacturer MACRONIX
Model MX30LF4G28AD
Device size 512 MiB
Page size 4096 b
OOB size 256 b
Erase size 262144 b
ecc strength 8 bits
ecc step size 512 b
subpagesize 4096 b
options 0x40004200
bbt options 0x00028000

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Best regards,
Mihai Sain

I'm in favor to have it even cover by one soc family. I would like to confirm on imx6 and imx8. If you are not in a rush.
Let's us test too

Agreed. This is a generic nand command, so it would of course be reasonable to test it on multiple nand controllers. I'm afraid I currently have only at91 boards on my desk for which I have a recent U-Boot _and_ a NAND chip soldered. So take your time for this patch.

If you don't mind I would be happy if you could merge the four trivial patches which do not add new features and which already got your reviewed-by in the next cycle already, and let those other patches with the new subcommands for debugging be tested as long as needed.

Kind regards
Alex

Quoted 15 lines

Michael

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#15 lore raw

Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'

HI

Quoted 136 lines · Alexander Dahl

Hello Michael,

Am Fri, Mar 22, 2024 at 12:54:27PM +0100 schrieb Michael Nazzareno Trimarchi:

Quoted 120 lines

HI

Quoted 117 lines · Alexander Dahl

Hello Mihai,

Am Fri, Mar 22, 2024 at 10:02:29AM +0000 schrieb [email protected]:

Quoted 10 lines

Hi Michael,

-------------------------------------------------------

I think this command can be really useful. Let try to have more testing on more boards

---------------------------------------------------------

I managed to test the command on sama7g54-curiosity board.

Thanks for that. Nice to see it works on other variants of the SoC family.

Quoted 1 line

I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min < 20000).

You did a similar thing for the sam9x75. These boards/socs seem to have a newer SMC / HSMC controller than sama5d2 or sam9x60? The driver claims all the (H)SMC incarnations do _not_ support these EDO modes 4 and 5. Maybe someone could have a deeper look at the datasheets of the newer SoCs and propose a patch to support those newer controllers in the atmel nand-controller driver? I guess the problem is the same in Linux, right?

Greets
Alex

Quoted 86 lines

=> nand onfi 0
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000004
HSMC_PULSE3:    0x140a140a
HSMC_CYCLE3:    0x00140014
HSMC_TIMINGS3:  0x880805f4
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)

NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 ns)
NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns)
NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  64 (320 ns)
TAR (ALE to REN Low Delay):    5 (25 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   4 (20 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 22.638 seconds

=> nand onfi 5
=> hsmc decode

MCK rate: 200 MHz

HSMC_SETUP3:    0x00000001
HSMC_PULSE3:    0x07040502
HSMC_CYCLE3:    0x00070005
HSMC_TIMINGS3:  0x880402f2
HSMC_MODE3:     0x001f0003
NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns)

NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns)
NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns)
NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns)
TDF optimization enabled
TDF cycles: 15 (75 ns)
Data Bus Width: 8-bit bus
NWAIT Mode: 0
Write operation controlled by NWE signal
Read operation controlled by NRD signal
NFSEL (NAND Flash Selection) is set
OCMS (Off Chip Memory Scrambling) is disabled

TWB (WEN High to REN to Busy): 64 (320 ns)
TRR (Ready to REN Low Delay):  4 (20 ns)
TAR (ALE to REN Low Delay):    2 (10 ns)
TADL (ALE to Data Start):      71 (355 ns)
TCLR (CLE to REN Low Delay):   2 (10 ns)

=> time nand torture 0x1000000 0x1000000

NAND torture: device 0 offset 0x1000000 size 0x1000000 (block size 0x40000)
Passed: 64, failed: 0

time: 11.661 seconds

=> nand info

Device 0: nand0, sector size 256 KiB
Manufacturer MACRONIX
Model MX30LF4G28AD
Device size 512 MiB
Page size 4096 b
OOB size 256 b
Erase size 262144 b
ecc strength 8 bits
ecc step size 512 b
subpagesize 4096 b
options 0x40004200
bbt options 0x00028000

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Best regards,
Mihai Sain

I'm in favor to have it even cover by one soc family. I would like to confirm on imx6 and imx8. If you are not in a rush.
Let's us test too

Agreed. This is a generic nand command, so it would of course be reasonable to test it on multiple nand controllers. I'm afraid I currently have only at91 boards on my desk for which I have a recent U-Boot _and_ a NAND chip soldered. So take your time for this patch.

Quoted 5 lines

If you don't mind I would be happy if you could merge the four trivial patches which do not add new features and which already got your reviewed-by in the next cycle already, and let those other patches with the new subcommands for debugging be tested as long as needed.

I think Dario already queue them

Michael

Quoted 18 lines

Kind regards
Alex

Quoted 15 lines

Michael

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#16 lore raw
In reply to Alexander Dahl

Hi Alexander,

Quoted 52 lines · Alexander Dahl

Hello everyone,

while working on NAND flash support for a custom board based on the at91 SAM9X60 SoC I stumbled over some issues in the raw nand subsystem.

Four of six patches are minor fixes.

Patch 4 introduces a new subcommand for the new atmel nand controller driver. Patch 6 introduces a new subcommand for the nand command to override ONFI timing mode. Both are are for debugging purposes only and thus optional, and need to be enabled through menu. Both helped me a lot when investigating issues.

Series is based on upstream next branch, but should also apply to master cleanly.

Greets
Alex

v1:

v2:

- rebased on recent next
- collected tags
- improved patch 4 after feedback from Mihai
- added new patch 5 with another help text fix
- added new patch 6 with a new debug command
- reworded cover letter

See per patch changes in patches for more detailed changes.

Alexander Dahl (6):
mtd: nand: raw: Use macro nand_to_mtd() where appropriate
mtd: nand: raw: Port another option flag from Linux
mtd: nand: raw: Fix (most) Kconfig indentation
mtd: nand: raw: atmel: Introduce optional debug commands
mtd: nand: raw: atmel: Fix comment in timings preparation
cmd: nand: Add new optional sub-command 'onfi'

 cmd/Kconfig                                  |  10 +
 cmd/nand.c                                   |  61 ++++
 drivers/mtd/nand/raw/Kconfig                 | 115 +++----
 drivers/mtd/nand/raw/atmel/nand-controller.c | 299 ++++++++++++++++++-
 drivers/mtd/nand/raw/nand_base.c             |   8 +-
 include/linux/mtd/rawnand.h                  |   8 +
 6 files changed, 441 insertions(+), 60 deletions(-)
Quoted 4 lines

base-commit: f048104999db28d49362201eaebfc91adb14f47c --
2.39.2

Applied to nand-next the first 4 patches.
For the others, we will conduct further testing before applying them.

Thanks and regards,
Dario

Signature · 17 lines
Dario Binacchi

Senior Embedded Linux Developer

[email protected]

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
[email protected]

www.amarulasolutions.com
#17 lore raw

Hello Dario,

Am Sun, Apr 14, 2024 at 03:41:38PM +0200 schrieb Dario Binacchi:

Quoted 55 lines

Hi Alexander,

Quoted 52 lines · Alexander Dahl

Hello everyone,

while working on NAND flash support for a custom board based on the at91 SAM9X60 SoC I stumbled over some issues in the raw nand subsystem.

Four of six patches are minor fixes.

Patch 4 introduces a new subcommand for the new atmel nand controller driver. Patch 6 introduces a new subcommand for the nand command to override ONFI timing mode. Both are are for debugging purposes only and thus optional, and need to be enabled through menu. Both helped me a lot when investigating issues.

Series is based on upstream next branch, but should also apply to master cleanly.

Greets
Alex

v1:

v2:

- rebased on recent next
- collected tags
- improved patch 4 after feedback from Mihai
- added new patch 5 with another help text fix
- added new patch 6 with a new debug command
- reworded cover letter

See per patch changes in patches for more detailed changes.

Alexander Dahl (6):
mtd: nand: raw: Use macro nand_to_mtd() where appropriate
mtd: nand: raw: Port another option flag from Linux
mtd: nand: raw: Fix (most) Kconfig indentation
mtd: nand: raw: atmel: Introduce optional debug commands
mtd: nand: raw: atmel: Fix comment in timings preparation
cmd: nand: Add new optional sub-command 'onfi'

 cmd/Kconfig                                  |  10 +
 cmd/nand.c                                   |  61 ++++
 drivers/mtd/nand/raw/Kconfig                 | 115 +++----
 drivers/mtd/nand/raw/atmel/nand-controller.c | 299 ++++++++++++++++++-
 drivers/mtd/nand/raw/nand_base.c             |   8 +-
 include/linux/mtd/rawnand.h                  |   8 +
 6 files changed, 441 insertions(+), 60 deletions(-)
Quoted 6 lines
Quoted 4 lines

base-commit: f048104999db28d49362201eaebfc91adb14f47c --
2.39.2

Applied to nand-next the first 4 patches.
For the others, we will conduct further testing before applying them.

Thanks so far. :-)

I have another fix for the atmel raw nand driver, which I forgot to send with this series. I could add it to v3. Or should I send it separately?

Greets
Alex

#18 lore raw

Hello Alexander,

Quoted 63 lines · Alexander Dahl

Hello Dario,

Am Sun, Apr 14, 2024 at 03:41:38PM +0200 schrieb Dario Binacchi:

Quoted 59 lines

Hi Alexander,

Quoted 56 lines · Alexander Dahl

Hello everyone,

while working on NAND flash support for a custom board based on the at91 SAM9X60 SoC I stumbled over some issues in the raw nand subsystem.

Four of six patches are minor fixes.

Patch 4 introduces a new subcommand for the new atmel nand controller driver. Patch 6 introduces a new subcommand for the nand command to override ONFI timing mode. Both are are for debugging purposes only and thus optional, and need to be enabled through menu. Both helped me a lot when investigating issues.

Series is based on upstream next branch, but should also apply to master cleanly.

Greets
Alex

v1:

v2:

- rebased on recent next
- collected tags
- improved patch 4 after feedback from Mihai
- added new patch 5 with another help text fix
- added new patch 6 with a new debug command
- reworded cover letter

See per patch changes in patches for more detailed changes.

Alexander Dahl (6):
mtd: nand: raw: Use macro nand_to_mtd() where appropriate
mtd: nand: raw: Port another option flag from Linux
mtd: nand: raw: Fix (most) Kconfig indentation
mtd: nand: raw: atmel: Introduce optional debug commands
mtd: nand: raw: atmel: Fix comment in timings preparation
cmd: nand: Add new optional sub-command 'onfi'

 cmd/Kconfig                                  |  10 +
 cmd/nand.c                                   |  61 ++++
 drivers/mtd/nand/raw/Kconfig                 | 115 +++----
 drivers/mtd/nand/raw/atmel/nand-controller.c | 299 ++++++++++++++++++-
 drivers/mtd/nand/raw/nand_base.c             |   8 +-
 include/linux/mtd/rawnand.h                  |   8 +
 6 files changed, 441 insertions(+), 60 deletions(-)

base-commit: f048104999db28d49362201eaebfc91adb14f47c --
2.39.2

Quoted 7 lines
Quoted 2 lines

Applied to nand-next the first 4 patches.
For the others, we will conduct further testing before applying them.

Thanks so far. :-)

I have another fix for the atmel raw nand driver, which I forgot to send with this series. I could add it to v3.

Of course, feel free to add it to version 3.

Thanks and regards,
Dario

Quoted 5 lines

Or should I send it
separately?

Greets
Alex

Signature · 17 lines
Dario Binacchi

Senior Embedded Linux Developer

[email protected]

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
[email protected]

www.amarulasolutions.com