Skip to contentSkip to conversation

mtd: nand: raw: Collected improvements

PATCH In review Alexander Dahl 5 participants 15 messages Apr 15, 2024 – Feb 12, 2025

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

v3 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.

Some trivial patches of previous iterations of this series were already applied.

Patch 1 introduces a new subcommand for the new atmel nand controller driver. Patch 2 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. Patch 3 is a fix carried over from at91bootstrap for faster at91 SoCs with certain raw NAND chips.

Series is based on post v2024.04 master now.

Greets
Alex

v3:

- 4 patches removed, applied to master
- other 2 patches from v2 unchanged, still under test
- added new third patch with a fix for atmel nand timings (forgot to send that with v2)

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

v1:

See per patch changes in patches for more detailed changes.

Alexander Dahl (3):
mtd: nand: raw: atmel: Introduce optional debug commands
cmd: nand: Add new optional sub-command 'onfi'
mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

 cmd/Kconfig                                  |  10 +
 cmd/nand.c                                   |  61 ++++
 drivers/mtd/nand/raw/Kconfig                 |   9 +
 drivers/mtd/nand/raw/atmel/nand-controller.c | 308 ++++++++++++++++++-
 drivers/mtd/nand/raw/nand_base.c             |   2 +-
 include/linux/mtd/rawnand.h                  |   1 +
 6 files changed, 386 insertions(+), 5 deletions(-)

base-commit: b03b49046af5dfca599d2ce8f0aafed89b97aa91

Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 1/3 mtd: nand: raw: atmel: Introduce optional debug commands

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:
v3:
- no changes to this patch

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

v1:
- initial patch version

 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 9f3f1267cbd..1c0084fd521 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
#2 lore raw

PATCH v3 2/3 cmd: nand: Add new optional sub-command 'onfi'

In reply to Alexander Dahl

Override the ONFI timing mode at runtime.

---

Notes:
v3:
- no changes to this patch

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 8eeb99eea5e..5dc47bd3f51 100644
@@ -1382,6 +1382,7 @@ config CMD_NAND
 	  NAND support.
 
 if CMD_NAND
+
 config CMD_NAND_TRIMFFS
 	bool "nand write.trimffs"
 	default y if ARCH_SUNXI
@@ -1398,6 +1399,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
#3 lore raw

PATCH v3 3/3 mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

In reply to Alexander Dahl

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

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

 drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -4
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 					  const struct nand_data_interface *conf,
 					  struct atmel_smc_cs_conf *smcconf)
 {
-	u32 ncycles, totalcycles, timeps, mckperiodps;
+	u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
 	struct atmel_nand_controller *nc;
 	int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 			 ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
 	/*
-	 * Read pulse timing directly matches tRP:
+	 * Read pulse timing would directly match tRP,
+	 * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+	 * do not work properly in timing mode 3.
+	 * The workaround is to extend the SMC NRD pulse to meet tREA
+	 * timing.
 	 *
-	 * NRD_PULSE = tRP
+	 * NRD_PULSE = max(tRP, tREA)
 	 */
-	ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+	pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+	ncycles = DIV_ROUND_UP(pulse, mckperiodps);
 	totalcycles += ncycles;
 	ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
 					  ncycles);
Signature · 1 line
2.39.2
#4 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 15 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

Quoted 8 lines

---

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

Greets
Alex

Quoted 40 lines
 drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -4
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 					  const struct nand_data_interface *conf,
 					  struct atmel_smc_cs_conf *smcconf)
 {
-	u32 ncycles, totalcycles, timeps, mckperiodps;
+	u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
 	struct atmel_nand_controller *nc;
 	int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 			 ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
 	/*
-	 * Read pulse timing directly matches tRP:
+	 * Read pulse timing would directly match tRP,
+	 * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+	 * do not work properly in timing mode 3.
+	 * The workaround is to extend the SMC NRD pulse to meet tREA
+	 * timing.
 	 *
-	 * NRD_PULSE = tRP
+	 * NRD_PULSE = max(tRP, tREA)
 	 */
-	ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+	pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+	ncycles = DIV_ROUND_UP(pulse, mckperiodps);
 	totalcycles += ncycles;
 	ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
 					  ncycles);
Signature · 1 line
2.39.2
Signature · 7 lines
Alexander Dahl           Thorsis Technologies GmbH   T +49 391 544 563 1000
Industrieautomation      Oststr. 18                  F +49 391 544 563 9099
T +49 391 544 563 3036   39114 Magdeburg             https://www.thorsis.com/

Sitz der Gesellschaft: Magdeburg
Amtsgericht Stendal HRB 30646
Geschäftsführer: Dipl.-Inf. Michael Huschke
#5 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Quoted 45 lines

