Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 1/1] driver:mtd:spi-nor: Add Micron quad I/O support

107 views
Skip to first unread message

bpqw

unread,
Sep 25, 2014, 2:30:02 AM9/25/14
to
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 <bea...@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Marek Vasut

unread,
Sep 25, 2014, 7:00:01 AM9/25/14
to
Why does this not return proper error code or even better, return value from
wait_till_ready() ?

Other than that, there's nothing wrong with the patch I think.

Best regards,
Marek Vasut

Marek Vasut

unread,
Sep 26, 2014, 4:50:01 AM9/26/14
to
On Friday, September 26, 2014 at 10:39:38 AM, bpqw wrote:
> >> + /* 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;
> >
> >Why does this not return proper error code or even better, return value
> >from wait_till_ready() ?
> >
> >Other than that, there's nothing wrong with the patch I think.
>
> Hi,Marek
> Thanks for your review,you can find the same usage in the spi-nor.c.
> Below method is OK? Or you can give me some suggestion.
>
> if (wait_till_ready(nor))
> return - EINVAL;

ret = wait_till_readynor()
if (ret)
return ret;

But all right, this means the subsystem isn't perfect. Well, others, what do you
think ?

bpqw

unread,
Sep 26, 2014, 4:50:01 AM9/26/14
to
>> + /* 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;

>Why does this not return proper error code or even better, return value from
>wait_till_ready() ?
>
>Other than that, there's nothing wrong with the patch I think.

Hi,Marek
Thanks for your review,you can find the same usage in the spi-nor.c.
Below method is OK? Or you can give me some suggestion.

if (wait_till_ready(nor))
return - EINVAL;

bpqw

unread,
Sep 27, 2014, 10:10:01 PM9/27/14
to
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 <bea...@micron.com>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b5ad6be..0c3b4fd 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 +929,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;
+ }

Marek Vasut

unread,
Sep 28, 2014, 6:50:01 PM9/28/14
to
On Sunday, September 28, 2014 at 03:59:42 AM, bpqw wrote:
> For Micron spi norflash,you can enable
> Quad spi transfer by clear EVCR(Enhanced
> Volatile Configuration Register) Quad I/O
> protocol bit.

OK, this information is nice and all, but what does this patch do? I can't learn
this information from the commit message as it is, can I ? And , the purpose of
the commit message is exactly to summarize the change the patch implements.
Why not just "return ret;" ?
[...]

bpqw

unread,
Sep 28, 2014, 8:40:01 PM9/28/14
to
>> For Micron spi norflash,you can enable Quad spi transfer by clear
>> EVCR(Enhanced Volatile Configuration Register) Quad I/O protocol bit.
>
>OK, this information is nice and all, but what does this patch do? I can't learn this information from the commit message as it is, can I ?
>And , the purpose of the commit message is exactly to summarize the change the patch implements.


you don't understand what purpose of this patch! just as subject and commit message described,
it is for enable Micron Quad spi transfer mode.do you read the spi-nor.c file? please pay attention
to the set_quad_mode() function.by the way,I can add more commit message for it,but I think
it is redundant,don't need.

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

>Why not just "return ret;" ?
>[...]

Ok,this is good,I will modify it in the next patch version.thanks.

Bean Huo 霍斌斌 (beanhuo)

unread,
Sep 29, 2014, 10:50:02 PM9/29/14
to
For Micron spi norflash,enables or disables quad I/O
protocol ,which controled by EVCR(Enhanced
Volatile Configuration Register) Quad I/O
protocol bit 7.When EVCR bit 7 is reset to 0,
the spi norflash will operate in quad I/O following
the next WRITE ENHANCED VOLATILE CONFIGURATION
command.

Signed-off-by: bean huo <bea...@micron.com>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

Marek Vasut

unread,
Sep 29, 2014, 11:10:01 PM9/29/14
to
On Monday, September 29, 2014 at 02:30:04 AM, bpqw wrote:
> >> For Micron spi norflash,you can enable Quad spi transfer by clear
> >> EVCR(Enhanced Volatile Configuration Register) Quad I/O protocol bit.
> >
> >OK, this information is nice and all, but what does this patch do? I can't
> >learn this information from the commit message as it is, can I ? And ,
> >the purpose of the commit message is exactly to summarize the change the
> >patch implements.
>
> you don't understand what purpose of this patch!

Well, I dare to say, reacting to feedback like you just did won't make you many
allies around here.

> just as subject and commit
> message described, it is for enable Micron Quad spi transfer mode.

I understand the subject part. The commit message, on the other hand, just
states that it is possible to frob with a certain register to achieve a certain
effect ; the commit message does not state what this patch does or how is the
patch useful.

Does this patch enable the bit or does it disable the bit ? I cannot tell
without looking into the code , I really have no clue just by reading the
subject and the commit message.

> do you
> read the spi-nor.c file?

No, I didn't even look at the code.

> please pay attention to the set_quad_mode()
> function.

No, what set_quad_mode_function() are you talking about ...

> by the way,I can add more commit message for it,but I think it is
> redundant,don't need.

The commit message shall state what the patch does in the first place, what the
hardware can do is ortogonal to that. The commit message can be as short as:

The hardware supports 4-bit I/O when bit FOO is set in register BAR. This patch
adds function that sets bit FOO in register BAR to enable 4-bit I/O if condition
BAZ and QUUX are met.

Then I do not even have to look at the code if I want to just get the high-level
overview of what the patch does. If I want to know the details, I will look into
the code.

Do you know what I'm getting at ?

[...]

Best regards,
Marek Vasut

Marek Vasut

unread,
Sep 30, 2014, 9:40:02 AM9/30/14
to
On Tuesday, September 30, 2014 at 04:47:39 AM, Bean Huo 霍斌斌 (beanhuo) wrote:
> For Micron spi norflash,enables or disables quad I/O
> protocol ,which controled by EVCR(Enhanced
> Volatile Configuration Register) Quad I/O
> protocol bit 7.When EVCR bit 7 is reset to 0,
> the spi norflash will operate in quad I/O following
> the next WRITE ENHANCED VOLATILE CONFIGURATION
> command.

You only do one WRITE ENHANCED VOLATILE CONFIGURATION command in the patch, so
this text doesn't add up.

Try something like this:
-->8--
This patch adds code which enables Quad I/O mode on Micron SPI NOR
flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol
is controled by EVCR (Enhanced Volatile Configuration Register),
Quad I/O protocol bit 7. When EVCR bit 7 is reset to 0, the SPI
NOR flash will operate in quad I/O mode.
--8<--

What do you think ?

Brian, am I bitching too much about pointless things ? Please stop me if you
think I do.

[...]

Best regards,
Marek Vasut

Bean Huo 霍斌斌 (beanhuo)

unread,
Oct 1, 2014, 10:30:02 AM10/1/14
to
>> For Micron spi norflash,enables or disables quad I/O protocol ,which
>> controled by EVCR(Enhanced Volatile Configuration Register) Quad I/O
>> protocol bit 7.When EVCR bit 7 is reset to 0, the spi norflash will
>> operate in quad I/O following the next WRITE ENHANCED VOLATILE
>> CONFIGURATION command.

>You only do one WRITE ENHANCED VOLATILE CONFIGURATION command in the patch, so this text doesn't add up.

>Try something like this:
>-->8--
>This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

>For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controled by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7. When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.
>--8<--

>What do you think ?
Perfect,I will modify my commit message and sumbit it again.thanks.

bpqw

unread,
Oct 1, 2014, 10:30:02 AM10/1/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

Marek Vasut

unread,
Oct 1, 2014, 10:40:01 AM10/1/14
to
Thank you. I didn't mean to grind you unnecessarily or be outright bitch, sorry
if it did sound like so.

Marek Vasut

unread,
Oct 1, 2014, 10:40:02 AM10/1/14
to
On Wednesday, October 01, 2014 at 04:28:17 PM, bpqw wrote:
> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>
> For Micron SPI NOR flash, enabling or disabling quad I/O protocol is
> controlled by EVCR (Enhanced Volatile Configuration Register), Quad I/O
> protocol bit 7. When EVCR bit 7 is reset to 0, the SPI NOR flash will
> operate in quad I/O mode.
>
> Signed-off-by: bean huo <bea...@micron.com>

I don't see anything obviously wrong.

Acked-by: Marek Vasut <ma...@denx.de>

Best regards,
Marek Vasut

bpqw

unread,
Oct 4, 2014, 2:00:02 AM10/4/14
to
>> Signed-off-by: bean huo <bea...@micron.com>

>I don't see anything obviously wrong.

>Acked-by: Marek Vasut <ma...@denx.de>

Hi,Brian

How do you think about this patch?

bpqw

unread,
Oct 15, 2014, 10:00:02 PM10/15/14
to
>Acked-by: Marek Vasut <ma...@denx.de>
Hi,brian
How about this patch? And can be accepted by linux-mtd?

Bean Huo 霍斌斌 (beanhuo)

unread,
Oct 16, 2014, 8:40:01 PM10/16/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

bpqw

unread,
Oct 19, 2014, 9:30:01 PM10/19/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

Bean Huo 霍斌斌 (beanhuo)

unread,
Oct 22, 2014, 9:00:06 PM10/22/14
to
>This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

>For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controlled by
>EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
>When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.

>Signed-off-by: bean huo <bea...@micron.com>
>Acked-by: Marek Vasut <ma...@denx.de>

Hi,Brian
Is this patch OK?

Bean Huo 霍斌斌 (beanhuo)

unread,
Oct 23, 2014, 8:40:07 PM10/23/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

bpqw

unread,
Oct 26, 2014, 8:20:05 PM10/26/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0, the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

bpqw

unread,
Oct 30, 2014, 10:40:06 AM10/30/14
to
>This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

>For Micron SPI NOR flash, enabling or disabling quad I/O
>protocol is controlled by EVCR (Enhanced Volatile Configuration
>Register), Quad I/O protocol bit 7.When EVCR bit 7 is reset to 0,
>the SPI NOR flash will operate in quad I/O mode.

>Signed-off-by: bean huo <bea...@micron.com>
>Acked-by: Marek Vasut <ma...@denx.de>

Hi,Brian
How about this patch?if can be accepted?
It has been long time.

bpqw

unread,
Nov 4, 2014, 8:30:07 AM11/4/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash,enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.
V3-v4:
Modify commit logs that wraped into 80 columns

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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 +929,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;
+ }

Brian Norris

unread,
Nov 5, 2014, 6:30:06 AM11/5/14
to
On Tue, Nov 04, 2014 at 01:25:14PM +0000, bpqw wrote:
> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>
> For Micron SPI NOR flash,enabling or disabling quad I/O protocol is controlled
> by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
> When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O mode.
>
> Signed-off-by: bean huo <bea...@micron.com>
> Acked-by: Marek Vasut <ma...@denx.de>
> ---
> v1-v2:modified to that capture wait_till_ready()
> return value,if error,directly return its
> the value.
> v2-v3:directly use the reurning error value of
> read_reg and write_reg,instead of -EINVAL.
> V3-v4:
> Modify commit logs that wraped into 80 columns

Please be aware that resending your patch every few days does not really
help your cause.

Also, your patch is still corrupt and cannot be applied as-is. Please
double-check your mailer settings and resend once you have something I
can apply.

Brian

bpqw

unread,
Nov 5, 2014, 10:00:06 PM11/5/14
to
>> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

>Also, your patch is still corrupt and cannot be applied as-is.
>Please double-check your mailer settings and resend once you have something I can apply.

>Brian

Hi,Brian

Thanks your patience.this maybe linux kernel has been updated again.
My patch based linux kernel is old. I will rebuild a new patch based
on latest linux-mtd,and submit it today.
This patch has been waiting for your reply too long time.I really hope
that this patch to be accepted as soon as possible, otherwise I will
rebuild it again,and one by one.

bpqw

unread,
Nov 5, 2014, 10:20:06 PM11/5/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash,enabling or disabling quad I/O protocol is controlled
by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O mode.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:
Modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:
Directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.
v3-v4:
Modify commit logs that wraped into 80 columns
v4-v5:
Rebuild new patch based on latest linux-mtd

drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 ++++++
2 files changed, 52 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index c51ee52..2a31742 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -874,6 +874,45 @@ 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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;
@@ -886,6 +925,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 046a0a2..42e7e37 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

Graham Moore

unread,
Nov 11, 2014, 3:00:08 PM11/11/14
to
On 11/05/2014 09:09 PM, bpqw wrote:
> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>
> For Micron SPI NOR flash,enabling or disabling quad I/O protocol is
> controlled
> by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
> When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O
> mode.

Hi, I'm having trouble with this patch using a Cadence QSPI controller and
Micron n25q00 part.

I can use quad commands in Extended SPI mode, but I can't make this EVCR Quad
mode work.

The Cadence QSPI Controller has fields to configure the quad transfer, and can
support quad opcode, quad address, and quad data, or some combination. There
is a chart in the docs which shows the combinations for various read commands.

Problem is, I've tried all of the combinations and all I get is FF with this
EVCR patch.

If I don't set the quad mode in the EVCR, then I can use quad read commands no
problem.

Bottom line, with the Cadence QSPI controller, if I use quad commands in
Extended SPI mode, then all good. If I use this EVCR quad mode, then all bad.

Anybody else have a Cadence QSPI controller and using EVCR quad mode
successfully?

Thanks,
Graham Moore

Jagan Teki

unread,
Nov 11, 2014, 5:00:06 PM11/11/14
to
On 12 November 2014 01:11, Graham Moore <grm...@opensource.altera.com> wrote:
> On 11/05/2014 09:09 PM, bpqw wrote:
>> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>>
>> For Micron SPI NOR flash,enabling or disabling quad I/O protocol is
>> controlled
>> by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
>> When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O
>> mode.
>
> Hi, I'm having trouble with this patch using a Cadence QSPI controller and
> Micron n25q00 part.
>
> I can use quad commands in Extended SPI mode, but I can't make this EVCR Quad
> mode work.
>
> The Cadence QSPI Controller has fields to configure the quad transfer, and can
> support quad opcode, quad address, and quad data, or some combination. There
> is a chart in the docs which shows the combinations for various read commands.
>
> Problem is, I've tried all of the combinations and all I get is FF with this
> EVCR patch.
>
> If I don't set the quad mode in the EVCR, then I can use quad read commands no
> problem.
>
> Bottom line, with the Cadence QSPI controller, if I use quad commands in
> Extended SPI mode, then all good. If I use this EVCR quad mode, then all bad.
>
> Anybody else have a Cadence QSPI controller and using EVCR quad mode
> successfully?

I have almost verified all the micros parts for operating quad mode
and the quad enable bit is
volatile by default and no need to set it on software.

Why this code is meant for - does micron has changed this bit
operation on newly added parts?

thanks!
--
Jagan.

bpqw

unread,
Nov 11, 2014, 8:00:06 PM11/11/14
to
>Hi, I'm having trouble with this patch using a Cadence QSPI controller and Micron n25q00 part.

>I can use quad commands in Extended SPI mode, but I can't make this EVCR Quad mode work.


Yes,but if you use quad commands in Extended spi mode,only for Quad commands,the command line is DQ0,
Address/data line is DQ0,DQ1,DQ2 and DQ3(1-x-4).
But if in Quad I/O mode,for all the commands,the command/address/data line will be 4,they are DQ0,DQ1,DQ2 and DQ3(4-x-4).

>The Cadence QSPI Controller has fields to configure the quad transfer, and can support quad opcode,
>quad address, and quad data, or some combination. There is a chart in the docs which shows the combinations for various read commands.

>Problem is, I've tried all of the combinations and all I get is FF with this EVCR patch.

This maybe your spi controller is still extended mode,
Once EVCR bit 7 is set to 0, the spi nor device will operate in quad I/O.Command-address-data line is 4-x-4.
So after send WRITE EVCR command , spi controller also must transfer to quad I/O Mode,and set its Command-address-data line also
Should be 4-x-4 .

>If I don't set the quad mode in the EVCR, then I can use quad read commands no problem.
Yes,you don't set the quad mode in the EVCR,you can use quad read commands,but this patch is for enable Micron SPI nor Quad I/O mode,
If you want to enable it ,you must set EVCR.

>Bottom line, with the Cadence QSPI controller, if I use quad commands in Extended SPI mode, then all good. If I use this EVCR quad mode, then all bad.

>Anybody else have a Cadence QSPI controller and using EVCR quad mode successfully?

>Thanks,
>Graham Moore

Hi,Brian

Whether this patch can be merged?thanks.

bpqw

unread,
Nov 11, 2014, 11:30:07 PM11/11/14
to
>I have almost verified all the micros parts for operating quad mode and the quad enable bit is
>volatile by default and no need to set it on software.

>Why this code is meant for - does micron has changed this bit operation on newly added parts?

>thanks!
>--
>Jagan.

For Micron Spi norflash,if you want to make it work Quad I/O mode,you can do it by set
Two registers,Nonvolatile Configuration resister(NVCR) and Enhanced volatile confuration register(EVCR),
but according to spi-nor.c,and micron spi nor,we recommend that if want to enable Micron spi nor Quad I/O
mode,the best way is to set EVCR.
Of course,you can use Quad/Dual operation command to read/write Micron spi nor in the spi nor Extended I/O mode.
But their command-address-data is different.

The purpose of this patch is only to enable Micron spi nor Quad I/O mode,if want to make Micron spi nor work
Under Quad I/O mode.

Hi,Brian

How about this patch?Please give me some tips,thanks.

Jagan Teki

unread,
Nov 12, 2014, 4:00:07 PM11/12/14
to
Best to define read_evsr()

> +
> + 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 ret;
> + }
> +
> + ret = wait_till_ready(nor);
> + if (ret)
> + return ret;

I don't think this will ready w/o wait time or something - may be use
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 ret;
> + }
> + if (val & EVCR_QUAD_EN_MICRON) {
> + dev_err(nor->dev, "Micron EVCR Quad bit not clear\n");
> + return -EINVAL;
> + }

IMHO, use read_evcr() as defined above and write the finite statement code like
ret = read_evcr(nor);
if (!(ret > 0 && (ret & EVCR_QUAD_EN_MICRON))) {
dev_err(nor->dev, "Micron EVCR Quad bit not clear\n");
thanks!
--
Jagan.

Graham Moore

unread,
Nov 13, 2014, 11:30:07 AM11/13/14
to


On Wed, 12 Nov 2014, bpqw wrote:

> This maybe your spi controller is still extended mode,
> Once EVCR bit 7 is set to 0, the spi nor device will operate in quad I/O.Command-address-data line is 4-x-4.
> So after send WRITE EVCR command , spi controller also must transfer to quad I/O Mode,and set its Command-address-data line also
> Should be 4-x-4 .

Thanks, this helped. I added some code to snoop the command stream for
WRITE EVCR with quad mode, and then set up the quad mode in the
controller. Seems kinda ugly, but working now.

-Graham

bpqw

unread,
Nov 13, 2014, 9:10:07 PM11/13/14
to
>> This maybe your spi controller is still extended mode, Once EVCR bit 7
>> is set to 0, the spi nor device will operate in quad I/O.Command-address-data line is 4-x-4.
>> So after send WRITE EVCR command , spi controller also must transfer
>> to quad I/O Mode,and set its Command-address-data line also Should be 4-x-4 .

>Thanks, this helped. I added some code to snoop the command stream for WRITE EVCR with quad mode,
>and then set up the quad mode in the controller. Seems kinda ugly, but working now.

>-Graham

Yes ,if enable spi nor Quad I/O, firstly, must check spi controller if support Quad I/O protocol,
and after enable spi nor Quad I/O mode ,spi controller also must be transferred to Quad I/O protocol.
Their two side must be matched together.
Maybe spi controller can do this changes.

Hi,Brian

Can you give me some tips about this patch? Thanks!

-Bean Huo

Brian Norris

unread,
Nov 25, 2014, 11:10:06 PM11/25/14
to
On Thu, Nov 06, 2014 at 03:09:06AM +0000, bpqw wrote:
> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>
> For Micron SPI NOR flash,enabling or disabling quad I/O protocol is controlled
> by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
> When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O mode.
>
> Signed-off-by: bean huo <bea...@micron.com>
> Acked-by: Marek Vasut <ma...@denx.de>
> ---
> v1-v2:
> Modified to that capture wait_till_ready()
> return value,if error,directly return its
> the value.
> v2-v3:
> Directly use the reurning error value of
> read_reg and write_reg,instead of -EINVAL.
> v3-v4:
> Modify commit logs that wraped into 80 columns
> v4-v5:
> Rebuild new patch based on latest linux-mtd

You probably aren't based on l2-mtd.git. Your patch still doesn't build.
I can fix it up if it's easy, but FYI. Still reviewing...

drivers/mtd/spi-nor/spi-nor.c: In function ‘micron_quad_enable’:
drivers/mtd/spi-nor/spi-nor.c:874:2: warning: passing argument 3 of ‘nor->read_reg’ from incompatible pointer type [enabled by default]
ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);
^
drivers/mtd/spi-nor/spi-nor.c:874:2: note: expected ‘u8 *’ but argument is of type ‘int *’
drivers/mtd/spi-nor/spi-nor.c:891:2: error: implicit declaration of function ‘wait_till_ready’ [-Werror=implicit-function-declaration]
ret = wait_till_ready(nor);
^
drivers/mtd/spi-nor/spi-nor.c:896:2: warning: passing argument 3 of ‘nor->read_reg’ from incompatible pointer type [enabled by default]
ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);
^
drivers/mtd/spi-nor/spi-nor.c:896:2: note: expected ‘u8 *’ but argument is of type ‘int *’

Brian

bpqw

unread,
Nov 26, 2014, 11:10:06 AM11/26/14
to
>You probably aren't based on l2-mtd.git. Your patch still doesn't build.
>I can fix it up if it's easy, but FYI. Still reviewing...

>Brian

Hi, Brian

Thanks for your hard work. Finally received your response, I am very happy.
How about this patch? Whether or not rebuild it based on lastest l2-mtd?
Look forward to your letter.thanks.

Brian Norris

unread,
Nov 26, 2014, 4:20:05 PM11/26/14
to
First of all, can you fix your mail so that you have a proper 'From'?
That should be your real name (not bpqw), so that it gives a proper
patch author. If you can't get your mail header to have the right
'From:' line, then it also works to begin your mail with:

From: Your Name <yo...@email.com>

On Thu, Nov 06, 2014 at 03:09:06AM +0000, bpqw wrote:
> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>
> For Micron SPI NOR flash,enabling or disabling quad I/O protocol is controlled
> by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
> When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O mode.

What's the difference between using EVCR and the ENTER QUAD I/O MODE
(35h) command I see in some of your datasheets? Are both supported on
all Micron quad I/O SPI NOR flash?

Also, which SPI NOR is this enabled for? I don't see any Micron entries
in spi_nor_ids[] which contain the SPI_NOR_QUAD_READ flag.

> Signed-off-by: bean huo <bea...@micron.com>
> Acked-by: Marek Vasut <ma...@denx.de>
> ---
> v1-v2:
> Modified to that capture wait_till_ready()
> return value,if error,directly return its
> the value.
> v2-v3:
> Directly use the reurning error value of
> read_reg and write_reg,instead of -EINVAL.
> v3-v4:
> Modify commit logs that wraped into 80 columns
> v4-v5:
> Rebuild new patch based on latest linux-mtd

Please rebase on l2-mtd.git. Sorry if that wasn't clear earlier.
Join the above two lines?

> + return ret;
> + }
> +
> + ret = wait_till_ready(nor);

It's spi_nor_wait_till_ready(), now.
Like with other register bitfields (SR, FSR), please place a comment
above to describe the register, like:

/* Enhanced Volatile Configuration Register bits */

