summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/coral/board.c11
-rw-r--r--board/coral/board.h1
-rw-r--r--common/system.c15
-rw-r--r--include/config.h3
-rw-r--r--include/ec_commands.h8
-rw-r--r--include/system.h8
6 files changed, 46 insertions, 0 deletions
diff --git a/board/coral/board.c b/board/coral/board.c
index 743eee8652..f32b81dc73 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -1101,6 +1101,17 @@ DECLARE_CONSOLE_COMMAND(board_id, command_board_id,
"<id|sku0|sku1>",
"Get board id or sku");
+uint32_t system_get_sku_id(void)
+{
+ uint8_t sku_id_lower = board_read_version(ADC_BOARD_SKU_0);
+ uint8_t sku_id_higher = board_read_version(ADC_BOARD_SKU_1);
+
+ assert(sku_id_lower < 16);
+ assert(sku_id_higher < 16);
+ return (uint32_t)((sku_id_higher << 4) | sku_id_lower);
+
+}
+
/* Keyboard scan setting */
struct keyboard_scan_config keyscan_config = {
/*
diff --git a/board/coral/board.h b/board/coral/board.h
index c39ddedbb3..c3f06eda65 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -280,6 +280,7 @@ enum sensor_id {
LID_ALS,
};
+#define CONFIG_HOSTCMD_SKUID
enum coral_board_version {
BOARD_VERSION_UNKNOWN = -1,
BOARD_VERSION_1,
diff --git a/common/system.c b/common/system.c
index dae29d159c..716053a870 100644
--- a/common/system.c
+++ b/common/system.c
@@ -1173,6 +1173,21 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_VERSION,
host_command_get_version,
EC_VER_MASK(0));
+#ifdef CONFIG_HOSTCMD_SKUID
+static int host_command_get_sku_id(struct host_cmd_handler_args *args)
+{
+ struct ec_response_sku_id *r = args->response;
+
+ r->sku_id = system_get_sku_id();
+ args->response_size = sizeof(*r);
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_GET_SKU_ID,
+ host_command_get_sku_id,
+ EC_VER_MASK(0));
+#endif
+
static int host_command_build_info(struct host_cmd_handler_args *args)
{
strzcpy(args->response, system_get_build_info(), args->response_max);
diff --git a/include/config.h b/include/config.h
index 8bf2f26e75..86f5bf51ec 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1470,6 +1470,9 @@
/* For access to VBNV on-EC battery-backed storage */
#undef CONFIG_HOSTCMD_VBNV_CONTEXT
+/* EC controls the board's SKU ID and can report that to the AP */
+#undef CONFIG_HOSTCMD_SKUID
+
/*****************************************************************************/
/* Enable debugging and profiling statistics for hook functions */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 5be3892d66..8be7a4df8a 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1098,6 +1098,14 @@ struct __ec_align4 ec_response_get_features {
};
/*****************************************************************************/
+/* Get the board's SKU ID from EC */
+#define EC_CMD_GET_SKU_ID 0x000E
+
+struct __ec_align4 ec_response_sku_id {
+ uint32_t sku_id;
+};
+
+/*****************************************************************************/
/* Flash commands */
/* Get flash info */
diff --git a/include/system.h b/include/system.h
index e432a994c3..5b7be4064f 100644
--- a/include/system.h
+++ b/include/system.h
@@ -213,6 +213,14 @@ int32_t system_get_rollback_version(enum system_image_copy_t copy);
const char *system_get_version(enum system_image_copy_t copy);
/**
+ * Get the SKU ID for a device
+ *
+ * @return A value that identifies the SKU variant of a model. Its meaning and
+ * the number of bits actually used is opaque outside board specific code.
+ */
+uint32_t system_get_sku_id(void);
+
+/**
* Return the board version number. The meaning of this number is
* board-dependent; boards where the code actually cares about this should
* declare enum board_version in board.h.