diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2017-11-30 17:58:38 -0800 |
---|---|---|
committer | Daisuke Nojiri <dnojiri@chromium.org> | 2017-12-07 08:28:57 -0800 |
commit | 7b7cbe8e06a24dd46fca01395ac2d0c98df82a62 (patch) | |
tree | 9e272e84fd113c124f1c8eb34947a753d1805d1a | |
parent | eeb21e9f6d73f0623fee2aa2c7bf81e773aea083 (diff) | |
download | chrome-ec-7b7cbe8e06a24dd46fca01395ac2d0c98df82a62.tar.gz |
system: Allow hibernate to clear AP_OFF flag
After firmware update, cr50 toggles the EC's reset line, expecting
the system will boot. This isn't the case for Chromebox because it
sets AP_OFF flag on a clean shutdown (to restore the previous power
state after power loss & restore).
This patch adds EC_REBOOT_HIBERNATE_CLEAR_AP_OFF to EC reboot
command. It makes EC first clear AP_OFF then hibernate.
BUG=b:69721737
BRANCH=none
TEST=Verify Fizz reboot after cr50 update.
Change-Id: If3207d7284f244ca1adf0d516ef744dbc739a9c1
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/802632
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | chip/ish/system.c | 5 | ||||
-rw-r--r-- | chip/mec1322/system.c | 5 | ||||
-rw-r--r-- | chip/npcx/system.c | 10 | ||||
-rw-r--r-- | common/system.c | 7 | ||||
-rw-r--r-- | include/ec_commands.h | 3 | ||||
-rw-r--r-- | include/system.h | 3 |
6 files changed, 30 insertions, 3 deletions
diff --git a/chip/ish/system.c b/chip/ish/system.c index bd8e0e265f..f532e8bf85 100644 --- a/chip/ish/system.c +++ b/chip/ish/system.c @@ -39,6 +39,11 @@ void chip_save_reset_flags(int flags) { } +uint32_t chip_read_reset_flags(void) +{ + return 0; +} + void _system_reset(int flags, int wake_from_hibernate) { } diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index 57e1f8816a..449d234343 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -98,6 +98,11 @@ void chip_save_reset_flags(int flags) MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = flags; } +uint32_t chip_read_reset_flags(void) +{ + return MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS); +} + __attribute__((noreturn)) void _system_reset(int flags, int wake_from_hibernate) { diff --git a/chip/npcx/system.c b/chip/npcx/system.c index 96879b40e4..e7826f794c 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -312,6 +312,11 @@ void chip_save_reset_flags(int flags) bbram_data_write(BBRM_DATA_INDEX_SAVED_RESET_FLAGS, flags); } +uint32_t chip_read_reset_flags(void) +{ + return bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS); +} + #ifdef CONFIG_POWER_BUTTON_INIT_IDLE /* * Set/clear AP_OFF flag. It's set when the system gracefully shuts down and @@ -338,7 +343,10 @@ static void board_chipset_shutdown(void) system_set_reset_flags(RESET_FLAG_AP_OFF); CPRINTS("Set AP_OFF flag"); } -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, + /* Slightly higher than handle_pending_reboot because + * it may clear AP_OFF flag. */ + HOOK_PRIO_DEFAULT - 1); #endif /* Check reset cause */ diff --git a/common/system.c b/common/system.c index 928fb1d21a..fcd7e0d795 100644 --- a/common/system.c +++ b/common/system.c @@ -890,6 +890,13 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd) system_disable_jump(); return EC_SUCCESS; #ifdef CONFIG_HIBERNATE + case EC_REBOOT_HIBERNATE_CLEAR_AP_OFF: +#ifdef CONFIG_POWER_BUTTON_INIT_IDLE + CPRINTS("Clearing AP_OFF"); + chip_save_reset_flags( + chip_read_reset_flags() & ~RESET_FLAG_AP_OFF); +#endif + /* Intentional fall-through */ case EC_REBOOT_HIBERNATE: CPRINTS("system hibernating"); system_hibernate(0, 0); diff --git a/include/ec_commands.h b/include/ec_commands.h index 094c866eaf..741b7234b7 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3984,7 +3984,8 @@ enum ec_reboot_cmd { /* (command 3 was jump to RW-B) */ EC_REBOOT_COLD = 4, /* Cold-reboot */ EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */ - EC_REBOOT_HIBERNATE = 6 /* Hibernate EC */ + EC_REBOOT_HIBERNATE = 6, /* Hibernate EC */ + EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_OFF flag */ }; /* Flags for ec_params_reboot_ec.reboot_flags */ diff --git a/include/system.h b/include/system.h index f0f934ccf4..a47f8a3af3 100644 --- a/include/system.h +++ b/include/system.h @@ -34,8 +34,9 @@ #define RESET_FLAG_RBOX (1 << 16) /* Fixed Reset Functionality */ #define RESET_FLAG_SECURITY (1 << 17) /* Security threat */ -/* Per chip implementation to save raw RESET_FLAG_ flags. */ +/* Per chip implementation to save/read raw RESET_FLAG_ flags. */ void chip_save_reset_flags(int flags); +uint32_t chip_read_reset_flags(void); /* System images */ enum system_image_copy_t { |