Moved BAR config to spi_flash_validate_ids, so its better to have all flash initalization at once.
Signed-off-by: Jagannadha Sutradharudu Teki <jaga...@xilinx.com> --- Changes for v2: - none drivers/mtd/spi/spi_flash_internal.h | 5 ----- drivers/mtd/spi/spi_flash_probe.c | 24 +++++++++++------------- include/spi_flash.h | 3 +++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index ce34ce0..6227d2e 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -31,11 +31,6 @@ #define SPI_FLASH_16MB_BOUN 0x1000000 -/* Manufacture ID's */ -#define SPI_FLASH_SPANSION_IDCODE0 0x01 -#define SPI_FLASH_STMICRO_IDCODE0 0x20 -#define SPI_FLASH_WINBOND_IDCODE0 0xef - #ifdef CONFIG_SPI_FLASH_BAR /* Bank addr access commands */ # define CMD_BANKADDR_BRWR 0x17 diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c index acccee0..db5f804 100644 --- a/drivers/mtd/spi/spi_flash_probe.c +++ b/drivers/mtd/spi/spi_flash_probe.c @@ -218,6 +218,12 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode) if (params->flags & E_FSR) flash->poll_cmd = CMD_FLAG_STATUS; +#ifdef CONFIG_SPI_FLASH_BAR + /* Configure the BAR - discover bank cmds and read current bank */ + if (spi_flash_bank_config(flash, idcode[0]) < 0) + return NULL; +#endif + /* Flash powers up read-only, so clear BP# bits */ if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) || ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) || @@ -235,12 +241,12 @@ int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0) /* discover bank cmds */ switch (idcode0) { - case SPI_FLASH_SPANSION_IDCODE0: + case SPI_FLASH_CFI_MFR_SPANSION: flash->bank_read_cmd = CMD_BANKADDR_BRRD; flash->bank_write_cmd = CMD_BANKADDR_BRWR; break; - case SPI_FLASH_STMICRO_IDCODE0: - case SPI_FLASH_WINBOND_IDCODE0: + case SPI_FLASH_CFI_MFR_STMICRO: + case SPI_FLASH_CFI_MFR_WINBOND: flash->bank_read_cmd = CMD_EXTNADDR_RDEAR; flash->bank_write_cmd = CMD_EXTNADDR_WREAR; break; @@ -298,7 +304,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, { struct spi_slave *spi; struct spi_flash *flash = NULL; - u8 idcode[5], *idp; + u8 idcode[5]; int ret; /* Setup spi_slave */ @@ -328,18 +334,10 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, #endif /* Validate ID's from flash dev table */ - idp = idcode; - flash = spi_flash_validate_ids(spi, idp); + flash = spi_flash_validate_ids(spi, idcode); if (!flash) goto err_read_id; -#ifdef CONFIG_SPI_FLASH_BAR - /* Configure the BAR - discover bank cmds and read current bank */ - ret = spi_flash_bank_config(flash, *idp); - if (ret < 0) - goto err_read_id; -#endif - #ifdef CONFIG_OF_CONTROL if (spi_flash_decode_fdt(gd->fdt_blob, flash)) { debug("SF: FDT decode error\n"); diff --git a/include/spi_flash.h b/include/spi_flash.h index 3e60fdc..14e4ae2 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -20,7 +20,10 @@ /* SPI flash CFI Manufacture ID's */ #define SPI_FLASH_CFI_MFR_ATMEL 0x1f #define SPI_FLASH_CFI_MFR_MACRONIX 0xc2 +#define SPI_FLASH_CFI_MFR_SPANSION 0x01 #define SPI_FLASH_CFI_MFR_SST 0xbf +#define SPI_FLASH_CFI_MFR_STMICRO 0x20 +#define SPI_FLASH_CFI_MFR_WINBOND 0xef /* SECT flags */ #define SECT_4K (1 << 0) -- 1.8.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot