Skip to contentSkip to conversation

sf: SST changes, Byte program

PATCH Superseded Jagannadha Sutradharudu Teki 3 participants 16 messages Dec 12, 2014 – Dec 14, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover sf: SST changes, Byte program

This patch-set added byte program support for sst flashes and some implementation changes in sf to support array slow and byte program specific controllers.

Changes for v2:
- commit message fixes

Bin Meng (3):
spi: sf: Support byte program for sst spi flash
x86: ich-spi: Set the rx operation mode for ich 7
x86: ich-spi: Set the tx operation mode for ich 7

Jagannadha Sutradharudu Teki (2):
sf: Fix look for the fastest read command
sf: Enable byte program support

Simon Glass (1):
spi: Fix flag collision for SST_WP

 drivers/mtd/spi/sf_internal.h |  22 ++++++---
 drivers/mtd/spi/sf_ops.c      |  31 +++++++++++++
 drivers/mtd/spi/sf_params.c   | 102 +++++++++++++++++++++---------------------
 drivers/mtd/spi/sf_probe.c    |   9 +++-
 drivers/spi/ich.c             |   9 ++++
 include/spi.h                 |   1 +
 6 files changed, 114 insertions(+), 60 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/6 sf: Fix look for the fastest read command

Few of the spi controllers are only supports array slow read which is quite different behaviour compared to others.

So this fix on sf will correctly handle the slow read supported controllers.

---
 drivers/mtd/spi/sf_internal.h |  13 +++---
 drivers/mtd/spi/sf_params.c   | 102 +++++++++++++++++++++---------------------
 drivers/mtd/spi/sf_probe.c    |   1 +
 3 files changed, 60 insertions(+), 56 deletions(-)
