All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: bcm47xxsflash: support reading flash out of mapping window
@ 2017-01-16 22:09 Rafał Miłecki
  2017-01-17  3:18 ` Marek Vasut
  2017-01-17 10:51 ` [PATCH V2] " Rafał Miłecki
  0 siblings, 2 replies; 17+ messages in thread
From: Rafał Miłecki @ 2017-01-16 22:09 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen
  Cc: linux-mtd, Hauke Mehrtens, Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

For reading flash content we use MMIO but it's possible to read only
first 16 MiB this way. It's simply an arch design/limitation.
To support flash sizes bigger than 16 MiB implement indirect access
using ChipCommon registers.
This has been tested using MX25L25635F.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/mtd/devices/bcm47xxsflash.c | 12 +++++++++++-
 drivers/mtd/devices/bcm47xxsflash.h |  3 +++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 4decd8c..5d57119 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -110,7 +110,17 @@ static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len,
 	if ((from + len) > mtd->size)
 		return -EINVAL;
 
-	memcpy_fromio(buf, b47s->window + from, len);
+	if (from + len <= BCM47XXSFLASH_WINDOW_SIZE) {
+		memcpy_fromio(buf, b47s->window + from, len);
+	} else {
+		size_t i;
+
+		for (i = 0; i < len; i++) {
+			b47s->cc_write(b47s, BCMA_CC_FLASHADDR, from++);
+			bcm47xxsflash_cmd(b47s, OPCODE_ST_READ4B);
+			*(buf++) = b47s->cc_read(b47s, BCMA_CC_FLASHDATA) & 0xff;
+		}
+	}
 	*retlen = len;
 
 	return len;
diff --git a/drivers/mtd/devices/bcm47xxsflash.h b/drivers/mtd/devices/bcm47xxsflash.h
index 1564b62..d8d1093 100644
--- a/drivers/mtd/devices/bcm47xxsflash.h
+++ b/drivers/mtd/devices/bcm47xxsflash.h
@@ -3,6 +3,8 @@
 
 #include <linux/mtd/mtd.h>
 
+#define BCM47XXSFLASH_WINDOW_SIZE		SZ_16M
+
 /* Used for ST flashes only. */
 #define OPCODE_ST_WREN		0x0006		/* Write Enable */
 #define OPCODE_ST_WRDIS		0x0004		/* Write Disable */
@@ -16,6 +18,7 @@
 #define OPCODE_ST_RES		0x03ab		/* Read Electronic Signature */
 #define OPCODE_ST_CSA		0x1000		/* Keep chip select asserted */
 #define OPCODE_ST_SSE		0x0220		/* Sub-sector Erase */
+#define OPCODE_ST_READ4B	0x6313
 
 /* Used for Atmel flashes only. */
 #define OPCODE_AT_READ				0x07e8
-- 
2.10.1

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

end of thread, other threads:[~2017-01-23  8:16 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 22:09 [PATCH] mtd: bcm47xxsflash: support reading flash out of mapping window Rafał Miłecki
2017-01-17  3:18 ` Marek Vasut
2017-01-17  6:58   ` Rafał Miłecki
2017-01-17  9:49     ` Marek Vasut
2017-01-17 10:39       ` Rafał Miłecki
2017-01-17 10:49         ` Marek Vasut
2017-01-17 10:50           ` Rafał Miłecki
2017-01-17 10:56             ` Marek Vasut
2017-01-17 10:51 ` [PATCH V2] " Rafał Miłecki
2017-01-17 11:00   ` Marek Vasut
2017-01-17 11:08     ` Rafał Miłecki
2017-01-17 11:49       ` Marek Vasut
2017-01-17 12:04         ` Rafał Miłecki
2017-01-17 12:37           ` Rafał Miłecki
2017-01-19 21:31             ` Marek Vasut
2017-01-19 21:30           ` Marek Vasut
2017-01-23  8:14             ` Rafał Miłecki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.