Greets
Alex

Quoted 40 lines
 drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -4
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 					  const struct nand_data_interface *conf,
 					  struct atmel_smc_cs_conf *smcconf)
 {
-	u32 ncycles, totalcycles, timeps, mckperiodps;
+	u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
 	struct atmel_nand_controller *nc;
 	int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 			 ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
 	/*
-	 * Read pulse timing directly matches tRP:
+	 * Read pulse timing would directly match tRP,
+	 * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+	 * do not work properly in timing mode 3.
+	 * The workaround is to extend the SMC NRD pulse to meet tREA
+	 * timing.
 	 *
-	 * NRD_PULSE = tRP
+	 * NRD_PULSE = max(tRP, tREA)
 	 */
-	ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+	pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+	ncycles = DIV_ROUND_UP(pulse, mckperiodps);
 	totalcycles += ncycles;
 	ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
 					  ncycles);
Signature · 1 line
2.39.2
#6 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Quoted 34 lines · Alexander Dahl

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

Quoted 6 lines

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Hello Alexander,

From at91 perspective I have no objections.
As these are very NAND specific, I defer the patches to the NAND maintainers.

Eugen

Quoted 53 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Quoted 45 lines

Greets
Alex

Quoted 40 lines
 drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -4
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 					  const struct nand_data_interface *conf,
 					  struct atmel_smc_cs_conf *smcconf)
 {
-	u32 ncycles, totalcycles, timeps, mckperiodps;
+	u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
 	struct atmel_nand_controller *nc;
 	int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
 			 ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
 	/*
-	 * Read pulse timing directly matches tRP:
+	 * Read pulse timing would directly match tRP,
+	 * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+	 * do not work properly in timing mode 3.
+	 * The workaround is to extend the SMC NRD pulse to meet tREA
+	 * timing.
 	 *
-	 * NRD_PULSE = tRP
+	 * NRD_PULSE = max(tRP, tREA)
 	 */
-	ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+	pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+	ncycles = DIV_ROUND_UP(pulse, mckperiodps);
 	totalcycles += ncycles;
 	ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
 					  ncycles);
Signature · 1 line
2.39.2
#7 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Hi

Quoted 43 lines · Eugen Hristev
Quoted 34 lines · Alexander Dahl

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

Quoted 6 lines

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Quoted 15 lines

Hello Alexander,

From at91 perspective I have no objections.
As these are very NAND specific, I defer the patches to the NAND maintainers.

Eugen

Quoted 8 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

I will review this series

Michael

Quoted 46 lines
Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
 drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                      const struct nand_data_interface *conf,
                                      struct atmel_smc_cs_conf *smcconf)
 {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
    struct atmel_nand_controller *nc;
    int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                     ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
    /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
     *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
     */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
    totalcycles += ncycles;
    ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                      ncycles);
--

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
#8 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Hello Michael,

Am Tue, Oct 08, 2024 at 02:12:38PM +0200 schrieb Michael Nazzareno Trimarchi:

Quoted 57 lines

Hi

Quoted 53 lines · Eugen Hristev
Quoted 34 lines · Alexander Dahl

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

Quoted 6 lines

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Hello Alexander,

From at91 perspective I have no objections.
As these are very NAND specific, I defer the patches to the NAND maintainers.

Eugen

Quoted 3 lines

Link to the series discussion for reference:

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

I will review this series

This might have fallen through the cracks? The series was initially based on v2024.04, now we are on v2025.01-rc4 already. Still applies cleanly to master, though. I'm especially interested in the timing fix of patch 3. Could you please have a look?

Greets
Alex

Quoted 63 lines

Michael

Quoted 46 lines
Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
 drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                      const struct nand_data_interface *conf,
                                      struct atmel_smc_cs_conf *smcconf)
 {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
    struct atmel_nand_controller *nc;
    int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                     ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
    /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
     *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
     */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
    totalcycles += ncycles;
    ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                      ncycles);
--

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
#9 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

In reply to Alexander Dahl
Quoted 43 lines · Alexander Dahl

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems
like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Quoted 7 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Hi Alex,

Apologies for the delay in response. I also faced the same kind of problem while testing our new sam7d65 board with MX30LF4G28AD nand flash. I just had a workaround to increase the pulse time by 5 nsecs just for testing. The issue has been reported to the validation team and an investigation is under progress.

I would request a few more days for this patch alone.

Thanks,
Bala.

Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
  drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                       const struct nand_data_interface *conf,
                                       struct atmel_smc_cs_conf *smcconf)
  {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
     struct atmel_nand_controller *nc;
     int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                      ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
     /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
      *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
      */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
     totalcycles += ncycles;
     ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                       ncycles);