drivers/mtd/spi/sf_internal.h +8 -5
index 5b7670c..e159f04 100644
@@ -23,13 +23,16 @@ enum spi_dual_flash {
 /* Enum list - Full read commands */
 enum spi_read_cmds {
 	ARRAY_SLOW		= 1 << 0,
-	DUAL_OUTPUT_FAST	= 1 << 1,
-	DUAL_IO_FAST		= 1 << 2,
-	QUAD_OUTPUT_FAST	= 1 << 3,
-	QUAD_IO_FAST		= 1 << 4,
+	ARRAY_FAST		= 1 << 1,
+	DUAL_OUTPUT_FAST	= 1 << 2,
+	DUAL_IO_FAST		= 1 << 3,
+	QUAD_OUTPUT_FAST	= 1 << 4,
+	QUAD_IO_FAST		= 1 << 5,
 };
 
-#define RD_EXTN	(ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST)
+/* Normal - Extended - Full command set */
+#define RD_NORM	(ARRAY_SLOW | ARRAY_FAST)
+#define RD_EXTN	(RD_NORM | DUAL_OUTPUT_FAST | DUAL_IO_FAST)
 #define RD_FULL	(RD_EXTN | QUAD_OUTPUT_FAST | QUAD_IO_FAST)
 
 /* sf param flags */
drivers/mtd/spi/sf_params.c +51 -51

135 lines not on this page · raw message

drivers/mtd/spi/sf_probe.c +1 -0
index 2636426..7cde4c0 100644
@@ -24,6 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Read commands array */
 static u8 spi_read_cmds_array[] = {
 	CMD_READ_ARRAY_SLOW,
+	CMD_READ_ARRAY_FAST,
 	CMD_READ_DUAL_OUTPUT_FAST,
 	CMD_READ_DUAL_IO_FAST,
 	CMD_READ_QUAD_OUTPUT_FAST,
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/6 sf: Fix look for the fastest read command

Quoted 6 lines · Jagannadha Sutradharudu Teki

Few of the spi controllers are only supports array slow read which is quite different behaviour compared to others.

So this fix on sf will correctly handle the slow read supported controllers.

Quoted 7 lines
---
 drivers/mtd/spi/sf_internal.h |  13 +++---
 drivers/mtd/spi/sf_params.c   | 102 +++++++++++++++++++++---------------------
 drivers/mtd/spi/sf_probe.c    |   1 +
 3 files changed, 60 insertions(+), 56 deletions(-)

Applied to u-boot-x86, thanks!

#3 lore raw

PATCH v2 2/6 spi: Fix flag collision for SST_WP

In reply to Jagannadha Sutradharudu Teki

From: Simon Glass <[email protected]>

At present SECT_4K is the same as SST_WP so we cannot tell these apart. Fix this so that the table in sf_params.c can be used correctly.

---
 drivers/mtd/spi/sf_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi/sf_internal.h +1 -1
index e159f04..7218e69 100644
@@ -41,6 +41,7 @@ enum {
 	SECT_32K	= 1 << 1,
 	E_FSR		= 1 << 2,
 	WR_QPP		= 1 << 3,
+	SST_WP		= 1 << 4,
 };
 
 #define SPI_FLASH_3B_ADDR_LEN		3
@@ -104,7 +105,6 @@ enum {
 
 /* SST specific */
 #ifdef CONFIG_SPI_FLASH_SST
-# define SST_WP		0x01	/* Supports AAI word program */
 # define CMD_SST_BP		0x02    /* Byte Program */
 # define CMD_SST_AAI_WP	0xAD	/* Auto Address Incr Word Program */
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/6 spi: Fix flag collision for SST_WP

Quoted 11 lines · Jagannadha Sutradharudu Teki

From: Simon Glass <[email protected]>

At present SECT_4K is the same as SST_WP so we cannot tell these apart. Fix this so that the table in sf_params.c can be used correctly.

---
 drivers/mtd/spi/sf_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-x86, thanks!

#5 lore raw

PATCH v2 3/6 spi: sf: Support byte program for sst spi flash

In reply to Jagannadha Sutradharudu Teki

From: Bin Meng <[email protected]>

Currently if SST flash advertises SST_WP flag in the params table the word program command (ADh) with auto address increment will be used for the flash write op. However some SPI controllers do not support the word program command (like the Intel ICH 7), the byte programm command (02h) has to be used.

---
 drivers/mtd/spi/sf_internal.h |  2 ++
 drivers/mtd/spi/sf_ops.c      | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/mtd/spi/sf_internal.h +2 -0
index 7218e69..fb53cb0 100644
@@ -110,6 +110,8 @@ enum {
 
 int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
 		const void *buf);
+int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
+		const void *buf);
 #endif
 
 /**
drivers/mtd/spi/sf_ops.c +31 -0
index 759231f..34bc54e 100644
@@ -517,4 +517,35 @@ int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
 	spi_release_bus(flash->spi);
 	return ret;
 }
+
+int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
+		const void *buf)
+{
+	size_t actual;
+	int ret;
+
+	ret = spi_claim_bus(flash->spi);
+	if (ret) {
+		debug("SF: Unable to claim SPI bus\n");
+		return ret;
+	}
+
+	for (actual = 0; actual < len; actual++) {
+		ret = sst_byte_write(flash, offset, buf + actual);
+		if (ret) {
+			debug("SF: sst byte program failed\n");
+			break;
+		}
+		offset++;
+	}
+
+	if (!ret)
+		ret = spi_flash_cmd_write_disable(flash);
+
+	debug("SF: sst: program %s %zu bytes @ 0x%zx\n",
+	      ret ? "failure" : "success", len, offset - actual);
+
+	spi_release_bus(flash->spi);
+	return ret;
+}
 #endif
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 3/6 spi: sf: Support byte program for sst spi flash

Quoted 8 lines · Jagannadha Sutradharudu Teki

From: Bin Meng <[email protected]>

Currently if SST flash advertises SST_WP flag in the params table the word program command (ADh) with auto address increment will be used for the flash write op. However some SPI controllers do not support the word program command (like the Intel ICH 7), the byte programm command (02h) has to be used.

Quoted 4 lines

Applied to u-boot-x86, thanks!

#7 lore raw

PATCH v2 4/6 sf: Enable byte program support

In reply to Jagannadha Sutradharudu Teki

Enabled byte program support for sst flashes in sf.

Few controllers will only support BP, so this patch gives a tx transfer flag to set the BP so-that sf will operate on byte program transfer.

A new TX operation mode SPI_OPM_TX_BP is introduced for such SPI controller to use byte program op for SST flash.

---
 drivers/mtd/spi/sf_internal.h |  5 ++++-
 drivers/mtd/spi/sf_params.c   | 18 +++++++++---------
 drivers/mtd/spi/sf_probe.c    |  8 ++++++--
 include/spi.h                 |  1 +
 4 files changed, 20 insertions(+), 12 deletions(-)
drivers/mtd/spi/sf_internal.h +4 -1
index fb53cb0..785f7a9 100644
@@ -40,10 +40,13 @@ enum {
 	SECT_4K		= 1 << 0,
 	SECT_32K	= 1 << 1,
 	E_FSR		= 1 << 2,
-	WR_QPP		= 1 << 3,
+	SST_BP		= 1 << 3,
 	SST_WP		= 1 << 4,
+	WR_QPP		= 1 << 5,
 };
 
+#define SST_WR		(SST_BP | SST_WP)
+
 #define SPI_FLASH_3B_ADDR_LEN		3
 #define SPI_FLASH_CMD_LEN		(1 + SPI_FLASH_3B_ADDR_LEN)
 #define SPI_FLASH_16MB_BOUN		0x1000000
drivers/mtd/spi/sf_params.c +9 -9
index 0f1f837..30875b3 100644
@@ -89,16 +89,16 @@ const struct spi_flash_params spi_flash_params_table[] = {
 	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048, RD_FULL, WR_QPP | E_FSR | SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_SST		/* SST */
-	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8, RD_NORM,          SECT_4K | SST_WP},
-	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16, RD_NORM,	    SECT_4K | SST_WP},
-	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32, RD_NORM,	    SECT_4K | SST_WP},
-	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64, RD_NORM,	    SECT_4K | SST_WP},
+	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8, RD_NORM,          SECT_4K | SST_WR},
+	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16, RD_NORM,	    SECT_4K | SST_WR},
+	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32, RD_NORM,	    SECT_4K | SST_WR},
+	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64, RD_NORM,	    SECT_4K | SST_WR},
 	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128, RD_NORM,		     SECT_4K},
