mtd: spi-nor-core: Perform a Soft Reset on boot
authorPratyush Yadav <p.yadav@ti.com>
Fri, 25 Jun 2021 19:17:25 +0000 (00:47 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Mon, 28 Jun 2021 06:35:17 +0000 (12:05 +0530)
commit0be8ab1f166844d53477387dc9a1184161ef44ef
tree4af63120f5477f44ff8ee9fdc6e8a26adb307181
parent575caf45004fb9be983db33f86425c95d4619213
mtd: spi-nor-core: Perform a Soft Reset on boot

When the flash is handed to us in a stateful mode like 8D-8D-8D, it is

difficult to detect the mode the flash is in. One option is to read SFDP
in all modes and see which one gives the correct "SFDP" signature, but
not all flashes support SFDP in 8D-8D-8D mode.

Further, even if you detect the mode of the flash via SFDP, you still
have the problem of actually reading the ID. The Read ID command is not
standardized across flash vendors. Flashes can have different dummy
cycles needed for reading the ID. Some flashes even expect a 4-byte
dummy address with the Read ID command. All this information cannot be
obtained from the SFDP table.

So, perform a Software Reset sequence before reading the ID and
initializing the flash. A Soft Reset will bring back the flash in its
default protocol mode assuming no non-volatile configuration was set.
This will let us detect the flash even if ROM hands it to us in Octal
DTR mode.

To accommodate cases where there is more than one flash on a board, and
only one of them needs a soft reset, failure to reset is not made fatal,
and we still try to read ID if possible.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/mtd/spi/Kconfig
drivers/mtd/spi/spi-nor-core.c