Power-on-Reset is a method to restore flash back to 1S-1S-1S mode from 8D-8D-8D
in the begging of probe.

Command extension type is not standardized across flash vendors in DTR mode.

For suiting different vendor flash devices, having second times Softreset with
different types is clumsy but useful in the begging of probe.

Signed-off-by: JaimeLiao <jaimeliao...@gmail.com>
---
 drivers/mtd/spi/spi-nor-core.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 6b195b1fd3..be6c58ad40 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3684,6 +3684,36 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
         */
        udelay(SPI_NOR_SRST_SLEEP_LEN);
 
+       /* Manufacturers with different command extension type. For suitting
+        * different flash devices, using command extension type is equal 
"INVERT"
+        * when second time Software Reset.
+        */
+
+       nor->cmd_ext_type = SPI_NOR_EXT_INVERT;
+       op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
+                       SPI_MEM_OP_NO_DUMMY,
+                       SPI_MEM_OP_NO_ADDR,
+                       SPI_MEM_OP_NO_DATA);
+       spi_nor_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR);
+       ret = spi_mem_exec_op(nor->spi, &op);
+       if (ret) {
+               dev_warn(nor->dev, "Software reset enable failed: %d\n", ret);
+               goto out;
+       }
+
+       op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0),
+                       SPI_MEM_OP_NO_DUMMY,
+                       SPI_MEM_OP_NO_ADDR,
+                       SPI_MEM_OP_NO_DATA);
+       spi_nor_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR);
+       ret = spi_mem_exec_op(nor->spi, &op);
+       if (ret) {
+               dev_warn(nor->dev, "Software reset failed: %d\n", ret);
+               goto out;
+       }
+
+       udelay(SPI_NOR_SRST_SLEEP_LEN);
+
 out:
        nor->cmd_ext_type = ext;
        return ret;
-- 
2.17.1

Reply via email to