diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2017-05-24 08:49:24 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-06-28 21:50:51 -0700 |
commit | 3a4298ef4835b1f75046ede8cace149e05089d1a (patch) | |
tree | 24d4174c733236a43e0a7a3ee72b4bd09207ae74 /chip | |
parent | 9eca99983175784a0cc5e17a65e67498b9cfc8b1 (diff) | |
download | chrome-ec-3a4298ef4835b1f75046ede8cace149e05089d1a.tar.gz |
npcx: Make system stay off after clean shutdown
This patch sets/clears RESET_FLAG_AP_OFF on S5<->S3 transitions.
It's set when the system gracefully shuts down and cleared when the
system boots up. The result is EC tries to go back to the
previous state upon AC plug-in on battery-less systems.
This is required for digital signage and kiosk.
This also reverts: CL 514209, 486946, and 486945.
BUG=b:37536389
BRANCH=none
TEST=Tested as follows:
A. Boot to S0
A.1. Unplug AC while system is in S0 then plug in - PASS
A.2. Unplug AC while system is in S3 then plug in - PASS
A.3. Press recovery+power in S0 - PASS
A.4. Press recovery+power in G3 - FAIL (To be fixed)
A.5. Execute reboot console command - PASS
A.6. Execute reboot OS command - PASS
A.7. Execute reboot console command in G3 - PASS
B. Boot to G3
B.1 Unplug AC while system is in G3 then plug in - PASS
B.2 Unplug AC after B.1 then plug in - PASS
B.3 Shutdown by power button on recovery screen then unplug
plug in AC - PASS
B.4 Execute reboot ap-off console command - PASS
B.5 Execute shutdown command from OS then plug in AC - PASS
Change-Id: Iaa6f930585050fdd3511c711b449dff47525066d
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/517287
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/npcx/system.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chip/npcx/system.c b/chip/npcx/system.c index f0f698684a..15d575658d 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -310,6 +310,35 @@ void chip_save_reset_flags(int flags) bbram_data_write(BBRM_DATA_INDEX_SAVED_RESET_FLAGS, flags); } +#ifdef CONFIG_POWER_BUTTON_INIT_IDLE +/* + * Set/clear AP_OFF flag. It's set when the system gracefully shuts down and + * it's cleared when the system boots up. The result is the system tries to + * go back to the previous state upon AC plug-in. If the system uncleanly + * shuts down, it boots immediately. If the system shuts down gracefully, + * it'll stay at S5 and wait for power button press. + */ +static void board_chipset_startup(void) +{ + uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS); + flags &= ~RESET_FLAG_AP_OFF; + chip_save_reset_flags(flags); + system_clear_reset_flags(RESET_FLAG_AP_OFF); + CPRINTS("Cleared AP_OFF flag"); +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); + +static void board_chipset_shutdown(void) +{ + uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS); + flags |= RESET_FLAG_AP_OFF; + chip_save_reset_flags(flags); + system_set_reset_flags(RESET_FLAG_AP_OFF); + CPRINTS("Set AP_OFF flag"); +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); +#endif + /* Check reset cause */ void system_check_reset_cause(void) { @@ -317,7 +346,12 @@ void system_check_reset_cause(void) uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS); /* Clear saved reset flags in bbram */ +#ifdef CONFIG_POWER_BUTTON_INIT_IDLE + /* We'll clear AP_OFF on S5->S3 transition */ + chip_save_reset_flags(flags & RESET_FLAG_AP_OFF); +#else chip_save_reset_flags(0); +#endif /* Clear saved hibernate wake flag in bbram , too */ bbram_data_write(BBRM_DATA_INDEX_WAKE, 0); |