diff options
-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 { |