[U-Boot] [PATCH v4 25/36] sf: probe: Simply the BAR configuration logic
Jagannadha Sutradharudu Teki
jagannadha.sutradharudu-teki at xilinx.com
Tue Sep 24 20:20:02 CEST 2013
Signed-off-by: Jagannadha Sutradharudu Teki <jaganna at xilinx.com>
---
Changes for v4:
- none
Changes for v3:
- none
Changes for v2:
- none
drivers/mtd/spi/spi_flash_internal.h | 3 --
drivers/mtd/spi/spi_flash_probe.c | 56 +++++++++++-------------------------
include/spi_flash.h | 3 --
3 files changed, 16 insertions(+), 46 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index 286082a..86966f6 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -97,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 8462195..2978480 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -220,56 +220,32 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
#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) ||
- ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST))
- spi_flash_cmd_write_status(flash, 0);
-
- return flash;
-}
-
-#ifdef CONFIG_SPI_FLASH_BAR
-int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
-{
- u8 cmd;
u8 curr_bank = 0;
-
- /* discover bank cmds */
- switch (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_CFI_MFR_STMICRO:
- case SPI_FLASH_CFI_MFR_WINBOND:
- 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 (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
+ ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
+ ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST))
+ spi_flash_cmd_write_status(flash, 0);
+
+ return flash;
}
-#endif
#ifdef CONFIG_OF_CONTROL
int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 34a167b..939da05 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -20,10 +20,7 @@
/* 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
More information about the U-Boot
mailing list