[PATCH v4 2/6] mtd: spi-nor: core: Handle ID collisions between SFDP & non-SFDP flashes

Tudor Ambarus tudor.ambarus at microchip.com
Mon Feb 28 05:45:01 PST 2022


A typical differentiator between flashes whose ID collide is whether they
support SFDP or not. For such a collision there will be a single
flash_info entry where the developer should specify:
1/ PARSE_SFDP - so that the flash that supports SFDP to initialize its
   parameters by parsing the SFDP tables
2/ any of the no_sfdp_flags less SPI_NOR_SKIP_SFDP, to initialize the
   flash parameters via the static no_sfdp_flags for the flash that
   doesn't support SFDP.
Use the logic the above to handle ID collisions between SFDP & non-SFDP
flashes.

Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
---
 drivers/mtd/spi-nor/core.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index fbf3278ba29a..aef00151c116 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2639,8 +2639,17 @@ static int spi_nor_init_params(struct spi_nor *nor)
 	if (nor->info->parse_sfdp) {
 		ret = spi_nor_parse_sfdp(nor);
 		if (ret) {
-			dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n");
-			return ret;
+			/*
+			 * Handle ID collisions between flashes that support
+			 * SFDP and flashes that don't. Initialize parameters
+			 * for the flash that doesn't support SFDP.
+			 */
+			if (nor->info->no_sfdp_flags & ~SPI_NOR_SKIP_SFDP) {
+				spi_nor_no_sfdp_init_params(nor);
+			} else {
+				dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n");
+				return ret;
+			}
 		}
 	} else if (nor->info->no_sfdp_flags & SPI_NOR_SKIP_SFDP) {
 		spi_nor_no_sfdp_init_params(nor);
-- 
2.25.1




More information about the linux-mtd mailing list