Patchwork [U-Boot,5/5] sf: Add bank selection support for dual stacked access

login
register
mail settings
Submitter Jagannadha Sutradharudu Teki
Date July 29, 2013, 3:23 p.m.
Message ID <34698383-11cd-4bc2-8328-56b1536f8fd5@AM1EHSMHS011.ehs.local>
Download mbox | patch
Permalink /patch/262838/
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Comments

Jagannadha Sutradharudu Teki - July 29, 2013, 3:23 p.m.
For upper memory, bank selection on dual stacked access
needs to subtract the calculated banks from the number of
banks available on a single memory.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
 drivers/mtd/spi/spi_flash.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index f7443fa..58d5899 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -190,6 +190,9 @@  int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
 		u8 bank_sel;
 
 		bank_sel = erase_addr / SPI_FLASH_16MB_BOUN;
+		if ((is_dual == SPI_FLASH_CONN_DUALSTACKED) &&
+				(flash->spi->u_page == 1))
+			bank_sel -= ((flash->size / 2) / SPI_FLASH_16MB_BOUN);
 
 		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
 		if (ret) {
@@ -242,6 +245,9 @@  int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
 		u8 bank_sel;
 
 		bank_sel = write_addr / SPI_FLASH_16MB_BOUN;
+		if ((is_dual == SPI_FLASH_CONN_DUALSTACKED) &&
+				(flash->spi->u_page == 1))
+			bank_sel -= ((flash->size / 2) / SPI_FLASH_16MB_BOUN);
 
 		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
 		if (ret) {
@@ -330,12 +336,19 @@  int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
 		}
 #ifdef CONFIG_SPI_FLASH_BAR
 		bank_sel = read_addr / SPI_FLASH_16MB_BOUN;
+		if ((is_dual == SPI_FLASH_CONN_DUALSTACKED) &&
+				(flash->spi->u_page == 1))
+			bank_sel -= ((flash->size / 2) / SPI_FLASH_16MB_BOUN);
 
 		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
 		if (ret) {
 			debug("SF: fail to set bank%d\n", bank_sel);
 			return ret;
 		}
+
+		if ((is_dual == SPI_FLASH_CONN_DUALSTACKED) &&
+				(flash->spi->u_page == 1))
+			bank_sel += ((flash->size / 2) / SPI_FLASH_16MB_BOUN);
 #endif
 		remain_len = (bank_boun * (bank_sel + 1) - read_addr);
 		if (len < remain_len)