-	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1, RD_NORM,	    SECT_4K | SST_WP},
-	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2, RD_NORM,          SECT_4K | SST_WP},
-	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4, RD_NORM,	    SECT_4K | SST_WP},
-	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8, RD_NORM,	    SECT_4K | SST_WP},
-	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16, RD_NORM,	    SECT_4K | SST_WP},
+	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1, RD_NORM,	    SECT_4K | SST_WR},
+	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2, RD_NORM,          SECT_4K | SST_WR},
+	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4, RD_NORM,	    SECT_4K | SST_WR},
+	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8, RD_NORM,	    SECT_4K | SST_WR},
+	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16, RD_NORM,	    SECT_4K | SST_WR},
 #endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
 	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16, RD_NORM,		           0},
drivers/mtd/spi/sf_probe.c +6 -2
index 7cde4c0..ce9987f 100644
@@ -136,8 +136,12 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 #ifndef CONFIG_DM_SPI_FLASH
 	flash->write = spi_flash_cmd_write_ops;
 #if defined(CONFIG_SPI_FLASH_SST)
-	if (params->flags & SST_WP)
-		flash->write = sst_write_wp;
+	if (params->flags & SST_WR) {
+		if (flash->spi->op_mode_tx & SPI_OPM_TX_BP)
+			flash->write = sst_write_bp;
+		else
+			flash->write = sst_write_wp;
+	}
 #endif
 	flash->erase = spi_flash_cmd_erase_ops;
 	flash->read = spi_flash_cmd_read_ops;
include/spi.h +1 -0
index 5b78271..ec17bd0 100644
@@ -34,6 +34,7 @@
 
 /* SPI TX operation modes */
 #define SPI_OPM_TX_QPP		(1 << 0)
