diff options
author | Furquan Shaikh <furquan@google.com> | 2018-08-24 11:51:38 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-29 06:27:14 -0700 |
commit | d5e08f7f0db8738b9e802b7029ece3410d22b943 (patch) | |
tree | 0b5af6c903a0e978602ef81dfe5fa7c29aa91768 /common/system.c | |
parent | 900f37a2dde6058ee8b64b6a36227a7e502e22d3 (diff) | |
download | chrome-ec-d5e08f7f0db8738b9e802b7029ece3410d22b943.tar.gz |
system: Make hibernate console command invoke chipset task if chipset is on
Instead of calling system_hibernate directly from hibernate console
command, set reboot_at_shutdown and trigger chipset_force_shutdown if
chipset is not already off. This allows hibernate to go through the
chipset task to allow it to put power rails into proper state before
EC hibernates. If chipset is already off, then system_hibernate would
be called directly.
BUG=b:113132913
BRANCH=None
TEST=Verified that system_hibernate is called from chipset task if
chipset is up.
Change-Id: Id3b4d8597f536c4854714f79bd5bd077a826ad22
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1188517
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'common/system.c')
-rw-r--r-- | common/system.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/common/system.c b/common/system.c index ca3ec6f06d..4e0ab91c2f 100644 --- a/common/system.c +++ b/common/system.c @@ -6,6 +6,7 @@ /* System module for Chrome EC : common functions */ #include "battery.h" #include "charge_manager.h" +#include "chipset.h" #include "clock.h" #include "common.h" #include "console.h" @@ -100,6 +101,11 @@ static int disable_jump; /* Disable ALL jumps if system is locked */ static int force_locked; /* Force system locked even if WP isn't enabled */ static enum ec_reboot_cmd reboot_at_shutdown; +#ifdef CONFIG_HIBERNATE +static uint32_t hibernate_seconds; +static uint32_t hibernate_microseconds; +#endif + /* On-going actions preventing going into deep-sleep mode */ uint32_t sleep_mask; @@ -921,7 +927,7 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd) /* Intentional fall-through */ case EC_REBOOT_HIBERNATE: CPRINTS("system hibernating"); - system_hibernate(0, 0); + system_hibernate(hibernate_seconds, hibernate_microseconds); /* That shouldn't return... */ return EC_ERROR_UNKNOWN; #endif @@ -1011,7 +1017,20 @@ static int command_hibernate(int argc, char **argv) else ccprintf("Hibernating until wake pin asserted.\n"); - system_hibernate(seconds, microseconds); + /* + * If chipset is already off, then call system_hibernate directly. Else, + * let chipset_task bring down the power rails and transition to proper + * state before system_hibernate is called. + */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + system_hibernate(seconds, microseconds); + else { + reboot_at_shutdown = EC_REBOOT_HIBERNATE; + hibernate_seconds = seconds; + hibernate_microseconds = microseconds; + + chipset_force_shutdown(CHIPSET_SHUTDOWN_CONSOLE_CMD); + } return EC_SUCCESS; } |