aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVignesh R <vigneshr@ti.com>2016-03-29 01:46:17 -0400
committerBrian Norris <computersforpeace@gmail.com>2016-04-05 14:06:57 -0400
commit08922f644878c9163ada8df3ef9def89be1d5e90 (patch)
treed29bb6fade704b652cfbe40078eca606a083debb
parent5651d6aaf489d1db48c253cf884b40214e91c2c5 (diff)
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>
-rw-r--r--drivers/mtd/devices/m25p80.c22
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,
131 /* convert the dummy cycles to the number of bytes */ 131 /* convert the dummy cycles to the number of bytes */
132 dummy /= 8; 132 dummy /= 8;
133 133
134 if (spi_flash_read_supported(spi)) {
135 struct spi_flash_read_message msg;
136 int ret;
137
138 memset(&msg, 0, sizeof(msg));
139
140 msg.buf = buf;
141 msg.from = from;
142 msg.len = len;
143 msg.read_opcode = nor->read_opcode;
144 msg.addr_width = nor->addr_width;
145 msg.dummy_bytes = dummy;
146 /* TODO: Support other combinations */
147 msg.opcode_nbits = SPI_NBITS_SINGLE;
148 msg.addr_nbits = SPI_NBITS_SINGLE;
149 msg.data_nbits = m25p80_rx_nbits(nor);
150
151 ret = spi_flash_read(spi, &msg);
152 *retlen = msg.retlen;
153 return ret;
154 }
155
134 spi_message_init(&m); 156 spi_message_init(&m);
135 memset(t, 0, (sizeof t)); 157 memset(t, 0, (sizeof t));
136 158