--

2.39.2

#10 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Hello Bala,

Am Wed, Oct 09, 2024 at 04:45:02AM +0000 schrieb [email protected]:

Quoted 54 lines · Alexander Dahl
Quoted 43 lines

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems
like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Quoted 7 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Hi Alex,

Quoted 7 lines

Apologies for the delay in response. I also faced the same kind of problem while testing our new sam7d65 board with MX30LF4G28AD nand flash. I just had a workaround to increase the pulse time by 5 nsecs just for testing. The issue has been reported to the validation team and an investigation is under progress.

I would request a few more days for this patch alone.

Did the validation team come to any conclusion on this?

Greets
Alex

Quoted 50 lines

Thanks,
Bala.

Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
  drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                       const struct nand_data_interface *conf,
                                       struct atmel_smc_cs_conf *smcconf)
  {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
     struct atmel_nand_controller *nc;
     int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                      ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
     /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
      *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
      */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
     totalcycles += ncycles;
     ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                       ncycles);
--

2.39.2

#11 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

In reply to [email protected]

Hello,

Am Wed, Oct 09, 2024 at 04:45:02AM +0000 schrieb [email protected]:

Quoted 54 lines · Alexander Dahl
Quoted 43 lines

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems
like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Quoted 7 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Hi Alex,

Quoted 7 lines

Apologies for the delay in response. I also faced the same kind of problem while testing our new sam7d65 board with MX30LF4G28AD nand flash. I just had a workaround to increase the pulse time by 5 nsecs just for testing. The issue has been reported to the validation team and an investigation is under progress.

I would request a few more days for this patch alone.

Why did the _same_ change I posted here last year in April appeared in linux4sam now with different credits? o.O

https://github.com/linux4sam/u-boot-at91/commit/4175c4c8535ea886e2c0fd99e94ead6bc7a4df5f

For reference: the issue was discussed in length here before I made the patch for U-Boot last year:

https://github.com/linux4sam/at91bootstrap/issues/174

Besides: this patch series was still not reviewed and not merged. Dear U-Boot NAND subsystem maintainer, what's the status?

Greets
Alex

Quoted 50 lines

Thanks,
Bala.

Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
  drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                       const struct nand_data_interface *conf,
                                       struct atmel_smc_cs_conf *smcconf)
  {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
     struct atmel_nand_controller *nc;
     int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                      ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
     /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
      *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
      */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
     totalcycles += ncycles;
     ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                       ncycles);
--

2.39.2

#12 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Quoted 73 lines · Alexander Dahl

Hello,

Am Wed, Oct 09, 2024 at 04:45:02AM +0000 schrieb [email protected]:

Quoted 54 lines · Alexander Dahl
Quoted 43 lines

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems
like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Quoted 7 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Hi Alex,

Quoted 7 lines

Apologies for the delay in response. I also faced the same kind of problem while testing our new sam7d65 board with MX30LF4G28AD nand flash. I just had a workaround to increase the pulse time by 5 nsecs just for testing. The issue has been reported to the validation team and an investigation is under progress.

I would request a few more days for this patch alone.

Why did the _same_ change I posted here last year in April appeared in linux4sam now with different credits? o.O

https://github.com/linux4sam/u-boot-at91/commit/4175c4c8535ea886e2c0fd99e94ead6bc7a4df5f

For reference: the issue was discussed in length here before I made the patch for U-Boot last year:

Quoted 7 lines

https://github.com/linux4sam/at91bootstrap/issues/174

Besides: this patch series was still not reviewed and not merged. Dear U-Boot NAND subsystem maintainer, what's the status?

Greets
Alex

Hello Alex,

As this change appeared downstream, apparently it's validated.

I can apply this as a fix through at91 tree.

Dario do you mind if I do that ? Apparently the patch is now on your list.

Eugen

Quoted 51 lines
Quoted 51 lines

Thanks,
Bala.

Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
  drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                       const struct nand_data_interface *conf,
                                       struct atmel_smc_cs_conf *smcconf)
  {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
     struct atmel_nand_controller *nc;
     int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                      ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
     /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
      *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
      */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
     totalcycles += ncycles;
     ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                       ncycles);
--

2.39.2

#13 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Hi Eugen

Please apply

Michael

Quoted 146 lines · Eugen Hristev
Quoted 73 lines · Alexander Dahl

Hello,

Am Wed, Oct 09, 2024 at 04:45:02AM +0000 schrieb [email protected]:

Quoted 54 lines · Alexander Dahl
Quoted 43 lines

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hello,

