linux-kernel.vger.kernel.org archive mirror
 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, Brian Norris
  Cc: b32955, marex, geert+renesas, grmoore, linux-mtd, linux-kernel

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

* Re: [PATCH 1/1] driver:mtd:spi-nor: Add Micron quad I/O support
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Marek Vasut @ 2014-09-25 10:11 UTC (permalink / raw)
  To: bpqw
  Cc: dwmw2, Brian Norris, b32955, geert+renesas, grmoore, linux-mtd,
	linux-kernel

On Thursday, September 25, 2014 at 08:20:35 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.
> 
> 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;

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

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

* RE: [PATCH 1/1] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-25 10:11 ` Marek Vasut
@ 2014-09-26  8:39   ` bpqw
  2014-09-26  8:46     ` Marek Vasut
  0 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-09-26  8:39 UTC (permalink / raw)
  To: Marek Vasut
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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

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

* Re: [PATCH 1/1] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:39   ` bpqw
@ 2014-09-26  8:46     ` Marek Vasut
  2014-09-28  1:59       ` [PATCH 1/1 v2] " bpqw
                         ` (9 more replies)
  0 siblings, 10 replies; 39+ messages in thread
From: Marek Vasut @ 2014-09-26  8:46 UTC (permalink / raw)
  To: bpqw
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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 ?

Best regards,
Marek Vasut

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

* [PATCH 1/1 v2] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
@ 2014-09-28  1:59       ` bpqw
  2014-09-28 22:43         ` Marek Vasut
  2014-09-30  2:47       ` [PATCH 1/1 v3] " Bean Huo 霍斌斌 (beanhuo)
                         ` (8 subsequent siblings)
  9 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-09-28  1:59 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

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

* Re: [PATCH 1/1 v2] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-28  1:59       ` [PATCH 1/1 v2] " bpqw
@ 2014-09-28 22:43         ` Marek Vasut
  2014-09-29  0:30           ` bpqw
  0 siblings, 1 reply; 39+ messages in thread
From: Marek Vasut @ 2014-09-28 22:43 UTC (permalink / raw)
  To: bpqw
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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.

> Signed-off-by: bean huo <beanhuo@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;

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

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

* RE: [PATCH 1/1 v2] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-28 22:43         ` Marek Vasut
@ 2014-09-29  0:30           ` bpqw
  2014-09-29 18:57             ` Marek Vasut
  0 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-09-29  0:30 UTC (permalink / raw)
  To: Marek Vasut
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

>> 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.

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

* Re: [PATCH 1/1 v2] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-29  0:30           ` bpqw
@ 2014-09-29 18:57             ` Marek Vasut
  0 siblings, 0 replies; 39+ messages in thread
From: Marek Vasut @ 2014-09-29 18:57 UTC (permalink / raw)
  To: bpqw
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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

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

* [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
  2014-09-28  1:59       ` [PATCH 1/1 v2] " bpqw
@ 2014-09-30  2:47       ` Bean Huo 霍斌斌 (beanhuo)
  2014-09-30 13:38         ` Marek Vasut
  2014-10-01 14:28       ` bpqw
                         ` (7 subsequent siblings)
  9 siblings, 1 reply; 39+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-09-30  2:47 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

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 <beanhuo@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;
+		}
+		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

* Re: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  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)
  0 siblings, 1 reply; 39+ messages in thread
From: Marek Vasut @ 2014-09-30 13:38 UTC (permalink / raw)
  To: Bean Huo 霍斌斌 (beanhuo)
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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

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

