diff options
author | Scott Collyer <scollyer@google.com> | 2021-03-20 16:34:12 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-10 21:48:42 +0000 |
commit | 8113e3d1f538039477ec4b1461031da770931055 (patch) | |
tree | 5714aa3c9a7bec1530dc7c1095e6e220941a00b3 /common/cbi.c | |
parent | f979f98b8336ad0908f948aa7fe1d57d0a5b54f8 (diff) | |
download | chrome-ec-8113e3d1f538039477ec4b1461031da770931055.tar.gz |
cbi: API for EC to update fw_config tag
This CL adds an API to the CBI to allow the EC to update the FW_CONFIG
tag field. This API is dependent on not having a the chipset task
defined.
BUG=b:164157329
BRANCH=quiche
TEST=Verified on quiche that long button presses toggle bit 0 of the
FW_CONFIG field.
Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: I3a4360b32feac4a04fe53b518c122940f4b340f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2776227
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Sam Hurst <shurst@google.com>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'common/cbi.c')
-rw-r--r-- | common/cbi.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/cbi.c b/common/cbi.c index b17faf3172..47d6bf42e1 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -596,4 +596,30 @@ DECLARE_CONSOLE_COMMAND(cbi, cc_cbi, "[set <tag> <value> <size> | " "Print or change Cros Board Info from flash"); #endif /* CONFIG_CMD_CBI */ +#ifndef HAS_TASK_CHIPSET +int cbi_set_fw_config(uint32_t fw_config) +{ + /* Check write protect status */ + if (eeprom_is_write_protected()) + return EC_ERROR_ACCESS_DENIED; + + /* Ensure that CBI has been configured */ + if (do_read_board_info()) + cbi_create(); + + /* Update the FW_CONFIG field */ + cbi_set_board_info(CBI_TAG_FW_CONFIG, (uint8_t *)&fw_config, + sizeof(int)); + + /* Update CRC calculation and write to serial EEPROM */ + head->crc = cbi_crc8(head); + if (write_board_info()) + return EC_ERROR_UNKNOWN; + + dump_cbi(); + + return EC_SUCCESS; +} +#endif + #endif /* !HOST_TOOLS_BUILD */ |