]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: spi_flash: Add support for read if offset is odd
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Tue, 31 Jan 2017 05:14:07 +0000 (10:44 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 31 Jan 2017 07:55:31 +0000 (08:55 +0100)
Add support ot read from flash if offset received is odd
incase of dual parallel. This fixes the issue of spi flash
read failures if received offset is odd

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/mtd/spi/spi_flash.c

index 169c3ea93dfd6426df88e1e2742250629d34fcab..93d255e4c7625d014a2deda420e0bb2d9d233f05 100644 (file)
@@ -599,6 +599,27 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
        u32 remain_len, read_len, read_addr, bank_addr;
        int bank_sel = 0;
        int ret = -1;
+#ifdef CONFIG_SF_DUAL_FLASH
+       u8 moveoffs = 0;
+       void *tempbuf = NULL;
+       size_t length = len;
+#endif
+
+#ifdef CONFIG_SF_DUAL_FLASH
+       /*
+        * Incase of dual parallel, if odd offset is received
+        * decrease it by 1 and read extra byte, otherwise
+        * any read with odd offset fails
+        */
+       if (flash->dual_flash == SF_DUAL_PARALLEL_FLASH) {
+               if (offset & 1) {
+                       offset -= 1;
+                       len += 1;
+                       moveoffs = 1;
+                       tempbuf = data;
+               }
+       }
+#endif
 
        /* Handle memory-mapped SPI */
        if (flash->memory_map) {
@@ -681,6 +702,15 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
                data += read_len;
        }
 
+#ifdef CONFIG_SF_DUAL_FLASH
+       if (flash->dual_flash == SF_DUAL_PARALLEL_FLASH) {
+               if (moveoffs) {
+                       data = tempbuf + 1;
+                       memcpy(tempbuf, data, length);
+               }
+       }
+#endif
+
        free(cmd);
        return ret;
 }