]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
mtd: devices: m25p80: add support for mmap read request
authorVignesh R <vigneshr@ti.com>
Tue, 29 Mar 2016 05:46:17 +0000 (11:16 +0530)
committerBrian Norris <computersforpeace@gmail.com>
Tue, 5 Apr 2016 18:06:57 +0000 (11:06 -0700)
Certain SPI controllers may provide accelerated hardware interface to
read from m25p80 type flash devices in order to provide better read
performance. SPI core supports such devices with spi_flash_read() API.
Call spi_flash_read(), if supported, to make use of such interface.

Signed-off-by: Vignesh R <vigneshr@ti.com>
[Brian: add memset()]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/devices/m25p80.c

index c9c3b7fa30511c2b4a8f1b9c97bdd1cd89992758..9d6854467651774182ab8895198d41ed7caaf945 100644 (file)
@@ -131,6 +131,28 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
        /* convert the dummy cycles to the number of bytes */
        dummy /= 8;
 
+       if (spi_flash_read_supported(spi)) {
+               struct spi_flash_read_message msg;
+               int ret;
+
+               memset(&msg, 0, sizeof(msg));
+
+               msg.buf = buf;
+               msg.from = from;
+               msg.len = len;
+               msg.read_opcode = nor->read_opcode;
+               msg.addr_width = nor->addr_width;
+               msg.dummy_bytes = dummy;
+               /* TODO: Support other combinations */
+               msg.opcode_nbits = SPI_NBITS_SINGLE;
+               msg.addr_nbits = SPI_NBITS_SINGLE;
+               msg.data_nbits = m25p80_rx_nbits(nor);
+
+               ret = spi_flash_read(spi, &msg);
+               *retlen = msg.retlen;
+               return ret;
+       }
+
        spi_message_init(&m);
        memset(t, 0, (sizeof t));