@@ -310,6 +310,29 @@ int spi_flash_cmd_extaddr_write(struct spi_flash *flash, u8 ear)
return 0;
}
+int spi_flash_cmd_extaddr_read(struct spi_flash *flash, void *data)
+{
+ u8 cmd;
+ u8 idcode0;
+ int ret;
+
+ ret = spi_flash_cmd(flash->spi, CMD_READ_ID, &idcode0, 1);
+ if (ret) {
+ debug("SF: fail to read read id\n");
+ return ret;
+ }
+
+ if (idcode0 == 0x01)
+ cmd = CMD_EXT_BRRD;
+ else {
+ printf("SF: unable to support extended addr reg read"
+ " for %s flash\n", flash->name);
+ return -1;
+ }
+
+ return spi_flash_read_common(flash, &cmd, 1, data, 1);
+}
+
/*
* The following table holds all device probe functions
*
@@ -30,6 +30,7 @@
/* Extended addr acess commands */
#define CMD_EXT_BRWR 0x17
+#define CMD_EXT_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 extended address register */
int spi_flash_cmd_extaddr_write(struct spi_flash *flash, u8 ear);
+/* Read the extended address register */
+int spi_flash_cmd_extaddr_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.
This patch provides support to read a flash extended address register. reading extended/bank address register will give whether the flash is operated on extended addressing or normal addressing in 3-byte address mode. Currently added an extended/bank address register reading support for spansion flashes. Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com> --- drivers/mtd/spi/spi_flash.c | 23 +++++++++++++++++++++++ drivers/mtd/spi/spi_flash_internal.h | 4 ++++ 2 files changed, 27 insertions(+), 0 deletions(-)