[U-Boot] [PATCH 1/2] cros_ec: Add function to read back flash parameters

Add support for reading back flash parameters as reported by the ec.
Signed-off-by: Moritz Fischer moritz.fischer@ettus.com Cc: Simon Glass sjg@chromium.org Cc: u-boot@lists.denx.de --- drivers/misc/cros_ec.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 06a7dcc..931fdf5 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -809,6 +809,27 @@ static int cros_ec_data_is_erased(const uint32_t *data, int size) return 1; }
+/** + * Read back flash parameters + * + * This function reads back parameters of the flash as reported by the EC + * + * @param dev Pointer to device + * @param info Pointer to output flash info struct + */ +int cros_ec_read_flashinfo(struct cros_ec_dev *dev, + struct ec_response_flash_info *info) +{ + int ret; + + ret = ec_command(dev, EC_CMD_FLASH_INFO, 0, + NULL, 0, info, sizeof(*info)); + if (ret < 0) + return ret; + + return ret < sizeof(*info) ? -1 : 0; +} + int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data, uint32_t offset, uint32_t size) {

Add command to print out the flash info as reported by the ec. The data read back includes size, write block size, erase block size.
Signed-off-by: Moritz Fischer moritz.fischer@ettus.com Cc: Simon Glass sjg@chromium.org Cc: u-boot@lists.denx.de --- drivers/misc/cros_ec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 931fdf5..cb5db0f 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1382,6 +1382,15 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("Offset: %x\n", offset); printf("Size: %x\n", size); } + } else if (0 == strcmp("flashinfo", cmd)) { + struct ec_response_flash_info p; + + ret = cros_ec_read_flashinfo(dev, &p); + if (!ret) { + printf("Flash size: %u\n", p.flash_size); + printf("Write block size: %u\n", p.write_block_size); + printf("Erase block size: %u\n", p.erase_block_size); + } } else if (0 == strcmp("vbnvcontext", cmd)) { uint8_t block[EC_VBNV_BLOCK_SIZE]; char buf[3]; @@ -1501,6 +1510,7 @@ U_BOOT_CMD( "crosec events Read CROS-EC host events\n" "crosec clrevents [mask] Clear CROS-EC host events\n" "crosec regioninfo <ro|rw> Read image info\n" + "crosec flashinfo Read flash info\n" "crosec erase <ro|rw> Erase EC image\n" "crosec read <ro|rw> <addr> [<size>] Read EC image\n" "crosec write <ro|rw> <addr> [<size>] Write EC image\n"

Hi Moritz,
On 13 September 2016 at 15:44, Moritz Fischer moritz.fischer@ettus.com wrote:
Add command to print out the flash info as reported by the ec. The data read back includes size, write block size, erase block size.
Signed-off-by: Moritz Fischer moritz.fischer@ettus.com Cc: Simon Glass sjg@chromium.org Cc: u-boot@lists.denx.de
drivers/misc/cros_ec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
If you have the energy, it might be useful to move the command code from this file into cmd/cros_ec.c
Regards, Simon

On 18 September 2016 at 18:58, Simon Glass sjg@chromium.org wrote:
Hi Moritz,
On 13 September 2016 at 15:44, Moritz Fischer moritz.fischer@ettus.com wrote:
Add command to print out the flash info as reported by the ec. The data read back includes size, write block size, erase block size.
Signed-off-by: Moritz Fischer moritz.fischer@ettus.com Cc: Simon Glass sjg@chromium.org Cc: u-boot@lists.denx.de
drivers/misc/cros_ec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
If you have the energy, it might be useful to move the command code from this file into cmd/cros_ec.c
Regards, Simon
Applied to u-boot-dm, thanks!

On 13 September 2016 at 15:44, Moritz Fischer moritz.fischer@ettus.com wrote:
Add support for reading back flash parameters as reported by the ec.
Signed-off-by: Moritz Fischer moritz.fischer@ettus.com Cc: Simon Glass sjg@chromium.org Cc: u-boot@lists.denx.de
drivers/misc/cros_ec.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
Acked-by: Simon Glass sjg@chromium.org

On 18 September 2016 at 18:58, Simon Glass sjg@chromium.org wrote:
On 13 September 2016 at 15:44, Moritz Fischer moritz.fischer@ettus.com wrote:
Add support for reading back flash parameters as reported by the ec.
Signed-off-by: Moritz Fischer moritz.fischer@ettus.com Cc: Simon Glass sjg@chromium.org Cc: u-boot@lists.denx.de
drivers/misc/cros_ec.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-dm, thanks!
participants (2)
-
Moritz Fischer
-
Simon Glass