[PATCH 5/7] rtc: class: Support setting backup switch mode from devicetree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>

Some RTC devices like the RV3028 have BSM disabled as factory default.
This makes the RTC quite useless if it is expected to preserve the
time on hardware that has a battery buffered supply for the RTC.

Let boards that have a buffered supply for the RTC available force
the BSM to the desired value via devicetree by setting the
'backup-switch-mode' property.

Signed-off-by: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
---
 drivers/rtc/class.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index e5b7b48cffac..79417d1fbeee 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -391,6 +391,11 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 	struct rtc_wkalrm alrm;
 	int err;
 
+	struct rtc_param bsm = {
+		.param = RTC_PARAM_BACKUP_SWITCH_MODE,
+		.uvalue = RTC_BSM_DISABLED,
+	};
+
 	if (!rtc->ops) {
 		dev_dbg(&rtc->dev, "no ops set\n");
 		return -EINVAL;
@@ -402,6 +407,15 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 	if (rtc->ops->set_offset)
 		set_bit(RTC_FEATURE_CORRECTION, rtc->features);
 
+	/* setup backup switching mode */
+	if (test_bit(RTC_FEATURE_BACKUP_SWITCH_MODE, rtc->features) &&
+	    !device_property_read_u32(rtc->dev.parent, "backup-switch-mode",
+				      (u32 *)&bsm.uvalue)) {
+		err = rtc->ops->param_set(rtc->dev.parent, &bsm);
+		if (err && err != -EINVAL)
+			return err;
+	}
+
 	rtc->owner = owner;
 	rtc_device_get_offset(rtc);
 
-- 
2.39.1




[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux