[U-Boot] [PATCH v4 5/5] sf: Update bank configuration

Jagannadha Sutradharudu Teki jagannadha.sutradharudu-teki at xilinx.com
Tue Feb 4 17:06:17 CET 2014


Updated bank configuration code to more readable.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna at xilinx.com>
---
 drivers/mtd/spi/sf_probe.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 22b6335..c0a3a35 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -217,21 +217,22 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
 
 	/* 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) {
-		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;
+		switch (idcode[0]) {
+		case SPI_FLASH_CFI_MFR_SPANSION:
+			flash->bank_read_cmd = CMD_BANKADDR_BRRD;
+			flash->bank_write_cmd = CMD_BANKADDR_BRWR;
+			break;
+		default:
+			flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
+			flash->bank_write_cmd = 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");
+					&flash->bank_curr, 1)) {
+			debug("SF: Fail to read bank addr register\n");
 			return NULL;
 		}
-		flash->bank_curr = curr_bank;
-	} else {
-		flash->bank_curr = curr_bank;
 	}
 #endif
 
-- 
1.8.3




More information about the U-Boot mailing list