]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: Add extended address register writing support for winbond and stmicro
authorJagannadha Sutradharudu Teki <jagannadha.sutradharudu-teki@xilinx.com>
Fri, 12 Apr 2013 14:01:26 +0000 (19:31 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 12 Apr 2013 14:11:00 +0000 (16:11 +0200)
This patch provides support to program 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 44e2b611a86d93b6ca2f32888b98f316c38ad534..fb9331a22250fd351f6657f981dd8a6ddd8d0dbf 100644 (file)
@@ -337,15 +337,31 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
 int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 ear)
 {
        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_BRWR;
+       } else if ((idcode0 == 0xef) || (idcode0 == 0x20)) {
+               cmd = CMD_EXT_WREAR;
+       } else {
+               printf("SF: unable to support extended addr reg write"
+                                               " for %s flash\n", flash->name);
+               return -1;
+       }
+
        ret = spi_flash_cmd_write_enable(flash);
        if (ret < 0) {
                debug("SF: enabling write failed\n");
                return ret;
        }
 
-       cmd = CMD_BANKADDR_BRWR;
        ret = spi_flash_cmd_write(flash->spi, &cmd, 1, &ear, 1);
        if (ret) {
                debug("SF: fail to write bank addr register\n");
index dc411e551970b36f9579ebd42014fc4abfe42028..37770e25e37465e5f0a6de683b0efdd696c28a23 100644 (file)
@@ -31,6 +31,7 @@
 /* Bank addr acess commands */
 #define CMD_BANKADDR_BRWR              0x17
 #define CMD_BANKADDR_BRRD              0x16
+#define CMD_EXT_WREAR                  0xC5
 
 /* Common status */
 #define STATUS_WIP                     0x01