diff options
-rw-r--r-- | chip/host/system.c | 2 | ||||
-rw-r--r-- | chip/ish/system.c | 2 | ||||
-rw-r--r-- | chip/it83xx/system.c | 2 | ||||
-rw-r--r-- | chip/lm4/system.c | 2 | ||||
-rw-r--r-- | chip/mec1322/system.c | 2 | ||||
-rw-r--r-- | chip/npcx/system.c | 2 | ||||
-rw-r--r-- | chip/nrf51/system.c | 2 | ||||
-rw-r--r-- | chip/stm32/system.c | 2 | ||||
-rw-r--r-- | common/system.c | 18 | ||||
-rw-r--r-- | include/system.h | 6 |
10 files changed, 32 insertions, 8 deletions
diff --git a/chip/host/system.c b/chip/host/system.c index 3820048fad..4acb19a2cd 100644 --- a/chip/host/system.c +++ b/chip/host/system.c @@ -150,7 +150,7 @@ test_mockable void system_reset(int flags) emulator_reboot(); } -test_mockable void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { uint32_t i; diff --git a/chip/ish/system.c b/chip/ish/system.c index 7110e85645..7fe3860d9a 100644 --- a/chip/ish/system.c +++ b/chip/ish/system.c @@ -96,7 +96,7 @@ uint32_t system_get_scratchpad(void) return 0; } -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { } diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c index 8ba3a970c1..e9b7f37e45 100644 --- a/chip/it83xx/system.c +++ b/chip/it83xx/system.c @@ -18,7 +18,7 @@ #include "version.h" #include "watchdog.h" -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { #ifdef CONFIG_HOSTCMD_PD /* Inform the PD MCU that we are going to hibernate. */ diff --git a/chip/lm4/system.c b/chip/lm4/system.c index 684b520dae..4ddfef4e35 100644 --- a/chip/lm4/system.c +++ b/chip/lm4/system.c @@ -381,7 +381,7 @@ static void hibernate(uint32_t seconds, uint32_t microseconds, uint32_t flags) __enter_hibernate(hibctl | LM4_HIBCTL_HIBREQ); } -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { /* Flush console before hibernating */ cflush(); diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index 4b2738e969..ba4b574b06 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -215,7 +215,7 @@ uint32_t system_get_scratchpad(void) return MEC1322_VBAT_RAM(HIBDATA_INDEX_SCRATCHPAD); } -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { int i; diff --git a/chip/npcx/system.c b/chip/npcx/system.c index 335cb9a44a..156075e278 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -596,7 +596,7 @@ void system_enable_hib_interrupt(void) task_enable_irq(NPCX_IRQ_MTC_WKINTAD_0); } -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { /* Flush console before hibernating */ cflush(); diff --git a/chip/nrf51/system.c b/chip/nrf51/system.c index 61bd2311a8..e2891831a0 100644 --- a/chip/nrf51/system.c +++ b/chip/nrf51/system.c @@ -31,7 +31,7 @@ const char *system_get_chip_revision(void) return ""; } -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { /* Flush console before hibernating */ cflush(); diff --git a/chip/stm32/system.c b/chip/stm32/system.c index b81dc0055c..43461579d7 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -103,7 +103,7 @@ void __no_hibernate(uint32_t seconds, uint32_t microseconds) void __enter_hibernate(uint32_t seconds, uint32_t microseconds) __attribute__((weak, alias("__no_hibernate"))); -void system_hibernate(uint32_t seconds, uint32_t microseconds) +void chip_hibernate(uint32_t seconds, uint32_t microseconds) { #ifdef CONFIG_HOSTCMD_PD /* Inform the PD MCU that we are going to hibernate. */ diff --git a/common/system.c b/common/system.c index b9e444c71c..73a23ccee6 100644 --- a/common/system.c +++ b/common/system.c @@ -4,6 +4,7 @@ */ /* System module for Chrome EC : common functions */ +#include "chipset.h" #include "clock.h" #include "common.h" #include "console.h" @@ -408,6 +409,23 @@ const char *system_image_copy_t_to_string(enum system_image_copy_t copy) return image_names[copy < ARRAY_SIZE(image_names) ? copy : 0]; } +test_mockable void system_hibernate(uint32_t seconds, uint32_t microseconds) +{ +#ifdef HAS_TASK_CHIPSET + /* Wait up to a second for chipset to shut down */ + int retries = 100; + + chipset_force_shutdown(); + while (--retries) { + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + break; + msleep(10); + } + if (!retries) + CPRINTS("Hibernate before chipset shutdown"); +#endif + chip_hibernate(seconds, microseconds); +} /** * Jump to what we hope is the init address of an image. * diff --git a/include/system.h b/include/system.h index 26a57d9d61..48af1c332a 100644 --- a/include/system.h +++ b/include/system.h @@ -322,6 +322,12 @@ int system_set_bbram(enum system_bbram_idx idx, uint8_t value); void system_hibernate(uint32_t seconds, uint32_t microseconds); /** + * Chip-level callback functions called in system_hibernate() after we force + * to shutdown the chipset and get ready to enter hibernate mode. + */ +void chip_hibernate(uint32_t seconds, uint32_t microseconds); + +/** * Optional board-level callback functions called before and after initiating * chip-level hibernate sequence. These function may or may not return, * depending if the board implements an alternate hibernate method. The _late |