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

2014-10-23 Thread beanhuo
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 
Acked-by: Marek Vasut 
---
 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, , 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, , 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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-23 Thread beanhuo
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 bean...@micron.com
Acked-by: Marek Vasut ma...@denx.de
---
 v1-v2:modified to that capture wait_till_ready()
 return value,if error,directly return its
 the value.
 v2-v3:directly use the reurning error value of
 read_reg and write_reg,instead of -EINVAL.

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

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c 
index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ static int spansion_quad_enable(struct spi_nor *nor)
return 0;
 }
 
+static int micron_quad_enable(struct spi_nor *nor) {
+   int ret, val;
+
+   ret = nor-read_reg(nor, SPINOR_OP_RD_EVCR, val, 1);
+   if (ret  0) {
+   dev_err(nor-dev, error %d reading EVCR\n, ret);
+   return ret;
+   }
+
+   write_enable(nor);
+
+   /* set EVCR ,enable quad I/O */
+   nor-cmd_buf[0] = val  ~EVCR_QUAD_EN_MICRON;
+   ret = nor-write_reg(nor, SPINOR_OP_WD_EVCR, nor-cmd_buf, 1, 0);
+   if (ret  0) {
+   dev_err(nor-dev,
+   error while writing EVCR register\n);
+   return ret;
+   }
+
+   ret = wait_till_ready(nor);
+   if (ret)
+   return ret;
+
+   /* read EVCR and check it */
+   ret = nor-read_reg(nor, SPINOR_OP_RD_EVCR, val, 1);
+   if (ret  0) {
+   dev_err(nor-dev, error %d reading EVCR\n, ret);
+   return ret;
+   }
+   if (val  EVCR_QUAD_EN_MICRON) {
+   dev_err(nor-dev, Micron EVCR Quad bit not clear\n);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)  {
int status;
@@ -890,6 +929,13 @@ static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)
return -EINVAL;
}
return status;
+   case CFI_MFR_ST:
+   status = micron_quad_enable(nor);
+   if (status) {
+   dev_err(nor-dev, Micron quad-read not enabled\n);
+   return -EINVAL;
+   }
+   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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-22 Thread beanhuo
>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 
>Acked-by: Marek Vasut 

Hi,Brian
Is this patch OK?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-22 Thread beanhuo
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 bean...@micron.com
Acked-by: Marek Vasut ma...@denx.de

Hi,Brian
Is this patch OK?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-19 Thread 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 
Acked-by: Marek Vasut 
---
 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, , 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, , 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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-19 Thread 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 bean...@micron.com
Acked-by: Marek Vasut ma...@denx.de
---
 v1-v2:modified to that capture wait_till_ready()
 return value,if error,directly return its
 the value.
 v2-v3:directly use the reurning error value of
 read_reg and write_reg,instead of -EINVAL.

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

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c 
index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ static int spansion_quad_enable(struct spi_nor *nor)
return 0;
 }
 
+static int micron_quad_enable(struct spi_nor *nor) {
+   int ret, val;
+
+   ret = nor-read_reg(nor, SPINOR_OP_RD_EVCR, val, 1);
+   if (ret  0) {
+   dev_err(nor-dev, error %d reading EVCR\n, ret);
+   return ret;
+   }
+
+   write_enable(nor);
+
+   /* set EVCR ,enable quad I/O */
+   nor-cmd_buf[0] = val  ~EVCR_QUAD_EN_MICRON;
+   ret = nor-write_reg(nor, SPINOR_OP_WD_EVCR, nor-cmd_buf, 1, 0);
+   if (ret  0) {
+   dev_err(nor-dev,
+   error while writing EVCR register\n);
+   return ret;
+   }
+
+   ret = wait_till_ready(nor);
+   if (ret)
+   return ret;
+
+   /* read EVCR and check it */
+   ret = nor-read_reg(nor, SPINOR_OP_RD_EVCR, val, 1);
+   if (ret  0) {
+   dev_err(nor-dev, error %d reading EVCR\n, ret);
+   return ret;
+   }
+   if (val  EVCR_QUAD_EN_MICRON) {
+   dev_err(nor-dev, Micron EVCR Quad bit not clear\n);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)  {
int status;
@@ -890,6 +929,13 @@ static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)
return -EINVAL;
}
return status;
+   case CFI_MFR_ST:
+   status = micron_quad_enable(nor);
+   if (status) {
+   dev_err(nor-dev, Micron quad-read not enabled\n);
+   return -EINVAL;
+   }
+   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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-16 Thread beanhuo
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 
Acked-by: Marek Vasut 
---
 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, , 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, , 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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-16 Thread beanhuo
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 bean...@micron.com
Acked-by: Marek Vasut ma...@denx.de
---
 v1-v2:modified to that capture wait_till_ready()
 return value,if error,directly return its
 the value.
 v2-v3:directly use the reurning error value of
 read_reg and write_reg,instead of -EINVAL.

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

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c 
index b5ad6be..486b167 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -878,6 +878,45 @@ static int spansion_quad_enable(struct spi_nor *nor)
return 0;
 }
 
