Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit eca1b3c

Browse files
rtc: rx8111: handle VLOW flag
Allow userspace to get battery status information and be able to warn when battery is low and has to be replaced. Tested-by: Waqar Hameed <waqar.hameed@axis.com> Reviewed-by: Waqar Hameed <waqar.hameed@axis.com> Link: https://lore.kernel.org/r/20240417191937.33790-2-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent b7ff9ef commit eca1b3c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/rtc/rtc-rx8111.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ enum rx8111_regfield {
9595
RX8111_REGF_INIEN,
9696
RX8111_REGF_CHGEN,
9797

98+
/* RX8111_REG_STATUS_MON. */
99+
RX8111_REGF_VLOW,
100+
98101
/* Sentinel value. */
99102
RX8111_REGF_MAX
100103
};
@@ -129,6 +132,8 @@ static const struct reg_field rx8111_regfields[] = {
129132
[RX8111_REGF_SWSEL1] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 3, 3),
130133
[RX8111_REGF_INIEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 6, 6),
131134
[RX8111_REGF_CHGEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 7, 7),
135+
136+
[RX8111_REGF_VLOW] = REG_FIELD(RX8111_REG_STATUS_MON, 1, 1),
132137
};
133138

134139
static const struct regmap_config rx8111_regmap_config = {
@@ -276,6 +281,13 @@ static int rx8111_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
276281

277282
vlval = regval ? RTC_VL_DATA_INVALID : 0;
278283

284+
ret = regmap_field_read(data->regfields[RX8111_REGF_VLOW],
285+
&regval);
286+
if (ret)
287+
return ret;
288+
289+
vlval |= regval ? RTC_VL_BACKUP_LOW : 0;
290+
279291
return put_user(vlval, (typeof(vlval) __user *)arg);
280292
default:
281293
return -ENOIOCTLCMD;

0 commit comments

Comments
 (0)