diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-08-10 13:15:15 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-13 14:22:23 -0700 |
commit | 521e97fd135cfaeb199e1de0f87aa2e45b4aa804 (patch) | |
tree | 0165060c22ee1501a0da3ecc13d1a9d2ac772d1e /chip/lm4/system.c | |
parent | 397a7aa33633b912cc08eabe125b88a6648efb10 (diff) | |
download | chrome-ec-521e97fd135cfaeb199e1de0f87aa2e45b4aa804.tar.gz |
Clean up EC hibernate logic
system_hibernate(0, 0) now hibernates until a wake pin assert, with no
RTC wake.
BUG=none
TEST=manual
command -> expected reset flags from 'sysinfo'
1. reboot -> soft
2. reboot hard -> power-on hard
3. hibernate (and press power button) -> power-on wake-pin
4. hibernate 3 (and wait for timeout) -> power-on rtc-alarm
5. hibernate 10 (and press power button before 10 sec) -> power-on wake-pin
hibdelay 10
then shut system down and run on battery
10 sec later, system should hibernate.
Change-Id: I399413d265f6fcf808adf9ed1db7b812a1b12fc2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29923
Reviewed-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'chip/lm4/system.c')
-rw-r--r-- | chip/lm4/system.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/chip/lm4/system.c b/chip/lm4/system.c index 83e6cbaefe..6046f15d4c 100644 --- a/chip/lm4/system.c +++ b/chip/lm4/system.c @@ -210,13 +210,26 @@ void system_set_rtc(uint32_t seconds) * * @param seconds Number of seconds to sleep before RTC alarm * @param microseconds Number of microseconds to sleep before RTC alarm - * @param flags Hibernate wake flags + * @param flags Additional hibernate wake flags */ static void hibernate(uint32_t seconds, uint32_t microseconds, uint32_t flags) { uint32_t rtc, rtcss; uint32_t hibctl; + /* Set up wake reasons and hibernate flags */ + hibctl = LM4_HIBERNATE_HIBCTL | LM4_HIBCTL_PINWEN; + flags |= HIBDATA_WAKE_PIN; + + if (seconds || microseconds) { + hibctl |= LM4_HIBCTL_RTCWEN; + flags |= HIBDATA_WAKE_RTC; + } else { + hibctl &= ~LM4_HIBCTL_RTCWEN; + } + wait_for_hibctl_wc(); + LM4_HIBERNATE_HIBCTL = hibctl; + /* Store hibernate flags */ hibdata_write(HIBDATA_INDEX_WAKE, flags); @@ -224,10 +237,6 @@ static void hibernate(uint32_t seconds, uint32_t microseconds, uint32_t flags) wait_for_hibctl_wc(); LM4_HIBERNATE_HIBIC = LM4_HIBERNATE_HIBRIS; - /* TODO: PRESERVE RESET FLAGS */ - - /* TODO: If sleeping forever, only wake on wake pin. */ - /* Add expected overhead for hibernate register writes */ microseconds += HIB_WAIT_USEC * 4; @@ -254,17 +263,15 @@ static void hibernate(uint32_t seconds, uint32_t microseconds, uint32_t flags) wait_for_hibctl_wc(); LM4_HIBERNATE_HIBRTCSS = rtcss << 16; - /* Go to hibernation and wake on RTC match or WAKE pin */ - hibctl = (LM4_HIBERNATE_HIBCTL | LM4_HIBCTL_RTCWEN | - LM4_HIBCTL_PINWEN | LM4_HIBCTL_HIBREQ); wait_for_hibctl_wc(); - __enter_hibernate(hibctl); + __enter_hibernate(hibctl | LM4_HIBCTL_HIBREQ); } - void system_hibernate(uint32_t seconds, uint32_t microseconds) { - hibernate(seconds, microseconds, HIBDATA_WAKE_RTC | HIBDATA_WAKE_PIN); + /* Flush console before hibernating */ + cflush(); + hibernate(seconds, microseconds, 0); } int system_pre_init(void) |