aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJagannadha Sutradharudu Teki2013-08-07 07:36:55 -0500
committerSomnath Mukherjee2013-08-08 07:49:58 -0500
commit339787f43d06d2030ffd85c18814dc7993f5f19f (patch)
tree15d8ec5ad88d01938c886a979c360c41ffac4456
parent2c55123e37a4a17e8211f0bb0488a0aa9c741ec3 (diff)
downloadglsdk-u-boot-339787f43d06d2030ffd85c18814dc7993f5f19f.tar.gz
glsdk-u-boot-339787f43d06d2030ffd85c18814dc7993f5f19f.tar.xz
glsdk-u-boot-339787f43d06d2030ffd85c18814dc7993f5f19f.zip
sf: Update sf read to support all sizes of flashes
This patch updated the spi_flash read func to support all sizes of flashes using bank reg addr facility. The same support has been added in below patch for erase/write spi_flash functions: "sf: Support all sizes of flashes using bank addr reg facility" (sha1: c956f600cbb0943d0afe1004cdb503f4fcd8f415) With these new updates on sf framework, the flashes which has < 16MB are not effected as per as performance is concern and but the u-boot.bin size incrased ~460 bytes. sf update(for first 16MBytes), Changes before: U-Boot> sf update 0x1000000 0x0 0x1000000 - N25Q256 16777216 bytes written, 0 bytes skipped in 199.72s, speed 86480 B/s - W25Q128BV 16777216 bytes written, 0 bytes skipped in 351.739s, speed 48913 B/s - S25FL256S_64K 16777216 bytes written, 0 bytes skipped in 65.659s, speed 262144 B/s sf update(for first 16MBytes), Changes before: U-Boot> sf update 0x1000000 0x0 0x1000000 - N25Q256 16777216 bytes written, 0 bytes skipped in 198.953s, speed 86480 B/s - W25Q128BV 16777216 bytes written, 0 bytes skipped in 350.90s, speed 49200 B/s - S25FL256S_64K 16777216 bytes written, 0 bytes skipped in 66.521s, speed 262144 B/s Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/mtd/spi/spi_flash.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 58b764120..1fed2f7ac 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -151,17 +151,47 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
151int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, 151int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
152 size_t len, void *data) 152 size_t len, void *data)
153{ 153{
154 u8 cmd[5]; 154 u8 cmd[5], bank_sel;
155 u32 remain_len, read_len;
156 int ret = -1;
155 157
156 /* Handle memory-mapped SPI */ 158 /* Handle memory-mapped SPI */
157 if (flash->memory_map) 159 if (flash->memory_map)
158 memcpy(data, flash->memory_map + offset, len); 160 memcpy(data, flash->memory_map + offset, len);
159 161
160 cmd[0] = CMD_READ_ARRAY_FAST; 162 cmd[0] = CMD_READ_ARRAY_FAST;
161 spi_flash_addr(offset, cmd);
162 cmd[4] = 0x00; 163 cmd[4] = 0x00;
163 164
164 return spi_flash_read_common(flash, cmd, sizeof(cmd), data, len); 165 while (len) {
166 bank_sel = offset / SPI_FLASH_16MB_BOUN;
167
168 ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
169 if (ret) {
170 debug("SF: fail to set bank%d\n", bank_sel);
171 return ret;
172 }
173
174 remain_len = (SPI_FLASH_16MB_BOUN * (bank_sel + 1) - offset);
175 if (len < remain_len)
176 read_len = len;
177 else
178 read_len = remain_len;
179
180 spi_flash_addr(offset, cmd);
181
182 ret = spi_flash_read_common(flash, cmd, sizeof(cmd),
183 data, read_len);
184 if (ret < 0) {
185 debug("SF: read failed\n");
186 break;
187 }
188
189 offset += read_len;
190 len -= read_len;
191 data += read_len;
192 }
193
194 return ret;
165} 195}
166 196
167int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout, 197int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,