aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBaolin Wang <baolin.wang@linaro.org>2018-10-18 04:52:29 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-10-24 20:35:40 -0400
commitbf2c532b67fc077051e17de4a1304a83e5ca5b15 (patch)
tree7b6f141c2b99729fd9e0b3884bdf34a6d40fb60f /drivers
parentb2ddc48582efa157635f7ef815c9d4a657e2cabd (diff)
rtc: sc27xx: Add check to see if need to enable the alarm interrupt
The RTC interrupt enable register is not put in always-power-on region supplied by VDDRTC, so we should check if we need enable the alarm interrupt when system booting. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-sc27xx.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-sc27xx.c b/drivers/rtc/rtc-sc27xx.c
index 4ecabe6c9429..72bb002c88ec 100644
--- a/drivers/rtc/rtc-sc27xx.c
+++ b/drivers/rtc/rtc-sc27xx.c
@@ -563,6 +563,32 @@ static int sprd_rtc_check_power_down(struct sprd_rtc *rtc)
563 return 0; 563 return 0;
564} 564}
565 565
566static int sprd_rtc_check_alarm_int(struct sprd_rtc *rtc)
567{
568 u32 val;
569 int ret;
570
571 ret = regmap_read(rtc->regmap, rtc->base + SPRD_RTC_SPG_VALUE, &val);
572 if (ret)
573 return ret;
574
575 /*
576 * The SPRD_RTC_INT_EN register is not put in always-power-on region
577 * supplied by VDDRTC, so we should check if we need enable the alarm
578 * interrupt when system booting.
579 *
580 * If we have set SPRD_RTC_POWEROFF_ALM_FLAG which is saved in
581 * always-power-on region, that means we have set one alarm last time,
582 * so we should enable the alarm interrupt to help RTC core to see if
583 * there is an alarm already set in RTC hardware.
584 */
585 if (!(val & SPRD_RTC_POWEROFF_ALM_FLAG))
586 return 0;
587
588 return regmap_update_bits(rtc->regmap, rtc->base + SPRD_RTC_INT_EN,
589 SPRD_RTC_ALARM_EN, SPRD_RTC_ALARM_EN);
590}
591
566static int sprd_rtc_probe(struct platform_device *pdev) 592static int sprd_rtc_probe(struct platform_device *pdev)
567{ 593{
568 struct device_node *node = pdev->dev.of_node; 594 struct device_node *node = pdev->dev.of_node;
@@ -596,6 +622,13 @@ static int sprd_rtc_probe(struct platform_device *pdev)
596 rtc->dev = &pdev->dev; 622 rtc->dev = &pdev->dev;
597 platform_set_drvdata(pdev, rtc); 623 platform_set_drvdata(pdev, rtc);
598 624
625 /* check if we need set the alarm interrupt */
626 ret = sprd_rtc_check_alarm_int(rtc);
627 if (ret) {
628 dev_err(&pdev->dev, "failed to check RTC alarm interrupt\n");
629 return ret;
630 }
631
599 /* check if RTC time values are valid */ 632 /* check if RTC time values are valid */
600 ret = sprd_rtc_check_power_down(rtc); 633 ret = sprd_rtc_check_power_down(rtc);
601 if (ret) { 634 if (ret) {