* RE: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-30 13:38         ` Marek Vasut
@ 2014-10-01 14:24           ` Bean Huo 霍斌斌 (beanhuo)
  2014-10-01 14:32             ` Marek Vasut
  0 siblings, 1 reply; 39+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-10-01 14:24 UTC (permalink / raw)
  To: Marek Vasut
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1026 bytes --]

>> 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.
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
  2014-09-28  1:59       ` [PATCH 1/1 v2] " bpqw
  2014-09-30  2:47       ` [PATCH 1/1 v3] " Bean Huo 霍斌斌 (beanhuo)
@ 2014-10-01 14:28       ` bpqw
  2014-10-01 14:33         ` Marek Vasut
  2014-10-17  0:37       ` Bean Huo 霍斌斌 (beanhuo)
                         ` (6 subsequent siblings)
  9 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-10-01 14:28 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

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 <beanhuo@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;
+		}
+		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	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-10-01 14:24           ` Bean Huo 霍斌斌 (beanhuo)
@ 2014-10-01 14:32             ` Marek Vasut
  0 siblings, 0 replies; 39+ messages in thread
From: Marek Vasut @ 2014-10-01 14:32 UTC (permalink / raw)
  To: Bean Huo 霍斌斌 (beanhuo)
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

On Wednesday, October 01, 2014 at 04:24:41 PM, 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 ?
> 
> Perfect,I will modify my commit message and sumbit it again.thanks.

Thank you. I didn't mean to grind you unnecessarily or be outright bitch, sorry 
if it did sound like so.

Best regards,
Marek Vasut

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

* Re: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  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
  0 siblings, 2 replies; 39+ messages in thread
From: Marek Vasut @ 2014-10-01 14:33 UTC (permalink / raw)
  To: bpqw
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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 <beanhuo@micron.com>

I don't see anything obviously wrong.

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

Best regards,
Marek Vasut

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

* RE: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-10-01 14:33         ` Marek Vasut
@ 2014-10-04  5:55           ` bpqw
  2014-10-16  1:53           ` bpqw
  1 sibling, 0 replies; 39+ messages in thread
From: bpqw @ 2014-10-04  5:55 UTC (permalink / raw)
  To: Marek Vasut, Brian Norris
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

>> Signed-off-by: bean huo <beanhuo@micron.com>

>I don't see anything obviously wrong.

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

Hi,Brian

How do you think about this patch?

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

* RE: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-10-01 14:33         ` Marek Vasut
  2014-10-04  5:55           ` bpqw
@ 2014-10-16  1:53           ` bpqw
  1 sibling, 0 replies; 39+ messages in thread
From: bpqw @ 2014-10-16  1:53 UTC (permalink / raw)
  To: Marek Vasut, Brian Norris
  Cc: dwmw2, Brian Norris, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

>Acked-by: Marek Vasut <marex@denx.de>
Hi,brian
 How about this patch? And can be accepted by linux-mtd?

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

* [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
                         ` (2 preceding siblings ...)
  2014-10-01 14:28       ` bpqw
@ 2014-10-17  0:37       ` Bean Huo 霍斌斌 (beanhuo)
  2014-10-20  1:24       ` bpqw
                         ` (5 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-10-17  0:37 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

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 <beanhuo@micron.com>
Acked-by: Marek Vasut <marex@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;
+		}
+		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	[flat|nested] 39+ messages in thread

* [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
                         ` (3 preceding siblings ...)
  2014-10-17  0:37       ` Bean Huo 霍斌斌 (beanhuo)
@ 2014-10-20  1:24       ` bpqw
  2014-10-23  0:58       ` Bean Huo 霍斌斌 (beanhuo)
                         ` (4 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: bpqw @ 2014-10-20  1:24 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

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 <beanhuo@micron.com>
Acked-by: Marek Vasut <marex@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;
+		}
+		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	[flat|nested] 39+ messages in thread

* RE: [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
                         ` (4 preceding siblings ...)
  2014-10-20  1:24       ` bpqw
@ 2014-10-23  0:58       ` Bean Huo 霍斌斌 (beanhuo)
  2014-10-24  0:31       ` Bean Huo 霍斌斌 (beanhuo)
                         ` (3 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-10-23  0:58 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

>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 <beanhuo@micron.com>
>Acked-by: Marek Vasut <marex@denx.de>

Hi,Brian
Is this patch OK?

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

* [PATCH 1/1 v3] driver:mtd:spi-nor: Add Micron quad I/O support
  2014-09-26  8:46     ` Marek Vasut
                         ` (5 preceding siblings ...)
  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
                         ` (2 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-10-24  0:31 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel, bpqw

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 <beanhuo@micron.com>
Acked-by: Marek Vasut <marex@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;
+		}
+		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	[flat|nested] 39+ messages in thread

* [PATCH 1/1 v3] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-09-26  8:46     ` Marek Vasut
                         ` (6 preceding siblings ...)
  2014-10-24  0:31       ` Bean Huo 霍斌斌 (beanhuo)
@ 2014-10-27  0:09       ` 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-06  3:09       ` [V5 PATCH 1/1] " bpqw
  9 siblings, 2 replies; 39+ messages in thread
From: bpqw @ 2014-10-27  0:09 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel, bpqw

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 <beanhuo@micron.com>
Acked-by: Marek Vasut <marex@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;
+		}
+		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	[flat|nested] 39+ messages in thread

* RE: [PATCH 1/1 v3] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  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
  1 sibling, 0 replies; 39+ messages in thread
From: bpqw @ 2014-10-30 14:31 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

>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 <beanhuo@micron.com>
>Acked-by: Marek Vasut <marex@denx.de>

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

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

* [PATCH 1/1 v4] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-09-26  8:46     ` Marek Vasut
                         ` (7 preceding siblings ...)
  2014-10-27  0:09       ` [PATCH 1/1 v3] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor bpqw
@ 2014-11-04 13:25       ` bpqw
  2014-11-05 11:26         ` Brian Norris
  2014-11-06  3:09       ` [V5 PATCH 1/1] " bpqw
  9 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-11-04 13:25 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel

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 <beanhuo@micron.com>
Acked-by: Marek Vasut <marex@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;
+		}
+		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	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/1 v4] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-04 13:25       ` [PATCH 1/1 v4] " bpqw
@ 2014-11-05 11:26         ` Brian Norris
  2014-11-06  2:56           ` bpqw
  0 siblings, 1 reply; 39+ messages in thread
From: Brian Norris @ 2014-11-05 11:26 UTC (permalink / raw)
  To: bpqw
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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 <beanhuo@micron.com>
> Acked-by: Marek Vasut <marex@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

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

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

* RE: [PATCH 1/1 v4] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-05 11:26         ` Brian Norris
@ 2014-11-06  2:56           ` bpqw
  0 siblings, 0 replies; 39+ messages in thread
From: bpqw @ 2014-11-06  2:56 UTC (permalink / raw)
  To: Brian Norris, bpqw
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

>> 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.

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

* [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-09-26  8:46     ` Marek Vasut
                         ` (8 preceding siblings ...)
  2014-11-04 13:25       ` [PATCH 1/1 v4] " bpqw
