summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/cbi.c7
-rw-r--r--include/cros_board_info.h1
-rw-r--r--include/ec_commands.h1
-rw-r--r--util/cbi-util.c23
-rw-r--r--util/ectool.c20
5 files changed, 39 insertions, 13 deletions
diff --git a/common/cbi.c b/common/cbi.c
index f37d6950b1..8ec4472b24 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -253,6 +253,12 @@ int cbi_get_oem_id(uint32_t *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);
+}
+
static int hc_cbi_get(struct host_cmd_handler_args *args)
{
const struct __ec_align4 ec_params_get_cbi *p = args->params;
@@ -367,6 +373,7 @@ static void dump_cbi(void)
print_tag("BOARD_VERSION", cbi_get_board_version(&val), &val);
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);
}
diff --git a/include/cros_board_info.h b/include/cros_board_info.h
index 23063d2766..8ed8737731 100644
--- a/include/cros_board_info.h
+++ b/include/cros_board_info.h
@@ -50,6 +50,7 @@ struct cbi_data {
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);
/**
* Primitive accessors
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 34d6bb7038..7e651ea214 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4958,6 +4958,7 @@ enum cbi_data_tag {
CBI_TAG_SKU_ID = 2, /* uint32_t or smaller */
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_COUNT,
};
diff --git a/util/cbi-util.c b/util/cbi-util.c
index cc4fda8ba5..2ea86b14cf 100644
--- a/util/cbi-util.c
+++ b/util/cbi-util.c
@@ -37,6 +37,7 @@ enum {
OPT_SKU_ID,
OPT_DRAM_PART_NUM,
OPT_OEM_NAME,
+ OPT_MODEL_ID,
OPT_SIZE,
OPT_ERASE_BYTE,
OPT_SHOW_ALL,
@@ -50,6 +51,7 @@ static const struct option opts_create[] = {
{"sku_id", 1, 0, OPT_SKU_ID},
{"dram_part_num", 1, 0, OPT_DRAM_PART_NUM},
{"oem_name", 1, 0, OPT_OEM_NAME},
+ {"model_id", 1, 0, OPT_MODEL_ID},
{"size", 1, 0, OPT_SIZE},
{"erase_byte", 1, 0, OPT_ERASE_BYTE},
{NULL, 0, 0, 0}
@@ -67,7 +69,8 @@ static const char *field_name[] = {
"OEM_ID",
"SKU_ID",
"DRAM_PART_NUM",
- "OEM_NAME"
+ "OEM_NAME",
+ "MODEL_ID",
};
BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT);
@@ -75,11 +78,11 @@ const char help_create[] =
"\n"
"'%s create [ARGS]' creates an EEPROM image file.\n"
"Required ARGS are:\n"
- " --file <file> Path to output file\n"
- " --board_version <value> Board version\n"
- " --oem_id <value> OEM ID\n"
- " --sku_id <value> SKU ID\n"
- " --size <size> Size of output file in bytes\n"
+ " --file <file> Path to output file\n"
+ " --board_version <value> Board version\n"
+ " --oem_id <value> OEM ID\n"
+ " --sku_id <value> SKU ID\n"
+ " --size <size> Size of output file in bytes\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"
@@ -88,6 +91,7 @@ const char help_create[] =
" --oem_name <string> OEM NAME\n"
" --erase_byte <uint8> Byte used for empty space. Default:0xff\n"
" --format_version <uint16> Data format version\n"
+ " --model_id <value> Model ID\n"
"<string> is a string\n"
"\n";
@@ -240,6 +244,7 @@ static int cmd_create(int argc, char **argv)
struct integer_field ver;
struct integer_field oem;
struct integer_field sku;
+ struct integer_field model;
const char *dram_part_num;
const char *oem_name;
} bi;
@@ -305,6 +310,10 @@ static int cmd_create(int argc, char **argv)
case OPT_OEM_NAME:
bi.oem_name = optarg;
break;
+ case OPT_MODEL_ID:
+ if (parse_integer_field(optarg, &bi.model))
+ return -1;
+ break;
}
}
@@ -330,6 +339,7 @@ static int cmd_create(int argc, char **argv)
p = cbi_set_data(p, CBI_TAG_BOARD_VERSION, &bi.ver.val, bi.ver.size);
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);
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);
@@ -458,6 +468,7 @@ static int cmd_show(int argc, char **argv)
print_integer(buf, CBI_TAG_BOARD_VERSION);
print_integer(buf, CBI_TAG_OEM_ID);
print_integer(buf, CBI_TAG_SKU_ID);
+ print_integer(buf, CBI_TAG_MODEL_ID);
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 03b0ecca17..f918c0b7eb 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -6805,6 +6805,7 @@ static void cmd_cbi_help(char *cmd)
" 2: SKU_ID\n"
" 3: DRAM_PART_NUM (string)\n"
" 4: OEM_NAME (string)\n"
+ " 5: MODEL_ID\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"
@@ -6815,6 +6816,11 @@ static void cmd_cbi_help(char *cmd)
" 10b: Set all fields to defaults first\n", cmd, cmd);
}
+static int cmd_cbi_is_string_field(enum cbi_data_tag tag)
+{
+ return tag == CBI_TAG_DRAM_PART_NUM || tag == CBI_TAG_OEM_NAME;
+}
+
/*
* Write value to CBI
*
@@ -6862,7 +6868,9 @@ static int cmd_cbi(int argc, char *argv[])
return -1;
}
r = ec_inbuf;
- if (tag != CBI_TAG_DRAM_PART_NUM && tag != CBI_TAG_OEM_NAME) {
+ if (cmd_cbi_is_string_field(tag)) {
+ printf("%.*s", rv, (const char *)r);
+ } else {
if (rv <= sizeof(uint32_t))
printf("As integer: %u (0x%x)\n", r[0], r[0]);
printf("As binary:");
@@ -6871,8 +6879,6 @@ static int cmd_cbi(int argc, char *argv[])
printf("\n");
printf(" %02x", r[i]);
}
- } else {
- printf("%.*s", rv, (const char *)r);
}
printf("\n");
return 0;
@@ -6890,7 +6896,10 @@ static int cmd_cbi(int argc, char *argv[])
memset(p, 0, ec_max_outsize);
p->tag = tag;
- if (tag != CBI_TAG_DRAM_PART_NUM && tag != CBI_TAG_OEM_NAME) {
+ if (cmd_cbi_is_string_field(tag)) {
+ val_ptr = argv[3];
+ size = strlen(val_ptr) + 1;
+ } else {
val = strtol(argv[3], &e, 0);
if (e && *e) {
fprintf(stderr, "Bad value\n");
@@ -6903,9 +6912,6 @@ static int cmd_cbi(int argc, char *argv[])
return -1;
}
val_ptr = &val;
- } else {
- val_ptr = argv[3];
- size = strlen(val_ptr) + 1;
}
if (size > ec_max_outsize - sizeof(*p)) {