> +
> /* Flag Status Register bits */
> #define FSR_READY 0x80
>

Brian

bpqw

unread,
Nov 27, 2014, 1:00:07 AM11/27/14
to
>First of all, can you fix your mail so that you have a proper 'From'?
>That should be your real name (not bpqw), so that it gives a proper patch author.
>If you can't get your mail header to have the right 'From:' line, then it also works to begin your mail with:

Sorry for this confusion. This bpqw email is our software public mailbox dedicated to submit linux patch.
Because our personal email title include Chinese name, this will result to messy code in from item.
I have ever submit one patch many times by my personal mail, but I always didn't accept maintainer's response.
So I think, maybe my patch with Chinese name has been moved into maintainer's junk folder.

I don't know my mail from-field with Chinese name can or not be accepted, if can,
I will submit next version patch by my personal mail.

>> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>>
>> For Micron SPI NOR flash,enabling or disabling quad I/O protocol is
>> controlled by EVCR (Enhanced Volatile Configuration Register), Quad I/O protocol bit 7.
>> When EVCR bit 7 is reset to 0,the SPI NOR flash will operate in quad I/O mode.

>What's the difference between using EVCR and the ENTER QUAD I/O MODE
>(35h) command I see in some of your datasheets? Are both supported on all Micron quad I/O SPI NOR flash?

