From: T Karthik Reddy Date: Tue, 9 Nov 2021 12:19:59 +0000 (-0700) Subject: mtd: spi-nor: Fix SST flash erase issue X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=757417189039858228e1a77874b109d76c713b95;p=thirdparty%2Fu-boot.git mtd: spi-nor: Fix SST flash erase issue SST flashes has multi size erase blocks like 8K, 32K and 64K bytes. We cannot perform a 64KB sector erase on all the blocks, So use 4k sector erase command to perform an erase operation. We could enable SPI_FLASH_USE_4K_SECTORS config to use 4K sector erase. But it will impact erase operation time on all large memory flashes. Signed-off-by: T Karthik Reddy --- diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 592a0f2255e..b62e708f39f 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -2655,6 +2655,12 @@ static int spi_nor_select_erase(struct spi_nor *nor, nor->erase_opcode = SPINOR_OP_SE; mtd->erasesize = info->sector_size << nor->shift; } + + if ((JEDEC_MFR(info) == SNOR_MFR_SST) && info->flags & SECT_4K) { + nor->erase_opcode = SPINOR_OP_BE_4K; + mtd->erasesize = 4096 << nor->shift; + } + return 0; }