From 8a6376f2ff40547ddd6f8a096914269b63764b4a Mon Sep 17 00:00:00 2001 From: Li Bin Date: Thu, 29 Feb 2024 16:37:12 +0800 Subject: [at91bootstrap][PATCH 1/1] driver:nandflash: update nand smc timing Some NAND flash (S34ML01G2 and W29N02KVxxAF) do not work properly in Timing Mode 3, since their maximum tREA time is 4ns longer then normal NAND flash. The workaround is to extend the SMC NRD pulse to meet tREA timing. Signed-off-by: Li Bin --- driver/nandflash.c | 11 ++++++++--- include/nand.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/driver/nandflash.c b/driver/nandflash.c index 4eda9c90..34380e39 100644 --- a/driver/nandflash.c +++ b/driver/nandflash.c @@ -76,6 +76,7 @@ static const struct nand_timing nand_onfi_timings[] = { .tCLR = 20000, .tADL = 400000, .tAR = 25000, + .tREA = 40000, .tRR = 40000, .tWB = 200000, }, @@ -93,6 +94,7 @@ static const struct nand_timing nand_onfi_timings[] = { .tCLR = 10000, .tADL = 400000, .tAR = 10000, + .tREA = 30000, .tRR = 20000, .tWB = 100000, }, @@ -110,6 +112,7 @@ static const struct nand_timing nand_onfi_timings[] = { .tCLR = 10000, .tADL = 400000, .tAR = 10000, + .tREA = 25000, .tRR = 20000, .tWB = 100000, }, @@ -127,6 +130,7 @@ static const struct nand_timing nand_onfi_timings[] = { .tCLR = 10000, .tADL = 400000, .tAR = 10000, + .tREA = 20000, .tRR = 20000, .tWB = 100000, }, @@ -155,7 +159,7 @@ static unsigned int smc_timing_encode_ncycles(unsigned int ncycles) void nandflash_smc_conf(unsigned int mode, unsigned int cs) { - unsigned int ncycles, mck_ps; + unsigned int ncycles, mck_ps, pulse; unsigned int nwe_setup, nwe_pulse, nwe_hold, nwe_cycle; unsigned int nrd_hold, nrd_pulse, nrd_cycle, tdf; mck_ps = (1000000000 / MASTER_CLOCK) * 1000; @@ -199,9 +203,10 @@ void nandflash_smc_conf(unsigned int mode, unsigned int cs) /* set NRD pulse length - NRD_PULSE = tRP + NRD_PULSE = max(tRP , tREA) */ - nrd_pulse = DIV_ROUND_UP(nand_onfi_timings[mode].tRP, mck_ps); + pulse = max(nand_onfi_timings[mode].tRP, nand_onfi_timings[mode].tREA); + nrd_pulse = DIV_ROUND_UP(pulse, mck_ps); ncycles += nrd_pulse; /* diff --git a/include/nand.h b/include/nand.h index 97de0785..143b4158 100644 --- a/include/nand.h +++ b/include/nand.h @@ -34,6 +34,7 @@ struct nand_timing { unsigned int tCLR; unsigned int tADL; unsigned int tAR; + unsigned int tREA; unsigned int tRR; unsigned int tWB; }; -- 2.34.1