Skip to contentSkip to conversation

spi_flash: support old STMicro parts with RES

PATCH New Thomas Chou 2 participants 5 messages Apr 21, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi_flash: support old STMicro parts with RES

Some old STMicro parts do not support JEDEC ID (0x9f). This patch uses RES (0xab) to get Electronic ID and translates it to JEDEC ID.

---
 drivers/mtd/spi/spi_flash.c |   12 ++++++++++++
 drivers/mtd/spi/stmicro.c   |    8 ++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/mtd/spi/spi_flash.c +12 -0
index 612f819..8986879 100644
@@ -120,6 +120,18 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	ret = spi_flash_cmd(spi, CMD_READ_ID, &idcode, sizeof(idcode));
 	if (ret)
 		goto err_read_id;
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	if (idcode[0] == 0xff) { /* try RES to read electronic id */
+		ret = spi_flash_cmd(spi, 0xab, &idcode, sizeof(idcode));
+		if (ret)
+			goto err_read_id;
+		if ((idcode[3] & 0xf0) == 0x10) {
+			idcode[0] = 0x20;
+			idcode[1] = 0x20;
+			idcode[2] = idcode[3] + 1;
+		}
+	}
+#endif
 
 	debug("SF: Got idcode %02x %02x %02x %02x %02x\n", idcode[0],
 			idcode[1], idcode[2], idcode[3], idcode[4]);
drivers/mtd/spi/stmicro.c +8 -0
index ae0d047..bdb49da 100644
@@ -46,6 +46,7 @@
 #define CMD_M25PXX_DP		0xb9	/* Deep Power-down */
 #define CMD_M25PXX_RES		0xab	/* Release from DP, and Read Signature */
 
+#define STM_ID_M25P10		0x11
 #define STM_ID_M25P16		0x15
 #define STM_ID_M25P20		0x12
 #define STM_ID_M25P32		0x16
@@ -78,6 +79,13 @@ static inline struct stmicro_spi_flash *to_stmicro_spi_flash(struct spi_flash
 
 static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
 	{
+		.idcode1 = STM_ID_M25P10,
+		.page_size = 256,
+		.pages_per_sector = 128,
+		.nr_sectors = 4,
+		.name = "M25P10",
+	},
+	{
 		.idcode1 = STM_ID_M25P16,
 		.page_size = 256,
 		.pages_per_sector = 256,
Signature · 1 line
1.6.6.1
#1 lore raw

PATCH 1/1 spi_flash: support old STMicro parts with RES

Quoted 9 lines · On Wednesday 21 April 2010 02:14:07 Thomas Chou wrote:
drivers/mtd/spi/spi_flash.c +2 -0
@@ -120,6 +120,18 @@ struct spi_flash *spi_flash_probe(unsigned int bus,
 unsigned int cs, ret = spi_flash_cmd(spi, CMD_READ_ID, &idcode,
 sizeof(idcode));
 	if (ret)
 		goto err_read_id;
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	if (idcode[0] == 0xff) { /* try RES to read electronic id */

drivers/mtd/spi/spi_flash.c struct spi_flash *spi_flash_probe(unsigned int bus, · line 135

Quoted 10 lines
drivers/mtd/spi/spi_flash.c +10 -0
+		ret = spi_flash_cmd(spi, 0xab, &idcode, sizeof(idcode));
+		if (ret)
+			goto err_read_id;
+		if ((idcode[3] & 0xf0) == 0x10) {
+			idcode[0] = 0x20;
+			idcode[1] = 0x20;
+			idcode[2] = idcode[3] + 1;
+		}
+	}
+#endif

please move this logic to stmicro's probe function to keep the common code clear of such cruft.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100421/002a377d/attachment.pgp

#2 lore raw

PATCH 1/1 spi_flash: support old STMicro parts with RES

Quoted 4 lines · Mike Frysinger

please move this logic to stmicro's probe function to keep the common code clear of such cruft.
-mike

Hi Mike,

Thanks. I can move them to stmicro.c. But I still need to sort 0xff to stmicro. Is this OK?

Best regards,
Thomas

drivers/mtd/spi/spi_flash.c +0 -0
index 8986879..d400639 100644
@@ -159,6 +159,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, 

unsigned int cs,
#endif

  #ifdef CONFIG_SPI_FLASH_STMICRO
      case 0x20:
+    case 0xff:
          flash = spi_flash_probe_stmicro(spi, idcode);
          break;

#endif

#3 lore raw

PATCH 1/1 spi_flash: support old STMicro parts with RES

Quoted 6 lines · On Wednesday 21 April 2010 03:51:33 Thomas Chou wrote:
Quoted 2 lines · Mike Frysinger

please move this logic to stmicro's probe function to keep the common code clear of such cruft.

Thanks. I can move them to stmicro.c. But I still need to sort 0xff to stmicro.

the id function is given a pointer to the idcode buffer which means the sub function is free to modify it, so there should be no need for that.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100421/02ba7dfd/attachment.pgp

#4 lore raw

PATCH v2 1/1 spi_flash: support old STMicro parts with RES

In reply to Thomas Chou

Some old STMicro parts do not support JEDEC ID (0x9f). This patch uses RES (0xab) to get Electronic ID and translates it to JEDEC ID.

---
move the logic to stmicro's probe function.

 drivers/mtd/spi/spi_flash.c |    1 +
 drivers/mtd/spi/stmicro.c   |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
drivers/mtd/spi/spi_flash.c +1 -0
index 612f819..c8e4bdd 100644
@@ -147,6 +147,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO
 	case 0x20:
+	case 0xff:
 		flash = spi_flash_probe_stmicro(spi, idcode);
 		break;
 #endif
drivers/mtd/spi/stmicro.c +21 -0
index ae0d047..21e9b00 100644
@@ -46,6 +46,7 @@
 #define CMD_M25PXX_DP		0xb9	/* Deep Power-down */
 #define CMD_M25PXX_RES		0xab	/* Release from DP, and Read Signature */
 
+#define STM_ID_M25P10		0x11
 #define STM_ID_M25P16		0x15
 #define STM_ID_M25P20		0x12
 #define STM_ID_M25P32		0x16
@@ -78,6 +79,13 @@ static inline struct stmicro_spi_flash *to_stmicro_spi_flash(struct spi_flash
 
 static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
 	{
+		.idcode1 = STM_ID_M25P10,
+		.page_size = 256,
+		.pages_per_sector = 128,
+		.nr_sectors = 4,
+		.name = "M25P10",
+	},
+	{
 		.idcode1 = STM_ID_M25P16,
 		.page_size = 256,
 		.pages_per_sector = 256,
@@ -316,6 +324,19 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
 	struct stmicro_spi_flash *stm;
 	unsigned int i;
 
+	if (idcode[0] == 0xff) {
+		i = spi_flash_cmd(spi, CMD_M25PXX_RES,
+				  idcode, 4);
+		if (i)
+			return NULL;
+		if ((idcode[3] & 0xf0) == 0x10) {
+			idcode[0] = 0x20;
+			idcode[1] = 0x20;
+			idcode[2] = idcode[3] + 1;
+		} else
+			return NULL;
+	}
+
 	for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) {
 		params = &stmicro_spi_flash_table[i];
 		if (params->idcode1 == idcode[2]) {
Signature · 1 line
1.6.6.1