There is no difference between using EVCR and the ENTER QUAD I/O MODE command.
But, for some Micron spi nor, there no ENTER Quad I/O command(35h),such as n25q064.
for all current Micron spi nor, if it support quad I/O mode, Using EVCR definitely be supported.
So, we recommend that enable QUAD I/O mode by writing ECVR.


>Also, which SPI NOR is this enabled for? I don't see any Micron entries in spi_nor_ids[] which contain the SPI_NOR_QUAD_READ flag.

Yes, we now don't see any Micron entries in spi_nor_ids[] which contain the SPI_NOR_QUAD_READ flag.
But Micron spi nor in spi_nor_ids[] all support Quad I/O mode. maybe customer want to use default mode(extended I/O mode),
When submitted relevant patch, they didn't SPI_NOR_QUAD_READ flag in the spi_nor_ids[].
This patch is just for wanting to enable Micron Quad I/O mode.


>> Signed-off-by: bean huo <bea...@micron.com>
>> Acked-by: Marek Vasut <ma...@denx.de>
>> ---
>> v1-v2:
>> Modified to that capture wait_till_ready()
>> return value,if error,directly return its
>> the value.
>> v2-v3:
>> Directly use the reurning error value of
>> read_reg and write_reg,instead of -EINVAL.
>> v3-v4:
>> Modify commit logs that wraped into 80 columns
>> v4-v5:
>> Rebuild new patch based on latest linux-mtd

