mtd: rawnand: fsmc: Fix timing computation
authorHerve Codina <herve.codina@bootlin.com>
Fri, 19 Nov 2021 15:03:16 +0000 (16:03 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 3 Dec 2021 13:33:45 +0000 (14:33 +0100)
commit9472335eaa1452b51dc8e8edaa1a342997cb80c7
treee101dc41d7e2f36430fda9323d18001dc1ca26b0
parenta4ca0c439f2d5ce9a3dc118d882f9f03449864c8
mtd: rawnand: fsmc: Fix timing computation

Under certain circumstances, the timing settings calculated by
the FSMC NAND controller driver were inaccurate.
These settings led to incorrect data reads or fallback to
timing mode 0 depending on the NAND chip used.

The timing computation did not take into account the following
constraint given in SPEAr3xx reference manual:
  twait >= tCEA - (tset * TCLK) + TOUTDEL + TINDEL

Enhance the timings calculation by taking into account this
additional constraint.

This change has no impact on slow timing modes such as mode 0.
Indeed, on mode 0, computed values are the same with and
without the patch.

NANDs which previously stayed in mode 0 because of fallback to
mode 0 can now work at higher speeds and NANDs which were not
working at all because of the corrupted data work at high
speeds without troubles.

Overall improvement on a Micron/MT29F1G08 (flash_speed tool):
                        mode0       mode3
eraseblock write speed  3220 KiB/s  4511 KiB/s
eraseblock read speed   4491 KiB/s  7529 KiB/s

Fixes: d9fb079571833 ("mtd: nand: fsmc: add support for SDR timings")
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20211119150316.43080-5-herve.codina@bootlin.com
drivers/mtd/nand/raw/fsmc_nand.c