]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
drivers: spi: allow limiting reads
authorÁlvaro Fernández Rojas <noltari@gmail.com>
Tue, 23 Jan 2018 16:14:56 +0000 (17:14 +0100)
committerJagan Teki <jagan@amarulasolutions.com>
Wed, 24 Jan 2018 06:33:43 +0000 (12:03 +0530)
For some SPI controllers it's not possible to keep the CS active between
transfers and they are limited to a known number of bytes.
This splits spi_flash reads into different iterations in order to respect
the SPI controller limits.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
drivers/mtd/spi/spi_flash.c
include/spi.h

index 51e28bf07b87cd02800aa826a76b91b6dc8a9b65..e40e1c01deb369727ac5b820b00c7c643ae9b25e 100644 (file)
@@ -516,6 +516,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
                else
                        read_len = remain_len;
 
+               if (spi->max_read_size)
+                       read_len = min(read_len, spi->max_read_size);
+
                spi_flash_addr(read_addr, cmd);
 
                ret = spi_flash_read_common(flash, cmd, cmdsz, data, read_len);
index 08c7480fda9c23f8aa8676de4b5432160ffb7e47..4787454e59e67ec0612d4100c4e7fef23a6bd550 100644 (file)
@@ -86,6 +86,8 @@ struct dm_spi_slave_platdata {
  * @cs:                        ID of the chip select connected to the slave.
  * @mode:              SPI mode to use for this slave (see SPI mode flags)
  * @wordlen:           Size of SPI word in number of bits
+ * @max_read_size:     If non-zero, the maximum number of bytes which can
+ *                     be read at once.
  * @max_write_size:    If non-zero, the maximum number of bytes which can
  *                     be written at once, excluding command bytes.
  * @memory_map:                Address of read-only SPI flash access.
@@ -102,6 +104,7 @@ struct spi_slave {
 #endif
        uint mode;
        unsigned int wordlen;
+       unsigned int max_read_size;
        unsigned int max_write_size;
        void *memory_map;