diff mbox series

rtc: pcf8523: report battery switch over

Message ID 992993372d0ae794dcd1da91c386048458b11d65.1639387133.git.baruch@tkos.co.il
State New
Headers show
Series rtc: pcf8523: report battery switch over | expand

Commit Message

Baruch Siach Dec. 13, 2021, 9:18 a.m. UTC
Set RTC_VL_BACKUP_SWITCH when reading the batter voltage level to
indicate switch to battery backup.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/rtc/rtc-pcf8523.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index c93acade7205..d0eb53265549 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -330,6 +330,9 @@  static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
 		if (value & PCF8523_CONTROL3_BLF)
 			flags |= RTC_VL_BACKUP_LOW;
 
+		if (value & PCF8523_CONTROL3_BSF)
+			flags |= RTC_VL_BACKUP_SWITCH;
+
 		ret = regmap_read(pcf8523->regmap, PCF8523_REG_SECONDS, &value);
 		if (ret < 0)
 			return ret;
@@ -339,6 +342,10 @@  static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
 
 		return put_user(flags, (unsigned int __user *)arg);
 
+	case RTC_VL_CLR:
+		return regmap_update_bits(pcf8523->regmap,
+				PCF8523_REG_CONTROL3, PCF8523_CONTROL3_BSF, 0);
+
 	default:
 		return -ENOIOCTLCMD;
 	}