+#define SPI_OPM_TX_BP		(1 << 1)
 
 /* SPI RX operation modes */
 #define SPI_OPM_RX_AS		(1 << 0)
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 4/6 sf: Enable byte program support

Quoted 9 lines · Jagannadha Sutradharudu Teki

Enabled byte program support for sst flashes in sf.

Few controllers will only support BP, so this patch gives a tx transfer flag to set the BP so-that sf will operate on byte program transfer.

A new TX operation mode SPI_OPM_TX_BP is introduced for such SPI controller to use byte program op for SST flash.

Quoted 8 lines
---
 drivers/mtd/spi/sf_internal.h |  5 ++++-
 drivers/mtd/spi/sf_params.c   | 18 +++++++++---------
 drivers/mtd/spi/sf_probe.c    |  8 ++++++--
 include/spi.h                 |  1 +
 4 files changed, 20 insertions(+), 12 deletions(-)

Applied to u-boot-x86, thanks!

#9 lore raw

PATCH v2 5/6 x86: ich-spi: Set the rx operation mode for ich 7

In reply to Jagannadha Sutradharudu Teki

From: Bin Meng <[email protected]>

ICH 7 SPI controller only supports array read command (03h). Fast array read command (0Bh) is not supported.

---
 drivers/spi/ich.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/spi/ich.c +4 -0
index f5c6f3e..0ef8bd4 100644
@@ -141,6 +141,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	ich->slave.max_write_size = ctlr.databytes;
 	ich->speed = max_hz;
 
+	/* ICH 7 SPI controller only supports array read command */
+	if (ctlr.ich_version == 7)
+		ich->slave.op_mode_rx = SPI_OPM_RX_AS;
+
 	return &ich->slave;
 }
 
Signature · 1 line
1.9.1
#10 lore raw

PATCH v2 5/6 x86: ich-spi: Set the rx operation mode for ich 7

Quoted 5 lines · Jagannadha Sutradharudu Teki

From: Bin Meng <[email protected]>

ICH 7 SPI controller only supports array read command (03h). Fast array read command (0Bh) is not supported.

Quoted 7 lines
---
 drivers/spi/ich.c | 4 ++++
 1 file changed, 4 insertions(+)

Applied to u-boot-x86, thanks!

#11 lore raw

PATCH v2 6/6 x86: ich-spi: Set the tx operation mode for ich 7

In reply to Jagannadha Sutradharudu Teki

From: Bin Meng <[email protected]>

ICH 7 SPI controller only supports byte program (02h) for SST flash. Word program (ADh) is not supported.

---
 drivers/spi/ich.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/spi/ich.c +7 -2
index 0ef8bd4..d5cea39 100644
@@ -141,9 +141,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	ich->slave.max_write_size = ctlr.databytes;
 	ich->speed = max_hz;
 
-	/* ICH 7 SPI controller only supports array read command */
-	if (ctlr.ich_version == 7)
+	/*
+	 * ICH 7 SPI controller only supports array read command
+	 * and byte program command for SST flash
+	 */
+	if (ctlr.ich_version == 7) {
 		ich->slave.op_mode_rx = SPI_OPM_RX_AS;
+		ich->slave.op_mode_tx = SPI_OPM_TX_BP;
+	}
 
 	return &ich->slave;
 }
Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 6/6 x86: ich-spi: Set the tx operation mode for ich 7

Quoted 10 lines · Jagannadha Sutradharudu Teki

From: Bin Meng <[email protected]>

ICH 7 SPI controller only supports byte program (02h) for SST flash. Word program (ADh) is not supported.

---
 drivers/spi/ich.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Applied to u-boot-x86, thanks!

author
#13 lore raw

v2 cover sf: SST changes, Byte program

In reply to Jagannadha Sutradharudu Teki
Quoted 19 lines · Jagannadha Sutradharudu Teki

This patch-set added byte program support for sst flashes and some implementation changes in sf to support array slow and byte program specific controllers.

Changes for v2:
- commit message fixes

