From: Siva Durga Prasad Paladugu Date: Fri, 25 Apr 2014 11:38:01 +0000 (+0530) Subject: sf: Correct bank select incase of dual stacked X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7be4a626a0690429adc9ee73d20522a5a7ce2fa4;p=thirdparty%2Fu-boot.git sf: Correct bank select incase of dual stacked Correct the bank selection issue incase of Dual stacked mode. This fix corrects the wrong bank selection if banks are accessed as below. 1. Access the bank2 in upper flash. 2. Access the bank1 in lower flash. 3. Now access the bank1 in upper flash. But here in the step3, the present code was accessing the bank2 in upper flash not bank1. This was because the code thinks the bank1 was already selected as part of step2 but it was not taking care of upper or lower flash. Signed-off-by: Siva Durga Prasad Paladugu Signed-off-by: Michal Simek --- diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 1f1bb360659..36c427767ef 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -97,10 +97,22 @@ static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) { u8 cmd; int ret; + u8 upage_curr; - if (flash->bank_curr == bank_sel) { - debug("SF: not require to enable bank%d\n", bank_sel); - return 0; + upage_curr = flash->spi->flags & SPI_XFER_U_PAGE; + + if (flash->dual_flash != SF_DUAL_STACKED_FLASH) { + if (flash->bank_curr == bank_sel) { + debug("SF: not require to enable bank%d\n", bank_sel); + return 0; + } + } else if (flash->upage_prev == upage_curr) { + if (flash->bank_curr == bank_sel) { + debug("SF: not require to enable bank%d\n", bank_sel); + return 0; + } + } else { + flash->upage_prev = upage_curr; } cmd = flash->bank_write_cmd; diff --git a/include/spi_flash.h b/include/spi_flash.h index f79f0eacca0..361df365002 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -108,6 +108,7 @@ struct spi_flash { u8 bank_read_cmd; u8 bank_write_cmd; u8 bank_curr; + u8 upage_prev; #endif u8 poll_cmd; u8 erase_cmd;