diff options
author | Philip Chen <philipchen@google.com> | 2017-09-19 19:05:49 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-28 15:59:05 -0700 |
commit | 78f485465fa28c6e669e834b2e6b862acff82226 (patch) | |
tree | aa12309277dcfab8f042b4ed81552d7a737cbf6b /chip | |
parent | c781609bfd19b16737bec5482da5c1a021a6afa6 (diff) | |
download | chrome-ec-78f485465fa28c6e669e834b2e6b862acff82226.tar.gz |
chip/stm32/clock: Wakeup AP when rtc alarm goes off
BUG=b:63908519
BRANCH=none
TEST='powerd_dbus_suspend --wakeup_timeout=10' and see
AP do S0->S3(10 secs)->S0
Change-Id: I35e248627e2f3b68b0ed3f27d6bae65eb73a745b
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/674054
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/stm32/clock-f.c | 10 | ||||
-rw-r--r-- | chip/stm32/clock-stm32f0.c | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/chip/stm32/clock-f.c b/chip/stm32/clock-f.c index 893e64bb86..51d3511e0e 100644 --- a/chip/stm32/clock-f.c +++ b/chip/stm32/clock-f.c @@ -72,6 +72,8 @@ static uint32_t sec_to_rtc_tr(uint32_t sec) } #ifdef CONFIG_HOSTCMD_RTC +static uint8_t host_rtc_alarm_set; + static uint32_t rtc_dr_to_sec(uint32_t rtc_dr) { struct calendar_date time; @@ -247,6 +249,13 @@ void __rtc_alarm_irq(void) struct rtc_time_reg rtc; reset_rtc_alarm(&rtc); +#ifdef CONFIG_HOSTCMD_RTC + /* Do not wake up the host if the alarm was not set by the host */ + if (host_rtc_alarm_set) { + host_set_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)); + host_rtc_alarm_set = 0; + } +#endif } DECLARE_IRQ(STM32_IRQ_RTC_ALARM, __rtc_alarm_irq, 1); @@ -392,6 +401,7 @@ static int system_rtc_set_alarm(struct host_cmd_handler_args *args) struct rtc_time_reg rtc; const struct ec_params_rtc *p = args->params; + host_rtc_alarm_set = 1; set_rtc_alarm(p->time, 0, &rtc); return EC_RES_SUCCESS; } diff --git a/chip/stm32/clock-stm32f0.c b/chip/stm32/clock-stm32f0.c index c63f773b9a..b7eb68ca07 100644 --- a/chip/stm32/clock-stm32f0.c +++ b/chip/stm32/clock-stm32f0.c @@ -313,6 +313,17 @@ void __idle(void) next_delay = __hw_clock_event_get() - t0.le.lo; if (DEEP_SLEEP_ALLOWED && +#ifdef CONFIG_HOSTCMD_RTC + /* + * Don't go to deep sleep mode when the host is using + * RTC alarm otherwise the wake point for the host + * would be overwritten. + * + * TODO(chromium:769503): Find a smart way to enable deep + * sleep mode even when the host is using stm32 rtc alarm. + */ + !(STM32_RTC_CR & STM32_RTC_CR_ALRAE) && +#endif (next_delay > (STOP_MODE_LATENCY + SET_RTC_MATCH_DELAY))) { /* deep-sleep in STOP mode */ idle_dsleep_cnt++; |