summaryrefslogtreecommitdiff
path: root/common/cbi.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-04-17 11:14:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-19 14:45:20 -0700
commit76814895ef0d9d2181bda57c0a9070d8194190ca (patch)
treeead8ca4f6648079d67af01c8e1ea5162b56cfa94 /common/cbi.c
parenta013f9eed6465569b99e96fe521c11b8c5f05e05 (diff)
downloadchrome-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 'common/cbi.c')
-rw-r--r--common/cbi.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/common/cbi.c b/common/cbi.c
index 06e0d464c1..d8feee3189 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -154,6 +154,12 @@ static int read_board_info(void)
return cached_read_result;
}
+__attribute__((weak))
+int cbi_board_override(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size)
+{
+ return EC_SUCCESS;
+}
+
int cbi_get_board_info(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size)
{
const struct cbi_data *d;
@@ -174,7 +180,8 @@ int cbi_get_board_info(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size)
/* Copy the value */
memcpy(buf, d->value, d->size);
*size = d->size;
- return EC_SUCCESS;
+
+ return cbi_board_override(tag, buf, size);
}
static void cbi_remove_tag(void *const cbi, struct cbi_data *const d)