
Reading using the already supported read command is causing regression after 4k bytes, as a result doing a page by page read. Its happening, because ti qpsi controller CS will get de asserted after 4096 bytes.
Signed-off-by: Sourav Poddar sourav.poddar@ti.com --- drivers/mtd/spi/spi_flash.c | 32 +++++++++++++++++++++++++++++++- 1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 6a6fe37..5f8db7b 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -303,6 +303,36 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, else read_len = remain_len;
+#ifdef CONFIG_TI_QSPI + unsigned long page_addr, byte_addr, page_size; + size_t chunk_len, actual; + int ret = 0; + + page_size = flash->page_size; + page_addr = offset / page_size; + byte_addr = offset % page_size; + + for (actual = 0; actual < read_len; actual += chunk_len) { + chunk_len = min(read_len - actual, page_size - byte_addr); + + cmd[1] = page_addr >> 8; + cmd[2] = page_addr; + cmd[3] = byte_addr; + + ret = spi_flash_read_common(flash, cmd, sizeof(cmd), + data + actual, chunk_len); + if (ret < 0) { + debug("SF: read failed"); + break; + } + + byte_addr += chunk_len; + if (byte_addr == page_size) { + page_addr++; + byte_addr = 0; + } + } +#else spi_flash_addr(offset, cmd);
ret = spi_flash_read_common(flash, cmd, sizeof(cmd), @@ -311,7 +341,7 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, debug("SF: read failed\n"); break; } - +#endif offset += read_len; len -= read_len; data += read_len;