summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-12-02 10:26:49 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-01 12:20:33 +0000
commit5c532b1d4fe9b92134b428cacee2a2fa9b4090f0 (patch)
treee5facc6223251fb47c9a9e6c0689e0c651db2cec
parentb5f89ac98cc6714709ba201961abdc4486a62baa (diff)
downloadchrome-ec-5c532b1d4fe9b92134b428cacee2a2fa9b4090f0.tar.gz
cbi: add FW_CONFIG CBI field
This field will be used to describe which "features" or path the firmware code should enable or disable. Firmware code should look at the firmware configuration value to make code decision for un-discoverable hardware connections or layouts that differ within the same firmware binary. Firmware should no longer use SKU_ID/VARIANT_ID to make decisions, only this new FW_CONFIG field. BRANCH=none BUG=b:145519081 TEST=Created cbi image with FW_CONFIG field Change-Id: I1db8e7638a15343173ea5061e9038a7d53bda090 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1945821 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit 25002abca7e900d6473b40354c8bc79c4dfa11c7) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387684 Tested-by: Marco Chen <marcochen@chromium.org> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Commit-Queue: Marco Chen <marcochen@chromium.org>
-rw-r--r--common/cbi.c13
-rw-r--r--include/cros_board_info.h3
-rw-r--r--include/ec_commands.h1
-rw-r--r--util/cbi-util.c16
-rw-r--r--util/ectool.c1
5 files changed, 33 insertions, 1 deletions
diff --git a/common/cbi.c b/common/cbi.c
index 8ec4472b24..4b99a5a33f 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -238,27 +238,39 @@ static int write_board_info(void)
int cbi_get_board_version(uint32_t *ver)
{
uint8_t size = sizeof(*ver);
+
return cbi_get_board_info(CBI_TAG_BOARD_VERSION, (uint8_t *)ver, &size);
}
int cbi_get_sku_id(uint32_t *id)
{
uint8_t size = sizeof(*id);
+
return cbi_get_board_info(CBI_TAG_SKU_ID, (uint8_t *)id, &size);
}
int cbi_get_oem_id(uint32_t *id)
{
uint8_t size = sizeof(*id);
+
return cbi_get_board_info(CBI_TAG_OEM_ID, (uint8_t *)id, &size);
}
int cbi_get_model_id(uint32_t *id)
{
uint8_t size = sizeof(*id);
+
return cbi_get_board_info(CBI_TAG_MODEL_ID, (uint8_t *)id, &size);
}
+int cbi_get_fw_config(uint32_t *fw_config)
+{
+ uint8_t size = sizeof(*fw_config);
+
+ return cbi_get_board_info(CBI_TAG_FW_CONFIG, (uint8_t *)fw_config,
+ &size);
+}
+
static int hc_cbi_get(struct host_cmd_handler_args *args)
{
const struct __ec_align4 ec_params_get_cbi *p = args->params;
@@ -375,6 +387,7 @@ static void dump_cbi(void)
print_tag("OEM_ID", cbi_get_oem_id(&val), &val);
print_tag("MODEL_ID", cbi_get_model_id(&val), &val);
print_tag("SKU_ID", cbi_get_sku_id(&val), &val);
+ print_tag("FW_CONFIG", cbi_get_fw_config(&val), &val);
}
static int cc_cbi(int argc, char **argv)
diff --git a/include/cros_board_info.h b/include/cros_board_info.h
index 8ed8737731..4bc711450f 100644
--- a/include/cros_board_info.h
+++ b/include/cros_board_info.h
@@ -44,13 +44,14 @@ struct cbi_data {
/**
* Board info accessors
*
- * @param version/sku_id/oem_id [OUT] Data read from EEPROM
+ * @param version/sku_id/oem_id/id/fw_config [OUT] Data read from EEPROM
* @return EC_SUCCESS on success or EC_ERROR_* otherwise.
*/
int cbi_get_board_version(uint32_t *version);
int cbi_get_sku_id(uint32_t *sku_id);
int cbi_get_oem_id(uint32_t *oem_id);
int cbi_get_model_id(uint32_t *id);
+int cbi_get_fw_config(uint32_t *fw_config);
/**
* Primitive accessors
diff --git a/include/ec_commands.h b/include/ec_commands.h
index eba10b6f4f..e87c94e843 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5043,6 +5043,7 @@ enum cbi_data_tag {
CBI_TAG_DRAM_PART_NUM = 3, /* variable length ascii, nul terminated. */
CBI_TAG_OEM_NAME = 4, /* variable length ascii, nul terminated. */
CBI_TAG_MODEL_ID = 5, /* uint32_t or smaller */
+ CBI_TAG_FW_CONFIG = 6, /* uint32_t bit field */
CBI_TAG_COUNT,
};
diff --git a/util/cbi-util.c b/util/cbi-util.c
index 2ea86b14cf..1dc4ec3cce 100644
--- a/util/cbi-util.c
+++ b/util/cbi-util.c
@@ -38,6 +38,7 @@ enum {
OPT_DRAM_PART_NUM,
OPT_OEM_NAME,
OPT_MODEL_ID,
+ OPT_FW_CONFIG,
OPT_SIZE,
OPT_ERASE_BYTE,
OPT_SHOW_ALL,
@@ -52,6 +53,7 @@ static const struct option opts_create[] = {
{"dram_part_num", 1, 0, OPT_DRAM_PART_NUM},
{"oem_name", 1, 0, OPT_OEM_NAME},
{"model_id", 1, 0, OPT_MODEL_ID},
+ {"fw_config", 1, 0, OPT_FW_CONFIG},
{"size", 1, 0, OPT_SIZE},
{"erase_byte", 1, 0, OPT_ERASE_BYTE},
{NULL, 0, 0, 0}
@@ -71,6 +73,7 @@ static const char *field_name[] = {
"DRAM_PART_NUM",
"OEM_NAME",
"MODEL_ID",
+ "FW_CONFIG",
};
BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT);
@@ -92,6 +95,11 @@ const char help_create[] =
" --erase_byte <uint8> Byte used for empty space. Default:0xff\n"
" --format_version <uint16> Data format version\n"
" --model_id <value> Model ID\n"
+ " --fw_config <value> Firmware configuration bit-field\n"
+ "\n"
+ "<value> must be a positive integer <= 0XFFFFFFFF and field size can\n"
+ " be optionally specified by <value:size> notation: e.g. 0xabcd:4.\n"
+ "<size> must be a positive integer <= 0XFFFF.\n"
"<string> is a string\n"
"\n";
@@ -245,6 +253,7 @@ static int cmd_create(int argc, char **argv)
struct integer_field oem;
struct integer_field sku;
struct integer_field model;
+ struct integer_field fw_config;
const char *dram_part_num;
const char *oem_name;
} bi;
@@ -314,6 +323,10 @@ static int cmd_create(int argc, char **argv)
if (parse_integer_field(optarg, &bi.model))
return -1;
break;
+ case OPT_FW_CONFIG:
+ if (parse_integer_field(optarg, &bi.fw_config))
+ return -1;
+ break;
}
}
@@ -340,6 +353,8 @@ static int cmd_create(int argc, char **argv)
p = cbi_set_data(p, CBI_TAG_OEM_ID, &bi.oem.val, bi.oem.size);
p = cbi_set_data(p, CBI_TAG_SKU_ID, &bi.sku.val, bi.sku.size);
p = cbi_set_data(p, CBI_TAG_MODEL_ID, &bi.model.val, bi.model.size);
+ p = cbi_set_data(p, CBI_TAG_FW_CONFIG, &bi.fw_config.val,
+ bi.fw_config.size);
if (bi.dram_part_num != NULL) {
p = cbi_set_data(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num,
strlen(bi.dram_part_num) + 1);
@@ -469,6 +484,7 @@ static int cmd_show(int argc, char **argv)
print_integer(buf, CBI_TAG_OEM_ID);
print_integer(buf, CBI_TAG_SKU_ID);
print_integer(buf, CBI_TAG_MODEL_ID);
+ print_integer(buf, CBI_TAG_FW_CONFIG);
print_string(buf, CBI_TAG_DRAM_PART_NUM);
print_string(buf, CBI_TAG_OEM_NAME);
diff --git a/util/ectool.c b/util/ectool.c
index 7d02a82932..985909e5c2 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -6960,6 +6960,7 @@ static void cmd_cbi_help(char *cmd)
" 3: DRAM_PART_NUM (string)\n"
" 4: OEM_NAME (string)\n"
" 5: MODEL_ID\n"
+ " 6: FW_CONFIG\n"
" <size> is the size of the data in byte. It should be zero for\n"
" string types.\n"
" <value/string> is an integer or a string to be set\n"