sf: Add extended read commands support
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v6 1/12 sf: Add extended read commands support
Current sf uses FAST_READ command, this patch adds support to use the different/extended read command.
This implementation will determine the fastest command by taking the supported commands from the flash and the controller, controller is always been a priority.
--- drivers/mtd/spi/sf_internal.h | 2 + drivers/mtd/spi/sf_ops.c | 2 +- drivers/mtd/spi/sf_probe.c | 190 +++++++++++++++++++++++------------------- include/spi.h | 8 ++ include/spi_flash.h | 10 +++ 5 files changed, 126 insertions(+), 86 deletions(-)
drivers/mtd/spi/sf_internal.h +2 -0
@@ -36,6 +36,8 @@/* Read commands */ #define CMD_READ_ARRAY_SLOW 0x03#define CMD_READ_ARRAY_FAST 0x0b +#define CMD_READ_DUAL_OUTPUT_FAST 0x3b +#define CMD_READ_DUAL_IO_FAST 0xbb#define CMD_READ_ID 0x9f/* Bank addr access commands */
drivers/mtd/spi/sf_ops.c +1 -1
@@ -285,7 +285,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,return 0 ; } - cmd[0 ] =CMD_READ_ARRAY_FAST ; + cmd[0 ] = flash->read_cmd; cmd[4 ] =0x00 ;while (len) {
drivers/mtd/spi/sf_probe.c +105 -85
239 lines not on this page · raw message
include/spi.h +8 -0
@@ -31,6 +31,12 @@#define SPI_XFER_MMAP_END 0x10/* Memory Mapped End */ #define SPI_XFER_ONCE (SPI_XFER_BEGIN | SPI_XFER_END) +/* SPI RX operation modes */ +#define SPI_OPM_RX_AS 1 << 0 +#define SPI_OPM_RX_DOUT 1 << 1 +#define SPI_OPM_RX_DIO 1 << 2 +#define SPI_OPM_RX_EXTN SPI_OPM_RX_AS | SPI_OPM_RX_DOUT | SPI_OPM_RX_DIO +/* Header byte that marks the start of the message */ #define SPI_PREAMBLE_END_BYTE 0xec
@@ -43,6 +49,7 @@* * @bus: ID of the bus that the slave is attached to. * @cs: ID of the chip select connected to the slave. +* @op_mode_rx: SPI RX operation mode. * @wordlen: Size of SPI word in number of bits * @max_write_size: If non-zero, the maximum number of bytes which can * be written@once, excluding command bytes.
@@ -51,6 +58,7 @@struct spi_slave {unsigned int bus;unsigned int cs; +u8 op_mode_rx;unsigned int wordlen;unsigned int max_write_size;void *memory_map;
include/spi_flash.h +10 -0
@@ -19,6 +19,14 @@#include <linux/types.h> #include <linux/compiler.h> +/* Enum list - Extended read commands */ +enum spi_read_cmds { +ARRAY_SLOW =1 <<0 , +DUAL_OUTPUT_FAST =1 <<1 , +DUAL_IO_FAST =1 <<2 , +}; +#define RD_EXTN ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST +/** * struct spi_flash - SPI flash structure *
@@ -33,6 +41,7 @@* @bank_curr: Current flash bank * @poll_cmd: Poll cmd - for flash erase/program * @erase_cmd: Erase cmd 4K, 32K, 64K +* @read_cmd: Read cmd - Array Fast and Extn read * @memory_map: Address of read-only SPI flash access * @read: Flash read ops: Read len bytes@offset into buf * Supported cmds: Fast Array Read
@@ -57,6 +66,7 @@ struct spi_flash {#endif u8 poll_cmd;u8 erase_cmd; +u8 read_cmd;void *memory_map;int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf);
Signature · 1 line
1.8.3
PATCH v6 2/12 sf: Add quad read/write commands support
In reply to a message not in the archiveThis patch add quad commands support like
- QUAD_PAGE_PROGRAM => for write program
- QUAD_OUTPUT_FAST ->> for read program
--- drivers/mtd/spi/sf_internal.h | 2 + drivers/mtd/spi/sf_ops.c | 2 +- drivers/mtd/spi/sf_probe.c | 178 ++++++++++++++++++++++-------------------- include/spi.h | 9 ++- include/spi_flash.h | 11 ++- 5 files changed, 113 insertions(+), 89 deletions(-)
drivers/mtd/spi/sf_internal.h +2 -0
@@ -28,6 +28,7 @@#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
@@ -38,6 +39,7 @@#define CMD_READ_ARRAY_FAST 0x0b#define CMD_READ_DUAL_OUTPUT_FAST 0x3b#define CMD_READ_DUAL_IO_FAST 0xbb +#define CMD_READ_QUAD_OUTPUT_FAST 0x6b#define CMD_READ_ID 0x9f/* Bank addr access commands */
drivers/mtd/spi/sf_ops.c +1 -1
@@ -210,7 +210,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, page_size = flash->page_size; - cmd[0 ] =CMD_PAGE_PROGRAM ; + cmd[0 ] = flash->write_cmd;for (actual =0 ; actual < len; actual += chunk_len) {#ifdef CONFIG_SPI_FLASH_BAR ret =spi_flash_bank (flash, offset);
drivers/mtd/spi/sf_probe.c +93 -85
210 lines not on this page · raw message
include/spi.h +8 -1
@@ -31,11 +31,16 @@#define SPI_XFER_MMAP_END 0x10/* Memory Mapped End */ #define SPI_XFER_ONCE (SPI_XFER_BEGIN | SPI_XFER_END) +/* SPI TX operation modes */ +#define SPI_OPM_TX_QPP 1 << 0 +/* SPI RX operation modes */ #define SPI_OPM_RX_AS 1 << 0#define SPI_OPM_RX_DOUT 1 << 1#define SPI_OPM_RX_DIO 1 << 2 -#define SPI_OPM_RX_EXTN SPI_OPM_RX_AS | SPI_OPM_RX_DOUT | SPI_OPM_RX_DIO +#define SPI_OPM_RX_QOF 1 << 3 +#define SPI_OPM_RX_EXTN SPI_OPM_RX_AS | SPI_OPM_RX_DOUT | \ + SPI_OPM_RX_DIO | SPI_OPM_RX_QOF/* Header byte that marks the start of the message */ #define SPI_PREAMBLE_END_BYTE 0xec
@@ -50,6 +55,7 @@* @bus: ID of the bus that the slave is attached to. * @cs: ID of the chip select connected to the slave. * @op_mode_rx: SPI RX operation mode. +* @op_mode_tx: SPI TX operation mode. * @wordlen: Size of SPI word in number of bits * @max_write_size: If non-zero, the maximum number of bytes which can * be written@once, excluding command bytes.
@@ -59,6 +65,7 @@ struct spi_slave {unsigned int bus;unsigned int cs;u8 op_mode_rx; +u8 op_mode_tx;unsigned int wordlen;unsigned int max_write_size;void *memory_map;
include/spi_flash.h +9 -2
@@ -19,13 +19,18 @@#include <linux/types.h> #include <linux/compiler.h> -/* Enum list - Extended read commands */ +/* No enum list for write commands only QPP */ +#define WR_QPP 1 << 0 + +/* 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 , };#define RD_EXTN ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST +#define RD_FULL RD_EXTN | QUAD_OUTPUT_FAST/** * struct spi_flash - SPI flash structure
@@ -41,7 +46,8 @@ enum spi_read_cmds {* @bank_curr: Current flash bank * @poll_cmd: Poll cmd - for flash erase/program * @erase_cmd: Erase cmd 4K, 32K, 64K -* @read_cmd: Read cmd - Array Fast and Extn read +* @read_cmd: Read cmd - Array Fast, Extn read and quad read. +* @write_cmd: Write cmd - page and quad program. * @memory_map: Address of read-only SPI flash access * @read: Flash read ops: Read len bytes@offset into buf * Supported cmds: Fast Array Read
@@ -67,6 +73,7 @@ struct spi_flash {u8 poll_cmd;u8 erase_cmd;u8 read_cmd; +u8 write_cmd;void *memory_map;int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf);
Signature · 1 line
1.8.3
PATCH v6 3/12 sf: ops: Add configuration register writing support
In reply to a message not in the archiveThis patch provides support to program a flash config register.
Configuration register contains the control bits used to configure the different configurations and security features of a device.
--- drivers/mtd/spi/sf_ops.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/mtd/spi/sf_ops.c +24 -0
@@ -38,6 +38,30 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)return 0 ; } +static int spi_flash_cmd_write_config (struct spi_flash *flash,u8 cr) +{ +u8 data[2 ]; +u8 cmd; +int ret; + + cmd =CMD_READ_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , &data[0 ],1 ); +if (ret <0 ) { +debug ("SF: fail to read status register\n" ); +return ret; + } + + cmd =CMD_WRITE_STATUS ; + data[1 ] = cr; + ret =spi_flash_write_common (flash, &cmd,1 , &data,2 ); +if (ret) { +debug ("SF: fail to write config register\n" ); +return ret; + } + +return 0 ; +} +#ifdef CONFIG_SPI_FLASH_BAR static int spi_flash_cmd_bankaddr_write (struct spi_flash *flash,u8 bank_sel) {
Signature · 1 line
1.8.3
PATCH v6 4/12 sf: Set quad enable bit support
In reply to a message not in the archiveThis patch provides support to set the quad enable bit on flash.
quad enable bit needs to set before performing any quad IO operations on respective SPI flashes.
Currently added set quad enable bit for winbond and spansion flash devices. stmicro flash doesn't require to set as qeb is volatile. remaining flash devices support will add in future patches.
--- drivers/mtd/spi/sf_internal.h | 10 ++++++++-- drivers/mtd/spi/sf_ops.c | 26 ++++++++++++++++++++++++++ drivers/mtd/spi/sf_probe.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-)
drivers/mtd/spi/sf_internal.h +8 -2
@@ -12,6 +12,11 @@#define SPI_FLASH_16MB_BOUN 0x1000000 +/* CFI Manufacture ID's */ +#define SPI_FLASH_CFI_MFR_SPANSION 0x01 +#define SPI_FLASH_CFI_MFR_STMICRO 0x20 +#define SPI_FLASH_CFI_MFR_WINBOND 0xef +/* SECT flags */ #define SECT_4K (1 << 1)#define SECT_32K (1 << 2)
@@ -52,6 +57,7 @@/* Common status */ #define STATUS_WIP 0x01 +#define STATUS_QEB_WINSPAN (1 << 1)#define STATUS_PEC 0x80/* Flash timeout values */
@@ -93,8 +99,8 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);/* Program the status register */ int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); -/* Set quad enbale bit */ -int spi_flash_set_qeb (struct spi_flash *flash); +/* Set quad enbale bit for winbond and spansion flashes */ +int spi_flash_set_qeb_winspan (struct spi_flash *flash);/* Enable writing on the SPI flash */ static inline int spi_flash_cmd_write_enable (struct spi_flash *flash)
drivers/mtd/spi/sf_ops.c +26 -0
@@ -38,6 +38,7 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)return 0 ; } +#if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND )static int spi_flash_cmd_write_config (struct spi_flash *flash,u8 cr) {u8 data[2 ];
@@ -62,6 +63,31 @@ static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)return 0 ; } +int spi_flash_set_qeb_winspan (struct spi_flash *flash) +{ +u8 qeb_status; +u8 cmd; +int ret; + + cmd =CMD_READ_CONFIG ; + ret =spi_flash_read_common (flash, &cmd,1 , &qeb_status,1 ); +if (ret <0 ) { +debug ("SF: fail to read config register\n" ); +return ret; + } + +if (qeb_status &STATUS_QEB_WINSPAN ) { +debug ("SF: Quad enable bit is already set\n" ); + }else { + ret =spi_flash_cmd_write_config (flash,STATUS_QEB_WINSPAN ); +if (ret <0 ) +return ret; + } + +return ret; +} +#endif +#ifdef CONFIG_SPI_FLASH_BAR static int spi_flash_cmd_bankaddr_write (struct spi_flash *flash,u8 bank_sel) {
drivers/mtd/spi/sf_probe.c +28 -0
@@ -165,6 +165,25 @@ static u8 spi_read_cmds_array[] = { CMD_READ_QUAD_OUTPUT_FAST, }; +static int spi_flash_set_qeb (struct spi_flash *flash,u8 idcode0) +{ +switch (idcode0) { +#if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) +case SPI_FLASH_CFI_MFR_SPANSION : +case SPI_FLASH_CFI_MFR_WINBOND : +return spi_flash_set_qeb_winspan (flash); +#endif +#ifdef CONFIG_SPI_FLASH_STMICRO +case SPI_FLASH_CFI_MFR_STMICRO : +debug ("SF: QEB is volatile for %02x flash\n" , idcode0); +return 0 ; +#endif +default : +printf ("SF: Need set QEB func for %02x flash\n" , idcode0); +return -1 ; + } +} +static struct spi_flash *spi_flash_validate_params (struct spi_slave *spi,u8 *idcode) {
@@ -250,6 +269,15 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,/* Go for default supported write cmd */ flash->write_cmd =CMD_PAGE_PROGRAM ; +/* Set the quad enable bit - only for quad commands */ +if ((flash->read_cmd ==CMD_READ_QUAD_OUTPUT_FAST ) || + (flash->write_cmd ==CMD_QUAD_PAGE_PROGRAM )) { +if (spi_flash_set_qeb (flash, idcode[0 ])) { +debug ("SF: Fail to set QEB for %02x\n" , idcode[0 ]); +return NULL ; + } + } +/* Poll cmd seclection */ flash->poll_cmd =CMD_READ_STATUS ;#ifdef CONFIG_SPI_FLASH_STMICRO
Signature · 1 line
1.8.3
PATCH v6 5/12 sf: probe: Enable RD_FULL and WR_QPP
In reply to a message not in the archiveThis patch enabled RD_FULL and WR_QPP for supported flashes in micron, winbond and spansion.
Remaining parts will be add in future patches.
--- drivers/mtd/spi/sf_probe.c | 60 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/mtd/spi/sf_probe.c +30 -30
@@ -78,15 +78,15 @@ static const struct spi_flash_params spi_flash_params_table[] = { {"S25FL016A", 0x010214, 0x0, 64 * 1024, 32, 0, 0}, {"S25FL032A", 0x010215, 0x0, 64 * 1024, 64, 0, 0}, {"S25FL064A", 0x010216, 0x0, 64 * 1024, 128, 0, 0}, - {"S25FL128P_256K", 0x012018, 0x0300, 256 * 1024, 64, 0, 0}, - {"S25FL128P_64K", 0x012018, 0x0301, 64 * 1024, 256, 0, 0}, - {"S25FL032P", 0x010215, 0x4d00, 64 * 1024, 64, 0, 0}, - {"S25FL064P", 0x010216, 0x4d00, 64 * 1024, 128, 0, 0}, - {"S25FL128S_64K", 0x012018, 0x4d01, 64 * 1024, 256, 0, 0}, + {"S25FL128P_256K", 0x012018, 0x0300, 256 * 1024, 64, RD_FULL, WR_QPP}, + {"S25FL128P_64K", 0x012018, 0x0301, 64 * 1024, 256, RD_FULL, WR_QPP}, + {"S25FL032P", 0x010215, 0x4d00, 64 * 1024, 64, RD_FULL, WR_QPP}, + {"S25FL064P", 0x010216, 0x4d00, 64 * 1024, 128, RD_FULL, WR_QPP}, + {"S25FL128S_64K", 0x012018, 0x4d01, 64 * 1024, 256, RD_FULL, WR_QPP}, {"S25FL256S_256K", 0x010219, 0x4d00, 64 * 1024, 512, RD_FULL, WR_QPP}, {"S25FL256S_64K", 0x010219, 0x4d01, 64 * 1024, 512, RD_FULL, WR_QPP}, - {"S25FL512S_256K", 0x010220, 0x4d00, 64 * 1024, 1024, 0, 0}, - {"S25FL512S_64K", 0x010220, 0x4d01, 64 * 1024, 1024, 0, 0}, + {"S25FL512S_256K", 0x010220, 0x4d00, 64 * 1024, 1024, RD_FULL, WR_QPP}, + {"S25FL512S_64K", 0x010220, 0x4d01, 64 * 1024, 1024, RD_FULL, WR_QPP}, #endif #ifdef CONFIG_SPI_FLASH_STMICRO /* STMICRO */ {"M25P10", 0x202011, 0x0, 32 * 1024, 4, 0, 0},
@@ -97,18 +97,18 @@ static const struct spi_flash_params spi_flash_params_table[] = { {"M25P32", 0x202016, 0x0, 64 * 1024, 64, 0, 0}, {"M25P64", 0x202017, 0x0, 64 * 1024, 128, 0, 0}, {"M25P128", 0x202018, 0x0, 256 * 1024, 64, 0, 0}, - {"N25Q32", 0x20ba16, 0x0, 64 * 1024, 64, 0, SECT_4K}, - {"N25Q32A", 0x20bb16, 0x0, 64 * 1024, 64, 0, SECT_4K}, - {"N25Q64", 0x20ba17, 0x0, 64 * 1024, 128, 0, SECT_4K}, - {"N25Q64A", 0x20bb17, 0x0, 64 * 1024, 128, 0, SECT_4K}, - {"N25Q128", 0x20ba18, 0x0, 64 * 1024, 256, 0, SECT_4K}, - {"N25Q128A", 0x20bb18, 0x0, 64 * 1024, 256, 0, SECT_4K}, - {"N25Q256", 0x20ba19, 0x0, 64 * 1024, 512, 0, SECT_4K}, - {"N25Q256A", 0x20bb19, 0x0, 64 * 1024, 512, 0, SECT_4K}, - {"N25Q512", 0x20ba20, 0x0, 64 * 1024, 1024, 0, E_FSR | SECT_4K}, - {"N25Q512A", 0x20bb20, 0x0, 64 * 1024, 1024, 0, E_FSR | SECT_4K}, - {"N25Q1024", 0x20ba21, 0x0, 64 * 1024, 2048, 0, E_FSR | SECT_4K}, - {"N25Q1024A", 0x20bb21, 0x0, 64 * 1024, 2048, 0, E_FSR | SECT_4K}, + {"N25Q32", 0x20ba16, 0x0, 64 * 1024, 64, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q32A", 0x20bb16, 0x0, 64 * 1024, 64, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q64", 0x20ba17, 0x0, 64 * 1024, 128, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q64A", 0x20bb17, 0x0, 64 * 1024, 128, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q128", 0x20ba18, 0x0, 64 * 1024, 256, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q128A", 0x20bb18, 0x0, 64 * 1024, 256, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q256", 0x20ba19, 0x0, 64 * 1024, 512, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q256A", 0x20bb19, 0x0, 64 * 1024, 512, RD_FULL, WR_QPP | SECT_4K}, + {"N25Q512", 0x20ba20, 0x0, 64 * 1024, 1024, RD_FULL, WR_QPP | E_FSR | SECT_4K}, + {"N25Q512A", 0x20bb20, 0x0, 64 * 1024, 1024, RD_FULL, WR_QPP | E_FSR | SECT_4K}, + {"N25Q1024", 0x20ba21, 0x0, 64 * 1024, 2048, RD_FULL, WR_QPP | E_FSR | SECT_4K}, + {"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, 0, SECT_4K | SST_WP},
@@ -130,17 +130,17 @@ static const struct spi_flash_params spi_flash_params_table[] = { {"W25X16", 0xef3015, 0x0, 64 * 1024, 32, 0, SECT_4K}, {"W25X32", 0xef3016, 0x0, 64 * 1024, 64, 0, SECT_4K}, {"W25X64", 0xef3017, 0x0, 64 * 1024, 128, 0, SECT_4K}, - {"W25Q80BL", 0xef4014, 0x0, 64 * 1024, 16, 0, SECT_4K}, - {"W25Q16CL", 0xef4015, 0x0, 64 * 1024, 32, 0, SECT_4K}, - {"W25Q32BV", 0xef4016, 0x0, 64 * 1024, 64, 0, SECT_4K}, - {"W25Q64CV", 0xef4017, 0x0, 64 * 1024, 128, 0, SECT_4K}, - {"W25Q128BV", 0xef4018, 0x0, 64 * 1024, 256, 0, SECT_4K}, - {"W25Q256", 0xef4019, 0x0, 64 * 1024, 512, 0, SECT_4K}, - {"W25Q80BW", 0xef5014, 0x0, 64 * 1024, 16, 0, SECT_4K}, - {"W25Q16DW", 0xef6015, 0x0, 64 * 1024, 32, 0, SECT_4K}, - {"W25Q32DW", 0xef6016, 0x0, 64 * 1024, 64, 0, SECT_4K}, - {"W25Q64DW", 0xef6017, 0x0, 64 * 1024, 128, 0, SECT_4K}, - {"W25Q128FW", 0xef6018, 0x0, 64 * 1024, 256, 0, SECT_4K}, + {"W25Q80BL", 0xef4014, 0x0, 64 * 1024, 16, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q16CL", 0xef4015, 0x0, 64 * 1024, 32, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q32BV", 0xef4016, 0x0, 64 * 1024, 64, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q64CV", 0xef4017, 0x0, 64 * 1024, 128, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q128BV", 0xef4018, 0x0, 64 * 1024, 256, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q256", 0xef4019, 0x0, 64 * 1024, 512, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q80BW", 0xef5014, 0x0, 64 * 1024, 16, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q16DW", 0xef6015, 0x0, 64 * 1024, 32, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q32DW", 0xef6016, 0x0, 64 * 1024, 64, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q64DW", 0xef6017, 0x0, 64 * 1024, 128, RD_FULL, WR_QPP | SECT_4K}, + {"W25Q128FW", 0xef6018, 0x0, 64 * 1024, 256, RD_FULL, WR_QPP | SECT_4K}, #endif /* * Note:
Signature · 1 line
1.8.3
PATCH v6 6/12 sf: Separate the flash params table
In reply to a message not in the archiveMoved the flash params table from sf_probe.c and placed on to sf_params.c, hence flash params file will alter based on new addons.
--- drivers/mtd/spi/Makefile | 4 +- drivers/mtd/spi/sf_params.c | 130 +++++++++++++++++++++++++++++++++++++++ drivers/mtd/spi/sf_probe.c | 146 +------------------------------------------- include/spi_flash.h | 23 +++++++ 4 files changed, 158 insertions(+), 145 deletions(-) create mode 100644 drivers/mtd/spi/sf_params.c
drivers/mtd/spi/Makefile +2 -2
@@ -10,8 +10,8 @@ obj-$(CONFIG_SPL_SPI_LOAD) += spi_spl_load.o obj-$(CONFIG_SPL_SPI_BOOT) += fsl_espi_spl.o endif -obj-$(CONFIG_CMD_SF) += sf.o -obj-$(CONFIG_SPI_FLASH) += sf_probe.o sf_ops.o +obj-$(CONFIG_CMD_SF) += sf.o +obj-$(CONFIG_SPI_FLASH) += sf_params.o sf_probe.o sf_ops.o obj-$(CONFIG_SPI_FRAM_RAMTRON) += ramtron.o obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o obj-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
drivers/mtd/spi/sf_params.c new file +130 -0
130 lines not on this page · raw message
drivers/mtd/spi/sf_probe.c +3 -143
168 lines not on this page · raw message
include/spi_flash.h +23 -0
@@ -33,6 +33,29 @@ enum spi_read_cmds {#define RD_FULL RD_EXTN | QUAD_OUTPUT_FAST/** +* struct spi_flash_params - SPI/QSPI flash device params structure +* +* @name: Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO]) +* @jedec: Device jedec ID (0x[1byte_manuf_id][2byte_dev_id]) +* @ext_jedec: Device ext_jedec ID +* @sector_size: Sector size of this device +* @nr_sectors: No.of sectors on this device +* @e_rd_cmd: Enum list for read commands +* @flags: Importent param, for flash specific behaviour +*/ +struct spi_flash_params { +const char *name; +u32 jedec; +u16 ext_jedec; +u32 sector_size; +u32 nr_sectors; +u8 e_rd_cmd; +u16 flags; +}; + +extern const struct spi_flash_params spi_flash_params_table[]; + +/** * struct spi_flash - SPI flash structure * * @spi: SPI slave
Signature · 1 line
1.8.3
PATCH v6 7/12 sf: Add QUAD_IO_FAST read support
In reply to a message not in the archiveThis patch adds support QUAD_IO_FAST read command.
--- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_probe.c | 2 ++ include/spi.h | 4 +++- include/spi_flash.h | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-)
drivers/mtd/spi/sf_internal.h +1 -0
@@ -45,6 +45,7 @@#define CMD_READ_DUAL_OUTPUT_FAST 0x3b#define CMD_READ_DUAL_IO_FAST 0xbb#define CMD_READ_QUAD_OUTPUT_FAST 0x6b +#define CMD_READ_QUAD_IO_FAST 0xeb#define CMD_READ_ID 0x9f/* Bank addr access commands */
drivers/mtd/spi/sf_probe.c +2 -0
@@ -25,6 +25,7 @@ static u8 spi_read_cmds_array[] = {CMD_READ_DUAL_OUTPUT_FAST ,CMD_READ_DUAL_IO_FAST ,CMD_READ_QUAD_OUTPUT_FAST , + CMD_READ_QUAD_IO_FAST, };static int spi_flash_set_qeb (struct spi_flash *flash,u8 idcode0)
@@ -131,6 +132,7 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,/* Set the quad enable bit - only for quad commands */ if ((flash->read_cmd ==CMD_READ_QUAD_OUTPUT_FAST ) || + (flash->read_cmd ==CMD_READ_QUAD_IO_FAST ) || (flash->write_cmd ==CMD_QUAD_PAGE_PROGRAM )) {if (spi_flash_set_qeb (flash, idcode[0 ])) {debug ("SF: Fail to set QEB for %02x\n" , idcode[0 ]);
include/spi.h +3 -1
@@ -39,8 +39,10 @@#define SPI_OPM_RX_DOUT 1 << 1#define SPI_OPM_RX_DIO 1 << 2#define SPI_OPM_RX_QOF 1 << 3 +#define SPI_OPM_RX_QIOF 1 << 4#define SPI_OPM_RX_EXTN SPI_OPM_RX_AS | SPI_OPM_RX_DOUT | \ - SPI_OPM_RX_DIO | SPI_OPM_RX_QOF + SPI_OPM_RX_DIO | SPI_OPM_RX_QOF | \ + SPI_OPM_RX_QIOF/* Header byte that marks the start of the message */ #define SPI_PREAMBLE_END_BYTE 0xec
include/spi_flash.h +2 -1
@@ -28,9 +28,10 @@ enum spi_read_cmds {DUAL_OUTPUT_FAST =1 <<1 ,DUAL_IO_FAST =1 <<2 ,QUAD_OUTPUT_FAST =1 <<3 , + QUAD_IO_FAST = 1 << 4, };#define RD_EXTN ARRAY_SLOW | DUAL_OUTPUT_FAST | DUAL_IO_FAST -#define RD_FULL RD_EXTN | QUAD_OUTPUT_FAST +#define RD_FULL RD_EXTN | QUAD_OUTPUT_FAST | QUAD_IO_FAST/** * struct spi_flash_params - SPI/QSPI flash device params structure
Signature · 1 line
1.8.3
PATCH v6 8/12 sf: Discover read dummy_cycles
In reply to a message not in the archiveDiscovered the read dummy_cycles based on the configured read command.
--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)
drivers/mtd/spi/sf_internal.h +2 -0
@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */
drivers/mtd/spi/sf_ops.c +6 -4
@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h>
@@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,int spi_flash_cmd_erase_ops (struct spi_flash *flash,u32 offset,size_t len) {u32 erase_size; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; erase_size = flash->erase_size;
@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; page_size = flash->page_size;
@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,int spi_flash_cmd_read_ops (struct spi_flash *flash,u32 offset,size_t len,void *data) { -u8 cmd[5 ], bank_sel =0 ; +u8 *cmd, bank_sel =0 ;u32 remain_len, read_len;int ret =-1 ;
@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,return 0 ; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) {#ifdef CONFIG_SPI_FLASH_BAR
drivers/mtd/spi/sf_probe.c +12 -0
@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } } +/* Read dummy cycles */ +switch (flash->read_cmd) { +case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +/* Poll cmd seclection */ flash->poll_cmd =CMD_READ_STATUS ;#ifdef CONFIG_SPI_FLASH_STMICRO
include/spi_flash.h +2 -0
@@ -72,6 +72,7 @@ extern const struct spi_flash_params spi_flash_params_table[];* @erase_cmd: Erase cmd 4K, 32K, 64K * @read_cmd: Read cmd - Array Fast, Extn read and quad read. * @write_cmd: Write cmd - page and quad program. +* @dummy_cycles: Dummy cycles for read operation. * @memory_map: Address of read-only SPI flash access * @read: Flash read ops: Read len bytes at offset into buf * Supported cmds: Fast Array Read
@@ -98,6 +99,7 @@ struct spi_flash {u8 erase_cmd;u8 read_cmd;u8 write_cmd; +u8 dummy_cycles;void *memory_map;int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf);
Signature · 1 line
1.8.3
PATCH v6 8/12 sf: Discover read dummy_cycles
Quoted 84 lines · Jagannadha Sutradharudu Teki
Discovered the read
dummy_cyclesbased on the configured read command.Signed-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)drivers/mtd/spi/sf_internal.h +2
-0@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */ drivers/mtd/spi/sf_ops.c +6
-4@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h> @@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,int spi_flash_cmd_erase_ops (struct spi_flash *flash,u32 offset,size_t len) {u32 erase_size; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; erase_size = flash->erase_size;@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; page_size = flash->page_size;@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,int spi_flash_cmd_read_ops (struct spi_flash *flash,u32 offset,size_t len,void *data) { -u8 cmd[5 ], bank_sel =0 ; +u8 *cmd, bank_sel =0 ;u32 remain_len, read_len;int ret =-1 ;@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,return 0 ; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) {#ifdef CONFIG_SPI_FLASH_BAR drivers/mtd/spi/sf_probe.c +2
-0@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } } +/* Read dummy cycles */ +switch (flash->read_cmd) {
drivers/mtd/spi/sf_probe.c static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, · line 154
Quoted 10 lines
drivers/mtd/spi/sf_probe.c +10
-0+case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +
what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?
Quoted 23 lines
drivers/mtd/spi/sf_probe.c +0
-0/* Poll cmd seclection */ flash->poll_cmd =CMD_READ_STATUS ;#ifdef CONFIG_SPI_FLASH_STMICRO include/spi_flash.h +2
-0@@ -72,6 +72,7 @@ extern const struct spi_flash_params spi_flash_params_table[];* @erase_cmd: Erase cmd 4K, 32K, 64K * @read_cmd: Read cmd - Array Fast, Extn read and quad read. * @write_cmd: Write cmd - page and quad program. +* @dummy_cycles: Dummy cycles for read operation. * @memory_map: Address of read-only SPI flash access * @read: Flash read ops: Read len bytes at offset into buf * Supported cmds: Fast Array Read @@ -98,6 +99,7 @@ struct spi_flash {u8 erase_cmd;u8 read_cmd;u8 write_cmd; +u8 dummy_cycles;void *memory_map;int (*read)(struct spi_flash *flash,u32 offset,size_t len,void *buf);
PATCH v6 8/12 sf: Discover read dummy_cycles
Hi Sourav,
Quoted 90 lines · Sourav Poddar
Quoted 89 lines · Jagannadha Sutradharudu Teki
Discovered the read
dummy_cyclesbased on the configured read command.Signed-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)drivers/mtd/spi/sf_internal.h +2
-0@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */ drivers/mtd/spi/sf_ops.c +2
-1@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h> @@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) { u32 erase_size; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;erase_size = flash->erase_size;drivers/mtd/spi/sf_ops.c +1
-1@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;page_size = flash->page_size;drivers/mtd/spi/sf_ops.c +3
-2@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, size_t len, void *data) { - u8 cmd[5], bank_sel = 0; + u8 *cmd, bank_sel = 0;u32 remain_len, read_len;int ret =-1 ;@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash,u32 offset, return 0; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) {#ifdef CONFIG_SPI_FLASH_BARdrivers/mtd/spi/sf_probe.c +0
-0@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } }
Quoted 16 lines
drivers/mtd/spi/sf_probe.c static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, · line 154
Quoted 12 lines
drivers/mtd/spi/sf_probe.c +12
-0+/* Read dummy cycles */ +switch (flash->read_cmd) { +case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?
Yes- Actually i miss used the names here.
These are dummy_byte_count
Ex: Except fast reads (array, dual and quad fast)dummy_byte_count = dummy_cycles * no.of lines
dual i/o (4 dummy_cycles) - 4 * 2 = 1 dummy_byte
quad i/o (4 dummy_cycles) - 4 * 4 = 2 dummy_byte
fast, dual and quad fast have 8 dummy_cycles means 1 byte dummy the reason why I am not including
no.of lines here is irrespective of fast(1 line), dual(2 lines) and quad(4 lines) only data can travel among the difference lines but the cmd,inst, dummy can travel only on single line. this can be opposite in i/o commands.
Hope you understand - I just said based on my knowledge.
I will change the dummy_cycles into dummy_bytes - nevertheless everything same.
Signature · 2 lines
Thanks, Jagan.
PATCH v6 8/12 sf: Discover read dummy_cycles
Quoted 107 lines · Jagan Teki
Hi Sourav,
Quoted 89 lines · Sourav Poddar
Quoted 88 lines · Jagannadha Sutradharudu Teki
Discovered the read
dummy_cyclesbased on the configured read command.Signed-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)drivers/mtd/spi/sf_internal.h +2
-0@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */ drivers/mtd/spi/sf_ops.c +2
-1@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h> @@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) { u32 erase_size; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;erase_size = flash->erase_size;drivers/mtd/spi/sf_ops.c +1
-1@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;page_size = flash->page_size;drivers/mtd/spi/sf_ops.c +3
-2@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, size_t len, void *data) { - u8 cmd[5], bank_sel = 0; + u8 *cmd, bank_sel = 0;u32 remain_len, read_len;int ret =-1 ;@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash,u32 offset, return 0; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) {#ifdef CONFIG_SPI_FLASH_BARdrivers/mtd/spi/sf_probe.c +0
-0@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } }Quoted 15 lines
drivers/mtd/spi/sf_probe.c static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, · line 154
Quoted 12 lines
drivers/mtd/spi/sf_probe.c +12
-0+/* Read dummy cycles */ +switch (flash->read_cmd) { +case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?
Quoted 8 lines
Yes- Actually i miss used the names here.
These aredummy_byte_countEx: Except fast reads (array, dual and quad fast)
dummy_byte_count=dummy_cycles* no.of lines
dual i/o (4dummy_cycles) - 4 * 2 = 1dummy_byte
quad i/o (4dummy_cycles) - 4 * 4 = 2dummy_byte
is this calculation documented in any of the flash sheet?
Quoted 10 lines
fast, dual and quad fast have 8
dummy_cyclesmeans 1 byte dummy the reason why I am not including
no.of lines here is irrespective of fast(1 line), dual(2 lines) and quad(4 lines) only data can travel among the difference lines but the cmd,inst, dummy can travel only on single line. this can be opposite in i/o commands.Hope you understand - I just said based on my knowledge.
I will change thedummy_cyclesintodummy_bytes- nevertheless everything same.
PATCH v6 8/12 sf: Discover read dummy_cycles
Quoted 119 lines · Sourav Poddar
Quoted 118 lines · Jagan Teki
Hi Sourav,
Quoted 93 lines · Sourav Poddar
Quoted 91 lines · Jagannadha Sutradharudu Teki
Discovered the read
dummy_cyclesbased on the configured read command.Signed-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)drivers/mtd/spi/sf_internal.h +2
-0@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */ drivers/mtd/spi/sf_ops.c +1
-0@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h> @@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd, int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset,
size_t
len){ u32 erase_size;drivers/mtd/spi/sf_ops.c +2
-2-u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; erase_size = flash->erase_size;@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;page_size = flash->page_size;drivers/mtd/spi/sf_ops.c +3
-2@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, size_t len, void *data) { - u8 cmd[5], bank_sel = 0; + u8 *cmd, bank_sel = 0;u32 remain_len, read_len;int ret =-1 ;@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash,u32 offset, return 0; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) {#ifdef CONFIG_SPI_FLASH_BARdrivers/mtd/spi/sf_probe.c +0
-0@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } }Quoted 16 lines
drivers/mtd/spi/sf_probe.c static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, · line 154
Quoted 12 lines
drivers/mtd/spi/sf_probe.c +12
-0+/* Read dummy cycles */ +switch (flash->read_cmd) { +case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?Yes- Actually i miss used the names here.
These aredummy_byte_count
Quoted 6 lines
Quoted 5 lines
Ex: Except fast reads (array, dual and quad fast)
dummy_byte_count=dummy_cycles* no.of lines
dual i/o (4dummy_cycles) - 4 * 2 = 1dummy_byte
quad i/o (4dummy_cycles) - 4 * 4 = 2dummy_byteis this calculation documented in any of the flash sheet?
I haven't see the exact calculation but ie. how the I/O operation usually works. quad read - cmd, 3byte_inst, 1 dummy_byte(8 dummy_cycles) goes on single line and data goes in 4 lines
quad i/o - except cmd(1 lines) remaining goes in 4 lines.
Quoted 13 lines
Quoted 12 lines
fast, dual and quad fast have 8
dummy_cyclesmeans 1 byte dummy the reason why I am not including
no.of lines here is irrespective of fast(1 line), dual(2 lines) and quad(4 lines) only data can travel among the difference lines but the cmd,inst, dummy can travel only on single line. this can be opposite in i/o commands.Hope you understand - I just said based on my knowledge.
I will change thedummy_cyclesintodummy_bytes- nevertheless everything same.
Signature · 2 lines
Thanks, Jagan.
PATCH v6 8/12 sf: Discover read dummy_cycles
Quoted 120 lines · Jagan Teki
Quoted 119 lines · Sourav Poddar
Quoted 118 lines · Jagan Teki
Hi Sourav,
Quoted 91 lines · Sourav Poddar
Quoted 90 lines · Jagannadha Sutradharudu Teki
Discovered the read
dummy_cyclesbased on the configured read command.Signed-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)drivers/mtd/spi/sf_internal.h +2
-0@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */ drivers/mtd/spi/sf_ops.c +1
-0@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h> @@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd, int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset,
size_t
len){ u32 erase_size;drivers/mtd/spi/sf_ops.c +2
-2-u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; erase_size = flash->erase_size;@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;page_size = flash->page_size;drivers/mtd/spi/sf_ops.c +3
-2@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, size_t len, void *data) { - u8 cmd[5], bank_sel = 0; + u8 *cmd, bank_sel = 0;u32 remain_len, read_len;int ret =-1 ;@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash,u32 offset, return 0; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) {#ifdef CONFIG_SPI_FLASH_BARdrivers/mtd/spi/sf_probe.c +0
-0@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } }Quoted 15 lines
drivers/mtd/spi/sf_probe.c static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, · line 154
Quoted 12 lines
drivers/mtd/spi/sf_probe.c +12
-0+/* Read dummy cycles */ +switch (flash->read_cmd) { +case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?Yes- Actually i miss used the names here.
These aredummy_byte_countEx: Except fast reads (array, dual and quad fast)
dummy_byte_count=dummy_cycles* no.of lines
dual i/o (4dummy_cycles) - 4 * 2 = 1dummy_byte
quad i/o (4dummy_cycles) - 4 * 4 = 2dummy_byte
Quoted 6 lines
Quoted 1 line
is this calculation documented in any of the flash sheet?
I haven't see the exact calculation but ie. how the I/O operation usually works. quad read - cmd, 3byte_inst, 1
dummy_byte(8 dummy_cycles)goes on single line and data goes in 4 lines
quad i/o - except cmd(1 lines) remaining goes in 4 lines.
Ok, got the point.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
fast, dual and quad fast have 8
dummy_cyclesmeans 1 byte dummy the reason why I am not including
no.of lines here is irrespective of fast(1 line), dual(2 lines) and quad(4 lines) only data can travel among the difference lines but the cmd,inst, dummy can travel only on single line. this can be opposite in i/o commands.Hope you understand - I just said based on my knowledge.
I will change thedummy_cyclesintodummy_bytes- nevertheless everything same.
PATCH v6 8/12 sf: Discover read dummy_cycles
Quoted 135 lines · Sourav Poddar
Quoted 134 lines · Jagan Teki
Quoted 130 lines · Sourav Poddar
Quoted 119 lines · Jagan Teki
Hi Sourav,
Quoted 97 lines · Sourav Poddar
Quoted 94 lines · Jagannadha Sutradharudu Teki
Discovered the read
dummy_cyclesbased on the configured read command.Signed-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 10 ++++++---- drivers/mtd/spi/sf_probe.c | 12 ++++++++++++ include/spi_flash.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)drivers/mtd/spi/sf_internal.h +2
-0@@ -10,6 +10,8 @@#ifndef _SF_INTERNAL_H_#define _SF_INTERNAL_H_ +#define SPI_FLASH_3B_ADDR_LEN 3 +#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000/* CFI Manufacture ID's */ drivers/mtd/spi/sf_ops.c +1
-0@@ -9,6 +9,7 @@*/ #include <common.h> +#include <malloc.h> #include <spi.h> #include <spi_flash.h> #include <watchdog.h> @@ -216,7 +217,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd, int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset,
size_t
len){ u32 erase_size;drivers/mtd/spi/sf_ops.c +2
-2-u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ; erase_size = flash->erase_size;@@ -255,7 +256,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, {unsigned long byte_addr, page_size;size_t chunk_len, actual; -u8 cmd[4 ]; +u8 cmd[SPI_FLASH_CMD_LEN ];int ret =-1 ;page_size = flash->page_size;drivers/mtd/spi/sf_ops.c +3
-2@@ -317,7 +318,7 @@ int spi_flash_read_common(struct spi_flash *flash,const u8 *cmd, int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, size_t len, void *data) { - u8 cmd[5], bank_sel = 0; + u8 *cmd, bank_sel = 0;u32 remain_len, read_len;int ret =-1 ;@@ -335,8 +336,9 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, return 0; } + cmd =malloc (SPI_FLASH_CMD_LEN + flash->dummy_cycles); +memset (cmd,0 ,SPI_FLASH_CMD_LEN + flash->dummy_cycles); cmd[0 ] = flash->read_cmd; - cmd[4 ] =0x00 ;while (len) { #ifdef CONFIG_SPI_FLASH_BARdrivers/mtd/spi/sf_probe.c +0
-0@@ -140,6 +140,18 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, } }Quoted 16 lines
drivers/mtd/spi/sf_probe.c static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, · line 154
Quoted 12 lines
drivers/mtd/spi/sf_probe.c +12
-0+/* Read dummy cycles */ +switch (flash->read_cmd) { +case CMD_READ_QUAD_IO_FAST : + flash->dummy_cycles =2 ; +break ; +case CMD_READ_ARRAY_SLOW : + flash->dummy_cycles =0 ; +break ; +default : + flash->dummy_cycles =1 ; + } +what about dummy cycles for dual i/o(0xbb), it has 4 clock bit dummy cycles(macronix), so
by your code you keep it to 1(8 bit) dummy cycle. ?Quoted 8 lines
Yes- Actually i miss used the names here.
These aredummy_byte_countEx: Except fast reads (array, dual and quad fast)
dummy_byte_count=dummy_cycles* no.of lines
dual i/o (4dummy_cycles) - 4 * 2 = 1dummy_byte
quad i/o (4dummy_cycles) - 4 * 4 = 2dummy_byteis this calculation documented in any of the flash sheet?
Quoted 7 lines
Quoted 6 lines
I haven't see the exact calculation but ie. how the I/O operation usually works.
quad read - cmd, 3byte_inst, 1dummy_byte(8 dummy_cycles)goes on single line and data goes in 4 lines
quad i/o - except cmd(1 lines) remaining goes in 4 lines.Ok, got the point.
Anyway I can add the comments on to of this code.
Thanks for notice.
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
fast, dual and quad fast have 8
dummy_cyclesmeans 1 byte dummy the reason why I am not including
no.of lines here is irrespective of fast(1 line), dual(2 lines) and quad(4 lines) only data can travel among the difference lines but the cmd,inst, dummy can travel only on single line. this can be opposite in i/o commands.Hope you understand - I just said based on my knowledge. I will change the
dummy_cyclesintodummy_bytes- nevertheless everything
same.
Signature · 2 lines
Thanks, Jagan.
PATCH v6 9/12 sf: Add macronix set QEB support
In reply to a message not in the archiveThis patch adds set QEB support for macronix flash devices which are trying to program/read quad operations.
--- drivers/mtd/spi/sf_internal.h | 5 +++++ drivers/mtd/spi/sf_ops.c | 26 ++++++++++++++++++++++++++ drivers/mtd/spi/sf_probe.c | 4 ++++ 3 files changed, 35 insertions(+)
drivers/mtd/spi/sf_internal.h +5 -0
@@ -17,6 +17,7 @@/* CFI Manufacture ID's */ #define SPI_FLASH_CFI_MFR_SPANSION 0x01#define SPI_FLASH_CFI_MFR_STMICRO 0x20 +#define SPI_FLASH_CFI_MFR_MACRONIX 0xc2#define SPI_FLASH_CFI_MFR_WINBOND 0xef/* SECT flags */
@@ -61,6 +62,7 @@/* Common status */ #define STATUS_WIP 0x01#define STATUS_QEB_WINSPAN (1 << 1) +#define STATUS_QEB_MXIC (1 << 6)#define STATUS_PEC 0x80/* Flash timeout values */
@@ -102,6 +104,9 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);/* Program the status register */ int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); +/* Set quad enbale bit for macronix flashes */ +int spi_flash_set_qeb_mxic (struct spi_flash *flash); +/* Set quad enbale bit for winbond and spansion flashes */ int spi_flash_set_qeb_winspan (struct spi_flash *flash);
drivers/mtd/spi/sf_ops.c +26 -0
@@ -39,6 +39,32 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)return 0 ; } +#ifdef CONFIG_SPI_FLASH_MACRONIX +int spi_flash_set_qeb_mxic (struct spi_flash *flash) +{ +u8 qeb_status; +u8 cmd; +int ret; + + cmd =CMD_READ_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , &qeb_status,1 ); +if (ret <0 ) { +debug ("SF: fail to read status register\n" ); +return ret; + } + +if (qeb_status &STATUS_QEB_MXIC ) { +debug ("SF: Quad enable bit is already set\n" ); + }else { + ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); +if (ret <0 ) +return ret; + } + +return ret; +} +#endif +#if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND )static int spi_flash_cmd_write_config (struct spi_flash *flash,u8 cr) {
drivers/mtd/spi/sf_probe.c +4 -0
@@ -31,6 +31,10 @@ static u8 spi_read_cmds_array[] = {static int spi_flash_set_qeb (struct spi_flash *flash,u8 idcode0) {switch (idcode0) { +#ifdef CONFIG_SPI_FLASH_MACRONIX +case SPI_FLASH_CFI_MFR_MACRONIX : +return spi_flash_set_qeb_mxic (flash); +#endif #if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND )case SPI_FLASH_CFI_MFR_SPANSION :case SPI_FLASH_CFI_MFR_WINBOND :
Signature · 1 line
1.8.3
PATCH v6 10/12 sf: probe: Enable macronix quad read/write cmds support
In reply to a message not in the archiveAdded macronix flash quad read/write commands support and it's up to the respective controller driver usecase to configure the respective commands by defining SPI RX/TX operation modes from include/spi.h on the driver.
--- drivers/mtd/spi/sf_params.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/spi/sf_params.c +4 -4
@@ -40,10 +40,10 @@ const struct spi_flash_params spi_flash_params_table[] = { {"MX25L1605D", 0xc22015, 0x0, 64 * 1024, 32, 0, 0}, {"MX25L3205D", 0xc22016, 0x0, 64 * 1024, 64, 0, 0}, {"MX25L6405D", 0xc22017, 0x0, 64 * 1024, 128, 0, 0}, - {"MX25L12805", 0xc22018, 0x0, 64 * 1024, 256, 0, 0}, - {"MX25L25635F", 0xc22019, 0x0, 64 * 1024, 512, 0, 0}, - {"MX25L51235F", 0xc2201a, 0x0, 64 * 1024, 1024, 0, 0}, - {"MX25L12855E", 0xc22618, 0x0, 64 * 1024, 256, 0, 0}, + {"MX25L12805", 0xc22018, 0x0, 64 * 1024, 256, RD_FULL, WR_QPP}, + {"MX25L25635F", 0xc22019, 0x0, 64 * 1024, 512, RD_FULL, WR_QPP}, + {"MX25L51235F", 0xc2201a, 0x0, 64 * 1024, 1024, RD_FULL, WR_QPP}, + {"MX25L12855E", 0xc22618, 0x0, 64 * 1024, 256, RD_FULL, WR_QPP}, #endif #ifdef CONFIG_SPI_FLASH_SPANSION /* SPANSION */ {"S25FL008A", 0x010213, 0x0, 64 * 1024, 16, 0, 0},
Signature · 1 line
1.8.3
PATCH v6 11/12 sf: Divide flash register ops from QEB code
In reply to a message not in the archiveQEB code comprises of couple of flash register read/write operations, this patch moved flash register operations on to sf_op
--- drivers/mtd/spi/sf_internal.h | 11 ++++--- drivers/mtd/spi/sf_ops.c | 75 +++++++++++++++---------------------------- drivers/mtd/spi/sf_probe.c | 44 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 53 deletions(-)
drivers/mtd/spi/sf_internal.h +7 -4
@@ -101,14 +101,17 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,/* Flash erase(sectors) operation, support all possible erase commands */ int spi_flash_cmd_erase_ops (struct spi_flash *flash,u32 offset,size_t len); +/* Read the status register */ +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs); +/* Program the status register */ int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); -/* Set quad enbale bit for macronix flashes */ -int spi_flash_set_qeb_mxic (struct spi_flash *flash); +/* Read the config register */ +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc); -/* Set quad enbale bit for winbond and spansion flashes */ -int spi_flash_set_qeb_winspan (struct spi_flash *flash); +/* Program the config register */ +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc);/* Enable writing on the SPI flash */ static inline int spi_flash_cmd_write_enable (struct spi_flash *flash)
drivers/mtd/spi/sf_ops.c +26 -49
120 lines not on this page · raw message
drivers/mtd/spi/sf_probe.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
1.8.3
PATCH v6 11/12 sf: Divide flash register ops from QEB code
Quoted 203 lines · Jagannadha Sutradharudu Teki
QEB code comprises of couple of flash register read/write operations, this patch moved flash register operations on to
sf_opSigned-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 11 ++++--- drivers/mtd/spi/sf_ops.c | 75 +++++++++++++++---------------------------- drivers/mtd/spi/sf_probe.c | 44 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 53 deletions(-)drivers/mtd/spi/sf_internal.h +7
-4@@ -101,14 +101,17 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,/* Flash erase(sectors) operation, support all possible erase commands */ int spi_flash_cmd_erase_ops (struct spi_flash *flash,u32 offset,size_t len); +/* Read the status register */ +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs); +/* Program the status register */ int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); -/* Set quad enbale bit for macronix flashes */ -int spi_flash_set_qeb_mxic (struct spi_flash *flash); +/* Read the config register */ +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc); -/* Set quad enbale bit for winbond and spansion flashes */ -int spi_flash_set_qeb_winspan (struct spi_flash *flash); +/* Program the config register */ +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc);/* Enable writing on the SPI flash */ static inline int spi_flash_cmd_write_enable (struct spi_flash *flash)drivers/mtd/spi/sf_ops.c +26
-49@@ -24,94 +24,71 @@ static void spi_flash_addr(u32 addr, u8 *cmd) cmd[3 ] = addr>>0 ; } -int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs) { -u8 cmd;int ret; +u8 cmd; - cmd =CMD_WRITE_STATUS ; - ret =spi_flash_write_common (flash,&cmd,1 ,&sr,1 ); + cmd =CMD_READ_STATUS ; + ret =spi_flash_read_common (flash,&cmd,1 , rs,1 );if (ret<0 ) { -debug ("SF: fail to write status register\n" ); +debug ("SF: fail to read status register\n" );return ret; }return 0 ; } -#ifdef CONFIG_SPI_FLASH_MACRONIX -int spi_flash_set_qeb_mxic (struct spi_flash *flash) +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) { -u8 qeb_status;u8 cmd;int ret; - cmd =CMD_READ_STATUS ; - ret =spi_flash_read_common (flash,&cmd,1 ,&qeb_status,1 ); + cmd =CMD_WRITE_STATUS ; + ret =spi_flash_write_common (flash,&cmd,1 ,&sr,1 );if (ret<0 ) { -debug ("SF: fail to read status register\n" ); +debug ("SF: fail to write status register\n" );return ret; } -if (qeb_status&STATUS_QEB_MXIC ) { -debug ("SF: Quad enable bit is already set\n" ); - }else { - ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); -if (ret<0 ) -return ret; - } - -return ret; +return 0 ; } -#endif #if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) -static int spi_flash_cmd_write_config (struct spi_flash *flash,u8 cr) +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc) { -u8 data[2 ]; -u8 cmd;int ret; +u8 cmd; - cmd =CMD_READ_STATUS ; - ret =spi_flash_read_common (flash,&cmd,1 ,&data[0 ],1 ); + cmd =CMD_READ_CONFIG ; + ret =spi_flash_read_common (flash,&cmd,1 , rc,1 );if (ret<0 ) { -debug ("SF: fail to read status register\n" ); -return ret; - } - - cmd =CMD_WRITE_STATUS ; - data[1 ] = cr; - ret =spi_flash_write_common (flash,&cmd,1 ,&data,2 ); -if (ret) { -debug ("SF: fail to write config register\n" ); +debug ("SF: fail to read config register\n" );return ret; }return 0 ; } -int spi_flash_set_qeb_winspan (struct spi_flash *flash) +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc) { -u8 qeb_status; +u8 data[2 ];u8 cmd;int ret; - cmd =CMD_READ_CONFIG ; - ret =spi_flash_read_common (flash,&cmd,1 ,&qeb_status,1 ); -if (ret<0 ) { -debug ("SF: fail to read config register\n" ); + ret =spi_flash_cmd_read_status (flash,&data[0 ]); +if (ret<0 )return ret; - } -if (qeb_status&STATUS_QEB_WINSPAN ) { -debug ("SF: Quad enable bit is already set\n" ); - }else { - ret =spi_flash_cmd_write_config (flash,STATUS_QEB_WINSPAN ); -if (ret<0 ) -return ret; + cmd =CMD_WRITE_STATUS ; + data[1 ] = wc; + ret =spi_flash_write_common (flash,&cmd,1 ,&data,2 ); +if (ret) { +debug ("SF: fail to write config register\n" ); +return ret; } -return ret; +return 0 ; }#endif drivers/mtd/spi/sf_probe.c +34
-0@@ -28,6 +28,50 @@ static u8 spi_read_cmds_array[] = { CMD_READ_QUAD_IO_FAST, }; +#ifdef CONFIG_SPI_FLASH_MACRONIX +static int spi_flash_set_qeb_mxic (struct spi_flash *flash) +{ +u8 qeb_status; +int ret; + + ret =spi_flash_cmd_read_status (flash,&qeb_status); +if (ret<0 ) +return ret; + +if (qeb_status&STATUS_QEB_MXIC ) { +debug ("SF: mxic: QEB is already set\n" ); + }else { + ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); +if (ret<0 ) +return ret; + } + +return ret; +} +#endif + +#if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) +static int spi_flash_set_qeb_winspan (struct spi_flash *flash) +{ +u8 qeb_status; +int ret; + + ret =spi_flash_cmd_read_config (flash,&qeb_status); +if (ret<0 ) +return ret; + +if (qeb_status&STATUS_QEB_WINSPAN ) { +debug ("SF: winspan: QEB is already set\n" );
drivers/mtd/spi/sf_probe.c static u8 spi_read_cmds_array[] = { · line 74
Quoted 10 lines
drivers/mtd/spi/sf_probe.c +10
-0+ } else { + ret =spi_flash_cmd_write_config (flash,STATUS_QEB_WINSPAN ); +if (ret<0 ) +return ret; + } + +return ret; +} +#endif +
This looks to be the generic function used to set quad mode for both spansion and
winbond flashes? If its the case, function name should be more generic and without a_winbond appended to it. Same goes with the other macros used in the function.
Quoted 3 lines
drivers/mtd/spi/sf_probe.c +0
-0static int spi_flash_set_qeb (struct spi_flash *flash,u8 idcode0) {switch (idcode0) {
PATCH v6 11/12 sf: Divide flash register ops from QEB code
Quoted 236 lines · Sourav Poddar
Quoted 225 lines · Jagannadha Sutradharudu Teki
QEB code comprises of couple of flash register read/write operations, this patch moved flash register operations on to
sf_opSigned-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 11 ++++--- drivers/mtd/spi/sf_ops.c | 75 +++++++++++++++---------------------------- drivers/mtd/spi/sf_probe.c | 44 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 53 deletions(-)drivers/mtd/spi/sf_internal.h +7
-4@@ -101,14 +101,17 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,/* Flash erase(sectors) operation, support all possible erase commands */ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len); +/* Read the status register */ +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs); +/* Program the status register */ int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); -/* Set quad enbale bit for macronix flashes */ -int spi_flash_set_qeb_mxic (struct spi_flash *flash); +/* Read the config register */ +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc); -/* Set quad enbale bit for winbond and spansion flashes */ -int spi_flash_set_qeb_winspan (struct spi_flash *flash); +/* Program the config register */ +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc);/* Enable writing on the SPI flash */
static inline intspi_flash_cmd_write_enable(struct spi_flash *flash)drivers/mtd/spi/sf_ops.c +19
-46@@ -24,94 +24,71 @@ static void spi_flash_addr(u32 addr, u8 *cmd) cmd[3 ] = addr>>0 ; } -int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs) { -u8 cmd;int ret; +u8 cmd; - cmd =CMD_WRITE_STATUS ; - ret =spi_flash_write_common (flash,&cmd,1 ,&sr,1 ); + cmd =CMD_READ_STATUS ; + ret =spi_flash_read_common (flash,&cmd,1 , rs,1 );if (ret<0 ) { -debug ("SF: fail to write status register\n" ); +debug ("SF: fail to read status register\n" );return ret; }return 0 ; } -#ifdef CONFIG_SPI_FLASH_MACRONIX -int spi_flash_set_qeb_mxic (struct spi_flash *flash) +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) { -u8 qeb_status;u8 cmd;int ret; - cmd =CMD_READ_STATUS ; - ret =spi_flash_read_common (flash,&cmd,1 ,&qeb_status,1 ); + cmd =CMD_WRITE_STATUS ; + ret =spi_flash_write_common (flash,&cmd,1 ,&sr,1 );if (ret<0 ) { -debug ("SF: fail to read status register\n" ); +debug ("SF: fail to write status register\n" );return ret; } -if (qeb_status&STATUS_QEB_MXIC ) { -debug ("SF: Quad enable bit is already set\n" ); - }else { - ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); -if (ret<0 ) -return ret; - } - -return ret; +return 0 ; } -#endif #if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) -static int spi_flash_cmd_write_config (struct spi_flash *flash,u8 cr) +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc) { -u8 data[2 ]; -u8 cmd;int ret; +u8 cmd; - cmd =CMD_READ_STATUS ; - ret =spi_flash_read_common (flash,&cmd,1 ,&data[0 ],1 ); + cmd =CMD_READ_CONFIG ; + ret =spi_flash_read_common (flash,&cmd,1 , rc,1 );if (ret<0 ) { -debug ("SF: fail to read status register\n" ); -return ret; - } - - cmd =CMD_WRITE_STATUS ; - data[1 ] = cr; - ret =spi_flash_write_common (flash,&cmd,1 ,&data,2 ); -if (ret) { -debug ("SF: fail to write config register\n" ); +debug ("SF: fail to read config register\n" );return ret; }return 0 ; } -int spi_flash_set_qeb_winspan (struct spi_flash *flash) +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc) { -u8 qeb_status; +u8 data[2 ];u8 cmd;int ret; - cmd =CMD_READ_CONFIG ; - ret =spi_flash_read_common (flash,&cmd,1 ,&qeb_status,1 ); -if (ret<0 ) { -debug ("SF: fail to read config register\n" ); + ret =spi_flash_cmd_read_status (flash,&data[0 ]); +if (ret<0 )return ret; - } -if (qeb_status&STATUS_QEB_WINSPAN ) { -debug ("SF: Quad enable bit is already set\n" ); - }else { - ret = spi_flash_cmd_write_config(flash,
STATUS_QEB_WINSPAN);drivers/mtd/spi/sf_ops.c +7
-3-if (ret<0 ) - return ret; + cmd =CMD_WRITE_STATUS ; + data[1 ] = wc; + ret =spi_flash_write_common (flash,&cmd,1 ,&data,2 ); +if (ret) { +debug ("SF: fail to write config register\n" ); +return ret; } -return ret; + return 0; }#endif drivers/mtd/spi/sf_probe.c +36
-0@@ -28,6 +28,50 @@ static u8 spi_read_cmds_array[] = { CMD_READ_QUAD_IO_FAST, }; +#ifdef CONFIG_SPI_FLASH_MACRONIX +static int spi_flash_set_qeb_mxic (struct spi_flash *flash) +{ +u8 qeb_status; +int ret; + + ret =spi_flash_cmd_read_status (flash,&qeb_status); +if (ret<0 ) +return ret; + +if (qeb_status&STATUS_QEB_MXIC ) { +debug ("SF: mxic: QEB is already set\n" ); + }else { + ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); +if (ret<0 ) +return ret; + } + +return ret; +} +#endif + +#if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) +static int spi_flash_set_qeb_winspan (struct spi_flash *flash) +{ +u8 qeb_status; +int ret; + + ret =spi_flash_cmd_read_config (flash,&qeb_status); +if (ret<0 ) +return ret; + +if (qeb_status&STATUS_QEB_WINSPAN ) { +debug ("SF: winspan: QEB is already set\n" ); + }else { + ret = spi_flash_cmd_write_config(flash,
STATUS_QEB_WINSPAN);drivers/mtd/spi/sf_probe.c static u8 spi_read_cmds_array[] = { · line 52
Quoted 8 lines
drivers/mtd/spi/sf_probe.c +8
-0+if (ret<0 ) + return ret; + } + +return ret; +} +#endif +
Quoted 6 lines
This looks to be the generic function used to set quad mode for both spansion and
winbond flashes? If its the case, function name should be more generic and without a_winbondappended to it. Same goes with the other macros used in the function.
Thats what I reflected on the name right - as this code specific to winbond and spansion -
I named as *_winspan() and macro looks the same *_WINSPAN
Any comments?
Signature · 2 lines
Thanks, Jagan.
PATCH v6 11/12 sf: Divide flash register ops from QEB code
Quoted 241 lines · Jagan Teki
Quoted 232 lines · Sourav Poddar
Quoted 231 lines · Jagannadha Sutradharudu Teki
QEB code comprises of couple of flash register read/write operations, this patch moved flash register operations on to
sf_opSigned-off-by Jagannadha Sutradharudu Teki<[email protected]>--- drivers/mtd/spi/sf_internal.h | 11 ++++--- drivers/mtd/spi/sf_ops.c | 75 +++++++++++++++---------------------------- drivers/mtd/spi/sf_probe.c | 44 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 53 deletions(-)drivers/mtd/spi/sf_internal.h +7
-4@@ -101,14 +101,17 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,/* Flash erase(sectors) operation, support all possible erase commands */ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len); +/* Read the status register */ +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs); +/* Program the status register */ int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); -/* Set quad enbale bit for macronix flashes */ -int spi_flash_set_qeb_mxic (struct spi_flash *flash); +/* Read the config register */ +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc); -/* Set quad enbale bit for winbond and spansion flashes */ -int spi_flash_set_qeb_winspan (struct spi_flash *flash); +/* Program the config register */ +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc);/* Enable writing on the SPI flash */
static inline intspi_flash_cmd_write_enable(struct spi_flash *flash)drivers/mtd/spi/sf_ops.c +19
-46@@ -24,94 +24,71 @@ static void spi_flash_addr(u32 addr, u8 *cmd) cmd[3 ] = addr>>0 ; } -int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) +int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs) { -u8 cmd;int ret; +u8 cmd; - cmd =CMD_WRITE_STATUS ; - ret =spi_flash_write_common (flash,&cmd,1 ,&sr,1 ); + cmd =CMD_READ_STATUS ; + ret =spi_flash_read_common (flash,&cmd,1 , rs,1 );if (ret<0 ) { -debug ("SF: fail to write status register\n" ); +debug ("SF: fail to read status register\n" );return ret; }return 0 ; } -#ifdef CONFIG_SPI_FLASH_MACRONIX -int spi_flash_set_qeb_mxic (struct spi_flash *flash) +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) { -u8 qeb_status;u8 cmd;int ret; - cmd =CMD_READ_STATUS ; - ret =spi_flash_read_common (flash,&cmd,1 ,&qeb_status,1 ); + cmd =CMD_WRITE_STATUS ; + ret =spi_flash_write_common (flash,&cmd,1 ,&sr,1 );if (ret<0 ) { -debug ("SF: fail to read status register\n" ); +debug ("SF: fail to write status register\n" );return ret; } -if (qeb_status&STATUS_QEB_MXIC ) { -debug ("SF: Quad enable bit is already set\n" ); - }else { - ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); -if (ret<0 ) -return ret; - } - -return ret; +return 0 ; } -#endif #if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) -static int spi_flash_cmd_write_config (struct spi_flash *flash,u8 cr) +int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc) { -u8 data[2 ]; -u8 cmd;int ret; +u8 cmd; - cmd =CMD_READ_STATUS ; - ret =spi_flash_read_common (flash,&cmd,1 ,&data[0 ],1 ); + cmd =CMD_READ_CONFIG ; + ret =spi_flash_read_common (flash,&cmd,1 , rc,1 );if (ret<0 ) { -debug ("SF: fail to read status register\n" ); -return ret; - } - - cmd =CMD_WRITE_STATUS ; - data[1 ] = cr; - ret =spi_flash_write_common (flash,&cmd,1 ,&data,2 ); -if (ret) { -debug ("SF: fail to write config register\n" ); +debug ("SF: fail to read config register\n" );return ret; }return 0 ; } -int spi_flash_set_qeb_winspan (struct spi_flash *flash) +int spi_flash_cmd_write_config (struct spi_flash *flash,u8 wc) { -u8 qeb_status; +u8 data[2 ];u8 cmd;int ret; - cmd =CMD_READ_CONFIG ; - ret =spi_flash_read_common (flash,&cmd,1 ,&qeb_status,1 ); -if (ret<0 ) { -debug ("SF: fail to read config register\n" ); + ret =spi_flash_cmd_read_status (flash,&data[0 ]); +if (ret<0 )return ret; - } -if (qeb_status&STATUS_QEB_WINSPAN ) { -debug ("SF: Quad enable bit is already set\n" ); - }else { - ret = spi_flash_cmd_write_config(flash,
STATUS_QEB_WINSPAN);drivers/mtd/spi/sf_ops.c +7
-3-if (ret<0 ) - return ret; + cmd =CMD_WRITE_STATUS ; + data[1 ] = wc; + ret =spi_flash_write_common (flash,&cmd,1 ,&data,2 ); +if (ret) { +debug ("SF: fail to write config register\n" ); +return ret; } -return ret; + return 0; }#endif drivers/mtd/spi/sf_probe.c +36
-0@@ -28,6 +28,50 @@ static u8 spi_read_cmds_array[] = { CMD_READ_QUAD_IO_FAST, }; +#ifdef CONFIG_SPI_FLASH_MACRONIX +static int spi_flash_set_qeb_mxic (struct spi_flash *flash) +{ +u8 qeb_status; +int ret; + + ret =spi_flash_cmd_read_status (flash,&qeb_status); +if (ret<0 ) +return ret; + +if (qeb_status&STATUS_QEB_MXIC ) { +debug ("SF: mxic: QEB is already set\n" ); + }else { + ret =spi_flash_cmd_write_status (flash,STATUS_QEB_MXIC ); +if (ret<0 ) +return ret; + } + +return ret; +} +#endif + +#if defined(CONFIG_SPI_FLASH_SPANSION ) || defined(CONFIG_SPI_FLASH_WINBOND ) +static int spi_flash_set_qeb_winspan (struct spi_flash *flash) +{ +u8 qeb_status; +int ret; + + ret =spi_flash_cmd_read_config (flash,&qeb_status); +if (ret<0 ) +return ret; + +if (qeb_status&STATUS_QEB_WINSPAN ) { +debug ("SF: winspan: QEB is already set\n" ); + }else { + ret = spi_flash_cmd_write_config(flash,
STATUS_QEB_WINSPAN);drivers/mtd/spi/sf_probe.c +7
-0+if (ret<0 ) + return ret; + } + +return ret; +} +#endif Quoted 8 lines
Quoted 1 line
+
This looks to be the generic function used to set quad mode for both spansion and
winbond flashes? If its the case, function name should be more generic and without a_winbondappended to it. Same goes with the other macros used in the function.
Quoted 6 lines
Thats what I reflected on the name right - as this code specific to winbond and spansion -
I named as*_winspan()and macro looks the same*_WINSPANAny comments?
Ok, yes, overlooked its winspan. its fine then.
PATCH v6 12/12 sf: Code cleanups
In reply to a message not in the archive- comment typo's
- func args have a proper names
--- drivers/mtd/spi/sf_internal.h | 6 +++--- drivers/mtd/spi/sf_ops.c | 4 ++-- drivers/mtd/spi/sf_probe.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/mtd/spi/sf_internal.h +3 -3
@@ -60,10 +60,10 @@#endif /* Common status */ -#define STATUS_WIP 0x01 +#define STATUS_WIP (1 << 0)#define STATUS_QEB_WINSPAN (1 << 1)#define STATUS_QEB_MXIC (1 << 6) -#define STATUS_PEC 0x80 +#define STATUS_PEC (1 << 7)/* Flash timeout values */ #define SPI_FLASH_PROG_TIMEOUT (2 * CONFIG_SYS_HZ)
@@ -105,7 +105,7 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);int spi_flash_cmd_read_status (struct spi_flash *flash,u8 *rs);/* Program the status register */ -int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr); +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws);/* Read the config register */ int spi_flash_cmd_read_config (struct spi_flash *flash,u8 *rc);
drivers/mtd/spi/sf_ops.c +2 -2
@@ -39,13 +39,13 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs)return 0 ; } -int spi_flash_cmd_write_status (struct spi_flash *flash,u8 sr) +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws) {u8 cmd;int ret; cmd =CMD_WRITE_STATUS ; - ret =spi_flash_write_common (flash, &cmd,1 , &sr,1 ); + ret =spi_flash_write_common (flash, &cmd,1 , &ws,1 );if (ret <0 ) {debug ("SF: fail to write status register\n" );return ret;
drivers/mtd/spi/sf_probe.c +2 -2
@@ -167,7 +167,7 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, cmd = spi_read_cmds_array[cmd -1 ]; flash->read_cmd = cmd; }else { -/* Go for for default supported read cmd */ +/* Go for default supported read cmd */ flash->read_cmd =CMD_READ_ARRAY_FAST ; }
@@ -200,7 +200,7 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, flash->dummy_cycles =1 ; } -/* Poll cmd seclection */ +/* Poll cmd selection */ flash->poll_cmd =CMD_READ_STATUS ;#ifdef CONFIG_SPI_FLASH_STMICRO if (params->flags &E_FSR )
Signature · 1 line
1.8.3