linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: pm8xxx: Read ALARM_EN and update to alarm enabled status
@ 2020-12-24 11:28 Guixiong Wei
  2021-01-12 22:46 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Guixiong Wei @ 2020-12-24 11:28 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni; +Cc: linux-rtc, linux-kernel, Guixiong Wei

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>
---
 drivers/rtc/rtc-pm8xxx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 0d9dd6f..70d1ff5 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 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 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);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: pm8xxx: Read ALARM_EN and update to alarm enabled status
  2020-12-24 11:28 [PATCH] rtc: pm8xxx: Read ALARM_EN and update to alarm enabled status Guixiong Wei
@ 2021-01-12 22:46 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2021-01-12 22:46 UTC (permalink / raw)
  To: a.zummo, Guixiong Wei; +Cc: Alexandre Belloni, linux-kernel, linux-rtc

On Thu, 24 Dec 2020 19:28:57 +0800, Guixiong Wei wrote:
> 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.

Applied, thanks!

[1/1] rtc: pm8xxx: Read ALARM_EN and update to alarm enabled status
      commit: 121f54efc3fb9854f581fede4f719a4aef7ed5b3

Best regards,
-- 
Alexandre Belloni <alexandre.belloni@bootlin.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-12 22:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-24 11:28 [PATCH] rtc: pm8xxx: Read ALARM_EN and update to alarm enabled status Guixiong Wei
2021-01-12 22:46 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).