summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Chen <marcochen@google.com>2020-08-10 12:19:10 +0800
committerCommit Bot <commit-bot@chromium.org>2021-05-20 06:53:10 +0000
commitd8b6a2f51374d6c2df829b10cc99184cd3e05720 (patch)
tree398c8cd05a181c788805539bd7300d475a2d25de
parent41fdb485cdcb86fb4ce68b1907cc80c040e9d67a (diff)
downloadchrome-ec-d8b6a2f51374d6c2df829b10cc99184cd3e05720.tar.gz
cbi: add Second Source Factory Cache (SSFC) CBI field
SSFC field will be leveraged to record what second source is used in the DUT by probing components in the factory or RMA. Firmware code should refer to this field to judge what driver should be configured for a specific component. For example, the board code can arrange what sensor driver should be set into motion_sensors array if there are multiple sources of base or lid sensor. As the definition of FW_CONFIG, it describe which "features" the firmware code should enable or disable. For example, whether lid / base sensors should be enabled or not but not care about what second source is in this DUT. Conflict of Cherry-picking: Since FW_CONFIG and PCB_SUPPLIER are not cherry-picked, the SSFC field is amended from CBI_TAG_SSFC = 8 to 6. BRANCH=none BUG=b:163285687 TEST=call `cbi-util` to create the cbi image with SSFC and show created content. TEST=`make buildall -j` TEST=`make runhosttests -j` Change-Id: Icb4aa00ae47ab025198e7fd5edd6aab96a4bf53e Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2344268 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> (cherry picked from commit 0212d4a3ce01452ddaba46f076f90e9a5e90e589) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2386685 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2909098
-rw-r--r--common/cbi.c9
-rw-r--r--include/cros_board_info.h5
-rw-r--r--include/ec_commands.h2
-rw-r--r--util/cbi-util.c11
-rw-r--r--util/ectool.c1
5 files changed, 26 insertions, 2 deletions
diff --git a/common/cbi.c b/common/cbi.c
index 5d1c195c84..82fa5e539b 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -279,6 +279,14 @@ int cbi_get_pcb_supplier(uint32_t *pcb_supplier)
&size);
}
+int cbi_get_ssfc(uint32_t *ssfc)
+{
+ uint8_t size = sizeof(*ssfc);
+
+ return cbi_get_board_info(CBI_TAG_SSFC, (uint8_t *)ssfc,
+ &size);
+}
+
static int hc_cbi_get(struct host_cmd_handler_args *args)
{
const struct __ec_align4 ec_params_get_cbi *p = args->params;
@@ -397,6 +405,7 @@ static void dump_cbi(void)
print_tag("SKU_ID", cbi_get_sku_id(&val), &val);
print_tag("FW_CONFIG", cbi_get_fw_config(&val), &val);
print_tag("PCB_SUPPLIER", cbi_get_pcb_supplier(&val), &val);
+ print_tag("SSFC", cbi_get_ssfc(&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 a8a1d5c023..ca5dc34d0a 100644
--- a/include/cros_board_info.h
+++ b/include/cros_board_info.h
@@ -44,8 +44,8 @@ struct cbi_data {
/**
* Board info accessors
*
- * @param version/sku_id/oem_id/id/fw_config/pcb_supplier [OUT] Data read from
- * EEPROM
+ * @param version/sku_id/oem_id/id/fw_config/pcb_supplier/ssfc [OUT] Data read
+ * from EEPROM
* @return EC_SUCCESS on success or EC_ERROR_* otherwise.
*/
int cbi_get_board_version(uint32_t *version);
@@ -54,6 +54,7 @@ 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);
int cbi_get_pcb_supplier(uint32_t *pcb_supplier);
+int cbi_get_ssfc(uint32_t *ssfc);
/**
* Primitive accessors
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 14efbeca62..81521c8cd2 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5012,6 +5012,8 @@ enum cbi_data_tag {
CBI_TAG_MODEL_ID = 5, /* uint32_t or smaller */
CBI_TAG_FW_CONFIG = 6, /* uint32_t bit field */
CBI_TAG_PCB_SUPPLIER = 7, /* uint32_t or smaller */
+ /* Second Source Factory Cache */
+ CBI_TAG_SSFC = 8, /* uint32_t bit field */
CBI_TAG_COUNT,
};
diff --git a/util/cbi-util.c b/util/cbi-util.c
index 328198f4f9..3c963b28c1 100644
--- a/util/cbi-util.c
+++ b/util/cbi-util.c
@@ -40,6 +40,7 @@ enum {
OPT_MODEL_ID,
OPT_FW_CONFIG,
OPT_PCB_SUPPLIER,
+ OPT_SSFC,
OPT_SIZE,
OPT_ERASE_BYTE,
OPT_SHOW_ALL,
@@ -56,6 +57,7 @@ static const struct option opts_create[] = {
{"model_id", 1, 0, OPT_MODEL_ID},
{"fw_config", 1, 0, OPT_FW_CONFIG},
{"pcb_supplier", 1, 0, OPT_PCB_SUPPLIER},
+ {"ssfc", 1, 0, OPT_SSFC},
{"size", 1, 0, OPT_SIZE},
{"erase_byte", 1, 0, OPT_ERASE_BYTE},
{NULL, 0, 0, 0}
@@ -77,6 +79,7 @@ static const char *field_name[] = {
"MODEL_ID",
"FW_CONFIG",
"PCB_SUPPLIER",
+ "SSFC",
};
BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT);
@@ -100,6 +103,7 @@ const char help_create[] =
" --model_id <value> Model ID\n"
" --fw_config <value> Firmware configuration bit-field\n"
" --pcb_supplier <value> PCB supplier\n"
+ " --ssfc <value> Second Source Factory Cache 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"
@@ -259,6 +263,7 @@ static int cmd_create(int argc, char **argv)
struct integer_field model;
struct integer_field fw_config;
struct integer_field pcb_supplier;
+ struct integer_field ssfc;
const char *dram_part_num;
const char *oem_name;
} bi;
@@ -336,6 +341,10 @@ static int cmd_create(int argc, char **argv)
if (parse_integer_field(optarg, &bi.pcb_supplier))
return -1;
break;
+ case OPT_SSFC:
+ if (parse_integer_field(optarg, &bi.ssfc))
+ return -1;
+ break;
}
}
@@ -366,6 +375,7 @@ static int cmd_create(int argc, char **argv)
bi.fw_config.size);
p = cbi_set_data(p, CBI_TAG_PCB_SUPPLIER, &bi.pcb_supplier.val,
bi.pcb_supplier.size);
+ p = cbi_set_data(p, CBI_TAG_SSFC, &bi.ssfc.val, bi.ssfc.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);
@@ -497,6 +507,7 @@ static int cmd_show(int argc, char **argv)
print_integer(buf, CBI_TAG_MODEL_ID);
print_integer(buf, CBI_TAG_FW_CONFIG);
print_integer(buf, CBI_TAG_PCB_SUPPLIER);
+ print_integer(buf, CBI_TAG_SSFC);
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 db394a983b..4347ec7520 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -6810,6 +6810,7 @@ static void cmd_cbi_help(char *cmd)
" 5: MODEL_ID\n"
" 6: FW_CONFIG\n"
" 7: PCB_VENDOR\n"
+ " 8: SSFC\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"