summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-02-01 07:46:02 -0800
committerMartin Roth <martinroth@google.com>2018-02-05 23:37:05 +0000
commit07f9748f2255f7c157d55feccd12ff713ce255c6 (patch)
treee7d53f35fa835ce870672ce2ca293a7359d35192
parentb0bea2bf6fd8d9ed1fe018ca55489d3adb33f0c5 (diff)
downloadcoreboot-07f9748f2255f7c157d55feccd12ff713ce255c6.tar.xz
ec/google: Get OEM ID and SKU ID from EC
This patch adds EC_CMD_GET_CROS_BOARD_INFO and two APIs to fetch OEM ID and SKU ID from cros EC. CBI abbreviates Cros Board Info. BUG=b:70294260 BRANCH=none TEST=Verify AP log shows expected OEM ID and SKU ID on Fizz. Change-Id: Iff69a2dc0e562d87dd287f79c407f23aeb09fb9e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://review.coreboot.org/23549 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--src/ec/google/chromeec/ec.c34
-rw-r--r--src/ec/google/chromeec/ec.h9
-rw-r--r--src/ec/google/chromeec/ec_commands.h60
3 files changed, 103 insertions, 0 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index 89241daaa1..4bb7bb38cf 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -558,6 +558,40 @@ int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags)
return google_chromeec_command(&cec_cmd);
}
+static int cbi_get_uint32(uint32_t *id, uint32_t type)
+{
+ struct chromeec_command cmd;
+ struct ec_params_get_cbi p;
+ uint32_t r;
+ int rv;
+
+ p.type = type;
+
+ cmd.cmd_code = EC_CMD_GET_CROS_BOARD_INFO;
+ cmd.cmd_version = 0;
+ cmd.cmd_data_in = &p;
+ cmd.cmd_data_out = &r;
+ cmd.cmd_size_in = sizeof(p);
+ cmd.cmd_size_out = sizeof(r);
+ cmd.cmd_dev_index = 0;
+
+ rv = google_chromeec_command(&cmd);
+ if (rv < 0)
+ return rv;
+ *id = r;
+ return 0;
+}
+
+int google_chromeec_cbi_get_sku_id(uint32_t *id)
+{
+ return cbi_get_uint32(id, CBI_DATA_SKU_ID);
+}
+
+int google_chromeec_cbi_get_oem_id(uint32_t *id)
+{
+ return cbi_get_uint32(id, CBI_DATA_OEM_ID);
+}
+
#ifndef __SMM__
u16 google_chromeec_get_board_version(void)
{
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index 90bb6fa9d2..c15a50641a 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -64,6 +64,15 @@ int google_chromeec_vstore_write(int slot, uint8_t *data, size_t size);
success, < 0 otherwise. */
int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags);
+/**
+ * Get OEM (or SKU) ID from Cros Board Info
+ *
+ * @param id [OUT] oem/sku id
+ * @return 0 on success or negative integer for errors.
+ */
+int google_chromeec_cbi_get_oem_id(uint32_t *id);
+int google_chromeec_cbi_get_sku_id(uint32_t *id);
+
/* MEC uses 0x800/0x804 as register/index pair, thus an 8-byte resource. */
#define MEC_EMI_BASE 0x800
#define MEC_EMI_SIZE 8
diff --git a/src/ec/google/chromeec/ec_commands.h b/src/ec/google/chromeec/ec_commands.h
index 92fb2a8a67..7c515c21b0 100644
--- a/src/ec/google/chromeec/ec_commands.h
+++ b/src/ec/google/chromeec/ec_commands.h
@@ -4363,6 +4363,66 @@ struct __ec_align4 ec_params_rwsig_action {
uint32_t action;
};
+/* Run verification on a slot */
+#define EC_CMD_EFS_VERIFY 0x011E
+
+struct __ec_align1 ec_params_efs_verify {
+ uint8_t region; /* enum ec_flash_region */
+};
+
+/*
+ * Retrieve info from Cros Board Info store. Response is based on the data
+ * type. Integers return a uint32. Strings return a string, using the response
+ * size to determine how big it is.
+ */
+#define EC_CMD_GET_CROS_BOARD_INFO 0x011F
+/*
+ * Write info into Cros Board Info on EEPROM. Write fails if the board has
+ * hardware write-protect enabled.
+ */
+#define EC_CMD_SET_CROS_BOARD_INFO 0x0120
+
+enum cbi_data_type {
+ /* integer types */
+ CBI_DATA_BOARD_VERSION = 0,
+ CBI_DATA_OEM_ID = 1,
+ CBI_DATA_SKU_ID = 2,
+ /* string types */
+ CBI_FIRST_STRING_PARAM = 0x1000,
+ CBI_DATA_COUNT,
+};
+
+/*
+ * Flags to control read operation
+ *
+ * RELOAD: Invalidate cache and read data from EEPROM. Useful to verify
+ * write was successful without reboot.
+ */
+#define CBI_GET_RELOAD (1 << 0)
+
+struct __ec_align4 ec_params_get_cbi {
+ uint32_t type; /* enum cbi_data_type */
+ uint32_t flag; /* CBI_GET_* */
+};
+
+/*
+ * Flags to control write behavior.
+ *
+ * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's
+ * useful when writing multiple fields in a row.
+ * INIT: Needs to be set when creating a new CBI from scratch. All fields
+ * will be initialized to zero first.
+ */
+#define CBI_SET_NO_SYNC (1 << 0)
+#define CBI_SET_INIT (1 << 1)
+
+struct __ec_align1 ec_params_set_cbi {
+ uint32_t type; /* enum cbi_data_type */
+ uint32_t flag; /* CBI_SET_* */
+ uint32_t data; /* For numeric value */
+ uint8_t raw[]; /* For string and raw data */
+};
+
/*****************************************************************************/
/* The command range 0x200-0x2FF is reserved for Rotor. */