From a241d4ecab6f6e10336e91bbd317feeb0ff73941 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Mon, 17 Aug 2015 18:55:02 +0530 Subject: zynq-common: Enable zynq qspi controller support This patch adds support for zynq qspi controller driver on zynq-common.h Signed-off-by: Jagan Teki Cc: Simon Glass Cc: Siva Durga Prasad Paladugu Acked-by: Michal Simek Tested-by: Jagan Teki --- include/configs/zynq-common.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 66b1e699c80..3910ae9a70b 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -72,6 +72,15 @@ # define CONFIG_CMD_SF #endif +/* QSPI */ +#ifdef CONFIG_ZYNQ_QSPI +# define CONFIG_SF_DEFAULT_SPEED 30000000 +# define CONFIG_SPI_FLASH_SPANSION +# define CONFIG_SPI_FLASH_STMICRO +# define CONFIG_SPI_FLASH_WINBOND +# define CONFIG_CMD_SF +#endif + /* NOR */ #ifndef CONFIG_SYS_NO_FLASH # define CONFIG_SYS_FLASH_BASE 0xE2000000 -- cgit v1.3.1 From 9a7620916d6234da29e766446b35a019615dc767 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Mon, 17 Aug 2015 18:56:38 +0530 Subject: zynq-common: Enable Bank/Extended address register support Enabled SPI flash Bank/Extended address register support. Bank/Extended address registers are used to access the flash which has size > 16MiB in 3-byte addressing. Signed-off-by: Jagan Teki --- include/configs/zynq-common.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 3910ae9a70b..cac76d2bb88 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -78,6 +78,7 @@ # define CONFIG_SPI_FLASH_SPANSION # define CONFIG_SPI_FLASH_STMICRO # define CONFIG_SPI_FLASH_WINBOND +# define CONFIG_SPI_FLASH_BAR # define CONFIG_CMD_SF #endif -- cgit v1.3.1 From 232a8e4ecc21c8ee4c500900c26f706cab60150d Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Fri, 4 Sep 2015 18:30:34 +0530 Subject: zynq-common: Enable ISSI SPI-NOR flash support This patch enabled CONFIG_SPI_FLASH_ISSI for qspi on zynq boards. Signed-off-by: Jagan Teki Cc: Siva Durga Prasad Paladugu Cc: Michal Simek --- include/configs/zynq-common.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index cac76d2bb88..acb8670b333 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -75,6 +75,7 @@ /* QSPI */ #ifdef CONFIG_ZYNQ_QSPI # define CONFIG_SF_DEFAULT_SPEED 30000000 +# define CONFIG_SPI_FLASH_ISSI # define CONFIG_SPI_FLASH_SPANSION # define CONFIG_SPI_FLASH_STMICRO # define CONFIG_SPI_FLASH_WINBOND -- cgit v1.3.1 From 8e0e01d330e76ec2b8db4da3fa5cb425603507f9 Mon Sep 17 00:00:00 2001 From: Siva Durga Prasad Paladugu Date: Mon, 14 Sep 2015 12:59:08 +0530 Subject: zynq-common: Add SPL SPI offset, size configs Define CONFIG_SYS_SPI_ARGS_OFFS, CONFIG_SYS_SPI_ARGS_SIZE and CONFIG_SYS_SPI_KERNEL_OFFS which will be used in SPL spi mode. These macros defines the device tree offset, size and the kernel image offset in flash respectively. Signed-off-by: Siva Durga Prasad Paladugu Reviewed-by: Jagan Teki --- include/configs/zynq-common.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index acb8670b333..ca5ef043023 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -355,6 +355,10 @@ #define CONFIG_SPL_SPI_LOAD #define CONFIG_SPL_SPI_FLASH_SUPPORT #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x100000 +#define CONFIG_SYS_SPI_ARGS_OFFS 0x200000 +#define CONFIG_SYS_SPI_ARGS_SIZE 0x80000 +#define CONFIG_SYS_SPI_KERNEL_OFFS (CONFIG_SYS_SPI_ARGS_OFFS + \ + CONFIG_SYS_SPI_ARGS_SIZE) #endif /* for booting directly linux */ -- cgit v1.3.1 From 1fabefddfce1bc79a3d704501efdaa053442b8c1 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 29 Sep 2015 11:17:02 +0530 Subject: sf: Make flash->flags use for generic usage Use the flash->flags for generic usage, not only for dm-spi-flash, this will be used for future flag additions. [Correct the spi flash flags detect logic] Signed-off-by: Bin Meng Tested-by: Bin Meng Signed-off-by: Jagan Teki --- drivers/mtd/spi/sf_internal.h | 4 ++++ drivers/mtd/spi/sf_probe.c | 10 +++++----- include/spi_flash.h | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 9c95d5616eb..53998fca457 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -51,6 +51,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 diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index f17ec173bf1..2634e90666a 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -163,15 +163,15 @@ 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) { + if (params->flags & SST_WR) + flash->flags |= SNOR_F_SST_WR; + + if (params->flags & SNOR_F_SST_WR) { if (flash->spi->op_mode_tx & SPI_OPM_TX_BP) flash->write = sst_write_bp; else @@ -466,7 +466,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 diff --git a/include/spi_flash.h b/include/spi_flash.h index 3b2d555c77b..8d854687054 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -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; -- cgit v1.3.1 From baaaa7539c7511e7e90453ecf0f20d8eaeeb70c6 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 29 Sep 2015 16:54:31 +0530 Subject: sf: Add FSR support to spi_flash_cmd_wait_ready This patch adds flag status register reading support to spi_flash_cmd_wait_ready. Cc: Simon Glass Cc: Marek Vasut Cc: Michal Simek Cc: Siva Durga Prasad Paladugu Cc: Stefan Roese Cc: Tom Warren Cc: Tom Rini Cc: Hou Zhiqiang Tested-by: Jagan Teki Tested-by: Bin Meng Signed-off-by: Jagan Teki --- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/sf_ops.c | 64 +++++++++++++++++++++++++++++++++++++++---- drivers/mtd/spi/sf_probe.c | 4 +-- include/spi_flash.h | 2 -- 4 files changed, 60 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 53998fca457..8a3e5ec3d7a 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -53,6 +53,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 diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index c820d48b6c0..f2a9244a14e 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -41,6 +41,20 @@ 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; + const u8 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; @@ -139,22 +153,60 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr) } #endif -int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout) +static 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; + + return !(sr & STATUS_WIP); +} + +static int spi_flash_fsr_ready(struct spi_flash *flash) +{ + u8 fsr; + int ret; + + ret = read_fsr(flash, &fsr); + if (ret < 0) + return ret; + + return fsr & STATUS_PEC; +} + +static int spi_flash_ready(struct spi_flash *flash) +{ + int sr, fsr; + + sr = spi_flash_sr_ready(flash); + if (sr < 0) + return sr; + + fsr = 1; + if (flash->flags & SNOR_F_USE_FSR) { + fsr = spi_flash_fsr_ready(flash); + if (fsr < 0) + return fsr; + } + + return sr && fsr; +} + +int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout) +{ int timebase, ret; timebase = get_timer(0); while (get_timer(timebase) < timeout) { - ret = spi_flash_cmd_read_status(flash, &sr); + ret = spi_flash_ready(flash); if (ret < 0) return ret; - - if (!(sr & STATUS_WIP)) + if (ret) return 0; - else - break; } printf("SF: Timeout!\n"); diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 2634e90666a..f591ab140b1 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -257,11 +257,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 */ diff --git a/include/spi_flash.h b/include/spi_flash.h index 8d854687054..4312d3d691e 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -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; -- cgit v1.3.1