summaryrefslogtreecommitdiff
path: root/zephyr/drivers/cros_rtc
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2021-04-05 20:43:21 -0700
committerCommit Bot <commit-bot@chromium.org>2021-04-14 16:03:19 +0000
commit9bf812de554b9a7e407f615c338e44abe2ff9531 (patch)
treefa56baa846ee69d5fda6e8ca1e0800054dfa5e53 /zephyr/drivers/cros_rtc
parentb07522e0973ae886479a2949b787afd86986b39c (diff)
downloadchrome-ec-9bf812de554b9a7e407f615c338e44abe2ff9531.tar.gz
zephyr: npcx: Change RTC IRQ enable/disable mechanism
This CL enables the RTC's irq when users set rtc alarm and disables it when users reset rtc alarm. It makes sure rtc alarm works properly when someone turn off the related WKEN unexpectedly. BUG=b:183745774 BRANCH=none TEST=zmake testall Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Change-Id: I1da24a497f10e2b1b94546979659e1eb188b1028 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2821115 Tested-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/drivers/cros_rtc')
-rw-r--r--zephyr/drivers/cros_rtc/cros_rtc_npcx.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
index 11aa1994e5..ed08386d81 100644
--- a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
+++ b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
@@ -173,8 +173,12 @@ static int cros_rtc_npcx_get_alarm(const struct device *dev, uint32_t *seconds,
static int cros_rtc_npcx_set_alarm(const struct device *dev, uint32_t seconds,
uint32_t microseconds)
{
+ const struct cros_rtc_npcx_config *config = DRV_CONFIG(dev);
ARG_UNUSED(microseconds);
+ /* Enable interrupt of the MTC alarm wake-up input source */
+ npcx_miwu_irq_enable(&config->mtc_alarm);
+
/* Make sure alarm restore to default state */
counter_npcx_reset_alarm(dev);
counter_npcx_set_alarm_val(dev, seconds);
@@ -184,6 +188,11 @@ static int cros_rtc_npcx_set_alarm(const struct device *dev, uint32_t seconds,
static int cros_rtc_npcx_reset_alarm(const struct device *dev)
{
+ const struct cros_rtc_npcx_config *config = DRV_CONFIG(dev);
+
+ /* Disable interrupt of the MTC alarm wake-up input source */
+ npcx_miwu_irq_disable(&config->mtc_alarm);
+
counter_npcx_reset_alarm(dev);
return 0;
@@ -216,9 +225,6 @@ static int cros_rtc_npcx_init(const struct device *dev)
npcx_miwu_interrupt_configure(&config->mtc_alarm, NPCX_MIWU_MODE_EDGE,
NPCX_MIWU_TRIG_HIGH);
- /* Enable interrupt of the wake-up input source */
- npcx_miwu_irq_enable(&config->mtc_alarm);
-
return 0;
}