diff options
Diffstat (limited to 'zephyr/subsys/ap_pwrseq/ap_power_interface.c')
-rw-r--r-- | zephyr/subsys/ap_pwrseq/ap_power_interface.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/zephyr/subsys/ap_pwrseq/ap_power_interface.c b/zephyr/subsys/ap_pwrseq/ap_power_interface.c index d6dc352033..1461ed139b 100644 --- a/zephyr/subsys/ap_pwrseq/ap_power_interface.c +++ b/zephyr/subsys/ap_pwrseq/ap_power_interface.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. */ @@ -6,12 +6,17 @@ #include <ap_power/ap_power_interface.h> #include <x86_non_dsx_common_pwrseq_sm_handler.h> -bool ap_power_in_state( - enum ap_power_state_mask state_mask) +LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); + +bool ap_power_in_state(enum ap_power_state_mask state_mask) { int need_mask = 0; switch (pwr_sm_get_state()) { + case SYS_POWER_STATE_UNINIT: + LOG_WRN("%s: init not yet complete; AP state is unknown", + __func__); + return false; case SYS_POWER_STATE_G3: need_mask = AP_POWER_STATE_HARD_OFF; break; @@ -21,16 +26,14 @@ bool ap_power_in_state( * In between hard and soft off states. Match only if caller * will accept both. */ - need_mask = AP_POWER_STATE_HARD_OFF | - AP_POWER_STATE_SOFT_OFF; + need_mask = AP_POWER_STATE_HARD_OFF | AP_POWER_STATE_SOFT_OFF; break; case SYS_POWER_STATE_S5: need_mask = AP_POWER_STATE_SOFT_OFF; break; case SYS_POWER_STATE_S5S4: case SYS_POWER_STATE_S4S5: - need_mask = AP_POWER_STATE_SOFT_OFF | - AP_POWER_STATE_SUSPEND; + need_mask = AP_POWER_STATE_SOFT_OFF | AP_POWER_STATE_SUSPEND; break; case SYS_POWER_STATE_S4: case SYS_POWER_STATE_S4S3: @@ -40,8 +43,7 @@ bool ap_power_in_state( break; case SYS_POWER_STATE_S3S0: case SYS_POWER_STATE_S0S3: - need_mask = AP_POWER_STATE_SUSPEND | - AP_POWER_STATE_ON; + need_mask = AP_POWER_STATE_SUSPEND | AP_POWER_STATE_ON; break; case SYS_POWER_STATE_S0: need_mask = AP_POWER_STATE_ON; @@ -60,10 +62,13 @@ bool ap_power_in_state( return (state_mask & need_mask) == need_mask; } -bool ap_power_in_or_transitioning_to_state( - enum ap_power_state_mask state_mask) +bool ap_power_in_or_transitioning_to_state(enum ap_power_state_mask state_mask) { switch (pwr_sm_get_state()) { + case SYS_POWER_STATE_UNINIT: + LOG_WRN("%s: init not yet complete; AP state is unknown", + __func__); + return 0; case SYS_POWER_STATE_G3: case SYS_POWER_STATE_S5G3: return state_mask & AP_POWER_STATE_HARD_OFF; @@ -107,7 +112,7 @@ void ap_power_exit_hardoff(void) power_state != SYS_POWER_STATE_S5G3 && power_state != SYS_POWER_STATE_S5) return; - request_exit_hardoff(true); + request_start_from_g3(); } void ap_power_init_reset_log(void) |