mtd: spi-nor-core: Detect Soft Reset sequence support from BFPT
authorPratyush Yadav <p.yadav@ti.com>
Fri, 25 Jun 2021 19:17:23 +0000 (00:47 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Mon, 28 Jun 2021 06:34:30 +0000 (12:04 +0530)
A Soft Reset sequence will return the flash to Power-on-Reset (POR)
state. It consists of two commands: Soft Reset Enable and Soft Reset.
Find out if the sequence is supported from BFPT DWORD 16.

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

index b5b1ac8b5b11747f257e33e948acfabf324641cb..0d38ffc4f335ced92243bb7602c4dd6a41938fb5 100644 (file)
@@ -153,6 +153,8 @@ struct sfdp_header {
 #define BFPT_DWORD15_QER_SR2_BIT1_NO_RD                (0x4UL << 20)
 #define BFPT_DWORD15_QER_SR2_BIT1              (0x5UL << 20) /* Spansion */
 
+#define BFPT_DWORD16_SOFT_RST                  BIT(12)
+
 #define BFPT_DWORD18_CMD_EXT_MASK              GENMASK(30, 29)
 #define BFPT_DWORD18_CMD_EXT_REP               (0x0UL << 29) /* Repeat */
 #define BFPT_DWORD18_CMD_EXT_INV               (0x1UL << 29) /* Invert */
@@ -2104,6 +2106,10 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
                break;
        }
 
+       /* Soft Reset support. */
+       if (bfpt.dwords[BFPT_DWORD(16)] & BFPT_DWORD16_SOFT_RST)
+               nor->flags |= SNOR_F_SOFT_RESET;
+
        /* Stop here if JESD216 rev B. */
        if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
                return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
index aae814f55747c3cd5fd2328a06aeaaa7a78592ee..b2159f631957e17f96e75b0b34b7fba034802918 100644 (file)
@@ -248,6 +248,7 @@ enum spi_nor_option_flags {
        SNOR_F_READY_XSR_RDY    = BIT(4),
        SNOR_F_USE_CLSR         = BIT(5),
        SNOR_F_BROKEN_RESET     = BIT(6),
+       SNOR_F_SOFT_RESET       = BIT(7),
 };
 
 struct spi_nor;