Am Tue, May 28, 2024 at 12:32:44PM +0200 schrieb Alexander Dahl:

Quoted 23 lines

Hei hei,

Am Mon, Apr 15, 2024 at 09:57:55AM +0200 schrieb Alexander Dahl:

Quoted 20 lines

From reading the S34ML02G1 and the SAM9X60 datasheets again, it seems
like we have to wait tREA after rising RE# before sampling the data. Thus pulse time must be at least tREA.

Without this fix we got PMECC errors when reading, after switching to ONFI timing mode 3 on SAM9X60 SoC with S34ML02G1 raw NAND flash chip.

The approach to set timings used before worked on sam9g20 and sama5d2 with the same flash (S34ML02G1), probably because those have a slower mck clock rate and thus the resolution of the timings setup is not as tight as with sam9x60.

The approach to fix the issue was carried over from at91bootstrap, and has been successfully tested in at91bootstrap, U-Boot and Linux.

---

Quoted 7 lines
Quoted 3 lines

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

This patch was send as part of a series, which you wanted to have some more time to test. Besides that, has anyone looked into this particular fix? Maybe it can be applied separately?

I'd kindly ask what the status of this patch series is from U-Boot NAND subsystem maintainers POV? Could you test it? Should I rebase and resend?

Two of these three patches are specific to at91 family, what's the opinion of at91 maintainers on this?

Quoted 7 lines

Link to the series discussion for reference:

https://lore.kernel.org/u-boot/[email protected]/T/#u

Greets
Alex

Hi Alex,

Quoted 7 lines

Apologies for the delay in response. I also faced the same kind of problem while testing our new sam7d65 board with MX30LF4G28AD nand flash. I just had a workaround to increase the pulse time by 5 nsecs just for testing. The issue has been reported to the validation team and an investigation is under progress.

I would request a few more days for this patch alone.

Why did the _same_ change I posted here last year in April appeared in linux4sam now with different credits? o.O

https://github.com/linux4sam/u-boot-at91/commit/4175c4c8535ea886e2c0fd99e94ead6bc7a4df5f

For reference: the issue was discussed in length here before I made the patch for U-Boot last year:

Quoted 7 lines

https://github.com/linux4sam/at91bootstrap/issues/174

Besides: this patch series was still not reviewed and not merged. Dear U-Boot NAND subsystem maintainer, what's the status?

Greets
Alex

Hello Alex,

As this change appeared downstream, apparently it's validated.

I can apply this as a fix through at91 tree.

Dario do you mind if I do that ? Apparently the patch is now on your list.

Eugen

Quoted 51 lines
Quoted 51 lines

Thanks,
Bala.

Quoted 45 lines
Quoted 45 lines

Greets
Alex

Quoted 40 lines
  drivers/mtd/nand/raw/atmel/nand-controller.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +9 -5
index bbafc88e44c..00ffeadd113 100644
@@ -1133,7 +1133,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                                       const struct nand_data_interface *conf,
                                       struct atmel_smc_cs_conf *smcconf)
  {
-   u32 ncycles, totalcycles, timeps, mckperiodps;
+   u32 ncycles, totalcycles, timeps, mckperiodps, pulse;
     struct atmel_nand_controller *nc;
     int ret;
 
@@ -1259,11 +1259,16 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
                      ATMEL_SMC_MODE_TDFMODE_OPTIMIZED;
 
     /*
-    * Read pulse timing directly matches tRP:
+    * Read pulse timing would directly match tRP,
+    * but some NAND flash chips (S34ML01G2 and W29N02KVxxAF)
+    * do not work properly in timing mode 3.
+    * The workaround is to extend the SMC NRD pulse to meet tREA
+    * timing.
      *
-    * NRD_PULSE = tRP
+    * NRD_PULSE = max(tRP, tREA)
      */
-   ncycles = DIV_ROUND_UP(conf->timings.sdr.tRP_min, mckperiodps);
+   pulse = max(conf->timings.sdr.tRP_min, conf->timings.sdr.tREA_max);
+   ncycles = DIV_ROUND_UP(pulse, mckperiodps);
     totalcycles += ncycles;
     ret = atmel_smc_cs_conf_set_pulse(smcconf, ATMEL_SMC_NRD_SHIFT,
                                       ncycles);
--

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
#14 lore raw

Re: [PATCH v3 3/3] mtd: nand: raw: atmel: Fix pulse read timing for certain NAND flashes

Quoted 6 lines · Michael Nazzareno Trimarchi

Hi Eugen

Please apply

Michael

Ok,

Applied to u-boot-at91/next

Eugen