summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2017-05-19 13:32:12 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-05-20 01:16:23 +0000
commitbcc12ca8fb72d9fb4ce7e658e25585da9ccabc65 (patch)
treec01e6057c2804d6161c85a67e3310b1168b983bf
parent71a15e7d11f25d319110a4792d7074ffa918fc82 (diff)
downloadchrome-ec-bcc12ca8fb72d9fb4ce7e658e25585da9ccabc65.tar.gz
npcx: system: Fixed bug that ec received unexpected rtc interrupt
In old system driver, ec clears "Predefined Time Occurred" (PTO) flag before setting a new alarm (PT field in WTC). If PT field is the same as the first 25 TTC bits at this moment, we might receive unexpected rtc interrupt again. This CL sets new alarm first then clears PTO flag to make sure rtc interrupt is issued from new alarm. BRANCH=none BUG=b:38310685 TEST=Duplicated the same symptom by the script in issue 38310685 on gru. No symptoms occurred with the same script for 3 hours by applying this CL. Change-Id: Ia6410d6aa4ef8e2acb7bfadf9192d619045bfa58 Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/510084 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--chip/npcx/system.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index 2d11217f5b..e3825c92ab 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -475,12 +475,15 @@ void system_set_rtc_alarm(uint32_t seconds, uint32_t microseconds)
alarm_secs = cur_secs + seconds;
alarm_secs = alarm_secs & MTC_ALARM_MASK;
+ /*
+ * We should set new alarm (first 25 bits of clock value) first before
+ * clearing PTO in case issue rtc interrupt immediately.
+ */
+ NPCX_WTC = alarm_secs;
+
/* Reset alarm first */
system_reset_rtc_alarm();
- /* Set alarm, use first 25 bits of clock value */
- NPCX_WTC = alarm_secs;
-
/* Enable interrupt mode alarm */
SET_BIT(NPCX_WTC, NPCX_WTC_WIE);