linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RESEND][PATCH] mtd: devices: m25p80: add support for mmap read request
@ 2016-03-29  5:46 Vignesh R
  2016-04-05 18:14 ` Brian Norris
  2016-05-18  9:23 ` Michal Suchanek
  0 siblings, 2 replies; 7+ messages in thread
From: Vignesh R @ 2016-03-29  5:46 UTC (permalink / raw)
  To: Brian Norris; +Cc: David Woodhouse, Vignesh R, linux-mtd, linux-kernel

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>
---

Resend v5:
Rebased on top of v4.6-rc1
v5: http://www.spinics.net/lists/devicetree/msg106696.html

 drivers/mtd/devices/m25p80.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index c9c3b7fa3051..7730e633d7d3 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -131,6 +131,26 @@ 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;
+
+		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));
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-05-18  9:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29  5:46 [RESEND][PATCH] mtd: devices: m25p80: add support for mmap read request Vignesh R
2016-04-05 18:14 ` Brian Norris
2016-04-06  5:18   ` Vignesh R
2016-04-06 13:44     ` Cyrille Pitchen
2016-05-18  9:23 ` Michal Suchanek
2016-05-18  9:39   ` Vignesh R
2016-05-18  9:49     ` Michal Suchanek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).