ipq6018: Adding support for new read id command sequence for spi nand
Some spi nand flash uses single byte read id(9FH) command,
for those devices the sequence is
byte1 byte2 byte3 byte4
9FH MID DID DID
some other spi nand flashes uses two byte read id(9F 00H) command
for those devices the sequence is
byte1 byte2 byte3 byte4
9FH A7-A0 MID DID
The first byte is the actual command and the second byte is a dummy byte.
For devices which uses new sequence, we need to pass
appropriate read id command with dummy byte.
Change-Id: Idf2e8740f8341596cd8f58d22d5e33a4b4972a31
Signed-off-by: Antony Arun T <antothom@codeaurora.org>
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index f5d8cc8..c8a93fc 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -1040,9 +1040,20 @@
u8 idcode[5];
u8 cmd;
int ret;
+#ifdef CONFIG_SPI_NAND_MULTI_BYTE_READ_ID
+ u8 command[2];
+ int dummy_byte = 0;
+ command[0] = CMD_READ_ID;
+ command[1] = 0; /*dummy byte*/
+
+try_with_dummy_byte:
/* Read the ID codes */
+ ret = spi_flash_cmd_read(spi, command, dummy_byte+1, idcode,
+ sizeof(idcode));
+#else
ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
+#endif
if (ret) {
printf("SF: Failed to get idcodes\n");
return -EINVAL;
@@ -1084,10 +1095,22 @@
if (!ret)
goto do_generic_probe;
#endif
+#ifdef CONFIG_SPI_NAND_MULTI_BYTE_READ_ID
+ if (dummy_byte == 0) {
+ dummy_byte = 1;
+ goto try_with_dummy_byte;
+ } else {
+ printf("SF: Unsupported flash IDs: ");
+ printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
+ idcode[0], jedec, ext_jedec);
+ return -EPROTONOSUPPORT;
+ }
+#else
printf("SF: Unsupported flash IDs: ");
printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
idcode[0], jedec, ext_jedec);
return -EPROTONOSUPPORT;
+#endif
}
/* Flash powers up read-only, so clear BP# bits */
diff --git a/include/configs/ipq6018.h b/include/configs/ipq6018.h
index b5ee8eb..e004613 100644
--- a/include/configs/ipq6018.h
+++ b/include/configs/ipq6018.h
@@ -212,6 +212,7 @@
#define CONFIG_SF_SPI_NAND_CS 1
#define CONFIG_IPQ_SPI_NAND_INFO_IDX 1
#define CONFIG_SF_NAND_BUS 1
+#define CONFIG_SPI_NAND_MULTI_BYTE_READ_ID
#endif
/*