[PATCH] mtd: spi-nor: Address the Macronix flash probe failure

Venkatesh Yadav Abbarapu venkatesh.abbarapu at amd.com
Fri Nov 15 06:06:56 CET 2024


When performing a soft reset on the OSPI flash, the default
cmd_ext_type is set to SPI_NOR_EXT_REPEAT. However, Macronix
flash requires the command type SPI_NOR_EXT_INVERT for soft
reset.

To address this issue, read the Manufacturer ID from the
flash. If the Manufacturer ID indicates Macronix, then
update the command type to SPI_NOR_EXT_INVERT.

Signed-off-by: Tejas Bhumkar <tejas.arvind.bhumkar at amd.com>
Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu at amd.com>
---
 drivers/mtd/spi/spi-nor-core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index ec841fb13b..baf1941d76 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -4316,6 +4316,7 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
 {
 	struct spi_mem_op op;
 	int ret;
+	u8 id[SPI_NOR_MAX_ID_LEN];
 	enum spi_nor_cmd_ext ext;
 
 	ext = nor->cmd_ext_type;
@@ -4326,6 +4327,16 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
 #endif /* SPI_NOR_BOOT_SOFT_RESET_EXT_INVERT */
 	}
 
+	ret = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
+	if (ret < 0) {
+		dev_dbg(nor->dev, "error %d reading JEDEC ID\n", ret);
+		return ret;
+	}
+
+	if (id[0] ==  SNOR_MFR_MACRONIX) {
+		nor->cmd_ext_type = SPI_NOR_EXT_INVERT;
+	}
+
 	op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
 			SPI_MEM_OP_NO_DUMMY,
 			SPI_MEM_OP_NO_ADDR,
-- 
2.17.1



More information about the U-Boot mailing list