mtd: rawnand: davinci: Add dummy read after sending command
authorBastien Curutchet <bastien.curutchet@bootlin.com>
Fri, 8 Mar 2024 07:46:09 +0000 (08:46 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 25 Mar 2024 10:18:07 +0000 (11:18 +0100)
commit31e6bb6787e730ddedf5cc9b90863c5ff438ead7
tree7f702a71ad1bb46b53eaa0027961e486eff3bd85
parent4cece764965020c22cff7665b18a012006359095
mtd: rawnand: davinci: Add dummy read after sending command

Sometimes, writes fail because the tWB_max is not correctly observed
after sending PAGEPROG. It leads to the R/B pin to be read as in
the "ready" state right after sending the command, thus preventing the
normal tPROG delay to be actually observed. This happens because the
ndelay() that waits for tWB_max starts before the command reaches the
NAND chip.

Add a dummy read when a delay is requested at the end of the executed
instruction to make sure that the sent command is received by the NAND
before starting the short ndelay() (<1us but rounded up to 1us in
practice). This read is done on the control register area because
doing it on the Async Data area would change the NAND's RE pin state.
This is not perfect as the two areas are behind two different
devm_ioremap_resource() and could possibly be located on different
interconnects (I did not find more details). This means either the
additional latency due to the load operation is enough impacting, or it
has the expected behavior of ensuring the write has been received.

This has been tested on two platforms designed off of the
DAVINCI/OMAP-L138. The first uses a Toshiba NAND Flash (TC58NYG2S3EBAI5),
the other a Macronix one (MX30UF4G18AC).

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20240308074609.9056-1-bastien.curutchet@bootlin.com
drivers/mtd/nand/raw/davinci_nand.c