]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd: spi-nor-core: Read status by Read Any Register
authorTakahiro Kuwano <Takahiro.Kuwano@infineon.com>
Tue, 29 Jun 2021 06:01:01 +0000 (15:01 +0900)
committerJagan Teki <jagan@amarulasolutions.com>
Tue, 29 Jun 2021 13:46:54 +0000 (19:16 +0530)
The spansion_sr_ready() reads status register 1 by Read Any Register
commnad. This function is called from Flash specific hook with die address
and dummy cycles to support multi-die package parts from Spansion/Cypress.

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Reviewed-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 d953c7e44fea448b676a3380041b2e301e15a181..7f1ed1bb3660c54210008d66cc2cdd6a6078ca6b 100644 (file)
@@ -669,6 +669,35 @@ static int set_4byte(struct spi_nor *nor, const struct flash_info *info,
        }
 }
 
+#ifdef CONFIG_SPI_FLASH_SPANSION
+/*
+ * Read status register 1 by using Read Any Register command to support multi
+ * die package parts.
+ */
+static int spansion_sr_ready(struct spi_nor *nor, u32 addr_base, u8 dummy)
+{
+       u32 reg_addr = addr_base + SPINOR_REG_ADDR_STR1V;
+       u8 sr;
+       int ret;
+
+       ret = spansion_read_any_reg(nor, reg_addr, dummy, &sr);
+       if (ret < 0)
+               return ret;
+
+       if (sr & (SR_E_ERR | SR_P_ERR)) {
+               if (sr & SR_E_ERR)
+                       dev_dbg(nor->dev, "Erase Error occurred\n");
+               else
+                       dev_dbg(nor->dev, "Programming Error occurred\n");
+
+               nor->write_reg(nor, SPINOR_OP_CLSR, NULL, 0);
+               return -EIO;
+       }
+
+       return !(sr & SR_WIP);
+}
+#endif
+
 static int spi_nor_sr_ready(struct spi_nor *nor)
 {
        int sr = read_sr(nor);
index e579ff2c7e59e45be92a13b82df5a8e69e7b6516..b9d66458a064afe4c310189bbcbb3a42f42b0324 100644 (file)
 #define SPINOR_OP_CLSR         0x30    /* Clear status register 1 */
 #define SPINOR_OP_RDAR         0x65    /* Read any register */
 #define SPINOR_OP_WRAR         0x71    /* Write any register */
+#define SPINOR_REG_ADDR_STR1V  0x00800000
 #define SPINOR_REG_ADDR_CFR1V  0x00800002
 
 /* Used for Micron flashes only. */