diff options
author | Simon Glass <sjg@chromium.org> | 2023-09-26 08:14:48 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-09-26 11:25:25 -0400 |
commit | e9c07619f9dce68bed99c9f4849ccf36c7390c90 (patch) | |
tree | 808e18ef08cda1964e1af6ec73fd80b7cb33ae0e | |
parent | 33940ab7be025f85c652595db6abf9de98fd0eb7 (diff) | |
download | u-boot-e9c07619f9dce68bed99c9f4849ccf36c7390c90.zip u-boot-e9c07619f9dce68bed99c9f4849ccf36c7390c90.tar.gz u-boot-e9c07619f9dce68bed99c9f4849ccf36c7390c90.tar.bz2 |
sandbox: Init the EC properly even if no state file is available
This currently relies on sandbox attempting to read a state file. At
present it always does, even when there is no state file, in which case it
fails, but still inits the EC.
That is a bug, so update this driver to set the current image always, even
if no state is read.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | drivers/misc/cros_ec_sandbox.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index 8dbe0b1..1201535 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -81,6 +81,7 @@ struct ec_pwm_channel { /** * struct ec_state - Information about the EC state * + * @valid: true if this struct contains valid state data * @vbnv_context: Vboot context data stored by EC * @ec_config: FDT config information about the EC (e.g. flashmap) * @flash_data: Contents of flash memory @@ -95,6 +96,7 @@ struct ec_pwm_channel { * @pwm: Information per PWM channel */ struct ec_state { + bool valid; u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2]; struct fdt_cros_ec ec_config; uint8_t *flash_data; @@ -145,6 +147,7 @@ static int cros_ec_read_state(const void *blob, int node) memcpy(ec->flash_data, prop, len); debug("%s: Loaded EC flash data size %#x\n", __func__, len); } + ec->valid = true; return 0; } @@ -589,6 +592,7 @@ static int process_cmd(struct ec_state *ec, printf(" ** Unknown EC command %#02x\n", req_hdr->command); return -1; } + debug(" - EC command %#0x, result %d\n", req_hdr->command, len); return len; } @@ -675,7 +679,10 @@ int cros_ec_probe(struct udevice *dev) ofnode node; int err; - memcpy(ec, &s_state, sizeof(*ec)); + if (s_state.valid) + memcpy(ec, &s_state, sizeof(*ec)); + else + ec->current_image = EC_IMAGE_RO; err = cros_ec_decode_ec_flash(dev, &ec->ec_config); if (err) { debug("%s: Cannot device EC flash\n", __func__); |