linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: <marcin.krzeminski@nokia.com>
To: <linux-mtd@lists.infradead.org>
Cc: <dwmw2@infradead.org>, <computersforpeace@gmail.com>,
	<hramrach@gmail.com>, <jteki@openedev.com>,
	<cyrille.pitchen@atmel.com>, <rfsw-patches@mlist.nokia.com>,
	<pawel.lenkow@itlen.com>
Subject: [RFC 2/3] mtd: spi-nor: Read Mode byte implementation
Date: Mon, 27 Jun 2016 12:20:59 +0200	[thread overview]
Message-ID: <1467022860-17552-3-git-send-email-marcin.krzeminski@nokia.com> (raw)
In-Reply-To: <1467022860-17552-1-git-send-email-marcin.krzeminski@nokia.com>

From: Marcin Krzeminski <marcin.krzeminski@nokia.com>

DUAL/QUAD I/O modes often need an additional byte at first
read command to configure flash in continuous read mode.
Continuous read mode is not supported, but we need to send this
byte to flash anyway.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 31 +++++++++++++++++++++++++++++++
 include/linux/mtd/spi-nor.h   |  9 +++++++++
 2 files changed, 40 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 847db69..026544b 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -164,6 +164,34 @@ static inline int spi_nor_read_dummy_cycles(struct spi_nor *nor)
 	return 0;
 }
 
+#ifdef CONFIG_DUAL_QUAD_IO
+/*
+ * Read mode option, allows to continue
+ * fast reading without sending the command again.
+ * Could be used by the driver or this framework
+ * to speed up reading.
+ */
+static void spi_nor_read_mode(struct spi_nor *nor,
+		const struct flash_info *info)
+{
+	nor->read_mode_size = 0;
+	nor->read_mode_cmd = 0;
+
+	if (nor->flash_read == SPI_NOR_QUADIO
+		|| nor->flash_read == SPI_NOR_DUALIO) {
+
+		switch (JEDEC_MFR(info)) {
+		case SNOR_MFR_SPANSION:
+			nor->read_mode_size = 8;
+			nor->read_mode_cmd = SPANSION_CONTINUOUS_READ_MODE;
+		break;
+		default:
+			break;
+		}
+	}
+}
+#endif
+
 /*
  * Write status register 1 byte
  * Returns negative if error occurred.
@@ -1541,6 +1569,9 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	}
 
 	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
+#ifdef CONFIG_DUAL_QUAD_IO
+	spi_nor_read_mode(nor, info);
+#endif
 
 	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
 			(long long)mtd->size >> 10);
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 652a8d2..78196a8 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -108,6 +108,11 @@
 /* Configuration Register bits. */
 #define CR_QUAD_EN_SPAN		BIT(1)	/* Spansion Quad I/O */
 
+#ifdef CONFIG_DUAL_QUAD_IO
+/* Spansion continuous read mode for Quad/Dual I/O reads */
+#define SPANSION_CONTINUOUS_READ_MODE 0xA0
+#endif
+
 enum read_mode {
 	SPI_NOR_NORMAL = 0,
 	SPI_NOR_FAST,
@@ -179,6 +184,10 @@ struct spi_nor {
 	bool			sst_write_second;
 	u32			flags;
 	u8			cmd_buf[SPI_NOR_MAX_CMD_SIZE];
+#ifdef CONFIG_DUAL_QUAD_IO
+	u32			read_mode_size; /*read mode command size in bits */
+	u32			read_mode_cmd; /*read mode command */
+#endif
 
 	int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops);
 	void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops);
-- 
2.7.4

  parent reply	other threads:[~2016-06-27 10:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 10:20 [RFC 0/3] mtd: spi-nor: DUAL/QUAD I/O read modes implementation marcin.krzeminski
2016-06-27 10:20 ` [RFC 1/3] mtd: spi-nor: DUAL I/O and QUAD I/O modes support marcin.krzeminski
2016-06-27 10:20 ` marcin.krzeminski [this message]
2016-06-27 10:21 ` [RFC 3/3] mtd: spi-nor: Support for s25fs512s marcin.krzeminski
  -- strict thread matches above, loose matches on Subject: below --
2016-06-27 10:19 [RFC 0/3] mtd: spi-nor: DUAL/QUAD I/O read modes implementation marcin.krzeminski
2016-06-27 10:19 ` [RFC 2/3] mtd: spi-nor: Read Mode byte implementation marcin.krzeminski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467022860-17552-3-git-send-email-marcin.krzeminski@nokia.com \
    --to=marcin.krzeminski@nokia.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dwmw2@infradead.org \
    --cc=hramrach@gmail.com \
    --cc=jteki@openedev.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=pawel.lenkow@itlen.com \
    --cc=rfsw-patches@mlist.nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).