>Please rebase on l2-mtd.git. Sorry if that wasn't clear earlier.

OK,I will rebase it and sumbit a new version. Thanks for your suggestion.

>> + dev_err(nor->dev,
>> + "error while writing EVCR register\n");

>Join the above two lines?

Will be fixed it in the next version.

>> + return ret;
>> + }
>> +
>> + ret = wait_till_ready(nor);

>It's spi_nor_wait_till_ready(), now.

OK, will be fixed it.

>>
>> #define SR_QUAD_EN_MX 0x40 /* Macronix Quad I/O */
>>
>> +#define EVCR_QUAD_EN_MICRON 0x80 /* Micron Quad I/O */

>Like with other register bitfields (SR, FSR), please place a comment above to describe the register, like:


OK, will be fixed it.

>Brian

All in all ,thanks for your response and valuable suggestions.
I will rebuild a new version, and submit it .

---Bean Huo---

Brian Norris

unread,
Nov 27, 2014, 4:20:07 AM11/27/14
to
On Thu, Nov 27, 2014 at 05:55:43AM +0000, bpqw wrote:

> >What's the difference between using EVCR and the ENTER QUAD I/O MODE
> >(35h) command I see in some of your datasheets? Are both supported on all Micron quad I/O SPI NOR flash?
>
> There is no difference between using EVCR and the ENTER QUAD I/O MODE command.
> But, for some Micron spi nor, there no ENTER Quad I/O command(35h),such as n25q064.
> for all current Micron spi nor, if it support quad I/O mode, Using EVCR definitely be supported.
> So, we recommend that enable QUAD I/O mode by writing ECVR.

