summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2017-05-19 13:32:12 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-19 20:47:36 -0700
commitb72178b6ec7ed9213b687d837d87e78ff6f28f52 (patch)
tree02abf183756c3d2d72d30b05ae49d8ec07e396cc
parent300403c83d7cc8354b04c399721553d9c4a289b4 (diff)
downloadchrome-ec-b72178b6ec7ed9213b687d837d87e78ff6f28f52.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/508572 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: 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 eda899d833..bce7b17e09 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -418,12 +418,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);