diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-01-12 12:52:18 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-18 05:09:31 -0800 |
commit | 5232cdd16bb2e1b15b281b0041c33c55bc9ca52d (patch) | |
tree | 348d2e911096addbf8d724f554afb10a744c852c /common/cbi.c | |
parent | c62060d9d987285c541c58e752c51d18bd7162a2 (diff) | |
download | chrome-ec-5232cdd16bb2e1b15b281b0041c33c55bc9ca52d.tar.gz |
CBI: Add host command to get board info
This patch adds host command to get board info from EEPROM.
BUG=b:70294260
BRANCH=none
TEST=Run ectool cbi get <type> to get board version, OEM, SKU
Change-Id: I41a84d3eea6da9d88fa8122db36dcd1df515842d
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/865161
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/cbi.c')
-rw-r--r-- | common/cbi.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/cbi.c b/common/cbi.c index dce8475d81..b82d0375c2 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -9,6 +9,7 @@ #include "console.h" #include "crc8.h" #include "cros_board_info.h" +#include "host_command.h" #include "i2c.h" #include "util.h" @@ -125,3 +126,31 @@ int board_get_version(void) return -1; return version; } + +static int hc_cbi_get(struct host_cmd_handler_args *args) +{ + const struct __ec_align4 ec_params_get_cbi *p = args->params; + + if (read_board_info()) + return EC_RES_ERROR; + + switch (p->type) { + case CBI_DATA_BOARD_VERSION: + *(uint32_t *)args->response = bi.version; + break; + case CBI_DATA_OEM_ID: + *(uint32_t *)args->response = bi.oem_id; + break; + case CBI_DATA_SKU_ID: + *(uint32_t *)args->response = bi.sku_id; + break; + default: + return EC_RES_INVALID_PARAM; + } + args->response_size = sizeof(uint32_t); + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_GET_CROS_BOARD_INFO, + hc_cbi_get, + EC_VER_MASK(0)); |