From f6805af8796784818697d4575fdf12000388e4af Mon Sep 17 00:00:00 2001 From: Philip Chen Date: Thu, 27 Dec 2018 18:42:02 -0800 Subject: chip/stm32/clock: Cleanly clear pending RTC alarm IRQ We want to reset RTC alarm and clear pending IRQ when EC wakes up from deep sleep mode. Unfortunately, RTC alarm IRQ is still latched and pending in NVIC unless we explicitly clear the flag in ICPR register. BUG=chromium:769503 BRANCH=scarlet TEST=confirm RTC alarm irq is not fired after EC exits deep sleep mode Change-Id: If6b9815337fbd24a0337116ef9c5fa1521671a93 Signed-off-by: Philip Chen Reviewed-on: https://chromium-review.googlesource.com/c/1392408 Reviewed-by: Philip Chen Commit-Queue: Philip Chen Tested-by: Philip Chen Trybot-Ready: Philip Chen --- chip/stm32/clock-f.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chip/stm32/clock-f.c b/chip/stm32/clock-f.c index 84c40dc557..3333538326 100644 --- a/chip/stm32/clock-f.c +++ b/chip/stm32/clock-f.c @@ -295,6 +295,9 @@ void reset_rtc_alarm(struct rtc_time_reg *rtc) STM32_EXTI_IMR &= ~EXTI_RTC_ALR_EVENT; STM32_EXTI_PR = EXTI_RTC_ALR_EVENT; + /* Clear the pending RTC alarm IRQ in NVIC */ + task_clear_pending_irq(STM32_IRQ_RTC_ALARM); + /* Read current time */ rtc_read(rtc); -- cgit v1.2.1