diff options
author | Dhruva Gole <d-gole@ti.com> | 2022-11-17 17:41:00 +0530 |
---|---|---|
committer | Anand Gadiyar <gadiyar@ti.com> | 2022-11-21 09:33:36 -0600 |
commit | 4e09478aa64a2959f9071d74359d7efca1b2c826 (patch) | |
tree | df83b5065d446a6b5beb9d3c98a6542621e069df /drivers | |
parent | 663e96dce3b4aa8e499f59d9e80adfe3aad2438b (diff) |
mtd: spi-nor-core: Read status by Read Any Register
Commit d2d79895da1b80275fe0ffd84d697519c73c924d upstream.
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>
Signed-off-by: Dhruva Gole <d-gole@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/spi/spi-nor-core.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 1f2f593ba0..57719229f5 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -680,6 +680,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); |