diff options
author | Jagannadha Sutradharudu Teki <jaganna@xilinx.com> | 2013-09-26 08:54:58 (GMT) |
---|---|---|
committer | Jagannadha Sutradharudu Teki <jaganna@xilinx.com> | 2013-10-07 12:25:45 (GMT) |
commit | 32ebd1a7d51818a327f2e23570d6bfc542c68e12 (patch) | |
tree | f1a33f67b52904e939b77944b7f57558ab96ce86 /drivers | |
parent | 0f6232801cee4f45dbdb0cec45f71172c9b617ca (diff) | |
download | u-boot-fsl-qoriq-32ebd1a7d51818a327f2e23570d6bfc542c68e12.tar.xz |
sf: probe: Simply the BAR configuration logic
Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/spi/spi_flash_internal.h | 8 | ||||
-rw-r--r-- | drivers/mtd/spi/spi_flash_probe.c | 66 |
2 files changed, 20 insertions, 54 deletions
diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index ce34ce0..61de237 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 @@ -102,9 +97,6 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr); #ifdef CONFIG_SPI_FLASH_BAR /* Program the bank address register */ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel); - -/* Configure the BAR - discover the bank cmds */ -int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0); #endif /* diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c index 8ea6915..cc30ad1 100644 --- a/drivers/mtd/spi/spi_flash_probe.c +++ b/drivers/mtd/spi/spi_flash_probe.c @@ -221,54 +221,36 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode) flash->poll_cmd = CMD_FLAG_STATUS; #endif - /* Flash powers up read-only, so clear BP# bits */ -#if defined(CONFIG_SPI_FLASH_ATMEL) || \ - defined(CONFIG_SPI_FLASH_MACRONIX) || \ - defined(CONFIG_SPI_FLASH_SST) - spi_flash_cmd_write_status(flash, 0); -#endif - - return flash; -} - #ifdef CONFIG_SPI_FLASH_BAR -int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0) -{ - u8 cmd; + /* Configure the BAR - discover bank cmds and read current bank */ u8 curr_bank = 0; - - /* discover bank cmds */ - switch (idcode0) { - case SPI_FLASH_SPANSION_IDCODE0: - 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: - flash->bank_read_cmd = CMD_EXTNADDR_RDEAR; - flash->bank_write_cmd = CMD_EXTNADDR_WREAR; - break; - default: - printf("SF: Unsupported bank commands %02x\n", idcode0); - return -1; - } - - /* read the bank reg - on which bank the flash is in currently */ - cmd = flash->bank_read_cmd; if (flash->size > SPI_FLASH_16MB_BOUN) { - if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) { + 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; + + if (spi_flash_read_common(flash, &flash->bank_read_cmd, 1, + &curr_bank, 1)) { debug("SF: fail to read bank addr register\n"); - return -1; + return NULL; } flash->bank_curr = curr_bank; } else { flash->bank_curr = curr_bank; } +#endif - return 0; -} + /* Flash powers up read-only, so clear BP# bits */ +#if defined(CONFIG_SPI_FLASH_ATMEL) || \ + defined(CONFIG_SPI_FLASH_MACRONIX) || \ + defined(CONFIG_SPI_FLASH_SST) + spi_flash_cmd_write_status(flash, 0); #endif + return flash; +} + #ifdef CONFIG_OF_CONTROL int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) { @@ -302,7 +284,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 */ @@ -332,18 +314,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"); |