public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spi_flash: support old STMicro parts with RES
@ 2010-04-21  6:14 Thomas Chou
  2010-04-21  7:42 ` Mike Frysinger
  2010-04-21  8:16 ` [U-Boot] [PATCH v2] " Thomas Chou
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Chou @ 2010-04-21  6:14 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 drivers/mtd/spi/spi_flash.c |   12 ++++++++++++
 drivers/mtd/spi/stmicro.c   |    8 ++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 612f819..8986879 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -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]);
diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c
index ae0d047..bdb49da 100644
--- a/drivers/mtd/spi/stmicro.c
+++ b/drivers/mtd/spi/stmicro.c
@@ -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,
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-21  9:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-21  6:14 [U-Boot] [PATCH] spi_flash: support old STMicro parts with RES Thomas Chou
2010-04-21  7:42 ` Mike Frysinger
2010-04-21  7:51   ` Thomas Chou
2010-04-21  9:54     ` Mike Frysinger
2010-04-21  8:16 ` [U-Boot] [PATCH v2] " Thomas Chou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox