Skip to contentSkip to conversation

mtd: spi-nor: Address the Macronix flash probe failure

PATCH In review Venkatesh Yadav Abbarapu 2 participants 2 messages Nov 15, 2024 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: spi-nor: Address the Macronix flash probe failure

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.

---
 drivers/mtd/spi/spi-nor-core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/mtd/spi/spi-nor-core.c +11 -0
index ec841fb13b..baf1941d76 100644
@@ -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,
Signature · 1 line
2.17.1
#1 lore raw
Quoted 34 lines · Venkatesh Yadav Abbarapu

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.

---
 drivers/mtd/spi/spi-nor-core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/mtd/spi/spi-nor-core.c +4 -0
index ec841fb13b..baf1941d76 100644
@@ -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);

drivers/mtd/spi/spi-nor-core.c static int spi_nor_soft_reset(struct spi_nor *nor) · line 4342

Quoted 10 lines
drivers/mtd/spi/spi-nor-core.c +7 -0
+		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,

Is this expected to fix the problem Jon was reporting still with commit 5d40b3d384dc ("mtd: spi-nor: Add parallel and stacked memories support") ? And if so, it's missing a Fixes tag as well.

Signature · 1 line
Tom