Good to know. Thanks for the info. Maybe you can note this somewhere in
your next version, like a comment in the commit description.

> >Also, which SPI NOR is this enabled for? I don't see any Micron entries in spi_nor_ids[] which contain the SPI_NOR_QUAD_READ flag.
>
> Yes, we now don't see any Micron entries in spi_nor_ids[] which
> contain the SPI_NOR_QUAD_READ flag. But Micron spi nor in
> spi_nor_ids[] all support Quad I/O mode.

Then add them! At least, for flash that support them (for all packages
that might share the same ID).

> maybe customer want to use default mode(extended I/O mode),
> When submitted relevant patch, they didn't SPI_NOR_QUAD_READ flag in the spi_nor_ids[].

The flag may have been omitted because it didn't exist at the time. Or
it didn't get tested.

Regardless, just because you enable this flag in spi_nor_ids[] doesn't
mean that it will enable Quad I/O for users that can't support it; board
files / DT descriptions still have to opt in by advertising hardware
support for Quad I/O.

See, for example, spi-tx-bus-width and spi-rx-bus-width properties in
Documentation/devicetree/bindings/spi/spi-bus.txt.

> This patch is just for wanting to enable Micron Quad I/O mode.

That's fine. But I'd welcome any follow-up patch to add the QUAD flag to
the right Micron table entries. Otherwise, this patch doesn't actually
help anyone.

