]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: Add extended address register reading support for winbond and stmicro
authorJagannadha Sutradharudu Teki <jagannadha.sutradharudu-teki@xilinx.com>
Fri, 12 Apr 2013 14:01:27 +0000 (19:31 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 12 Apr 2013 14:11:35 +0000 (16:11 +0200)
This patch provides support to read a flash extended address
register for winbond and stmicro SPI flashes.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/mtd/spi/spi_flash.c
drivers/mtd/spi/spi_flash_internal.h

index fb9331a22250fd351f6657f981dd8a6ddd8d0dbf..035dd38ab11664f94e58322e0780da4308b708e3 100644 (file)
@@ -380,8 +380,25 @@ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 ear)
 int spi_flash_cmd_bankaddr_read(struct spi_flash *flash, void *data)
 {
        u8 cmd;
+       u8 idcode0;
+       int ret;
+
+       ret = spi_flash_cmd(flash->spi, CMD_READ_ID, &idcode0, 1);
+       if (ret) {
+               debug("SF: fail to read read id\n");
+               return ret;
+       }
+
+       if (idcode0 == 0x01) {
+               cmd = CMD_BANKADDR_BRRD;
+       } else if ((idcode0 == 0xef) || (idcode0 == 0x20)) {
+               cmd = CMD_EXT_RDEAR;
+       } else {
+               printf("SF: unable to support extended addr reg read"
+                       " for %s flash\n", flash->name);
+               return -1;
+       }
 
-       cmd = CMD_BANKADDR_BRRD;
        return spi_flash_read_common(flash, &cmd, 1, data, 1);
 }
 
index 37770e25e37465e5f0a6de683b0efdd696c28a23..2a54288e3e7db8d328590944a0c0745093fad0eb 100644 (file)
@@ -32,6 +32,7 @@
 #define CMD_BANKADDR_BRWR              0x17
 #define CMD_BANKADDR_BRRD              0x16
 #define CMD_EXT_WREAR                  0xC5
+#define CMD_EXT_RDEAR                  0xC8
 
 /* Common status */
 #define STATUS_WIP                     0x01