public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] driver:mtd:spi-nor: Add Micron quad I/O support
@ 2014-09-25  6:20 bpqw
  2014-09-25 10:11 ` Marek Vasut
  0 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-09-25  6:20 UTC (permalink / raw)
  To: dwmw2@infradead.org, Brian Norris
  Cc: b32955@freescale.com, marex@denx.de, geert+renesas@glider.be,
	grmoore@altera.com, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org

For Micron spi norflash,you can enable Quad spi transfer
by clear EVCR(Enhanced Volatile Configuration Register)
Quad I/O protocol bit.

Signed-off-by: bean huo <beanhuo@micron.com>
---
 drivers/mtd/spi-nor/spi-nor.c |   45 +++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/spi-nor.h   |    6 ++++++
 2 files changed, 51 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b5ad6be..e72894f 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,44 @@ static int spansion_quad_enable(struct spi_nor *nor)
 	return 0;
 }
 
+static int micron_quad_enable(struct spi_nor *nor)
+{
+	int ret, val;
+
+	ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);
+	if (ret < 0) {
+		dev_err(nor->dev, "error %d reading EVCR\n", ret);
+		return -EINVAL;
+	}
+
+	write_enable(nor);
+
+	/* set EVCR ,enable quad I/O */
+	nor->cmd_buf[0] = val & ~EVCR_QUAD_EN_MICRON;
+	ret = nor->write_reg(nor, SPINOR_OP_WD_EVCR, nor->cmd_buf, 1, 0);
+	if (ret < 0) {
+		dev_err(nor->dev,
+			"error while writing EVCR register\n");
+		return -EINVAL;
+	}
+
+	if (wait_till_ready(nor))
+		return 1;
+
+	/* read EVCR and check it */
+	ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);
+	if (ret < 0) {
+		dev_err(nor->dev, "error %d reading EVCR\n", ret);
+		return -EINVAL;
+	}
+	if (val & EVCR_QUAD_EN_MICRON) {
+		dev_err(nor->dev, "Micron EVCR Quad bit not clear\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)
 {
 	int status;
@@ -890,6 +928,13 @@ static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)
 			return -EINVAL;
 		}
 		return status;
+	case CFI_MFR_ST:
+		status = micron_quad_enable(nor);
+		if (status) {
+			dev_err(nor->dev, "Micron quad-read not enabled\n");
+			return -EINVAL;
+		}
+		return status;
 	default:
 		status = spansion_quad_enable(nor);
 		if (status) {
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 9e6294f..d71b659 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -56,6 +56,10 @@
 /* Used for Spansion flashes only. */
 #define SPINOR_OP_BRWR		0x17	/* Bank register write */
 
+/* Used for Micron flashes only. */
+#define SPINOR_OP_RD_EVCR	0x65	/* Read EVCR register */
+#define SPINOR_OP_WD_EVCR	0x61	/* Write EVCR register */
+
 /* Status Register bits. */
 #define SR_WIP			1	/* Write in progress */
 #define SR_WEL			2	/* Write enable latch */
@@ -67,6 +71,8 @@
 
 #define SR_QUAD_EN_MX		0x40	/* Macronix Quad I/O */
 
+#define EVCR_QUAD_EN_MICRON	0x80	/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY		0x80
 
-- 
1.7.9.5

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

end of thread, other threads:[~2014-11-30 16:11 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25  6:20 [PATCH 1/1] driver:mtd:spi-nor: Add Micron quad I/O support bpqw
2014-09-25 10:11 ` Marek Vasut
2014-09-26  8:39   ` bpqw
2014-09-26  8:46     ` Marek Vasut
2014-09-28  1:59       ` [PATCH 1/1 v2] " bpqw
2014-09-28 22:43         ` Marek Vasut
2014-09-29  0:30           ` bpqw
2014-09-29 18:57             ` Marek Vasut
2014-09-30  2:47       ` [PATCH 1/1 v3] " Bean Huo 霍斌斌 (beanhuo)
2014-09-30 13:38         ` Marek Vasut
2014-10-01 14:24           ` Bean Huo 霍斌斌 (beanhuo)
2014-10-01 14:32             ` Marek Vasut
2014-10-01 14:28       ` bpqw
2014-10-01 14:33         ` Marek Vasut
2014-10-04  5:55           ` bpqw
2014-10-16  1:53           ` bpqw
2014-10-17  0:37       ` Bean Huo 霍斌斌 (beanhuo)
2014-10-20  1:24       ` bpqw
2014-10-23  0:58       ` Bean Huo 霍斌斌 (beanhuo)
2014-10-24  0:31       ` Bean Huo 霍斌斌 (beanhuo)
2014-10-27  0:09       ` [PATCH 1/1 v3] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor bpqw
2014-10-30 14:31         ` bpqw
2014-11-12 20:59         ` Jagan Teki
2014-11-04 13:25       ` [PATCH 1/1 v4] " bpqw
2014-11-05 11:26         ` Brian Norris
2014-11-06  2:56           ` bpqw
2014-11-06  3:09       ` [V5 PATCH 1/1] " bpqw
     [not found]         ` <54613259.4070903@opensource.altera.com>
2014-11-11 19:41           ` Graham Moore
2014-11-11 21:55             ` Jagan Teki
2014-11-12  1:19               ` bpqw
2014-11-12  0:58             ` bpqw
2014-11-13 16:26               ` Graham Moore
2014-11-14  2:06                 ` bpqw
2014-11-26  4:06         ` Brian Norris
2014-11-26 16:08           ` bpqw
2014-11-26 21:12         ` Brian Norris
2014-11-27  5:55           ` bpqw
2014-11-27  9:14             ` Brian Norris
2014-11-30 16:11               ` Bean Huo 霍斌斌 (beanhuo)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox