Skip to contentSkip to conversation

cros_ec: Add function to read back flash parameters

PATCH New Moritz Fischer 2 participants 6 messages Sep 13, 2016 – Oct 2, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cros_ec: Add function to read back flash parameters

Add support for reading back flash parameters as reported by the ec.

Cc Simon Glass <[email protected]>
Cc u-boot at lists.denx.de
---
 drivers/misc/cros_ec.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/misc/cros_ec.c +21 -0
index 06a7dcc..931fdf5 100644
@@ -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)
 {
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 cros_ec: Add crosec flashinfo command

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.

Cc Simon Glass <[email protected]>
Cc u-boot at lists.denx.de
---
 drivers/misc/cros_ec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/misc/cros_ec.c +10 -0
index 931fdf5..cb5db0f 100644
@@ -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"
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 cros_ec: Add crosec flashinfo command

Hi Moritz,

Quoted 10 lines · Moritz Fischer

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.

Cc Simon Glass <[email protected]>
Cc u-boot at lists.denx.de
---
 drivers/misc/cros_ec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

If you have the energy, it might be useful to move the command code from this file into cmd/cros_ec.c

Regards,
Simon

#3 lore raw

PATCH 2/2 cros_ec: Add crosec flashinfo command

Quoted 14 lines · Simon Glass

Hi Moritz,

Quoted 10 lines · Moritz Fischer

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.

Cc Simon Glass <[email protected]>
Cc u-boot at lists.denx.de
---
 drivers/misc/cros_ec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Quoted 7 lines

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!

#5 lore raw

PATCH 1/2 cros_ec: Add function to read back flash parameters

Quoted 4 lines · Simon Glass
Quoted 3 lines · Moritz Fischer

Add support for reading back flash parameters as reported by the ec.

Quoted 8 lines
Quoted 6 lines
Cc Simon Glass <[email protected]>
Cc u-boot at lists.denx.de
---
 drivers/misc/cros_ec.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Applied to u-boot-dm, thanks!