[U-Boot] [PATCH 2/4] sf: Add extended address register reading support

Jagannadha Sutradharudu Teki jagannadha.sutradharudu-teki at xilinx.com
Sat Feb 23 12:38:59 CET 2013


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 at xilinx.com>
---
 drivers/mtd/spi/spi_flash.c          |   23 +++++++++++++++++++++++
 drivers/mtd/spi/spi_flash_internal.h |    4 ++++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 232ccc0..c168c1c 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -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
  *
diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index dbceb81..65960ad 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -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.
-- 
1.7.4




More information about the U-Boot mailing list