BTW, given that you aren't changing any entries to spi_nor_ids[] yet,
have you actually tested this patch? Or are you only working off the
specifications / datasheets?

Thanks,
Brian

Bean Huo 霍斌斌 (beanhuo)

unread,
Nov 30, 2014, 11:20:06 AM11/30/14
to
>>>Also, which SPI NOR is this enabled for? I don't see any Micron entries in spi_nor_ids[] which contain the SPI_NOR_QUAD_READ flag.
>>
>> Yes, we now don't see any Micron entries in spi_nor_ids[] which
>> contain the SPI_NOR_QUAD_READ flag. But Micron spi nor in
>> spi_nor_ids[] all support Quad I/O mode.

>Then add them! At least, for flash that support them (for all packages that might share the same ID).

Ok,I will add them for our Micron spi nor.

>> This patch is just for wanting to enable Micron Quad I/O mode.

>That's fine. But I'd welcome any follow-up patch to add the QUAD flag to the right Micron table entries. Otherwise, this patch doesn't actually help anyone.

>BTW, given that you aren't changing any entries to spi_nor_ids[] yet, have you actually tested this patch? Or are you only working off the specifications / datasheets?

Yes, I have tested my patch based on latest linux kernel ,the spi nor are just our Micron spi nor,
such as 45nm MT25QL256Mb and Mt25TL245Mb.Before submitting a patch, our team will review and test it.
only past testing and confirm OK,this patch can be submitted.

>Thanks,
>Brian

Hi, Brian

Thanks again for your warming response. I rebase a new version patch based on latest l2-mtd.
Besides, we will submit patch by our personal email.

Bean Huo 霍斌斌 (beanhuo)

unread,
Dec 5, 2014, 2:20:06 AM12/5/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash,enabling or disabling quad I/O protocol can be done
By two methods, which are to use EVCR(Enhanced Volatile Configuration Register)
and the ENTER QUAD I/O MODE command.There is no difference between these two
methods.Unfortunately,for some Micron spi nor flashes,there no ENTER Quad I/O
command(35h),such as n25q064.But for all current Micron spi nor,if it support
quad I/O mode,using EVCR definitely be supported.It is a recommended method to
enable Quad I/O mode by EVCR,Quad I/O protocol bit 7.When EVCR bit 7 is reset
to 0,the SPI NOR flash will operate in quad I/O mode.

This patch has been tested on N25Q512A and MT25TL256BAA1ESF.Micron spi nor of
spi_nor_ids[] table all support this method.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:
Modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:
Directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.
v3-v4:
Modify commit logs that wraped into 80 columns.
v4-v5:
Rebuild new patch based on latest linux-mtd.
v5-v6:
Rebuild patch based on latest l2-mtd.
add some comments.
Add SPI_NOR_QUAD_READ flag in the spi_nor_ids[] for Micron spi nor.

