diff options
Diffstat (limited to 'power/common.c')
-rw-r--r-- | power/common.c | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/power/common.c b/power/common.c index cccb34911a..09501a16ec 100644 --- a/power/common.c +++ b/power/common.c @@ -873,37 +873,69 @@ DECLARE_CONSOLE_COMMAND(pause_in_s5, command_pause_in_s5, static enum host_sleep_event host_sleep_state; void __attribute__((weak)) -power_chipset_handle_host_sleep_event(enum host_sleep_event state) +power_chipset_handle_host_sleep_event(enum host_sleep_event state, + struct host_sleep_event_context *ctx) { /* Default weak implementation -- no action required. */ } static int host_command_host_sleep_event(struct host_cmd_handler_args *args) { - const struct ec_params_host_sleep_event *p = args->params; + const struct ec_params_host_sleep_event_v1 *p = args->params; + struct ec_response_host_sleep_event_v1 *r = args->response; + struct host_sleep_event_context ctx; + enum host_sleep_event state = p->sleep_event; - host_sleep_state = p->sleep_event; + host_sleep_state = state; + switch (state) { + case HOST_SLEEP_EVENT_S3_SUSPEND: + case HOST_SLEEP_EVENT_S0IX_SUSPEND: + case HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND: + ctx.sleep_timeout_ms = EC_HOST_SLEEP_TIMEOUT_DEFAULT; + + /* The original version contained only state. */ + if (args->version >= 1) + ctx.sleep_timeout_ms = + p->suspend_params.sleep_timeout_ms; + + break; + + default: + break; + } - power_chipset_handle_host_sleep_event(host_sleep_state); + power_chipset_handle_host_sleep_event(host_sleep_state, &ctx); + switch (state) { + case HOST_SLEEP_EVENT_S3_RESUME: + case HOST_SLEEP_EVENT_S0IX_RESUME: + if (args->version >= 1) { + r->resume_response.sleep_transitions = + ctx.sleep_transitions; + + args->response_size = sizeof(*r); + } + + break; + + default: + break; + } return EC_RES_SUCCESS; } DECLARE_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, host_command_host_sleep_event, - EC_VER_MASK(0)); + EC_VER_MASK(0) | EC_VER_MASK(1)); enum host_sleep_event power_get_host_sleep_state(void) { return host_sleep_state; } -#ifdef CONFIG_POWER_S0IX -void power_reset_host_sleep_state(void) +void power_set_host_sleep_state(enum host_sleep_event state) { - host_sleep_state = HOST_SLEEP_EVENT_DEFAULT_RESET; - power_chipset_handle_host_sleep_event(host_sleep_state); + host_sleep_state = state; } -#endif /* CONFIG_POWER_S0IX */ #endif /* CONFIG_POWER_TRACK_HOST_SLEEP_STATE */ |