sf: BAR/wait_ready logic updates
Subsystems (3)
cover sf: BAR/wait_ready logic updates
BAR and spi_flash_cmd_wait_ready are updated to make more module to add new status checks.
Jagan Teki (6):
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 spi_flash_cmd_wait_ready
drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 153 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 +++++++++++------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 113 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/6 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 2/6 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 3/6 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 4/6 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 | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-)
drivers/mtd/spi/sf_ops.c +13 -30
@@ -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
@@ -383,7 +367,6 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, {u8 *cmd, cmdsz;u32 remain_len, read_len, read_addr; -int bank_sel =0 ;int ret =-1 ;/* Handle memory-mapped SPI */
@@ -416,12 +399,12 @@ 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;#endif remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) * - (bank_sel +1 )) - offset; + (flash->bank_curr +1 )) - offset;if (len < remain_len) read_len = len;else
Signature · 1 line
1.9.1
PATCH 5/6 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 6/6 sf: Update 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 61.784s, speed 279620 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_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 110 ++++++++++++++++++++++++------------------ drivers/mtd/spi/sf_probe.c | 4 +- include/spi_flash.h | 2 - 4 files changed, 64 insertions(+), 53 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 +62 -48
140 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 6/6 sf: Update spi_flash_cmd_wait_ready
Quoted 24 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 61.784s, speed 279620 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]>
Quoted 1 line
---
Please split this into two patches, one which makes the code modular and next one which adds new features (the FSR reading or whatever).
Best regards,
Marek Vasut
cover sf: BAR/wait_ready logic updates
In reply to Jagan TekiHi Michal/Siva,
Quoted 10 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Jagan Teki (6):
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: Updatespi_flash_cmd_wait_ready
Pls- test BAR/wait_ready for all supported spi-nor flash.
Quoted 11 lines
drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 153 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 +++++++++++------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 113 deletions(-)--
1.9.1
thanks!
Signature · 1 line
Jagan | openedev.
cover sf: BAR/wait_ready logic updates
Hi Zhiqiang,
Quoted 13 lines · Jagan Teki
Hi Michal/Siva,
Quoted 10 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Jagan Teki (6):
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: Updatespi_flash_cmd_wait_ready
Add your clear status register support on-top this, and let me know for any inputs.
Quoted 13 lines
Pls- test BAR/wait_ready for all supported spi-nor flash.
Quoted 10 lines
drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 153 +++++++++++++++++++++--------------------- drivers/mtd/spi/sf_probe.c | 64 +++++++++++------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 113 deletions(-)--
1.9.1
thanks!
Signature · 1 line
Jagan | openedev.
cover sf: BAR/wait_ready logic updates
Hello Jagan,
Quoted 24 lines
-----Original Message-----
From: Jagan Teki [mailto:jteki at openedev.com]
Sent: 2015?8?16? 16:50
To: u-boot at lists.denx.de; Hou Zhiqiang-B48286; Sun York-R58495
Cc: Jagan Teki
Subject: Re: [PATCH 0/6] sf: BAR/wait_ready logic updatesHi Zhiqiang,
Quoted 13 lines · Jagan Teki
Hi Michal/Siva,
Quoted 10 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Jagan Teki (6):
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: Updatespi_flash_cmd_wait_ready
Quoted 3 lines
Add your clear status register support on-top this, and let me know for any inputs.
Sorry, I'm not in this context.
What do you mean by 'Add your clear status register support on-top this'? Generate the patch base on the latest base?
Quoted 14 lines
Quoted 6 lines
Pls- test BAR/wait_ready for all supported spi-nor flash.
Quoted 3 lines
drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_ops.c | 153 +++++++++++++++++++++---------------------
Quoted 7 lines
Quoted 7 lines
drivers/mtd/spi/sf_probe.c | 64 +++++++++++------- drivers/spi/zynq_spi.c | 6 +- include/spi_flash.h | 6 +- 5 files changed, 121 insertions(+), 113 deletions(-)--
1.9.1
Thanks,
Zhiqiang
cover sf: BAR/wait_ready logic updates
Quoted 26 lines · Hou Zhiqiang
Hello Jagan,
Quoted 24 lines
-----Original Message-----
From: Jagan Teki [mailto:jteki at openedev.com]
Sent: 2015?8?16? 16:50
To: u-boot at lists.denx.de; Hou Zhiqiang-B48286; Sun York-R58495
Cc: Jagan Teki
Subject: Re: [PATCH 0/6] sf: BAR/wait_ready logic updatesHi Zhiqiang,
Quoted 13 lines · Jagan Teki
Hi Michal/Siva,
Quoted 10 lines · Jagan Teki
BAR and
spi_flash_cmd_wait_readyare updated to make more module to add new status checks.Jagan Teki (6):
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: Updatespi_flash_cmd_wait_ready
Quoted 7 lines
Quoted 3 lines
Add your clear status register support on-top this, and let me know for any inputs.
Sorry, I'm not in this context.
What do you mean by 'Add your clear status register support on-top this'? Generate the patch base on the latest base?
I have send some patches related wait_ready updates.
Pls- refer this repo
http://git.denx.de/?p=u-boot/u-boot-spi.git;a=tree;h=refs/heads/spi-nor;hb=refs/heads/spi-nor
I have updated wait_ready logic to fit it on your requirements. Add clear flag status on top of that, do test both fsr, cfsr.
thanks!
Signature · 1 line
Jagan | openedev.