diff options
author | Peter Marheine <pmarheine@chromium.org> | 2022-12-01 15:50:07 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-02 05:02:22 +0000 |
commit | 43a7c919bbe845c5cb45e5eb3535ae43d1f49dc5 (patch) | |
tree | e92474ce5531c0f239ea1ea0163d88405dd668b5 /zephyr/subsys | |
parent | 4e61180495797e59edca0374d62c7c0539cf0099 (diff) | |
download | chrome-ec-43a7c919bbe845c5cb45e5eb3535ae43d1f49dc5.tar.gz |
ap_pwrseq: support blocking power-on if insufficient power
This prevents the system from booting the AP if there's not enough power
according to configuration. Although there is similar logic in the power
button task, typical AP configuration is to boot directly after entry to
S5, meaning both are needed:
* From G3, this new path gates whether the system boots (matching
similar logic in the legacy power sequencing code) by preventing
transition to S5.
* From S5 (as in after shutdown and not yet having gone to G3), the
power button gates booting.
BUG=b:234049176,b:242627237,b:260909787
TEST=On craask, modify MIN_POWER settings to prevent hibernate during
testing and fake low battery; verify that an instrumented version
of charge_prevent_power_on indicates that the battery is too low
to boot, although the "factory override" still allows this DUT to
boot (because hardware WP is off).
BRANCH=nissa
Change-Id: I9cce0817dec8ffb59c133dbe54e63037542e5e55
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4066722
Commit-Queue: Andrew McRae <amcrae@google.com>
Tested-by: Andrew McRae <amcrae@google.com>
Reviewed-by: Andrew McRae <amcrae@google.com>
Code-Coverage: Andrew McRae <amcrae@google.com>
Diffstat (limited to 'zephyr/subsys')
-rw-r--r-- | zephyr/subsys/ap_pwrseq/include/ap_power_override_functions.h | 11 | ||||
-rw-r--r-- | zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/zephyr/subsys/ap_pwrseq/include/ap_power_override_functions.h b/zephyr/subsys/ap_pwrseq/include/ap_power_override_functions.h index 0d9195e5f2..f120c18cef 100644 --- a/zephyr/subsys/ap_pwrseq/include/ap_power_override_functions.h +++ b/zephyr/subsys/ap_pwrseq/include/ap_power_override_functions.h @@ -23,6 +23,17 @@ #include <zephyr/devicetree.h> /** + * @brief Evaluate whether system state is OK to start the AP. + * + * This is most often used to block startup when there is insufficient power + * available to reliably run the AP, such as if an attached battery's state of + * charge is very low. + * + * @return true if the system may proceed out of hard-off. + */ +bool board_ap_power_is_startup_ok(void); + +/** * @brief Force AP shutdown * * Immediately shut down the AP. diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c index 55f1414a4b..006c55490e 100644 --- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c +++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c @@ -256,6 +256,11 @@ static int common_pwr_sm_run(int state) k_msleep(start_from_g3_delay_ms); start_from_g3_delay_ms = 0; + if (!board_ap_power_is_startup_ok()) { + LOG_INF("Start from G3 inhibited" + " by !is_startup_ok"); + break; + } return SYS_POWER_STATE_G3S5; } |