[U-Boot] [PATCH v2 02/16] sf: Add bank address register reading support

This patch provides support to read a flash bank address register.
reading extended/bank address register will give whether the flash is operated on extended/bank addressing or normal addressing in 3-byte address mode.
Currently added an extended/bank address register reading support for spansion flashes.
reff' the spec for more details about bank addr register in Page-63, Table 8.16 http://www.spansion.com/Support/Datasheets/S25FL128S_256S_00.pdf
Signed-off-by: Jagannadha Sutradharudu Teki jaganna@xilinx.com --- Changes for v2: - none
drivers/mtd/spi/spi_flash.c | 15 +++++++++++++++ drivers/mtd/spi/spi_flash_internal.h | 4 ++++ 2 files changed, 19 insertions(+)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 7aba520..193de42 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -312,6 +312,21 @@ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) return 0; }
+int spi_flash_cmd_bankaddr_read(struct spi_flash *flash, void *data) +{ + u8 cmd; + u8 idcode0 = flash->idcode0; + + if (idcode0 == 0x01) { + cmd = CMD_BANKADDR_BRRD; + } else { + printf("SF: Unsupported bank addr read %02x\n", idcode0); + return -1; + } + + return spi_flash_read_common(flash, &cmd, 1, data, 1); +} + #ifdef CONFIG_OF_CONTROL int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) { diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index 6e38494..2567bbc 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -30,6 +30,7 @@
/* Bank addr acess commands */ #define CMD_BANKADDR_BRWR 0x17 +#define CMD_BANKADDR_BRRD 0x16
/* Common status */ #define STATUS_WIP 0x01 @@ -83,6 +84,9 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr); /* Program the bank address register */ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel);
+/* Read the bank address register */ +int spi_flash_cmd_bankaddr_read(struct spi_flash *flash, void *data); + /* * Same as spi_flash_cmd_read() except it also claims/releases the SPI * bus. Used as common part of the ->read() operation.
participants (1)
-
Jagannadha Sutradharudu Teki