diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-07-01 14:05:38 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-02 22:04:29 +0000 |
commit | cb8fcbb2f26671d6e7e7abdc9a7c553ebb16026b (patch) | |
tree | 9bcee853b1208bc4901b9de96961836edb02817a /common/charge_state_v2.c | |
parent | 9986674de50489039df7c945cde40f307b123908 (diff) | |
download | chrome-ec-cb8fcbb2f26671d6e7e7abdc9a7c553ebb16026b.tar.gz |
chgstv2: Avoid force shutdown if chipset is shutting down
Currently, EC forces the system to shut down even if the chipset is
about to shut down. This patch makes EC wait for 1 second before it
triggers a force shutdown if the chipset is shutting down.
BUG=b:192463842
BRANCH=None
TEST=buildall
TEST=Verify Guybrush settles into S5 when it shuts down for low
battery.
Change-Id: Ic0bb3f17ac251d71907b282ae35279472077d576
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3000851
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r-- | common/charge_state_v2.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 2851e35efb..17bd7b375e 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -23,6 +23,7 @@ #include "host_command.h" #include "i2c.h" #include "math_util.h" +#include "power.h" #include "printf.h" #include "system.h" #include "task.h" @@ -1562,17 +1563,21 @@ static int shutdown_on_critical_battery(void) return 1; /* Timer has expired */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) { + if (chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF)) { switch (board_critical_shutdown_check(&curr)) { case CRITICAL_SHUTDOWN_HIBERNATE: if (IS_ENABLED(CONFIG_HIBERNATE)) { + if (power_get_state() == POWER_S3S5) + sleep(1); CPRINTS("Hibernate due to critical battery"); + cflush(); system_hibernate(0, 0); } break; case CRITICAL_SHUTDOWN_CUTOFF: + if (power_get_state() == POWER_S3S5) + sleep(1); CPRINTS("Cutoff due to critical battery"); - /* Ensure logs are flushed. */ cflush(); board_cut_off_battery(); break; |