summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2021-04-18 22:29:28 -0700
committerCommit Bot <commit-bot@chromium.org>2021-04-21 04:41:01 +0000
commit9a7702b34b1c2246bb094de1c9d86c7cf892b2cc (patch)
tree9126b6334210df5d58a54e9938ce073ed01ae1f1
parent1eb4fcc824a54ab9b1f538fb8c4e97e6add89933 (diff)
downloadchrome-ec-9a7702b34b1c2246bb094de1c9d86c7cf892b2cc.tar.gz
power: go to hibernate mode immediately if woken up by rtc overflow.
If platform uses PSL (Power Switch Logic) for hibernating and RTC is also supported, this CL determines whether ec is woken up by RTC with overflow event (16 weeks). If so, let it go to hibernate mode immediately for better power consumption. BRANCH=none BUG=b:171919875 TEST= test console command "hibernate" with NPCX_LCT_MAX = 1000 and enable chipset_task on npcx9 EVB. Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Change-Id: I52543ee3cd980d444758c6a0cab32c34bd690b9a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2835259 Reviewed-by: Wai-Hong Tam <waihong@google.com>
-rw-r--r--chip/npcx/system.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index da688c2c42..3f6f5d9ccd 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -45,6 +45,11 @@
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
+#if defined(NPCX_LCT_SUPPORT)
+/* A flag for waking up from hibernate mode by RTC overflow event */
+static int is_rtc_overflow_event;
+#endif
+
/*****************************************************************************/
/* Internal functions */
@@ -328,6 +333,15 @@ static void chip_set_hib_flag(uint32_t *flags, uint32_t hib_wake_flags)
if (npcx_lct_is_event_set()) {
*flags |= EC_RESET_FLAG_RTC_ALARM |
EC_RESET_FLAG_HIBERNATE;
+ /* Is RTC overflow event? */
+ if (bbram_data_read(BBRM_DATA_INDEX_LCT_TIME) ==
+ NPCX_LCT_MAX) {
+ /*
+ * Mark it as RTC overflow event and handle it
+ * in hook init function later for logging info.
+ */
+ is_rtc_overflow_event = 1;
+ }
npcx_lct_clear_event();
return;
}
@@ -1134,6 +1148,23 @@ int system_is_reboot_warm(void)
return 1;
}
+#if defined(CONFIG_HIBERNATE_PSL) && defined(NPCX_LCT_SUPPORT)
+static void system_init_check_rtc_wakeup_event(void)
+{
+ /*
+ * If platform uses PSL (Power Switch Logic) for hibernating and RTC is
+ * also supported, determine whether ec is woken up by RTC with overflow
+ * event (16 weeks). If so, let it go to hibernate mode immediately.
+ */
+ if (is_rtc_overflow_event){
+ CPRINTS("Hibernate due to RTC overflow event");
+ system_hibernate(0, 0);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, system_init_check_rtc_wakeup_event,
+ HOOK_PRIO_DEFAULT - 1);
+#endif
+
/*****************************************************************************/
/* Console commands */
void print_system_rtc(enum console_channel ch)