summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2017-09-28 18:47:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-02 23:28:28 -0700
commit29dc221f98fa85efd3b351f0816c037562952753 (patch)
treebb66b768388269743124b866b7f6cf5e47f8d214
parentb097ecdcc5785f24f6405eb8a19dce52064912a2 (diff)
downloadchrome-ec-29dc221f98fa85efd3b351f0816c037562952753.tar.gz
chip/stm32/clock: Allow the host to reset rtc alarm
When the host sets rtc alarm wake time = 0, it wants to reset and disable the alarm. Also, align the implementation in npcx with that in stm32 to check both delay_s and delay_us. BUG=b:66971951, b:63908519 BRANCH=none TEST='ectool rtcsetalarm 3'. After alarm goes off, run 'ectool rtcgetalarm' and then see 'Alarm not set'. Change-Id: I693f1c72cba492e837891c716f79e2aa4da59b2a Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/691256 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
-rw-r--r--chip/npcx/system.c2
-rw-r--r--chip/stm32/clock-f.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index 012a508208..5135fd0979 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -543,7 +543,7 @@ void system_set_rtc_alarm(uint32_t seconds, uint32_t microseconds)
{
uint32_t cur_secs, alarm_secs;
- if (seconds == EC_RTC_ALARM_CLEAR) {
+ if (seconds == EC_RTC_ALARM_CLEAR && !microseconds) {
CLEAR_BIT(NPCX_WTC, NPCX_WTC_WIE);
SET_BIT(NPCX_WTC, NPCX_WTC_PTO);
diff --git a/chip/stm32/clock-f.c b/chip/stm32/clock-f.c
index 51d3511e0e..b64903de44 100644
--- a/chip/stm32/clock-f.c
+++ b/chip/stm32/clock-f.c
@@ -167,6 +167,11 @@ void set_rtc_alarm(uint32_t delay_s, uint32_t delay_us,
{
uint32_t alarm_sec, alarm_us;
+ if (delay_s == EC_RTC_ALARM_CLEAR && !delay_us) {
+ reset_rtc_alarm(rtc);
+ return;
+ }
+
/* Alarm must be within 1 day (86400 seconds) */
ASSERT((delay_s + delay_us / SECOND) < SECS_PER_DAY);