+static int micron_quad_enable(struct spi_nor *nor) {
+   int ret, val;
+
+   ret = nor-read_reg(nor, SPINOR_OP_RD_EVCR, val, 1);
+   if (ret  0) {
+   dev_err(nor-dev, error %d reading EVCR\n, ret);
+   return ret;
+   }
+
+   write_enable(nor);
+
+   /* set EVCR ,enable quad I/O */
+   nor-cmd_buf[0] = val  ~EVCR_QUAD_EN_MICRON;
+   ret = nor-write_reg(nor, SPINOR_OP_WD_EVCR, nor-cmd_buf, 1, 0);
+   if (ret  0) {
+   dev_err(nor-dev,
+   error while writing EVCR register\n);
+   return ret;
+   }
+
+   ret = wait_till_ready(nor);
+   if (ret)
+   return ret;
+
+   /* read EVCR and check it */
+   ret = nor-read_reg(nor, SPINOR_OP_RD_EVCR, val, 1);
+   if (ret  0) {
+   dev_err(nor-dev, error %d reading EVCR\n, ret);
+   return ret;
+   }
+   if (val  EVCR_QUAD_EN_MICRON) {
+   dev_err(nor-dev, Micron EVCR Quad bit not clear\n);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)  {
int status;
@@ -890,6 +929,13 @@ static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)
return -EINVAL;
}
return status;
+   case CFI_MFR_ST:
+   status = micron_quad_enable(nor);
+   if (status) {
+   dev_err(nor-dev, Micron quad-read not enabled\n);
+   return -EINVAL;
+   }
+   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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-15 Thread bpqw
>Acked-by: Marek Vasut 
Hi,brian
 How about this patch? And can be accepted by linux-mtd?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-15 Thread bpqw
Acked-by: Marek Vasut ma...@denx.de
Hi,brian
 How about this patch? And can be accepted by linux-mtd?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-03 Thread bpqw
>> Signed-off-by: bean huo 

>I don't see anything obviously wrong.

>Acked-by: Marek Vasut 

Hi,Brian

How do you think about this patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-03 Thread bpqw
 Signed-off-by: bean huo bean...@micron.com

I don't see anything obviously wrong.

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

Hi,Brian

How do you think about this patch?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-01 Thread Marek Vasut
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 

I don't see anything obviously wrong.

Acked-by: Marek Vasut 

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-01 Thread Marek Vasut
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-01 Thread 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 
---
 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, , 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, , 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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-01 Thread beanhuo
>> 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.


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

2014-10-01 Thread beanhuo
 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.


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

2014-10-01 Thread 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 bean...@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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
--
1.7.9.5
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-01 Thread Marek Vasut
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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-10-01 Thread Marek Vasut
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 bean...@micron.com

I don't see anything obviously wrong.

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

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-09-30 Thread Marek Vasut
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-09-30 Thread Marek Vasut
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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-09-29 Thread beanhuo
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 
---
 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, , 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, , 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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-09-29 Thread beanhuo
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 bean...@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_MICRON0x80/* Micron Quad I/O */
+
 /* Flag Status Register bits */
 #define FSR_READY  0x80
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/