@ 2014-11-06  3:09       ` bpqw
       [not found]         ` <54613259.4070903@opensource.altera.com>
                           ` (2 more replies)
  9 siblings, 3 replies; 39+ messages in thread
From: bpqw @ 2014-11-06  3:09 UTC (permalink / raw)
  To: Marek Vasut, dwmw2, Brian Norris
  Cc: shijie8, geert+renesas, grmoore, linux-mtd, linux-kernel, bpqw

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 <beanhuo@micron.com>
Acked-by: Marek Vasut <marex@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

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

* Re: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
       [not found]         ` <54613259.4070903@opensource.altera.com>
@ 2014-11-11 19:41           ` Graham Moore
  2014-11-11 21:55             ` Jagan Teki
  2014-11-12  0:58             ` bpqw
  0 siblings, 2 replies; 39+ messages in thread
From: Graham Moore @ 2014-11-11 19:41 UTC (permalink / raw)
  To: bpqw
  Cc: Marek Vasut, dwmw2, Brian Norris, geert+renesas, linux-kernel,
	linux-mtd, shijie8, Graham Moore

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


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

* Re: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  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
  1 sibling, 1 reply; 39+ messages in thread
From: Jagan Teki @ 2014-11-11 21:55 UTC (permalink / raw)
  To: Graham Moore
  Cc: bpqw, Marek Vasut, geert+renesas, shijie8, linux-kernel,
	linux-mtd, Brian Norris, dwmw2

On 12 November 2014 01:11, Graham Moore <grmoore@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.

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-11 19:41           ` Graham Moore
  2014-11-11 21:55             ` Jagan Teki
@ 2014-11-12  0:58             ` bpqw
  2014-11-13 16:26               ` Graham Moore
  1 sibling, 1 reply; 39+ messages in thread
From: bpqw @ 2014-11-12  0:58 UTC (permalink / raw)
  To: Graham Moore, Brian Norris
  Cc: Marek Vasut, dwmw2, geert+renesas, linux-kernel, linux-mtd,
	shijie8, bpqw

>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.

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-11 21:55             ` Jagan Teki
@ 2014-11-12  1:19               ` bpqw
  0 siblings, 0 replies; 39+ messages in thread
From: bpqw @ 2014-11-12  1:19 UTC (permalink / raw)
  To: Jagan Teki, Graham Moore, Brian Norris
  Cc: bpqw, Marek Vasut, geert+renesas, shijie8, linux-kernel,
	linux-mtd, dwmw2

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1119 bytes --]

>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.
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH 1/1 v3] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  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
  1 sibling, 0 replies; 39+ messages in thread
From: Jagan Teki @ 2014-11-12 20:59 UTC (permalink / raw)
  To: bpqw
  Cc: Marek Vasut, dwmw2, Brian Norris, geert+renesas, grmoore,
	linux-kernel, linux-mtd, shijie8

On 27 October 2014 05:39, bpqw <bpqw@micron.com> 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 <beanhuo@micron.com>
> Acked-by: Marek Vasut <marex@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;
> +       }

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");
                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;
> +               }
> +               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
>

thanks!
-- 
Jagan.

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-12  0:58             ` bpqw
@ 2014-11-13 16:26               ` Graham Moore
  2014-11-14  2:06                 ` bpqw
  0 siblings, 1 reply; 39+ messages in thread
