diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2019-04-17 11:14:32 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-19 14:45:20 -0700 |
commit | 76814895ef0d9d2181bda57c0a9070d8194190ca (patch) | |
tree | ead8ca4f6648079d67af01c8e1ea5162b56cfa94 /include/cros_board_info.h | |
parent | a013f9eed6465569b99e96fe521c11b8c5f05e05 (diff) | |
download | chrome-ec-76814895ef0d9d2181bda57c0a9070d8194190ca.tar.gz |
CBI: Allow board to compose data from other sources
Currently, the source of CBI data is only EEPROM. This patch allows
CBI data to be composed from other sources such as ADC or some chip
register.
cbi_board_override is called by CBI library when data is being
requested. Boards can implement this callback to add additional bits
or bytes to the data.
A board itself may need to get CBI data first to manipulate data
properly. For such a case, a board can return EC_ERROR_BUSY to inform
the callers that the data is not fully ready while a board itself can
accept EC_ERROR_BUSY as an expected value.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b/129569858
BRANCH=none
TEST=Read LCM_ID properly
Change-Id: Ie1f962c64c8d1461a6c171bc6c6d0c855c82e945
Reviewed-on: https://chromium-review.googlesource.com/1572439
Commit-Ready: YH Lin <yueherngl@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/cros_board_info.h')
-rw-r--r-- | include/cros_board_info.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/include/cros_board_info.h b/include/cros_board_info.h index e7a1f1bb48..7650cfc078 100644 --- a/include/cros_board_info.h +++ b/include/cros_board_info.h @@ -46,6 +46,7 @@ struct cbi_data { * * @param version/sku_id/oem_id [OUT] Data read from EEPROM * @return EC_SUCCESS on success or EC_ERROR_* otherwise. + * EC_ERROR_BUSY to indicate data is not ready. */ int cbi_get_board_version(uint32_t *version); int cbi_get_sku_id(uint32_t *sku_id); @@ -53,14 +54,24 @@ int cbi_get_oem_id(uint32_t *oem_id); int cbi_get_model_id(uint32_t *id); /** - * Primitive accessors + * Get data from CBI store * * @param tag Tag of the target data. * @param buf Buffer where data is passed. * @param size (IN) Size of <buf>. (OUT) Size of the data returned. * @return EC_SUCCESS on success or EC_ERROR_* otherwise. + * EC_ERROR_BUSY to indicate data is not ready. */ int cbi_get_board_info(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size); + +/** + * Set data in CBI store + * + * @param tag Tag of the target data. + * @param buf Buffer where data is passed. + * @param size (IN) Size of <buf>. (OUT) Size of the data returned. + * @return EC_SUCCESS on success or EC_ERROR_* otherwise. + */ int cbi_set_board_info(enum cbi_data_tag tag, const uint8_t *buf, uint8_t size); /* @@ -114,4 +125,21 @@ uint8_t *cbi_set_string(uint8_t *p, enum cbi_data_tag tag, const char *str); */ struct cbi_data *cbi_find_tag(const void *cbi, enum cbi_data_tag tag); +/** + * Callback implemented by board to manipulate data + * + * Note that this is part of the APIs (cbi_get_*) which can be called in any + * order any time. Your callback should return EC_SUCCESS only after it has all + * the data needed for manipulation. Until then, it should return EC_ERROR_BUSY. + * That'll provide a consistent view to the callers, which is critical for CBI + * to be functional. + * + * @param tag Tag of the data field to be manipulated + * @param buf Pointer to the buffer containing the data being manipulated. + * @param size size of the date in bytes + * @return EC_SUCCESS to indicate the data is ready. + * EC_ERROR_BUSY to indicate supplemental data is not ready. + */ +int cbi_board_override(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size); + #endif /* __CROS_EC_CROS_BOARD_INFO_H */ |