]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: spi: Set the current bank of flash to zero after doing clear bar
authorVipul Kumar <vipul.kumar@xilinx.com>
Fri, 20 Apr 2018 05:06:23 +0000 (10:36 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 23 Apr 2018 11:18:02 +0000 (13:18 +0200)
clean_bar() function selecting bank zero but not setting the
flash current bank to zero. After erase operation, bank zero is selected
but the flash current bank is pointing to bank one. So, during
write operation, while trying to write bank one, it actually writes in
bank zero.
This patch fixed this issue by setting the current bank of flash
to zero after doing clear_bar() after erase, write and read operations.

Signed-off-by: Vipul Kumar <vipul.kumar@xilinx.com>
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/mtd/spi/spi_flash.c

index 8e79a4a125a78876ab5e363e82702b59023cb54a..cba61da744aa6d4945b8ec552ad078c1459226b3 100644 (file)
@@ -165,12 +165,21 @@ static int write_cr(struct spi_flash *flash, u8 wc)
 static int clean_bar(struct spi_flash *flash)
 {
        u8 cmd, bank_sel = 0;
+       int ret;
 
        if (flash->bank_curr == 0)
                return 0;
        cmd = flash->bank_write_cmd;
 
-       return spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1);
+       ret = spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1);
+       if (ret) {
+               debug("SF: fail to write bank register\n");
+               return ret;
+       }
+
+       flash->bank_curr = bank_sel;
+
+       return ret;
 }
 
 static int write_bar(struct spi_flash *flash, u32 offset)