Bin Meng (3):
spi: sf: Support byte program for sst spi flash
x86: ich-spi: Set the rx operation mode for ich 7
x86: ich-spi: Set the tx operation mode for ich 7

Jagannadha Sutradharudu Teki (2):
sf: Fix look for the fastest read command
sf: Enable byte program support

Simon Glass (1):
spi: Fix flag collision for SST_WP

Quoted 7 lines
 drivers/mtd/spi/sf_internal.h |  22 ++++++---
 drivers/mtd/spi/sf_ops.c      |  31 +++++++++++++
 drivers/mtd/spi/sf_params.c   | 102 +++++++++++++++++++++---------------------
 drivers/mtd/spi/sf_probe.c    |   9 +++-
 drivers/spi/ich.c             |   9 ++++
 include/spi.h                 |   1 +
 6 files changed, 114 insertions(+), 60 deletions(-)

Bin, these will push as part of a PR - let me know for any missing's

Simon, any plan to take these on your branch or shall I send a PR from my side?

thanks!

Signature · 1 line
Jagan.
#14 lore raw

v2 cover sf: SST changes, Byte program

Hi Jagan,

Quoted 29 lines · Jagan Teki
Quoted 19 lines · Jagannadha Sutradharudu Teki

This patch-set added byte program support for sst flashes and some implementation changes in sf to support array slow and byte program specific controllers.

Changes for v2:
- commit message fixes

Bin Meng (3):
spi: sf: Support byte program for sst spi flash
x86: ich-spi: Set the rx operation mode for ich 7
x86: ich-spi: Set the tx operation mode for ich 7

Jagannadha Sutradharudu Teki (2):
sf: Fix look for the fastest read command
sf: Enable byte program support

Simon Glass (1):
spi: Fix flag collision for SST_WP

Quoted 7 lines
 drivers/mtd/spi/sf_internal.h |  22 ++++++---
 drivers/mtd/spi/sf_ops.c      |  31 +++++++++++++
 drivers/mtd/spi/sf_params.c   | 102 +++++++++++++++++++++---------------------
 drivers/mtd/spi/sf_probe.c    |   9 +++-
 drivers/spi/ich.c             |   9 ++++
 include/spi.h                 |   1 +
 6 files changed, 114 insertions(+), 60 deletions(-)
Quoted 1 line

Bin, these will push as part of a PR - let me know for any missing's

Looks good to me. Thanks for taking care of these.

Quoted 5 lines

Simon, any plan to take these on your branch or shall I send a PR from my side?

thanks!
--
Jagan.

Regards,
Bin

#15 lore raw

v2 cover sf: SST changes, Byte program

In reply to Jagan Teki

Hi Jagan,

Quoted 29 lines · Jagan Teki
Quoted 19 lines · Jagannadha Sutradharudu Teki

This patch-set added byte program support for sst flashes and some implementation changes in sf to support array slow and byte program specific controllers.

Changes for v2:
- commit message fixes

Bin Meng (3):
spi: sf: Support byte program for sst spi flash
x86: ich-spi: Set the rx operation mode for ich 7
x86: ich-spi: Set the tx operation mode for ich 7

Jagannadha Sutradharudu Teki (2):
sf: Fix look for the fastest read command
sf: Enable byte program support

Simon Glass (1):
spi: Fix flag collision for SST_WP

Quoted 7 lines
 drivers/mtd/spi/sf_internal.h |  22 ++++++---
 drivers/mtd/spi/sf_ops.c      |  31 +++++++++++++
 drivers/mtd/spi/sf_params.c   | 102 +++++++++++++++++++++---------------------
 drivers/mtd/spi/sf_probe.c    |   9 +++-
 drivers/spi/ich.c             |   9 ++++
 include/spi.h                 |   1 +
 6 files changed, 114 insertions(+), 60 deletions(-)
Quoted 3 lines

Bin, these will push as part of a PR - let me know for any missing's

Simon, any plan to take these on your branch or shall I send a PR from my side?

It applies cleanly for me, so I will pick up this series.

Regards,
Simon