[U-Boot] [U-Boot,v2 3/6] sf: Add status register reading support

Jagannadha Sutradharudu Teki jagannadh.teki at gmail.com
Wed Dec 19 17:27:40 CET 2012


This patch provides support to read a flash status register.

Status register contains a control bits used to verify
the progress of flash program and erase operations.

User need to get the data through spi_flash_cmd_read_status()
based on their usage.

Signed-off-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>
---
Changes in v2:none

 drivers/mtd/spi/spi_flash.c          |   15 +++++++++++++++
 drivers/mtd/spi/spi_flash_internal.h |    3 +++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 9e8939c..bf5ec4a 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -264,6 +264,21 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
 	return 0;
 }
 
+int spi_flash_cmd_read_status(struct spi_flash *flash, void *data)
+{
+	u8 cmd;
+	int ret;
+
+	cmd = CMD_READ_STATUS;
+	ret = spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)data, 1);
+	if (ret < 0) {
+		debug("SF: fail to read status register\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 /*
  * 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 141cfa8..8232595 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -77,6 +77,9 @@ static inline int spi_flash_cmd_write_disable(struct spi_flash *flash)
 /* Program the status register. */
 int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
 
+/* Read the status register */
+int spi_flash_cmd_read_status(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.0.4



More information about the U-Boot mailing list