mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-05 22:41:44 +00:00
common: add host command to push AP SKU ID to ec
add host command to set AP SKU ID to ec. BUG=b:65359225 BRANCH=reef TEST=make buildall -j Change-Id: I76ffa4485be4de996b001097fa3f5a371f3a92ce Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/650277 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
@@ -101,6 +101,47 @@ static enum ec_reboot_cmd reboot_at_shutdown;
|
||||
/* On-going actions preventing going into deep-sleep mode */
|
||||
uint32_t sleep_mask;
|
||||
|
||||
#ifdef CONFIG_HOSTCMD_AP_SET_SKUID
|
||||
static uint32_t ap_sku_id;
|
||||
|
||||
uint32_t system_get_sku_id(void)
|
||||
{
|
||||
return ap_sku_id;
|
||||
}
|
||||
|
||||
#define AP_SKUID_SYSJUMP_TAG 0x4153 /* AS */
|
||||
#define AP_SKUID_HOOK_VERSION 1
|
||||
|
||||
/**
|
||||
* Preserve AP SKUID across a sysjump.
|
||||
*/
|
||||
|
||||
static void ap_sku_id_preserve_state(void)
|
||||
{
|
||||
system_add_jump_tag(AP_SKUID_SYSJUMP_TAG, AP_SKUID_HOOK_VERSION,
|
||||
sizeof(ap_sku_id), &ap_sku_id);
|
||||
}
|
||||
DECLARE_HOOK(HOOK_SYSJUMP, ap_sku_id_preserve_state, HOOK_PRIO_DEFAULT);
|
||||
|
||||
/**
|
||||
* Restore AP SKUID after a sysjump.
|
||||
*/
|
||||
static void ap_sku_id_restore_state(void)
|
||||
{
|
||||
const uint32_t *prev_ap_sku_id;
|
||||
int size, version;
|
||||
|
||||
prev_ap_sku_id = (const uint32_t *)system_get_jump_tag(
|
||||
AP_SKUID_SYSJUMP_TAG, &version, &size);
|
||||
|
||||
if (prev_ap_sku_id && version == AP_SKUID_HOOK_VERSION &&
|
||||
size == sizeof(prev_ap_sku_id)) {
|
||||
memcpy(&ap_sku_id, prev_ap_sku_id, sizeof(ap_sku_id));
|
||||
}
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, ap_sku_id_restore_state, HOOK_PRIO_DEFAULT);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the program memory address where the image `copy` begins or should
|
||||
* begin. In the case of external storage, the image may or may not currently
|
||||
@@ -1186,7 +1227,7 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_VERSION,
|
||||
#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;
|
||||
struct ec_sku_id_info *r = args->response;
|
||||
|
||||
r->sku_id = system_get_sku_id();
|
||||
args->response_size = sizeof(*r);
|
||||
@@ -1198,6 +1239,20 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_SKU_ID,
|
||||
EC_VER_MASK(0));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HOSTCMD_AP_SET_SKUID
|
||||
static int host_command_set_sku_id(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_sku_id_info *p = args->params;
|
||||
|
||||
ap_sku_id = p->sku_id;
|
||||
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_SET_SKU_ID,
|
||||
host_command_set_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);
|
||||
|
||||
@@ -1500,6 +1500,9 @@
|
||||
/* EC controls the board's SKU ID and can report that to the AP */
|
||||
#undef CONFIG_HOSTCMD_SKUID
|
||||
|
||||
/* Set SKU ID from AP */
|
||||
#undef CONFIG_HOSTCMD_AP_SET_SKUID
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Enable debugging and profiling statistics for hook functions */
|
||||
|
||||
@@ -1122,7 +1122,10 @@ 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 {
|
||||
/* Set SKU ID from AP */
|
||||
#define EC_CMD_SET_SKU_ID 0x000F
|
||||
|
||||
struct __ec_align4 ec_sku_id_info {
|
||||
uint32_t sku_id;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user