drivers/mtd/spi-nor/spi-nor.c | 61 +++++++++++++++++++++++++++++++++++------
include/linux/mtd/spi-nor.h | 7 +++++
2 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 0f8ec3c..128941e 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -560,14 +560,14 @@ static const struct spi_device_id spi_nor_ids[] = {
{ "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },

/* Micron */
- { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, 0) },
- { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) },
- { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) },
- { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
- { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) },
- { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
- { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) },
- { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR) },
+ { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) },
+ { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, SPI_NOR_QUAD_READ) },
+ { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) },
+ { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) },
+ { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
+ { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+ { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+ { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },

/* PMC */
{ "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) },
@@ -891,6 +891,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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = spi_nor_wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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, struct flash_info *info)
{
int status;
@@ -903,6 +941,13 @@ static int set_quad_mode(struct spi_nor *nor, struct flash_info *info)
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 63aeccf..4720b86 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,9 @@

#define SR_QUAD_EN_MX 0x40 /* Macronix Quad I/O */

+/* Enhanced Volatile Configuration Register bits */
+#define EVCR_QUAD_EN_MICRON 0x80 /* Micron Quad I/O */
+
/* Flag Status Register bits */
#define FSR_READY 0x80

--
1.7.9.5

Bean Huo 霍斌斌 (beanhuo)

unread,
Dec 8, 2014, 4:00:06 AM12/8/14
to
Hi,Brian

This patch is based on the latest l2-mtd,I don't know if can pass?
I have one question is that about following code.
I have added our Mciron quad flag into spi_nor_ids[] table,but line over 80 characters,
If I divided one line into two lines,this will make spi_nor_ids[] table look ugly.I also find that
There are other venders configure line that also over 80 characters,such as Spansion,Catalyst.
So I don't divide my following configure line into two two lines,I don't know if this can
Be accepted?

+ { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
+ { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+ { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+ { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },



Rafał Miłecki

unread,
Dec 8, 2014, 4:10:06 AM12/8/14
to
On 8 December 2014 at 09:50, Bean Huo 霍斌斌 (beanhuo) <bea...@micron.com> wrote:
> This patch is based on the latest l2-mtd,I don't know if can pass?
> I have one question is that about following code.
> I have added our Mciron quad flag into spi_nor_ids[] table,but line over 80 characters,
> If I divided one line into two lines,this will make spi_nor_ids[] table look ugly.I also find that
> There are other venders configure line that also over 80 characters,such as Spansion,Catalyst.
> So I don't divide my following configure line into two two lines,I don't know if this can
> Be accepted?
>
> + { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
> + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
> + { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
> + { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },

Even the CodingStyle says exceeding 80 columns can be accepted:

> Statements longer than 80 columns will be broken into sensible chunks, unless
> exceeding 80 columns significantly increases readability and does not hide
> information.

Various hardware tables often happen to use more chars/line.

Bean Huo 霍斌斌 (beanhuo)

unread,
Dec 15, 2014, 9:30:07 AM12/15/14
to
>> + { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
>> + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
>> + { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
>> + { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },

>Even the CodingStyle says exceeding 80 columns can be accepted:

>> Statements longer than 80 columns will be broken into sensible chunks,
>> unless exceeding 80 columns significantly increases readability and
>> does not hide information.

> Various hardware tables often happen to use more chars/line.

Thanks for response.

Dear MTD maintainer:

How about this patch? And it has updated to sixth version.
Is there other spaces to be updated?

Brian Norris

unread,
Dec 16, 2014, 10:40:06 PM12/16/14
to
Are you sure *all* of these support quad mode? I know some manufacturers
have been known to reuse IDs, and I wouldn't want a false positive to
slip in here, where an old part might not support it but the new one
does...

>
> /* PMC */
> { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) },
> @@ -891,6 +891,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);

sparse (rightfully) complains about this line:

drivers/mtd/spi-nor/spi-nor.c: In function ‘micron_quad_enable’:
drivers/mtd/spi-nor/spi-nor.c:898:2: warning: passing argument 3 of ‘nor->read_reg’ from incompatible pointer type [enabled by default]
ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);
^
drivers/mtd/spi-nor/spi-nor.c:898:2: note: expected ‘u8 *’ but argument is of type ‘int *’
drivers/mtd/spi-nor/spi-nor.c:898:54: warning: incorrect type in argument 3 (different type sizes) [sparse]
drivers/mtd/spi-nor/spi-nor.c:898:54: expected unsigned char [usertype] *buf [sparse]
drivers/mtd/spi-nor/spi-nor.c:898:54: got int *<noident> [sparse]

So 'val' should be of type u8. Otherwise, you risk utilizing
uninitialized data for the other 32-8 bits.

> + if (ret < 0) {
> + dev_err(nor->dev, "error %d reading EVCR\n", ret);
> + return ret;
> + }
> +
> + write_enable(nor);
> +
> + /* set EVCR ,enable quad I/O */

You have the space on the wrong side of the comma.

> + 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 ret;
> + }
> +
> + ret = spi_nor_wait_till_ready(nor);
> + if (ret)
> + return ret;
> +
> + /* read EVCR and check it */
> + ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);

Same here:

drivers/mtd/spi-nor/spi-nor.c:919:2: warning: passing argument 3 of ‘nor->read_reg’ from incompatible pointer type [enabled by default]
ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1);
^
drivers/mtd/spi-nor/spi-nor.c:919:2: note: expected ‘u8 *’ but argument is of type ‘int *’
drivers/mtd/spi-nor/spi-nor.c:919:54: warning: incorrect type in argument 3 (different type sizes) [sparse]
drivers/mtd/spi-nor/spi-nor.c:919:54: expected unsigned char [usertype] *buf [sparse]
drivers/mtd/spi-nor/spi-nor.c:919:54: got int *<noident> [sparse]
With int vs. u8 fixed up, this looks good. Hopefully I can take v7!

Thanks,
Brian

Bean Huo 霍斌斌 (beanhuo)

unread,
Dec 16, 2014, 11:50:05 PM12/16/14
to
>> + { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) },
>> + { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, SPI_NOR_QUAD_READ) },
>> + { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) },
>> + { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) },
>> + { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
>> + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
>> + { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
>> + { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },

>Are you sure *all* of these support quad mode? I know some manufacturers
>have been known to reuse IDs, and I wouldn't want a false positive to slip
>in here, where an old part might not support it but the new one does...

Yes,I am sure that all Micron spi nor in above table support quad mode,they are
all N25Q serial spi nor.As for our Micron spi nor without quad mode,
I don't add them in the above table,and they have different ID with above device.


>With int vs. u8 fixed up, this looks good. Hopefully I can take v7!

Thanks ,it's very nice of you.

>Thanks,
>Brian

Bean Huo 霍斌斌 (beanhuo)

unread,
Dec 17, 2014, 2:40:05 AM12/17/14
to
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash, enabling or disabling quad I/O protocol can be done
By two methods, which are to use EVCR(Enhanced Volatile Configuration Register)
and the ENTER QUAD I/O MODE command. There is no difference between these two
methods. Unfortunately, for some Micron spi nor flashes, there no ENTER Quad I/O
command(35h),such as n25q064.But for all current Micron spi nor, if it support
quad I/O mode, using EVCR definitely be supported. It is a recommended method to
enable Quad I/O mode by EVCR, Quad I/O protocol bit 7.When EVCR bit 7 is reset
to 0,the SPI NOR flash will operate in quad I/O mode.

This patch has been tested on N25Q512A and MT25TL256BAA1ESF.Micron spi nor of
spi_nor_ids[] table all support this method.

Signed-off-by: bean huo <bea...@micron.com>
Acked-by: Marek Vasut <ma...@denx.de>
---
v1-v2:
Modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
v2-v3:
Directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.
v3-v4:
Modify commit logs that wraped into 80 columns.
v4-v5:
Rebuild new patch based on latest linux-mtd.
v5-v6:
Rebuild patch based on latest l2-mtd.
add some comments.
Add SPI_NOR_QUAD_READ flag in the spi_nor_ids[] for Micron spi nor.
V6-v7:
Fixed up val with u8 in micron_quad_enable().

drivers/mtd/spi-nor/spi-nor.c | 62 +++++++++++++++++++++++++++++++++++------
include/linux/mtd/spi-nor.h | 7 +++++
2 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 0f8ec3c..ea196c1 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -560,14 +560,14 @@ static const struct spi_device_id spi_nor_ids[] = {
{ "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },

/* Micron */
- { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, 0) },
- { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) },
- { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) },
- { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
- { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) },
- { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
- { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) },
- { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR) },
+ { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) },
+ { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, SPI_NOR_QUAD_READ) },
+ { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) },
+ { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) },
+ { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
+ { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+ { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+ { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },

/* PMC */
{ "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) },
@@ -891,6 +891,45 @@ static int spansion_quad_enable(struct spi_nor *nor)
return 0;
}

+static int micron_quad_enable(struct spi_nor *nor)
+{
+ int ret;
+ u8 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 ret;
+ }
+
+ 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 ret;
+ }
+
+ ret = spi_nor_wait_till_ready(nor);
+ if (ret)
+ return ret;
+
+ /* 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 ret;
+ }
+ 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, struct flash_info *info)
{
int status;
@@ -903,6 +942,13 @@ static int set_quad_mode(struct spi_nor *nor, struct flash_info *info)
--
1.7.9.5

Brian Norris

unread,
Jan 7, 2015, 2:40:06 PM1/7/15
to
On Wed, Dec 17, 2014 at 07:35:45AM +0000, Bean Huo 霍斌斌 (beanhuo) wrote:
> This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
>
> For Micron SPI NOR flash, enabling or disabling quad I/O protocol can be done
> By two methods, which are to use EVCR(Enhanced Volatile Configuration Register)
> and the ENTER QUAD I/O MODE command. There is no difference between these two
> methods. Unfortunately, for some Micron spi nor flashes, there no ENTER Quad I/O
> command(35h),such as n25q064.But for all current Micron spi nor, if it support
> quad I/O mode, using EVCR definitely be supported. It is a recommended method to
> enable Quad I/O mode by EVCR, Quad I/O protocol bit 7.When EVCR bit 7 is reset
> to 0,the SPI NOR flash will operate in quad I/O mode.
>
> This patch has been tested on N25Q512A and MT25TL256BAA1ESF.Micron spi nor of
> spi_nor_ids[] table all support this method.
>
> Signed-off-by: bean huo <bea...@micron.com>
> Acked-by: Marek Vasut <ma...@denx.de>

Pushed to l2-mtd.git. Thanks.

Brian
0 new messages