Skip to content

Commit 435998b

Browse files
ccpalexUlrich Hecht
authored andcommitted
mtd: nand: raw: atmel: Respect tAR, tCLR in read setup timing
[ Upstream commit fd779eac2d659668be4d3dbdac0710afd5d6db12 ] Having setup time 0 violates tAR, tCLR of some chips, for instance TOSHIBA TC58NVG2S3ETAI0 cannot be detected successfully (first ID byte being read duplicated, i.e. 98 98 dc 90 15 76 14 03 instead of 98 dc 90 15 76 ...). Atmel Application Notes postulated 1 cycle NRD_SETUP without explanation [1], but it looks more appropriate to just calculate setup time properly. [1] Link: https://ww1.microchip.com/downloads/aemDocuments/documents/MPU32/ApplicationNotes/ApplicationNotes/doc6255.pdf Cc: stable@vger.kernel.org Fixes: f9ce2ed ("mtd: nand: atmel: Add ->setup_data_interface() hooks") Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Tested-by: Alexander Dahl <ada@thorsis.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent 2a959fb commit 435998b

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

drivers/mtd/nand/raw/atmel/nand-controller.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,14 +1332,24 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
13321332
if (ret)
13331333
return ret;
13341334

1335+
/*
1336+
* Read setup timing depends on the operation done on the NAND:
1337+
*
1338+
* NRD_SETUP = max(tAR, tCLR)
1339+
*/
1340+
timeps = max(conf->timings.sdr.tAR_min, conf->timings.sdr.tCLR_min);
1341+
ncycles = DIV_ROUND_UP(timeps, mckperiodps);
1342+
totalcycles += ncycles;
1343+
ret = atmel_smc_cs_conf_set_setup(smcconf, ATMEL_SMC_NRD_SHIFT, ncycles);
1344+
if (ret)
1345+
return ret;
1346+
13351347
/*
13361348
* The read cycle timing is directly matching tRC, but is also
13371349
* dependent on the setup and hold timings we calculated earlier,
13381350
* which gives:
13391351
*
1340-
* NRD_CYCLE = max(tRC, NRD_PULSE + NRD_HOLD)
1341-
*
1342-
* NRD_SETUP is always 0.
1352+
* NRD_CYCLE = max(tRC, NRD_SETUP + NRD_PULSE + NRD_HOLD)
13431353
*/
13441354
ncycles = DIV_ROUND_UP(conf->timings.sdr.tRC_min, mckperiodps);
13451355
ncycles = max(totalcycles, ncycles);

0 commit comments

Comments
 (0)