* [U-Boot] [PATCH 1/3] sf: Minor cleanup
@ 2015-12-14 17:03 Jagan Teki
2015-12-14 17:03 ` [U-Boot] [PATCH 2/3] sf: Use BIT macro Jagan Teki
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jagan Teki @ 2015-12-14 17:03 UTC (permalink / raw)
To: u-boot
- Tab space
- Place all read commands at one place.
- Re-arrange write commands.
Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
drivers/mtd/spi/sf_internal.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index ed5c391..0fa3abb 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -75,12 +75,8 @@ enum spi_nor_option_flags {
#define CMD_WRITE_STATUS 0x01
#define CMD_PAGE_PROGRAM 0x02
#define CMD_WRITE_DISABLE 0x04
-#define CMD_READ_STATUS 0x05
-#define CMD_QUAD_PAGE_PROGRAM 0x32
-#define CMD_READ_STATUS1 0x35
#define CMD_WRITE_ENABLE 0x06
-#define CMD_READ_CONFIG 0x35
-#define CMD_FLAG_STATUS 0x70
+#define CMD_QUAD_PAGE_PROGRAM 0x32
/* Read commands */
#define CMD_READ_ARRAY_SLOW 0x03
@@ -90,6 +86,10 @@ enum spi_nor_option_flags {
#define CMD_READ_QUAD_OUTPUT_FAST 0x6b
#define CMD_READ_QUAD_IO_FAST 0xeb
#define CMD_READ_ID 0x9f
+#define CMD_READ_STATUS 0x05
+#define CMD_READ_STATUS1 0x35
+#define CMD_READ_CONFIG 0x35
+#define CMD_FLAG_STATUS 0x70
/* Bank addr access commands */
#ifdef CONFIG_SPI_FLASH_BAR
@@ -102,7 +102,7 @@ enum spi_nor_option_flags {
/* Common status */
#define STATUS_WIP (1 << 0)
#define STATUS_QEB_WINSPAN (1 << 1)
-#define STATUS_QEB_MXIC (1 << 6)
+#define STATUS_QEB_MXIC (1 << 6)
#define STATUS_PEC (1 << 7)
#define SR_BP0 BIT(2) /* Block protect 0 */
#define SR_BP1 BIT(3) /* Block protect 1 */
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/3] sf: Use BIT macro
2015-12-14 17:03 [U-Boot] [PATCH 1/3] sf: Minor cleanup Jagan Teki
@ 2015-12-14 17:03 ` Jagan Teki
2015-12-15 4:18 ` Bin Meng
2015-12-14 17:03 ` [U-Boot] [PATCH 3/3] sf: Fix quad bit set for micron devices Jagan Teki
2015-12-15 4:18 ` [U-Boot] [PATCH 1/3] sf: Minor cleanup Bin Meng
2 siblings, 1 reply; 7+ messages in thread
From: Jagan Teki @ 2015-12-14 17:03 UTC (permalink / raw)
To: u-boot
Used BIT macro like 1 << nr as BIT(nr) where nr is 0...n
Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
drivers/mtd/spi/sf_internal.h | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 0fa3abb..561abc3 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -16,18 +16,18 @@
/* Dual SPI flash memories - see SPI_COMM_DUAL_... */
enum spi_dual_flash {
SF_SINGLE_FLASH = 0,
- SF_DUAL_STACKED_FLASH = 1 << 0,
- SF_DUAL_PARALLEL_FLASH = 1 << 1,
+ SF_DUAL_STACKED_FLASH = BIT(0),
+ SF_DUAL_PARALLEL_FLASH = BIT(1),
};
/* Enum list - Full read commands */
enum spi_read_cmds {
- ARRAY_SLOW = 1 << 0,
- ARRAY_FAST = 1 << 1,
- DUAL_OUTPUT_FAST = 1 << 2,
- DUAL_IO_FAST = 1 << 3,
- QUAD_OUTPUT_FAST = 1 << 4,
- QUAD_IO_FAST = 1 << 5,
+ ARRAY_SLOW = BIT(0),
+ ARRAY_FAST = BIT(1),
+ DUAL_OUTPUT_FAST = BIT(2),
+ DUAL_IO_FAST = BIT(3),
+ QUAD_OUTPUT_FAST = BIT(4),
+ QUAD_IO_FAST = BIT(5),
};
/* Normal - Extended - Full command set */
@@ -37,20 +37,20 @@ enum spi_read_cmds {
/* sf param flags */
enum {
-#ifdef CONFIG_SPI_FLASH_USE_4K_SECTORS
- SECT_4K = 1 << 0,
+#ifndef CONFIG_SPI_FLASH_USE_4K_SECTORS
+ SECT_4K = 0,
#else
- SECT_4K = 0 << 0,
+ SECT_4K = BIT(0),
#endif
- SECT_32K = 1 << 1,
- E_FSR = 1 << 2,
- SST_WR = 1 << 3,
- WR_QPP = 1 << 4,
+ SECT_32K = BIT(1),
+ E_FSR = BIT(2),
+ SST_WR = BIT(3),
+ WR_QPP = BIT(4),
};
enum spi_nor_option_flags {
- SNOR_F_SST_WR = (1 << 0),
- SNOR_F_USE_FSR = (1 << 1),
+ SNOR_F_SST_WR = BIT(0),
+ SNOR_F_USE_FSR = BIT(1),
};
#define SPI_FLASH_3B_ADDR_LEN 3
@@ -100,10 +100,10 @@ enum spi_nor_option_flags {
#endif
/* Common status */
-#define STATUS_WIP (1 << 0)
-#define STATUS_QEB_WINSPAN (1 << 1)
-#define STATUS_QEB_MXIC (1 << 6)
-#define STATUS_PEC (1 << 7)
+#define STATUS_WIP BIT(0)
+#define STATUS_QEB_WINSPAN BIT(1)
+#define STATUS_QEB_MXIC BIT(6)
+#define STATUS_PEC BIT(7)
#define SR_BP0 BIT(2) /* Block protect 0 */
#define SR_BP1 BIT(3) /* Block protect 1 */
#define SR_BP2 BIT(4) /* Block protect 2 */
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 3/3] sf: Fix quad bit set for micron devices
2015-12-14 17:03 [U-Boot] [PATCH 1/3] sf: Minor cleanup Jagan Teki
2015-12-14 17:03 ` [U-Boot] [PATCH 2/3] sf: Use BIT macro Jagan Teki
@ 2015-12-14 17:03 ` Jagan Teki
2015-12-15 4:18 ` [U-Boot] [PATCH 1/3] sf: Minor cleanup Bin Meng
2 siblings, 0 replies; 7+ messages in thread
From: Jagan Teki @ 2015-12-14 17:03 UTC (permalink / raw)
To: u-boot
Setting up quad bit for micron devices need to do the
same way as other flash devices like spansion, winbond
etc does using enhanced volatile config register so this
patch adds this support instead of printing "QEB is volatile"
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Peter Pan <peterpandong@micron.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
drivers/mtd/spi/sf_internal.h | 3 ++
drivers/mtd/spi/spi_flash.c | 66 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 561abc3..55ba81e 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -77,6 +77,7 @@ enum spi_nor_option_flags {
#define CMD_WRITE_DISABLE 0x04
#define CMD_WRITE_ENABLE 0x06
#define CMD_QUAD_PAGE_PROGRAM 0x32
+#define CMD_WRITE_EVCR 0x61
/* Read commands */
#define CMD_READ_ARRAY_SLOW 0x03
@@ -90,6 +91,7 @@ enum spi_nor_option_flags {
#define CMD_READ_STATUS1 0x35
#define CMD_READ_CONFIG 0x35
#define CMD_FLAG_STATUS 0x70
+#define CMD_READ_EVCR 0x65
/* Bank addr access commands */
#ifdef CONFIG_SPI_FLASH_BAR
@@ -104,6 +106,7 @@ enum spi_nor_option_flags {
#define STATUS_QEB_WINSPAN BIT(1)
#define STATUS_QEB_MXIC BIT(6)
#define STATUS_PEC BIT(7)
+#define STATUS_QEB_MICRON BIT(7)
#define SR_BP0 BIT(2) /* Block protect 0 */
#define SR_BP1 BIT(3) /* Block protect 1 */
#define SR_BP2 BIT(4) /* Block protect 2 */
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 6fe8c9d..2ec465a 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -73,6 +73,37 @@ static int write_sr(struct spi_flash *flash, u8 ws)
return 0;
}
+#ifdef CONFIG_SPI_FLASH_STMICRO
+static int read_evcr(struct spi_flash *flash, u8 *evcr)
+{
+ int ret;
+ const u8 cmd = CMD_READ_EVCR;
+
+ ret = spi_flash_read_common(flash, &cmd, 1, evcr, 1);
+ if (ret < 0) {
+ debug("SF: error reading EVCR\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int write_evcr(struct spi_flash *flash, u8 evcr)
+{
+ u8 cmd;
+ int ret;
+
+ cmd = CMD_WRITE_EVCR;
+ ret = spi_flash_write_common(flash, &cmd, 1, &evcr, 1);
+ if (ret < 0) {
+ debug("SF: error while writing EVCR register\n");
+ return ret;
+ }
+
+ return 0;
+}
+#endif
+
#if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
static int read_cr(struct spi_flash *flash, u8 *rc)
{
@@ -843,6 +874,38 @@ static int spansion_quad_enable(struct spi_flash *flash)
}
#endif
+#ifdef CONFIG_SPI_FLASH_STMICRO
+static int micron_quad_enable(struct spi_flash *flash)
+{
+ u8 qeb_status;
+ int ret;
+
+ ret = read_evcr(flash, &qeb_status);
+ if (ret < 0)
+ return ret;
+
+ if (qeb_status & STATUS_QEB_MICRON) {
+ ret = write_evcr(flash, qeb_status & ~STATUS_QEB_MICRON);
+ if (ret < 0)
+ return ret;
+ } else {
+ debug("SF: Micron EVCR Quad bit clear\n");
+ }
+
+ /* read EVCR and check it */
+ ret = read_evcr(flash, &qeb_status);
+ if (ret < 0)
+ return ret;
+
+ if (qeb_status & STATUS_QEB_MICRON) {
+ printf("SF: Micron EVCR Quad bit not clear\n");
+ return -EINVAL;
+ }
+
+ return ret;
+}
+#endif
+
static int set_quad_mode(struct spi_flash *flash, u8 idcode0)
{
switch (idcode0) {
@@ -857,8 +920,7 @@ static int set_quad_mode(struct spi_flash *flash, u8 idcode0)
#endif
#ifdef CONFIG_SPI_FLASH_STMICRO
case SPI_FLASH_CFI_MFR_STMICRO:
- debug("SF: QEB is volatile for %02x flash\n", idcode0);
- return 0;
+ return micron_quad_enable(flash);
#endif
default:
printf("SF: Need set QEB func for %02x flash\n", idcode0);
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/3] sf: Minor cleanup
2015-12-14 17:03 [U-Boot] [PATCH 1/3] sf: Minor cleanup Jagan Teki
2015-12-14 17:03 ` [U-Boot] [PATCH 2/3] sf: Use BIT macro Jagan Teki
2015-12-14 17:03 ` [U-Boot] [PATCH 3/3] sf: Fix quad bit set for micron devices Jagan Teki
@ 2015-12-15 4:18 ` Bin Meng
2015-12-15 6:27 ` Jagan Teki
2 siblings, 1 reply; 7+ messages in thread
From: Bin Meng @ 2015-12-15 4:18 UTC (permalink / raw)
To: u-boot
On Tue, Dec 15, 2015 at 1:03 AM, Jagan Teki <jteki@openedev.com> wrote:
> - Tab space
> - Place all read commands at one place.
> - Re-arrange write commands.
>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/3] sf: Use BIT macro
2015-12-14 17:03 ` [U-Boot] [PATCH 2/3] sf: Use BIT macro Jagan Teki
@ 2015-12-15 4:18 ` Bin Meng
2015-12-15 6:23 ` Jagan Teki
0 siblings, 1 reply; 7+ messages in thread
From: Bin Meng @ 2015-12-15 4:18 UTC (permalink / raw)
To: u-boot
On Tue, Dec 15, 2015 at 1:03 AM, Jagan Teki <jteki@openedev.com> wrote:
> Used BIT macro like 1 << nr as BIT(nr) where nr is 0...n
>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/3] sf: Use BIT macro
2015-12-15 4:18 ` Bin Meng
@ 2015-12-15 6:23 ` Jagan Teki
0 siblings, 0 replies; 7+ messages in thread
From: Jagan Teki @ 2015-12-15 6:23 UTC (permalink / raw)
To: u-boot
On 15 December 2015 at 09:48, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Tue, Dec 15, 2015 at 1:03 AM, Jagan Teki <jteki@openedev.com> wrote:
>> Used BIT macro like 1 << nr as BIT(nr) where nr is 0...n
>>
>> Cc: Bin Meng <bmeng.cn@gmail.com>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/3] sf: Minor cleanup
2015-12-15 4:18 ` [U-Boot] [PATCH 1/3] sf: Minor cleanup Bin Meng
@ 2015-12-15 6:27 ` Jagan Teki
0 siblings, 0 replies; 7+ messages in thread
From: Jagan Teki @ 2015-12-15 6:27 UTC (permalink / raw)
To: u-boot
On 15 December 2015 at 09:48, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Tue, Dec 15, 2015 at 1:03 AM, Jagan Teki <jteki@openedev.com> wrote:
>> - Tab space
>> - Place all read commands at one place.
>> - Re-arrange write commands.
>>
>> Cc: Bin Meng <bmeng.cn@gmail.com>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-12-15 6:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-14 17:03 [U-Boot] [PATCH 1/3] sf: Minor cleanup Jagan Teki
2015-12-14 17:03 ` [U-Boot] [PATCH 2/3] sf: Use BIT macro Jagan Teki
2015-12-15 4:18 ` Bin Meng
2015-12-15 6:23 ` Jagan Teki
2015-12-14 17:03 ` [U-Boot] [PATCH 3/3] sf: Fix quad bit set for micron devices Jagan Teki
2015-12-15 4:18 ` [U-Boot] [PATCH 1/3] sf: Minor cleanup Bin Meng
2015-12-15 6:27 ` Jagan Teki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox