summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-pm8xxx.c
diff options
context:
space:
mode:
authorGuixiong Wei <guixiong@codeaurora.org>2020-12-24 19:28:57 +0800
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2021-01-12 23:46:46 +0100
commit121f54efc3fb9854f581fede4f719a4aef7ed5b3 (patch)
treec4395c95f2133477b5bb8c8c9d799b03469c92f6 /drivers/rtc/rtc-pm8xxx.c
parent5c8fe583cce542aa0b84adc939ce85293de36e5e (diff)
downloadlinux-121f54efc3fb9854f581fede4f719a4aef7ed5b3.tar.gz
linux-121f54efc3fb9854f581fede4f719a4aef7ed5b3.tar.bz2
linux-121f54efc3fb9854f581fede4f719a4aef7ed5b3.zip
rtc: pm8xxx: Read ALARM_EN and update to alarm enabled status
ALARM_EN status is retained in PMIC register after device shutdown if poweron_alarm is enabled. Read it to make sure the driver has consistent value with the register status. Signed-off-by: Guixiong Wei <guixiong@codeaurora.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/1608809337-18852-1-git-send-email-guixiong@codeaurora.org
Diffstat (limited to 'drivers/rtc/rtc-pm8xxx.c')
-rw-r--r--drivers/rtc/rtc-pm8xxx.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 0d9dd6faabba..70d1ff53b813 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -20,6 +20,7 @@
/* RTC_CTRL register bit fields */
#define PM8xxx_RTC_ENABLE BIT(7)
#define PM8xxx_RTC_ALARM_CLEAR BIT(0)
+#define PM8xxx_RTC_ALARM_ENABLE BIT(7)
#define NUM_8_BIT_RTC_REGS 0x4
@@ -265,6 +266,7 @@ rtc_rw_fail:
static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
int rc;
+ unsigned int ctrl_reg;
u8 value[NUM_8_BIT_RTC_REGS];
unsigned long secs;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
@@ -282,6 +284,13 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
rtc_time64_to_tm(secs, &alarm->time);
+ rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
+ if (rc) {
+ dev_err(dev, "Read from RTC alarm control register failed\n");
+ return rc;
+ }
+ alarm->enabled = !!(ctrl_reg & PM8xxx_RTC_ALARM_ENABLE);
+
dev_dbg(dev, "Alarm set for - h:m:s=%ptRt, y-m-d=%ptRdr\n",
&alarm->time, &alarm->time);