From: Graham Moore @ 2014-11-13 16:26 UTC (permalink / raw)
  To: bpqw
  Cc: Graham Moore, Brian Norris, Marek Vasut, dwmw2, geert+renesas,
	linux-kernel, linux-mtd, shijie8



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

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-13 16:26               ` Graham Moore
@ 2014-11-14  2:06                 ` bpqw
  0 siblings, 0 replies; 39+ messages in thread
From: bpqw @ 2014-11-14  2:06 UTC (permalink / raw)
  To: Graham Moore, Brian Norris
  Cc: Marek Vasut, dwmw2, geert+renesas, linux-kernel, linux-mtd,
	shijie8, bpqw

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

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

* Re: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-06  3:09       ` [V5 PATCH 1/1] " bpqw
       [not found]         ` <54613259.4070903@opensource.altera.com>
@ 2014-11-26  4:06         ` Brian Norris
  2014-11-26 16:08           ` bpqw
  2014-11-26 21:12         ` Brian Norris
  2 siblings, 1 reply; 39+ messages in thread
From: Brian Norris @ 2014-11-26  4:06 UTC (permalink / raw)
  To: bpqw
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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 <beanhuo@micron.com>
> Acked-by: Marek Vasut <marex@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

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-26  4:06         ` Brian Norris
@ 2014-11-26 16:08           ` bpqw
  0 siblings, 0 replies; 39+ messages in thread
From: bpqw @ 2014-11-26 16:08 UTC (permalink / raw)
  To: Brian Norris
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 498 bytes --]

>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.
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-06  3:09       ` [V5 PATCH 1/1] " bpqw
       [not found]         ` <54613259.4070903@opensource.altera.com>
  2014-11-26  4:06         ` Brian Norris
@ 2014-11-26 21:12         ` Brian Norris
  2014-11-27  5:55           ` bpqw
  2 siblings, 1 reply; 39+ messages in thread
From: Brian Norris @ 2014-11-26 21:12 UTC (permalink / raw)
  To: bpqw
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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 <your@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 <beanhuo@micron.com>
> Acked-by: Marek Vasut <marex@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.

>  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");

Join the above two lines?

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

It's spi_nor_wait_till_ready(), now.

> +	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 */

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

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-26 21:12         ` Brian Norris
@ 2014-11-27  5:55           ` bpqw
  2014-11-27  9:14             ` Brian Norris
  0 siblings, 1 reply; 39+ messages in thread
From: bpqw @ 2014-11-27  5:55 UTC (permalink / raw)
  To: Brian Norris
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel, bpqw

>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 <beanhuo@micron.com>
>> Acked-by: Marek Vasut <marex@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---


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

* Re: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-27  5:55           ` bpqw
@ 2014-11-27  9:14             ` Brian Norris
  2014-11-30 16:11               ` Bean Huo 霍斌斌 (beanhuo)
  0 siblings, 1 reply; 39+ messages in thread
From: Brian Norris @ 2014-11-27  9:14 UTC (permalink / raw)
  To: bpqw
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

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

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

* RE: [V5 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor
  2014-11-27  9:14             ` Brian Norris
@ 2014-11-30 16:11               ` Bean Huo 霍斌斌 (beanhuo)
  0 siblings, 0 replies; 39+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-11-30 16:11 UTC (permalink / raw)
  To: Brian Norris
  Cc: Marek Vasut, dwmw2, shijie8, geert+renesas, grmoore, linux-mtd,
	linux-kernel

>>>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.


^ permalink raw reply	[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;
as well as URLs for NNTP newsgroup(s).