Skip to contentSkip to conversation

SF: always read 5 bytes for the idcode

PATCH New Mike Frysinger 2 participants 4 messages Mar 28, 2009 – Mar 29, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SF: always read 5 bytes for the idcode

Some SPI flash drivers like to have extended id information available (like the spansion flash), so rather than making it re-issue the ID cmd to get at the last 2 bytes, have the common code read 5 bytes rather than just 3. This also matches the Linux behavior where it always reads 5 id bytes from all flashes.

CC Mingkai Hu <[email protected]>
CC Haavard Skinnemoen <[email protected]>
---
 drivers/mtd/spi/spansion.c  |   10 ++--------
 drivers/mtd/spi/spi_flash.c |    2 +-
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/mtd/spi/spansion.c +2 -8
index 9de4b7b..b9746fd 100644
@@ -310,15 +310,9 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
 	struct spansion_spi_flash *spsn;
 	unsigned int i;
 	unsigned short jedec, ext_jedec;
-	int ret;
-	u8 id[5] = {0};
-
-	ret = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id));
-	if (ret)
-		return NULL;
 
-	jedec = id[1] << 8 | id[2];
-	ext_jedec = id[3] << 8 | id[4];
+	jedec = idcode[1] << 8 | idcode[2];
+	ext_jedec = idcode[3] << 8 | idcode[4];
 
 	for (i = 0; i < ARRAY_SIZE(spansion_spi_flash_table); i++) {
 		params = &spansion_spi_flash_table[i];
drivers/mtd/spi/spi_flash.c +1 -1
index 57ef002..9c09d44 100644
@@ -101,7 +101,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	struct spi_slave *spi;
 	struct spi_flash *flash;
 	int ret;
-	u8 idcode[3];
+	u8 idcode[5];
 
 	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
 	if (!spi) {
Signature · 1 line
1.6.2
#1 lore raw

PATCH 1/1 SF: always read 5 bytes for the idcode

Quoted 9 lines · Mike Frysinger

Some SPI flash drivers like to have extended id information available (like the spansion flash), so rather than making it re-issue the ID cmd to get at the last 2 bytes, have the common code read 5 bytes rather than just 3. This also matches the Linux behavior where it always reads 5 id bytes from all flashes.

CC Mingkai Hu <[email protected]>
CC Haavard Skinnemoen <[email protected]>

Yes, that's much better. But perhaps you should pass the last two bytes to the debug() call a bit further down too?

I guess it's not essential though, so

#2 lore raw

PATCH 1/1 SF: always read 5 bytes for the idcode

Quoted 7 lines · On Sunday 29 March 2009 08:40:10 Haavard Skinnemoen wrote:
Quoted 6 lines · Mike Frysinger

Some SPI flash drivers like to have extended id information available (like the spansion flash), so rather than making it re-issue the ID cmd to get at the last 2 bytes, have the common code read 5 bytes rather than just 3. This also matches the Linux behavior where it always reads 5 id bytes from all flashes.

Quoted 6 lines
Quoted 3 lines
CC Mingkai Hu <[email protected]>
CC Haavard Skinnemoen <[email protected]>

Yes, that's much better. But perhaps you should pass the last two bytes to the debug() call a bit further down too?

np, i'll update the patch 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/20090329/b8350d48/attachment-0001.pgp

#3 lore raw

PATCH v2 1/1 sf: always read 5 bytes for the idcode

In reply to Haavard Skinnemoen

Some SPI flash drivers like to have extended id information available (like the spansion flash), so rather than making it re-issue the ID cmd to get at the last 2 bytes, have the common code read 5 bytes rather than just 3. This also matches the Linux behavior where it always reads 5 id bytes from all flashes.

---
v2
- display all 5 bytes in the debug() output

 drivers/mtd/spi/spansion.c  |   10 ++--------
 drivers/mtd/spi/spi_flash.c |    6 +++---
 2 files changed, 5 insertions(+), 11 deletions(-)
drivers/mtd/spi/spansion.c +2 -8
index 9de4b7b..b9746fd 100644
@@ -310,15 +310,9 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
 	struct spansion_spi_flash *spsn;
 	unsigned int i;
 	unsigned short jedec, ext_jedec;
-	int ret;
-	u8 id[5] = {0};
-
-	ret = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id));
-	if (ret)
-		return NULL;
 
-	jedec = id[1] << 8 | id[2];
-	ext_jedec = id[3] << 8 | id[4];
+	jedec = idcode[1] << 8 | idcode[2];
+	ext_jedec = idcode[3] << 8 | idcode[4];
 
 	for (i = 0; i < ARRAY_SIZE(spansion_spi_flash_table); i++) {
 		params = &spansion_spi_flash_table[i];
drivers/mtd/spi/spi_flash.c +3 -3
index 1902960..c8c460b 100644
@@ -101,7 +101,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	struct spi_slave *spi;
 	struct spi_flash *flash;
 	int ret;
-	u8 idcode[3];
+	u8 idcode[5];
 
 	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
 	if (!spi) {
@@ -120,8 +120,8 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	if (ret)
 		goto err_read_id;
 
-	debug("SF: Got idcode %02x %02x %02x\n", idcode[0],
-			idcode[1], idcode[2]);
+	debug("SF: Got idcode %02x %02x %02x %02x %02x\n", idcode[0],
+			idcode[1], idcode[2], idcode[3], idcode[4]);
 
 	switch (idcode[0]) {
 #ifdef CONFIG_SPI_FLASH_SPANSION
Signature · 1 line
1.6.2