045-mtd-devices-m25p80-add-support-for-mmap-read-request.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From 08922f644878c9163ada8df3ef9def89be1d5e90 Mon Sep 17 00:00:00 2001
  2. From: Vignesh R <vigneshr@ti.com>
  3. Date: Tue, 29 Mar 2016 11:16:17 +0530
  4. Subject: [PATCH] mtd: devices: m25p80: add support for mmap read request
  5. Certain SPI controllers may provide accelerated hardware interface to
  6. read from m25p80 type flash devices in order to provide better read
  7. performance. SPI core supports such devices with spi_flash_read() API.
  8. Call spi_flash_read(), if supported, to make use of such interface.
  9. Signed-off-by: Vignesh R <vigneshr@ti.com>
  10. [Brian: add memset()]
  11. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  12. ---
  13. --- a/drivers/mtd/devices/m25p80.c
  14. +++ b/drivers/mtd/devices/m25p80.c
  15. @@ -131,6 +131,28 @@ static int m25p80_read(struct spi_nor *n
  16. /* convert the dummy cycles to the number of bytes */
  17. dummy /= 8;
  18. + if (spi_flash_read_supported(spi)) {
  19. + struct spi_flash_read_message msg;
  20. + int ret;
  21. +
  22. + memset(&msg, 0, sizeof(msg));
  23. +
  24. + msg.buf = buf;
  25. + msg.from = from;
  26. + msg.len = len;
  27. + msg.read_opcode = nor->read_opcode;
  28. + msg.addr_width = nor->addr_width;
  29. + msg.dummy_bytes = dummy;
  30. + /* TODO: Support other combinations */
  31. + msg.opcode_nbits = SPI_NBITS_SINGLE;
  32. + msg.addr_nbits = SPI_NBITS_SINGLE;
  33. + msg.data_nbits = m25p80_rx_nbits(nor);
  34. +
  35. + ret = spi_flash_read(spi, &msg);
  36. + *retlen = msg.retlen;
  37. + return ret;
  38. + }
  39. +
  40. spi_message_init(&m);
  41. memset(t, 0, (sizeof t));