Commit 8af74edc30bb60a90a5c4d2769ff3129b187796e

Authored by Álvaro Fernández Rojas
Committed by Jagan Teki
1 parent 48263504c8

drivers: spi: allow limiting reads

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>

Showing 2 changed files with 6 additions and 0 deletions Side-by-side Diff

drivers/mtd/spi/spi_flash.c
... ... @@ -516,6 +516,9 @@
516 516 else
517 517 read_len = remain_len;
518 518  
  519 + if (spi->max_read_size)
  520 + read_len = min(read_len, spi->max_read_size);
  521 +
519 522 spi_flash_addr(read_addr, cmd);
520 523  
521 524 ret = spi_flash_read_common(flash, cmd, cmdsz, data, read_len);
... ... @@ -86,6 +86,8 @@
86 86 * @cs: ID of the chip select connected to the slave.
87 87 * @mode: SPI mode to use for this slave (see SPI mode flags)
88 88 * @wordlen: Size of SPI word in number of bits
  89 + * @max_read_size: If non-zero, the maximum number of bytes which can
  90 + * be read at once.
89 91 * @max_write_size: If non-zero, the maximum number of bytes which can
90 92 * be written at once, excluding command bytes.
91 93 * @memory_map: Address of read-only SPI flash access.
... ... @@ -102,6 +104,7 @@
102 104 #endif
103 105 uint mode;
104 106 unsigned int wordlen;
  107 + unsigned int max_read_size;
105 108 unsigned int max_write_size;
106 109 void *memory_map;
107 110