BAR/wait_ready logic updates
Subsystems (3)
v2 cover BAR/wait_ready logic updates
BAR and spi_flash_cmd_wait_ready are updated to make more module to add new status checks.
Changes for v2:
- Update bank_sel for non-bar case.
- split the spi_flash_cmd_wait_ready logic into SR and FSR patches.
Clone spi-nor branch u-boot-spi.git repo for changes
http://git.denx.de/?p=u-boot/u-boot-spi.git;a=tree;h=refs/heads/spi-nor;hb=refs/heads/spi-nor
Jagan Teki (7):
spi: zynq_spi: Remove unneeded headers
sf: Return proper bank_sel, if flash->bank_curr == bank_sel
sf: Make BAR discovery, as spi_flash_read_bar
sf: Optimize BAR write code
sf: Make flash->flags use for generic usage
sf: Update status reg check in spi_flash_cmd_wait_ready
sf: Add FSR support to spi_flash_cmd_wait_ready
drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 151 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 ++++++++++-------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 111 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/7 spi: zynq_spi: Remove unneeded headers
- Removed unneeded inclusion of header files
- Add "Xilinx" on license text
--- drivers/spi/zynq_spi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/spi/zynq_spi.c +1 -5
@@ -1,5 +1,5 @@/* -* (C) Copyright 2013 Inc. +* (C) Copyright 2013 Xilinx, Inc. * (C) Copyright 2015 Jagan Teki <[email protected]> * * Xilinx Zynq PS SPI controller driver (master mode only)
@@ -7,15 +7,11 @@* SPDX-License-Identifier: GPL-2.0+ */ -#include <config.h> #include <common.h> #include <dm.h> -#include <errno.h> #include <malloc.h> #include <spi.h> -#include <fdtdec.h> #include <asm/io.h> -#include <asm/arch/hardware.h> DECLARE_GLOBAL_DATA_PTR ;
Signature · 1 line
1.9.1
PATCH v2 2/7 sf: Return proper bank_sel, if flash->bank_curr == bank_sel
In reply to Jagan TekiIf computed bank_sel is same as flash->bank_curr which is computed at probe time, then return the bank_sel instead of zero.
--- drivers/mtd/spi/sf_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi/sf_ops.c +1 -1
@@ -101,7 +101,7 @@ static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)if (flash->bank_curr == bank_sel) {debug ("SF: not require to enable bank%d\n" , bank_sel); -return 0 ; +return bank_sel; } cmd = flash->bank_write_cmd;
Signature · 1 line
1.9.1
PATCH v2 3/7 sf: Make BAR discovery, as spi_flash_read_bar
In reply to Jagan TekiAdd spi_flash_read_bar function for reading bar and discovering bar commands at probe time.
--- drivers/mtd/spi/sf_probe.c | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 19 deletions(-)
drivers/mtd/spi/sf_probe.c +35 -19
@@ -99,6 +99,37 @@ static int spi_flash_set_qeb(struct spi_flash *flash, u8 idcode0) } } +#ifdef CONFIG_SPI_FLASH_BAR +static int spi_flash_read_bank (struct spi_flash *flash,u8 idcode0) +{ +u8 curr_bank =0 ; +int ret; + +if (flash->size <=SPI_FLASH_16MB_BOUN ) + goto bank_end; + +switch (idcode0) { +case SPI_FLASH_CFI_MFR_SPANSION : + flash->bank_read_cmd =CMD_BANKADDR_BRRD ; + flash->bank_write_cmd =CMD_BANKADDR_BRWR ; +default : + flash->bank_read_cmd =CMD_EXTNADDR_RDEAR ; + flash->bank_write_cmd =CMD_EXTNADDR_WREAR ; + } + + ret =spi_flash_read_common (flash, &flash->bank_read_cmd,1 , + &curr_bank,1 ); +if (ret) { +debug ("SF: fail to read bank addr register\n" ); +return ret; + } + +bank_end: + flash->bank_curr = curr_bank; +return 0 ; +} +#endif +static int spi_flash_validate_params (struct spi_slave *spi,u8 *idcode,struct spi_flash *flash) {
@@ -106,6 +137,7 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,u8 cmd;u16 jedec = idcode[1 ] <<8 | idcode[2 ];u16 ext_jedec = idcode[3 ] <<8 | idcode[4 ]; +int ret;/* Validate params from spi_flash_params table */ params = spi_flash_params_table;
@@ -235,25 +267,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,/* Configure the BAR - discover bank cmds and read current bank */ #ifdef CONFIG_SPI_FLASH_BAR -u8 curr_bank =0 ; -if (flash->size >SPI_FLASH_16MB_BOUN ) { -int ret; - - flash->bank_read_cmd = (idcode[0 ] ==0x01 ) ? -CMD_BANKADDR_BRRD :CMD_EXTNADDR_RDEAR ; - flash->bank_write_cmd = (idcode[0 ] ==0x01 ) ? -CMD_BANKADDR_BRWR :CMD_EXTNADDR_WREAR ; - - ret =spi_flash_read_common (flash, &flash->bank_read_cmd,1 , - &curr_bank,1 ); -if (ret) { -debug ("SF: fail to read bank addr register\n" ); -return ret; - } - flash->bank_curr = curr_bank; - }else { - flash->bank_curr = curr_bank; - } + ret =spi_flash_read_bank (flash, idcode[0 ]); +if (ret <0 ) +return ret;#endif /* Flash powers up read-only, so clear BP# bits */
Signature · 1 line
1.9.1
PATCH v2 3/7 sf: Make BAR discovery, as spi_flash_read_bar
Hi Jagan,
Quoted 80 lines · Jagan Teki
Add
spi_flash_read_barfunction for reading bar and discovering bar commands at probe time.Signed-off-by Jagan Teki <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>--- drivers/mtd/spi/sf_probe.c | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 19 deletions(-)drivers/mtd/spi/sf_probe.c +32
-16@@ -99,6 +99,37 @@ static int spi_flash_set_qeb(struct spi_flash *flash, u8 idcode0) } } +#ifdef CONFIG_SPI_FLASH_BAR +static int spi_flash_read_bank (struct spi_flash *flash,u8 idcode0) +{ +u8 curr_bank =0 ; +int ret; + +if (flash->size <=SPI_FLASH_16MB_BOUN ) + goto bank_end; + +switch (idcode0) { +case SPI_FLASH_CFI_MFR_SPANSION : + flash->bank_read_cmd =CMD_BANKADDR_BRRD ; + flash->bank_write_cmd =CMD_BANKADDR_BRWR ; +default : + flash->bank_read_cmd =CMD_EXTNADDR_RDEAR ; + flash->bank_write_cmd =CMD_EXTNADDR_WREAR ; + } + + ret =spi_flash_read_common (flash, &flash->bank_read_cmd,1 , + &curr_bank,1 ); +if (ret) { +debug ("SF: fail to read bank addr register\n" ); +return ret; + } + +bank_end: + flash->bank_curr = curr_bank; +return 0 ; +} +#endif +static int spi_flash_validate_params (struct spi_slave *spi,u8 *idcode,struct spi_flash *flash) {@@ -106,6 +137,7 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,u8 cmd;u16 jedec = idcode[1 ] <<8 | idcode[2 ];u16 ext_jedec = idcode[3 ] <<8 | idcode[4 ]; +int ret;/* Validate params from spi_flash_params table */ params = spi_flash_params_table;@@ -235,25 +267,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,/* Configure the BAR - discover bank cmds and read current bank */ #ifdef CONFIG_SPI_FLASH_BAR -u8 curr_bank =0 ; -if (flash->size >SPI_FLASH_16MB_BOUN ) { -int ret; - - flash->bank_read_cmd = (idcode[0 ] ==0x01 ) ? -CMD_BANKADDR_BRRD :CMD_EXTNADDR_RDEAR ; - flash->bank_write_cmd = (idcode[0 ] ==0x01 ) ? -CMD_BANKADDR_BRWR :CMD_EXTNADDR_WREAR ; - - ret =spi_flash_read_common (flash, &flash->bank_read_cmd,1 , - &curr_bank,1 ); -if (ret) { -debug ("SF: fail to read bank addr register\n" ); -return ret; - } - flash->bank_curr = curr_bank;
drivers/mtd/spi/sf_probe.c static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
Quoted 10 lines
drivers/mtd/spi/sf_probe.c +3
-4- } else { - flash->bank_curr = curr_bank; - } + ret =spi_flash_read_bank (flash, idcode[0 ]); +if (ret <0 ) +return ret;#endif /* Flash powers up read-only, so clear BP# bits */ --
This commit is causing build warnings:
drivers/mtd/spi/sf_probe.c: In function ?spi_flash_validate_params?:drivers/mtd/spi/sf_probe.c:140:6: warning: unused variable ?ret? [-Wunused-variable]
Regards,
Bin
PATCH v2 3/7 sf: Make BAR discovery, as spi_flash_read_bar
Quoted 91 lines · Bin Meng
Hi Jagan,
Quoted 88 lines · Jagan Teki
Add
spi_flash_read_barfunction for reading bar and discovering bar commands at probe time.Signed-off-by Jagan Teki <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>--- drivers/mtd/spi/sf_probe.c | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 19 deletions(-)drivers/mtd/spi/sf_probe.c +35
-19@@ -99,6 +99,37 @@ static int spi_flash_set_qeb(struct spi_flash *flash, u8 idcode0) } } +#ifdef CONFIG_SPI_FLASH_BAR +static int spi_flash_read_bank (struct spi_flash *flash,u8 idcode0) +{ +u8 curr_bank =0 ; +int ret; + +if (flash->size <=SPI_FLASH_16MB_BOUN ) + goto bank_end; + +switch (idcode0) { +case SPI_FLASH_CFI_MFR_SPANSION : + flash->bank_read_cmd =CMD_BANKADDR_BRRD ; + flash->bank_write_cmd =CMD_BANKADDR_BRWR ; +default : + flash->bank_read_cmd =CMD_EXTNADDR_RDEAR ; + flash->bank_write_cmd =CMD_EXTNADDR_WREAR ; + } + + ret =spi_flash_read_common (flash, &flash->bank_read_cmd,1 , + &curr_bank,1 ); +if (ret) { +debug ("SF: fail to read bank addr register\n" ); +return ret; + } + +bank_end: + flash->bank_curr = curr_bank; +return 0 ; +} +#endif +static int spi_flash_validate_params (struct spi_slave *spi,u8 *idcode,struct spi_flash *flash) {@@ -106,6 +137,7 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,u8 cmd;u16 jedec = idcode[1 ] <<8 | idcode[2 ];u16 ext_jedec = idcode[3 ] <<8 | idcode[4 ]; +int ret;/* Validate params from spi_flash_params table */ params = spi_flash_params_table;@@ -235,25 +267,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,/* Configure the BAR - discover bank cmds and read current bank */ #ifdef CONFIG_SPI_FLASH_BAR -u8 curr_bank =0 ; -if (flash->size >SPI_FLASH_16MB_BOUN ) { -int ret; - - flash->bank_read_cmd = (idcode[0 ] ==0x01 ) ? -CMD_BANKADDR_BRRD :CMD_EXTNADDR_RDEAR ; - flash->bank_write_cmd = (idcode[0 ] ==0x01 ) ? -CMD_BANKADDR_BRWR :CMD_EXTNADDR_WREAR ; - - ret =spi_flash_read_common (flash, &flash->bank_read_cmd,1 , - &curr_bank,1 ); -if (ret) { -debug ("SF: fail to read bank addr register\n" ); -return ret; - } - flash->bank_curr = curr_bank; - }else { - flash->bank_curr = curr_bank; - } + ret =spi_flash_read_bank (flash, idcode[0 ]); +if (ret <0 ) +return ret;#endif
Quoted 8 lines
drivers/mtd/spi/sf_probe.c static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
Quoted 2 lines
drivers/mtd/spi/sf_probe.c +0
-1/* Flash powers up read-only, so clear BP# bits */ --This commit is causing build warnings:
drivers/mtd/spi/sf_probe.c: In function ?spi_flash_validate_params?:drivers/mtd/spi/sf_probe.c:140:6: warning: unused variable ?ret? [-Wunused-variable]
Yes, this I knew - will fix the same.
thanks!
Signature · 1 line
Jagan | openedev.
PATCH v2 4/7 sf: Optimize BAR write code
In reply to Jagan TekiOptimized spi-flash bar writing code and also removed unnecessary bank_sel in read_ops.
--- drivers/mtd/spi/sf_ops.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-)
drivers/mtd/spi/sf_ops.c +13 -28
@@ -94,15 +94,14 @@ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc)#endif #ifdef CONFIG_SPI_FLASH_BAR -static int spi_flash_cmd_bankaddr_write (struct spi_flash *flash,u8 bank_sel) +static int spi_flash_write_bank (struct spi_flash *flash,u32 offset) { -u8 cmd; +u8 cmd, bank_sel;int ret; -if (flash->bank_curr == bank_sel) { -debug ("SF: not require to enable bank%d\n" , bank_sel); -return bank_sel; - } + bank_sel = offset / (SPI_FLASH_16MB_BOUN << flash->shift); +if (bank_sel == flash->bank_curr) + goto bar_end; cmd = flash->bank_write_cmd; ret =spi_flash_write_common (flash, &cmd,1 , &bank_sel,1 );
@@ -110,25 +109,10 @@ static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)debug ("SF: fail to write bank register\n" ); return ret; } - flash->bank_curr = bank_sel; - -return 0 ; -} - -static int spi_flash_bank (struct spi_flash *flash,u32 offset) -{ -u8 bank_sel; -int ret; - - bank_sel = offset / (SPI_FLASH_16MB_BOUN << flash->shift); - - ret =spi_flash_cmd_bankaddr_write (flash, bank_sel); -if (ret) { -debug ("SF: fail to set bank%d\n" , bank_sel); -return ret; - } -return bank_sel; +bar_end: + flash->bank_curr = bank_sel; +return flash->bank_curr; }#endif
@@ -284,7 +268,7 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len)spi_flash_dual_flash (flash, &erase_addr);#endif #ifdef CONFIG_SPI_FLASH_BAR - ret =spi_flash_bank (flash, erase_addr); + ret =spi_flash_write_bank (flash, erase_addr);if (ret <0 )return ret;#endif
@@ -326,7 +310,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,spi_flash_dual_flash (flash, &write_addr);#endif #ifdef CONFIG_SPI_FLASH_BAR - ret =spi_flash_bank (flash, write_addr); + ret =spi_flash_write_bank (flash, write_addr);if (ret <0 )return ret;#endif
@@ -416,9 +400,10 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,spi_flash_dual_flash (flash, &read_addr);#endif #ifdef CONFIG_SPI_FLASH_BAR - bank_sel =spi_flash_bank (flash, read_addr); -if (bank_sel <0 ) + ret =spi_flash_write_bank (flash, read_addr); +if (ret <0 )return ret; + bank_sel = flash->bank_curr;#endif remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) * (bank_sel +1 )) - offset;
Signature · 1 line
1.9.1
PATCH v2 5/7 sf: Make flash->flags use for generic usage
In reply to Jagan TekiUse the flash->flags for generic usage, not only for dm-spi-flash, this will be used for future flag additions.
--- drivers/mtd/spi/sf_internal.h | 4 ++++ drivers/mtd/spi/sf_probe.c | 6 ++---- include/spi_flash.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/mtd/spi/sf_internal.h +4 -0
@@ -47,6 +47,10 @@ enum {#define SST_WR (SST_BP | SST_WP) +enum spi_nor_option_flags { +SNOR_F_SST_WR = (1 <<0 ), +}; +#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_probe.c +2 -4
@@ -164,15 +164,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode, flash->name = params->name; flash->memory_map = spi->memory_map; flash->dual_flash = flash->spi->option; -#ifdef CONFIG_DM_SPI_FLASH - flash->flags = params->flags; -#endif /* Assign spi_flash ops */ #ifndef CONFIG_DM_SPI_FLASH flash->write = spi_flash_cmd_write_ops; #if defined(CONFIG_SPI_FLASH_SST) if (params->flags & SST_WR) { + flash->flags |= SNOR_F_SST_WR; if (flash->spi->op_mode_tx & SPI_OPM_TX_BP) flash->write = sst_write_bp; else
@@ -467,7 +465,7 @@ int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,struct spi_flash *flash =dev_get_uclass_priv (dev);#if defined(CONFIG_SPI_FLASH_SST ) -if (flash->flags &SST_WR ) { +if (flash->flags &SNOR_F_SST_WR ) {if (flash->spi->op_mode_tx &SPI_OPM_TX_BP )return sst_write_bp (flash, offset, len, buf);else
include/spi_flash.h +2 -2
@@ -38,10 +38,10 @@ struct spi_slave;* * @spi: SPI slave * @dev: SPI flash device -* @flags: Indication of spi flash flags * @name: Name of SPI flash * @dual_flash: Indicates dual flash memories - dual stacked, parallel * @shift: Flash shift useful in dual parallel +* @flags: Indication of spi flash flags * @size: Total flash size * @page_size: Write (page) size * @sector_size: Sector size
@@ -67,11 +67,11 @@ struct spi_flash {struct spi_slave *spi;#ifdef CONFIG_DM_SPI_FLASH struct udevice *dev; -u16 flags;#endif const char *name;u8 dual_flash;u8 shift; +u16 flags;u32 size;u32 page_size;
Signature · 1 line
1.9.1
PATCH v2 5/7 sf: Make flash->flags use for generic usage
Hi Jagan,
Quoted 76 lines · Jagan Teki
Use the
flash->flagsfor generic usage, not only for dm-spi-flash, this will be used for future flag additions.Signed-off-by Jagan Teki <[email protected]>Cc Bin Meng <[email protected]>--- drivers/mtd/spi/sf_internal.h | 4 ++++ drivers/mtd/spi/sf_probe.c | 6 ++---- include/spi_flash.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-)drivers/mtd/spi/sf_internal.h +4
-0@@ -47,6 +47,10 @@ enum {#define SST_WR (SST_BP | SST_WP) +enum spi_nor_option_flags { +SNOR_F_SST_WR = (1 <<0 ), +}; +#define SPI_FLASH_3B_ADDR_LEN 3#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000drivers/mtd/spi/sf_probe.c +2
-4@@ -164,15 +164,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode, flash->name = params->name; flash->memory_map = spi->memory_map; flash->dual_flash = flash->spi->option; -#ifdef CONFIG_DM_SPI_FLASH - flash->flags = params->flags; -#endif /* Assign spi_flash ops */ #ifndef CONFIG_DM_SPI_FLASH flash->write = spi_flash_cmd_write_ops; #if defined(CONFIG_SPI_FLASH_SST) if (params->flags & SST_WR) { + flash->flags |= SNOR_F_SST_WR; if (flash->spi->op_mode_tx & SPI_OPM_TX_BP) flash->write = sst_write_bp; else@@ -467,7 +465,7 @@ int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,struct spi_flash *flash =dev_get_uclass_priv (dev);#if defined(CONFIG_SPI_FLASH_SST ) -if (flash->flags &SST_WR ) { +if (flash->flags &SNOR_F_SST_WR ) {if (flash->spi->op_mode_tx &SPI_OPM_TX_BP )return sst_write_bp (flash, offset, len, buf);else include/spi_flash.h +1
-1@@ -38,10 +38,10 @@ struct spi_slave;* * @spi: SPI slave * @dev: SPI flash device -* @flags: Indication of spi flash flags * @name: Name of SPI flash * @dual_flash: Indicates dual flash memories - dual stacked, parallel * @shift: Flash shift useful in dual parallel +* @flags: Indication of spi flash flags * @size: Total flash size * @page_size: Write (page) size * @sector_size: Sector size @@ -67,11 +67,11 @@ struct spi_flash {struct spi_slave *spi;#ifdef CONFIG_DM_SPI_FLASH struct udevice *dev;
include/spi_flash.h struct spi_flash {
Quoted 10 lines
include/spi_flash.h +1
-2-u16 flags;#endif const char *name;u8 dual_flash;u8 shift; +u16 flags;u32 size;u32 page_size; --
This is the commit that breaks the SF flash on Intel Crown Bay. I've tested like this:
Power-on the board, type "setenv testcase whatever" and "saveenv", do a "reset", and check if the "testcase" variable is there.
Unfortunately with this commit, sometimes my board does not even boot after "reset". I checked that if must be the SF driver writes the wrong places into the flash which corrupts the codes.
Regards,
Bin
PATCH v2 5/7 sf: Make flash->flags use for generic usage
Hi Bin,
Quoted 93 lines · Bin Meng
Hi Jagan,
Quoted 76 lines · Jagan Teki
Use the
flash->flagsfor generic usage, not only for dm-spi-flash, this will be used for future flag additions.Signed-off-by Jagan Teki <[email protected]>Cc Bin Meng <[email protected]>--- drivers/mtd/spi/sf_internal.h | 4 ++++ drivers/mtd/spi/sf_probe.c | 6 ++---- include/spi_flash.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-)drivers/mtd/spi/sf_internal.h +4
-0@@ -47,6 +47,10 @@ enum {#define SST_WR (SST_BP | SST_WP) +enum spi_nor_option_flags { +SNOR_F_SST_WR = (1 <<0 ), +}; +#define SPI_FLASH_3B_ADDR_LEN 3#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)#define SPI_FLASH_16MB_BOUN 0x1000000drivers/mtd/spi/sf_probe.c +2
-4@@ -164,15 +164,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode, flash->name = params->name; flash->memory_map = spi->memory_map; flash->dual_flash = flash->spi->option; -#ifdef CONFIG_DM_SPI_FLASH - flash->flags = params->flags; -#endif /* Assign spi_flash ops */ #ifndef CONFIG_DM_SPI_FLASH flash->write = spi_flash_cmd_write_ops; #if defined(CONFIG_SPI_FLASH_SST) if (params->flags & SST_WR) { + flash->flags |= SNOR_F_SST_WR; if (flash->spi->op_mode_tx & SPI_OPM_TX_BP) flash->write = sst_write_bp; else@@ -467,7 +465,7 @@ int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,struct spi_flash *flash =dev_get_uclass_priv (dev);#if defined(CONFIG_SPI_FLASH_SST ) -if (flash->flags &SST_WR ) { +if (flash->flags &SNOR_F_SST_WR ) {if (flash->spi->op_mode_tx &SPI_OPM_TX_BP )return sst_write_bp (flash, offset, len, buf);else include/spi_flash.h +1
-1@@ -38,10 +38,10 @@ struct spi_slave;* * @spi: SPI slave * @dev: SPI flash device -* @flags: Indication of spi flash flags * @name: Name of SPI flash * @dual_flash: Indicates dual flash memories - dual stacked, parallel * @shift: Flash shift useful in dual parallel +* @flags: Indication of spi flash flags * @size: Total flash size * @page_size: Write (page) size * @sector_size: Sector size @@ -67,11 +67,11 @@ struct spi_flash {struct spi_slave *spi;#ifdef CONFIG_DM_SPI_FLASH struct udevice *dev;include/spi_flash.h struct spi_flash {
Quoted 10 lines
include/spi_flash.h +1
-2-u16 flags;#endif const char *name;u8 dual_flash;u8 shift; +u16 flags;u32 size;u32 page_size; --This is the commit that breaks the SF flash on Intel Crown Bay. I've tested like this:
Quoted 6 lines
Power-on the board, type "setenv testcase whatever" and "saveenv", do a "reset", and check if the "testcase" variable is there.
Unfortunately with this commit, sometimes my board does not even boot after "reset". I checked that if must be the SF driver writes the wrong places into the flash which corrupts the codes.
Sorry, I couldn't find any wrong in this commit.
We assigned directly params (SST_WR, for SST flash's) flags to flash flags and check the param flags in dm-spi-write calls. So instead of that this commit assigns local macro to flash flags if SST_WR and this will check in dm-spi-write calls instead of param flags.
Could you please provide any command error info say sf probe, sf erase/write
thanks!
Signature · 1 line
Jagan | openedev.
PATCH v2 6/7 sf: Update status reg check in spi_flash_cmd_wait_ready
In reply to Jagan TekiCurrent flash wait_ready logic is not modular to add new register status check, hence few of the logic is used from Linux spi-nor framework.
Below are the sf speed runs with 'sf update' on whole flash, 16MiB.
=> sf update 0x100 0x0 0x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 59.564s, speed 289262 B/s
=> sf update 0x100 0x0 0x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 62.549s, speed 275036 B/s
=> sf update 0x100 0x0 0x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 61.276s, speed 284359 B/s
--- drivers/mtd/spi/sf_ops.c | 76 ++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 58 deletions(-)
drivers/mtd/spi/sf_ops.c +18 -58
@@ -138,72 +138,32 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif -static int spi_flash_poll_status (struct spi_slave *spi,unsigned long timeout, -u8 cmd,u8 poll_bit) +/* +* Service routine to read status register until ready, or timeout occurs. +* Returns non-zero if error. +*/ +int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long deadline) { -unsigned long timebase; -unsigned long flags =SPI_XFER_BEGIN ; -int ret; -u8 status; -u8 check_status =0x0 ; +int timeout, ret, sr; -if (cmd ==CMD_FLAG_STATUS ) - check_status = poll_bit; + timeout =get_timer (0 ); -#ifdef CONFIG_SF_DUAL_FLASH -if (spi->flags &SPI_XFER_U_PAGE ) - flags |=SPI_XFER_U_PAGE ; -#endif - ret =spi_xfer (spi,8 , &cmd,NULL , flags); -if (ret) { -debug ("SF: fail to read %s status register\n" , - cmd ==CMD_READ_STATUS ?"read" :"flag" ); -return ret; - } - - timebase =get_timer (0 ); -do { -WATCHDOG_RESET (); - - ret =spi_xfer (spi,8 ,NULL , &status,0 ); -if (ret) -return -1 ; +while (get_timer (timeout) < deadline) { + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; -if ((status & poll_bit) == check_status) +if (sr <0 )break ; +else if (!(sr &STATUS_WIP )) +return 0 ; - }while (get_timer (timebase) < timeout); - -spi_xfer (spi,0 ,NULL ,NULL ,SPI_XFER_END ); - -if ((status & poll_bit) == check_status) -return 0 ; - -/* Timed out */ -debug ("SF: time out!\n" ); -return -1 ; -} - -int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long timeout) -{ -struct spi_slave *spi = flash->spi; -int ret; -u8 poll_bit =STATUS_WIP ; -u8 cmd =CMD_READ_STATUS ; - - ret =spi_flash_poll_status (spi, timeout, cmd, poll_bit); -if (ret <0 ) -return ret; - -if (flash->poll_cmd ==CMD_FLAG_STATUS ) { - poll_bit =STATUS_PEC ; - cmd =CMD_FLAG_STATUS ; - ret =spi_flash_poll_status (spi, timeout, cmd, poll_bit); -if (ret <0 ) -return ret; +cond_resched (); } -return 0 ; +printf ("SF: Timeout!\n" ); + +return -ETIMEDOUT ; } int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
Signature · 1 line
1.9.1
PATCH v2 6/7 sf: Update status reg check in spi_flash_cmd_wait_ready
Quoted 38 lines · Jagan Teki
Current flash
wait_readylogic is not modular to add new register status check, hence few of the logic is used from Linux spi-nor framework.Below are the sf speed runs with 'sf update' on whole flash, 16MiB.
=> sf update
0x1000x00x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 59.564s, speed 289262 B/s=> sf update
0x1000x00x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 62.549s, speed 275036 B/s=> sf update
0x1000x00x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 61.276s, speed 284359 B/sSigned-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Tested-by Jagan Teki <[email protected]>--- drivers/mtd/spi/sf_ops.c | 76++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 58 deletions(-)
drivers/mtd/spi/sf_ops.c +0
-0
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash · line 144
Quoted 8 lines
drivers/mtd/spi/sf_ops.c +3
-1@@ -138,72 +138,32 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif -static int spi_flash_poll_status (struct spi_slave *spi,unsigned long timeout, - u8 cmd, u8 poll_bit) +/* +* Service routine to read status register until ready, or timeout occurs. +* Returns non-zero if error.
If you're adding this sort of description, please make it a kerneldoc.
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash · line 147
Quoted 3 lines
drivers/mtd/spi/sf_ops.c +2
-0+*/ +int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long deadline) {
Please rename $deadline to $timeout and note in the kerneldoc that the timeout is in mSec.
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 149
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +2
-7-unsigned long timebase; -unsigned long flags =SPI_XFER_BEGIN ; -int ret; -u8 status; -u8 check_status =0x0 ; +int timeout, ret, sr; -if (cmd ==CMD_FLAG_STATUS ) - check_status = poll_bit; + timeout =get_timer (0 );
This should be $start or something.
Quoted 49 lines
drivers/mtd/spi/sf_ops.c +7
-38-#ifdef CONFIG_SF_DUAL_FLASH -if (spi->flags &SPI_XFER_U_PAGE ) - flags |=SPI_XFER_U_PAGE ; -#endif - ret =spi_xfer (spi,8 , &cmd,NULL , flags); -if (ret) { -debug ("SF: fail to read %s status register\n" , - cmd ==CMD_READ_STATUS ?"read" :"flag" ); -return ret; - } - - timebase =get_timer (0 ); -do { -WATCHDOG_RESET (); - - ret =spi_xfer (spi,8 ,NULL , &status,0 ); -if (ret) -return -1 ; +while (get_timer (timeout) < deadline) { + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; -if ((status & poll_bit) == check_status) +if (sr <0 )break ; +else if (!(sr &STATUS_WIP )) +return 0 ; - }while (get_timer (timebase) < timeout); - -spi_xfer (spi,0 ,NULL ,NULL ,SPI_XFER_END ); - -if ((status & poll_bit) == check_status) -return 0 ; - -/* Timed out */ -debug ("SF: time out!\n" ); -return -1 ; -} - -int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long timeout) -{ -struct spi_slave *spi = flash->spi; -int ret; -u8 poll_bit =STATUS_WIP ; -u8 cmd =CMD_READ_STATUS ; - - ret =spi_flash_poll_status (spi, timeout, cmd, poll_bit);
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 161
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +1
-9-if (ret <0 ) -return ret; - -if (flash->poll_cmd ==CMD_FLAG_STATUS ) { - poll_bit =STATUS_PEC ; - cmd =CMD_FLAG_STATUS ; - ret =spi_flash_poll_status (spi, timeout, cmd, poll_bit); -if (ret <0 ) -return ret; +cond_resched ();
Huh ? Why do you need cond_resched() here at all ? Drop it please.
Quoted 9 lines
drivers/mtd/spi/sf_ops.c +3
-1} -return 0 ; +printf ("SF: Timeout!\n" ); + +return -ETIMEDOUT ; } int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
PATCH v2 6/7 sf: Update status reg check in spi_flash_cmd_wait_ready
Quoted 42 lines · Marek Vasut
Quoted 41 lines · Jagan Teki
Current flash
wait_readylogic is not modular to add new register status check, hence few of the logic is used from Linux spi-nor framework.Below are the sf speed runs with 'sf update' on whole flash, 16MiB.
=> sf update
0x1000x00x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 59.564s, speed 289262 B/s=> sf update
0x1000x00x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 62.549s, speed 275036 B/s=> sf update
0x1000x00x1000000
device 0 whole chip
16777216 bytes written, 0 bytes skipped in 61.276s, speed 284359 B/sSigned-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Tested-by Jagan Teki <[email protected]>--- drivers/mtd/spi/sf_ops.c | 76++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 58 deletions(-)
drivers/mtd/spi/sf_ops.c +0
-0@@ -138,72 +138,32 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif
Quoted 7 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 143
Quoted 5 lines
drivers/mtd/spi/sf_ops.c +3
-1-static int spi_flash_poll_status (struct spi_slave *spi,unsigned long timeout, - u8 cmd, u8 poll_bit) +/* +* Service routine to read status register until ready, or timeout occurs. +* Returns non-zero if error. If you're adding this sort of description, please make it a kerneldoc.
Probably I will remove these comments, there are no comments before.
Quoted 7 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash · line 147
Quoted 4 lines
drivers/mtd/spi/sf_ops.c +2
-0+*/ +int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long deadline) {Please rename $deadline to $timeout and note in the kerneldoc that the timeout is in mSec.
Yes, will revert back to timeout
Quoted 67 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 149
Quoted 11 lines
drivers/mtd/spi/sf_ops.c +2
-7-unsigned long timebase; -unsigned long flags =SPI_XFER_BEGIN ; -int ret; -u8 status; -u8 check_status =0x0 ; +int timeout, ret, sr; -if (cmd ==CMD_FLAG_STATUS ) - check_status = poll_bit; + timeout =get_timer (0 );This should be $start or something.
Quoted 53 lines
drivers/mtd/spi/sf_ops.c +7
-42-#ifdef CONFIG_SF_DUAL_FLASH -if (spi->flags &SPI_XFER_U_PAGE ) - flags |=SPI_XFER_U_PAGE ; -#endif - ret =spi_xfer (spi,8 , &cmd,NULL , flags); -if (ret) { -debug ("SF: fail to read %s status register\n" , - cmd ==CMD_READ_STATUS ?"read" :"flag" ); -return ret; - } - - timebase =get_timer (0 ); -do { -WATCHDOG_RESET (); - - ret =spi_xfer (spi,8 ,NULL , &status,0 ); -if (ret) -return -1 ; +while (get_timer (timeout) < deadline) { + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; -if ((status & poll_bit) == check_status) +if (sr <0 )break ; +else if (!(sr &STATUS_WIP )) +return 0 ; - }while (get_timer (timebase) < timeout); - -spi_xfer (spi,0 ,NULL ,NULL ,SPI_XFER_END ); - -if ((status & poll_bit) == check_status) -return 0 ; - -/* Timed out */ -debug ("SF: time out!\n" ); -return -1 ; -} - -int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long timeout) -{ -struct spi_slave *spi = flash->spi; -int ret; -u8 poll_bit =STATUS_WIP ; -u8 cmd =CMD_READ_STATUS ; - - ret =spi_flash_poll_status (spi, timeout, cmd, poll_bit); -if (ret <0 ) -return ret; - -if (flash->poll_cmd ==CMD_FLAG_STATUS ) {
Quoted 8 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 161
Quoted 6 lines
drivers/mtd/spi/sf_ops.c +1
-5- poll_bit =STATUS_PEC ; - cmd =CMD_FLAG_STATUS ; - ret =spi_flash_poll_status (spi, timeout, cmd, poll_bit); -if (ret <0 ) -return ret; +cond_resched ();Huh ? Why do you need
cond_resched()here at all ? Drop it please.
Yes will do.
Quoted 8 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 167
Quoted 8 lines
drivers/mtd/spi/sf_ops.c +3
-1} -return 0 ; +printf ("SF: Timeout!\n" ); + +return -ETIMEDOUT ; }
thanks!
Signature · 1 line
Jagan | openedev.
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
In reply to Jagan TekiThis patch adds flag status register reading support to spi_flash_cmd_wait_ready.
--- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66 +++++++++++++++++++++++++++++++++++++++---- drivers/mtd/spi/sf_probe.c | 4 +-- include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)
drivers/mtd/spi/sf_internal.h +1 -0
@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ), };#define SPI_FLASH_3B_ADDR_LEN 3
drivers/mtd/spi/sf_ops.c +60 -6
90 lines not on this page · raw message
drivers/mtd/spi/sf_probe.c +1 -3
@@ -256,11 +256,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode, flash->dummy_byte =1 ; } -/* Poll cmd selection */ - flash->poll_cmd =CMD_READ_STATUS ;#ifdef CONFIG_SPI_FLASH_STMICRO if (params->flags &E_FSR ) - flash->poll_cmd =CMD_FLAG_STATUS ; + flash->flags |=SNOR_F_USE_FSR ;#endif /* Configure the BAR - discover bank cmds and read current bank */
include/spi_flash.h +0 -2
@@ -49,7 +49,6 @@ struct spi_slave;* @bank_read_cmd: Bank read cmd * @bank_write_cmd: Bank write cmd * @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, Extn read and quad read. * @write_cmd: Write cmd - page and quad program.
@@ -82,7 +81,6 @@ struct spi_flash {u8 bank_write_cmd;u8 bank_curr;#endif -u8 poll_cmd;u8 erase_cmd;u8 read_cmd;u8 write_cmd;
Signature · 1 line
1.9.1
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 64 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>--- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66 +++++++++++++++++++++++++++++++++++++++---- drivers/mtd/spi/sf_probe.c | 4 +-- include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ), };#define SPI_FLASH_3B_ADDR_LEN 3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws) {u8 cmd;@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash · line 165
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )
Have you ever seen u8 value that's < 0 ? :-)
Quoted 4 lines
drivers/mtd/spi/sf_ops.c +4
-0+return sr; + else + return !(sr & STATUS_WIP); +}
[...]
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 65 lines · Marek Vasut
Quoted 64 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>--- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66 +++++++++++++++++++++++++++++++++++++++---- drivers/mtd/spi/sf_probe.c | 4 +-- include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ), };#define SPI_FLASH_3B_ADDR_LEN 3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws) {u8 cmd;@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif
Quoted 12 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 165
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )Have you ever seen u8 value that's < 0 ? :-)
Yes, over looked, It's been fixed on next patches as well.
Quoted 5 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 169
Quoted 5 lines
drivers/mtd/spi/sf_ops.c +4
-0+return sr; + else + return !(sr & STATUS_WIP); +}
thanks!
Signature · 1 line
Jagan | openedev.
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 92 lines · Jagan Teki
Quoted 78 lines · Marek Vasut
Quoted 77 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>---
drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66+++++++++++++++++++++++++++++++++++++++----
drivers/mtd/spi/sf_probe.c| 4 +--
include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/spi/sf_internal.hindex e97c716..4ecfd0c 100644drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ),};
#define
SPI_FLASH_3B_ADDR_LEN3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws){
u8 cmd;drivers/mtd/spi/sf_ops.c +0
-0@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif Quoted 12 lines
drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) · line 165
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )Have you ever seen u8 value that's < 0 ? :-)
Quoted 1 line
Yes, over looked, It's been fixed on next patches as well.
Please don't apply broken code, fix this and repost.
Best regards,
Marek Vasut
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 93 lines · Marek Vasut
Quoted 92 lines · Jagan Teki
Quoted 90 lines · Marek Vasut
Quoted 77 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>---
drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66+++++++++++++++++++++++++++++++++++++++----
drivers/mtd/spi/sf_probe.c| 4 +--
include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/spi/sf_internal.hindex e97c716..4ecfd0c 100644drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ),};
#define
SPI_FLASH_3B_ADDR_LEN3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws){
u8 cmd;drivers/mtd/spi/sf_ops.c +0
-0@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct spi_flash · line 166
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )Have you ever seen u8 value that's < 0 ? :-)
Quoted 3 lines
Quoted 1 line
Yes, over looked, It's been fixed on next patches as well.
Please don't apply broken code, fix this and repost.
I don't know what your talking about, there is patch already submitted with this fix and even you're CCed [1]
[1] https://patchwork.ozlabs.org/patch/508166/
thanks!
Signature · 1 line
Jagan | openedev.
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 95 lines · Jagan Teki
Quoted 94 lines · Marek Vasut
Quoted 93 lines · Jagan Teki
Quoted 91 lines · Marek Vasut
Quoted 78 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>---
drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66+++++++++++++++++++++++++++++++++++++++----
drivers/mtd/spi/sf_probe.c| 4 +--
include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/spi/sf_internal.hindex e97c716..4ecfd0c 100644drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ),};
#define
SPI_FLASH_3B_ADDR_LEN3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws){
u8 cmd;drivers/mtd/spi/sf_ops.c +0
-0@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct · line 166
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )Have you ever seen u8 value that's < 0 ? :-)
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Yes, over looked, It's been fixed on next patches as well.
Please don't apply broken code, fix this and repost.
I don't know what your talking about, there is patch already submitted with this fix and even you're CCed [1]
I am talking about not applying patches which are known to be defective. If you plan to apply this particular patch, make sure to fix it, repost it and then apply this. Do NOT apply a patch which is broken only to apply another patch which repairs the breakage, that's just nonsense.
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 103 lines · Marek Vasut
Quoted 102 lines · Jagan Teki
Quoted 94 lines · Marek Vasut
Quoted 93 lines · Jagan Teki
Quoted 91 lines · Marek Vasut
Quoted 78 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>---
drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66+++++++++++++++++++++++++++++++++++++++----
drivers/mtd/spi/sf_probe.c| 4 +--
include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/spi/sf_internal.hindex e97c716..4ecfd0c 100644drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ),};
#define
SPI_FLASH_3B_ADDR_LEN3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws){
u8 cmd;drivers/mtd/spi/sf_ops.c +0
-0@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct · line 166
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )Have you ever seen u8 value that's < 0 ? :-)
Quoted 3 lines
Quoted 1 line
Yes, over looked, It's been fixed on next patches as well.
Please don't apply broken code, fix this and repost.
I don't know what your talking about, there is patch already submitted with this fix and even you're CCed [1]
Quoted 6 lines
Quoted 1 line
I am talking about not applying patches which are known to be defective. If you plan to apply this particular patch, make sure to fix it, repost it and then apply this. Do NOT apply a patch which is broken only to apply another patch which repairs the breakage, that's just nonsense.
Sorry, we are not here to apply broken patches, that you must understand clearly.
And we haven't re-post the series yet, if you have any concerns just wait for next series and comment. Any applied patches before I have re-posted to ML then only applied.
thanks!
Signature · 1 line
Jagan | openedev.
PATCH v2 7/7 sf: Add FSR support to spi_flash_cmd_wait_ready
Quoted 106 lines · Jagan Teki
Quoted 105 lines · Marek Vasut
Quoted 103 lines · Jagan Teki
Quoted 94 lines · Marek Vasut
Quoted 93 lines · Jagan Teki
Quoted 91 lines · Marek Vasut
Quoted 78 lines · Jagan Teki
This patch adds flag status register reading support to
spi_flash_cmd_wait_ready.Signed-off-by Jagan Teki <[email protected]>Cc Simon Glass <[email protected]>Cc Marek Vasut <[email protected]>Cc Michal Simek <[email protected]>Cc Siva Durga Prasad Paladugu <[email protected]>Cc Stefan Roese <[email protected]>Cc Tom Warren <[email protected]>Cc Bin Meng <[email protected]>Cc Tom Rini <[email protected]>Cc Hou Zhiqiang <[email protected]>Tested-by Jagan Teki <[email protected]>---
drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 66+++++++++++++++++++++++++++++++++++++++----
drivers/mtd/spi/sf_probe.c| 4 +--
include/spi_flash.h | 2 -- 4 files changed, 62 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/spi/sf_internal.hindex e97c716..4ecfd0c 100644drivers/mtd/spi/sf_internal.h +1
-0@@ -49,6 +49,7 @@ enum {enum spi_nor_option_flags {SNOR_F_SST_WR = (1 <<0 ), +SNOR_F_USE_FSR = (1 <<1 ),};
#define
SPI_FLASH_3B_ADDR_LEN3drivers/mtd/spi/sf_ops.c +15
-0@@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs) return 0; } +static int read_fsr (struct spi_flash *flash,u8 *fsr) +{ +int ret; +u8 cmd; + + cmd =CMD_FLAG_STATUS ; + ret =spi_flash_read_common (flash, &cmd,1 , fsr,1 ); +if (ret <0 ) { +debug ("SF: fail to read flag status register\n" ); +return ret; + } + +return 0 ; +} +int spi_flash_cmd_write_status (struct spi_flash *flash,u8 ws){
u8 cmd;drivers/mtd/spi/sf_ops.c +0
-0@@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) }#endif drivers/mtd/spi/sf_ops.c static void spi_flash_dual_flash(struct · line 166
Quoted 10 lines
drivers/mtd/spi/sf_ops.c +10
-0+static inline int spi_flash_sr_ready (struct spi_flash *flash) +{ +u8 sr; +int ret; + + ret =spi_flash_cmd_read_status (flash, &sr); +if (ret <0 ) +return ret; + +if (sr <0 )Have you ever seen u8 value that's < 0 ? :-)
Quoted 3 lines
Quoted 1 line
Yes, over looked, It's been fixed on next patches as well.
Please don't apply broken code, fix this and repost.
I don't know what your talking about, there is patch already submitted with this fix and even you're CCed [1]
Quoted 7 lines
Quoted 4 lines
I am talking about not applying patches which are known to be defective. If you plan to apply this particular patch, make sure to fix it, repost it and then apply this. Do NOT apply a patch which is broken only to apply another patch which repairs the breakage, that's just nonsense.
Sorry, we are not here to apply broken patches, that you must understand clearly.
I'm stopping this discussion here, sorry.
Quoted 3 lines
And we haven't re-post the series yet, if you have any concerns just wait for next series and comment. Any applied patches before I have re-posted to ML then only applied.
Sorry, I don't understand this sentence.
Quoted 1 line
thanks!
v2 cover BAR/wait_ready logic updates
In reply to Jagan TekiHi Jagan,
Quoted 19 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Changes for v2:
- Updatebank_selfor non-bar case.
- split thespi_flash_cmd_wait_readylogic into SR and FSR patches.Clone spi-nor branch u-boot-spi.git repo for changes
http://git.denx.de/?p=u-boot/u-boot-spi.git;a=tree;h=refs/heads/spi-nor;hb=refs/heads/spi-norJagan Teki (7):
spi:zynq_spi: Remove unneeded headers
sf: Return properbank_sel, ifflash->bank_curr==bank_sel
sf: Make BAR discovery, asspi_flash_read_bar
sf: Optimize BAR write code
sf: Makeflash->flagsuse for generic usage
sf: Update status reg check inspi_flash_cmd_wait_ready
sf: Add FSR support tospi_flash_cmd_wait_ready
Quoted 8 lines
drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 151 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 ++++++++++-------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 111 deletions(-)--
Unfortunately with this series the SF flash was broken on Crown Bay. Please take a look.
Regards,
Bin
v2 cover BAR/wait_ready logic updates
Quoted 29 lines · Bin Meng
Hi Jagan,
Quoted 26 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Changes for v2:
- Updatebank_selfor non-bar case.
- split thespi_flash_cmd_wait_readylogic into SR and FSR patches.Clone spi-nor branch u-boot-spi.git repo for changes
http://git.denx.de/?p=u-boot/u-boot-spi.git;a=tree;h=refs/heads/spi-nor;hb=refs/heads/spi-norJagan Teki (7):
spi:zynq_spi: Remove unneeded headers
sf: Return properbank_sel, ifflash->bank_curr==bank_sel
sf: Make BAR discovery, asspi_flash_read_bar
sf: Optimize BAR write code
sf: Makeflash->flagsuse for generic usage
sf: Update status reg check inspi_flash_cmd_wait_ready
sf: Add FSR support tospi_flash_cmd_wait_readydrivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 151 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 ++++++++++-------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 111 deletions(-)
Quoted 4 lines
Quoted 1 line
--
Unfortunately with this series the SF flash was broken on Crown Bay. Please take a look.
Please specify which sort of error it is from, "Timeout" form wait_ready or something.
thanks!
Signature · 1 line
Jagan | openedev.
v2 cover BAR/wait_ready logic updates
Hi Jagan,
Quoted 30 lines · Jagan Teki
Quoted 29 lines · Bin Meng
Hi Jagan,
Quoted 26 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Changes for v2:
- Updatebank_selfor non-bar case.
- split thespi_flash_cmd_wait_readylogic into SR and FSR patches.Clone spi-nor branch u-boot-spi.git repo for changes
http://git.denx.de/?p=u-boot/u-boot-spi.git;a=tree;h=refs/heads/spi-nor;hb=refs/heads/spi-norJagan Teki (7):
spi:zynq_spi: Remove unneeded headers
sf: Return properbank_sel, ifflash->bank_curr==bank_sel
sf: Make BAR discovery, asspi_flash_read_bar
sf: Optimize BAR write code
sf: Makeflash->flagsuse for generic usage
sf: Update status reg check inspi_flash_cmd_wait_ready
sf: Add FSR support tospi_flash_cmd_wait_readydrivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 151 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 ++++++++++-------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 111 deletions(-)
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
--
Unfortunately with this series the SF flash was broken on Crown Bay. Please take a look.
Please specify which sort of error it is from, "Timeout" form
wait_readyor something.
I will need apply the patch in this series one by one and find which one breaks.
Regards,
Bin