diff options
author | Vignesh R <vigneshr@ti.com> | 2016-03-29 08:46:17 +0300 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2016-04-05 21:06:57 +0300 |
commit | 08922f644878c9163ada8df3ef9def89be1d5e90 (patch) | |
tree | d29bb6fade704b652cfbe40078eca606a083debb /drivers/mtd/devices/m25p80.c | |
parent | 5651d6aaf489d1db48c253cf884b40214e91c2c5 (diff) | |
download | linux-08922f644878c9163ada8df3ef9def89be1d5e90.tar.xz |
mtd: devices: m25p80: add support for mmap read request
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>
Diffstat (limited to 'drivers/mtd/devices/m25p80.c')
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index c9c3b7fa3051..9d6854467651 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -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)); |