diff mbox

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

Message ID 63ee6d90-0ed4-45c5-80ca-43954327fae0@CH1EHSMHS029.ehs.local
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagannadha Sutradharudu Teki Feb. 23, 2013, 11:38 a.m. UTC
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(-)

Comments

thomas.langer@lantiq.com Feb. 24, 2013, 3:51 p.m. UTC | #1
Hello Jagan,

Am 23.02.2013 12:38, schrieb Jagannadha Sutradharudu Teki:
> 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.

The same comments as for patch 1/4 apply here.

[...]

Best Regards,
Thomas
diff mbox

Patch

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.