[PATCH 1/3] mtd: spi-nor-core: Introduce SPI_NOR_SOFT_RESET flash_info flag

Tudor Ambarus tudor.ambarus at microchip.com
Wed Nov 3 17:24:52 CET 2021


Some flashes can determine if Soft Reset is supported by parsing
BFPT_DWORD(16). There are however flashes that do not define any of
the SFDP tables, so they can't discover this capability at SFDP
parsing time. For such cases introduce the SPI_NOR_SOFT_RESET
flash_info flag to be able to specify statically this support.
This flag must be used together with the SPI_NOR_SKIP_SFDP flag.
For flashes that support Soft Reset and define BFPT, but have
the BFPT_DWORD(16) missing or with a wrong value, a post_sfdp()
fixup hook should be used instead, where SNOR_F_SOFT_RESET should
be set.

Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
---
 drivers/mtd/spi/sf_internal.h  | 5 +++++
 drivers/mtd/spi/spi-nor-core.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index d3ef69ec74..9a16e07bc4 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -69,6 +69,11 @@ struct flash_info {
 #define SPI_NOR_HAS_SST26LOCK	BIT(15)	/* Flash supports lock/unlock via BPR */
 #define SPI_NOR_OCTAL_READ	BIT(16)	/* Flash supports Octal Read */
 #define SPI_NOR_OCTAL_DTR_READ	BIT(17)	/* Flash supports Octal DTR Read */
+#define SPI_NOR_SOFT_RESET	BIT(18)	/*
+					 * Used by flashes that do not define
+					 * any SFDP tables, i.e. in conjunction
+					 * with SPI_NOR_SKIP_SFDP.
+					 */
 };
 
 extern const struct flash_info spi_nor_ids[];
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 4388a08a90..ce1ecae899 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3813,6 +3813,9 @@ int spi_nor_scan(struct spi_nor *nor)
 	if (info->flags & SPI_NOR_NO_ERASE)
 		mtd->flags |= MTD_NO_ERASE;
 
+	if (info->flags & SPI_NOR_SOFT_RESET)
+		nor->flags |= SNOR_F_SOFT_RESET;
+
 	nor->page_size = params.page_size;
 	mtd->writebufsize = nor->page_size;
 
-- 
2.25.1



More information about the U-Boot mailing list