summaryrefslogtreecommitdiff
path: root/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c')
-rw-r--r--zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c
index 7bacbcd8cd..ee6e2cf41e 100644
--- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c
+++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_host_command.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,14 +12,14 @@ host_command_reboot_ap_on_g3(struct host_cmd_handler_args *args)
const struct ec_params_reboot_ap_on_g3_v1 *cmd = args->params;
/* Store request for processing at g3 */
- request_exit_hardoff(true);
+ request_start_from_g3();
switch (args->version) {
case 0:
break;
case 1:
/* Store user specified delay to wait in G3 state */
- set_reboot_ap_at_g3_delay_seconds(cmd->reboot_ap_at_g3_delay);
+ set_start_from_g3_delay_seconds(cmd->reboot_ap_at_g3_delay);
break;
default:
return EC_RES_INVALID_PARAM;
@@ -27,8 +27,66 @@ host_command_reboot_ap_on_g3(struct host_cmd_handler_args *args)
return EC_RES_SUCCESS;
}
-DECLARE_HOST_COMMAND(EC_CMD_REBOOT_AP_ON_G3,
- host_command_reboot_ap_on_g3,
+DECLARE_HOST_COMMAND(EC_CMD_REBOOT_AP_ON_G3, host_command_reboot_ap_on_g3,
EC_VER_MASK(0) | EC_VER_MASK(1));
+#if CONFIG_AP_PWRSEQ_HOST_SLEEP
+/* Track last reported sleep event */
+static enum host_sleep_event host_sleep_state;
+
+static enum ec_status
+host_command_host_sleep_event(struct host_cmd_handler_args *args)
+{
+ 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 = state;
+ ctx.sleep_transitions = 0;
+ switch (state) {
+ case HOST_SLEEP_EVENT_S0IX_SUSPEND:
+ case HOST_SLEEP_EVENT_S3_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;
+ }
+
+ ap_power_chipset_handle_host_sleep_event(host_sleep_state, &ctx);
+ switch (state) {
+ case HOST_SLEEP_EVENT_S0IX_RESUME:
+ case HOST_SLEEP_EVENT_S3_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(1));
+
+void power_set_host_sleep_state(enum host_sleep_event state)
+{
+ host_sleep_state = state;
+}
+#endif /* CONFIG_AP_PWRSEQ_HOST_SLEEP */
+
/* End of host commands */