[U-Boot] [PATH v3 1/2] sf: Add status register reading support

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@gmail.com --- Changes in v3: improved coding style
drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 3 +++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 9e8939c..0f05b91 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -264,6 +264,14 @@ 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; + + cmd = CMD_READ_STATUS; + return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)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 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.

This patch provides support to read a flash config register.
Config register contains a control bits used to verify the different configurations and security features of a device.
User need to get the data through spi_flash_cmd_read_config() based on their usage.
Signed-off-by: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- Changes in v3: improved coding style
drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 4 ++++ 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index b4d726e..fdae94d 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -307,6 +307,14 @@ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr) return 0; }
+int spi_flash_cmd_read_config(struct spi_flash *flash, void *data) +{ + u8 cmd; + + cmd = CMD_READ_CONFIG; + return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)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 825b398..844e82e 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -22,6 +22,7 @@ #define CMD_PAGE_PROGRAM 0x02 #define CMD_WRITE_DISABLE 0x04 #define CMD_READ_STATUS 0x05 +#define CMD_READ_CONFIG 0x35 #define CMD_WRITE_ENABLE 0x06 #define CMD_ERASE_4K 0x20 #define CMD_ERASE_32K 0x52 @@ -83,6 +84,9 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, void *data); /* Program the config register. */ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr);
+/* Read the config register */ +int spi_flash_cmd_read_config(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.

Hi Jagannadha
On Thu, Jan 3, 2013 at 6:51 AM, Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com wrote:
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.
Do you have a console command for this, and the control register also?
Regards, Simon
Signed-off-by: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com
Changes in v3: improved coding style
drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 3 +++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 9e8939c..0f05b91 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -264,6 +264,14 @@ 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;
cmd = CMD_READ_STATUS;
return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)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 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
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Simon,
On Fri, Jan 11, 2013 at 7:52 AM, Simon Glass sjg@chromium.org wrote:
Hi Jagannadha
On Thu, Jan 3, 2013 at 6:51 AM, Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com wrote:
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.
Do you have a console command for this, and the control register also?
There is no sf command for status register read.
Usage is based on the user code, see how I am using this function on Quad Enable bit setting. http://patchwork.ozlabs.org/patch/207454/
Please tell me if you still unclear.
Thanks, Jagan.
Regards, Simon
Signed-off-by: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com
Changes in v3: improved coding style
drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 3 +++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 9e8939c..0f05b91 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -264,6 +264,14 @@ 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;
cmd = CMD_READ_STATUS;
return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)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 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
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Jagan,
On Fri, Jan 11, 2013 at 7:51 AM, Jagan Teki jagannadh.teki@gmail.com wrote:
Hi Simon,
On Fri, Jan 11, 2013 at 7:52 AM, Simon Glass sjg@chromium.org wrote:
Hi Jagannadha
On Thu, Jan 3, 2013 at 6:51 AM, Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com wrote:
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.
Do you have a console command for this, and the control register also?
There is no sf command for status register read.
Usage is based on the user code, see how I am using this function on Quad Enable bit setting. http://patchwork.ozlabs.org/patch/207454/
Please tell me if you still unclear.
Yes, but do you think such a command might be useful? Or is it better to have commands for each individual feature? I am thinking of locking of part of the flash and anything else that the status register provides.
Regards, Simon
Thanks, Jagan.
Regards, Simon
Signed-off-by: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com
Changes in v3: improved coding style
drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 3 +++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 9e8939c..0f05b91 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -264,6 +264,14 @@ 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;
cmd = CMD_READ_STATUS;
return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)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 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
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Simon,
On Fri, Jan 11, 2013 at 9:29 PM, Simon Glass sjg@chromium.org wrote:
Hi Jagan,
On Fri, Jan 11, 2013 at 7:51 AM, Jagan Teki jagannadh.teki@gmail.com wrote:
Hi Simon,
On Fri, Jan 11, 2013 at 7:52 AM, Simon Glass sjg@chromium.org wrote:
Hi Jagannadha
On Thu, Jan 3, 2013 at 6:51 AM, Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com wrote:
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.
Do you have a console command for this, and the control register also?
There is no sf command for status register read.
Usage is based on the user code, see how I am using this function on Quad Enable bit setting. http://patchwork.ozlabs.org/patch/207454/
Please tell me if you still unclear.
Yes, but do you think such a command might be useful? Or is it better to have commands for each individual feature? I am thinking of locking of part of the flash and anything else that the status register provides
I don't think so.
The status and config registers read and write functionalities are used based on the usage level in flash programming (flash reads/writes). so these special features are valid in those cases.
User can use these features by calling a respective register function calls with respective their need.
Thanks, Jagan.
Regards, Simon
Thanks, Jagan.
Regards, Simon
Signed-off-by: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com
Changes in v3: improved coding style
drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 3 +++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 9e8939c..0f05b91 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -264,6 +264,14 @@ 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;
cmd = CMD_READ_STATUS;
return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)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 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
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
participants (3)
-
Jagan Teki
-
Jagannadha Sutradharudu Teki
-
Simon Glass