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>
This commit is contained in:
parent
b7ff9efebc
commit
eca1b3c2e7
@ -95,6 +95,9 @@ enum rx8111_regfield {
|
|||||||
RX8111_REGF_INIEN,
|
RX8111_REGF_INIEN,
|
||||||
RX8111_REGF_CHGEN,
|
RX8111_REGF_CHGEN,
|
||||||
|
|
||||||
|
/* RX8111_REG_STATUS_MON. */
|
||||||
|
RX8111_REGF_VLOW,
|
||||||
|
|
||||||
/* Sentinel value. */
|
/* Sentinel value. */
|
||||||
RX8111_REGF_MAX
|
RX8111_REGF_MAX
|
||||||
};
|
};
|
||||||
@ -129,6 +132,8 @@ static const struct reg_field rx8111_regfields[] = {
|
|||||||
[RX8111_REGF_SWSEL1] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 3, 3),
|
[RX8111_REGF_SWSEL1] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 3, 3),
|
||||||
[RX8111_REGF_INIEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 6, 6),
|
[RX8111_REGF_INIEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 6, 6),
|
||||||
[RX8111_REGF_CHGEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 7, 7),
|
[RX8111_REGF_CHGEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 7, 7),
|
||||||
|
|
||||||
|
[RX8111_REGF_VLOW] = REG_FIELD(RX8111_REG_STATUS_MON, 1, 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct regmap_config rx8111_regmap_config = {
|
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)
|
|||||||
|
|
||||||
vlval = regval ? RTC_VL_DATA_INVALID : 0;
|
vlval = regval ? RTC_VL_DATA_INVALID : 0;
|
||||||
|
|
||||||
|
ret = regmap_field_read(data->regfields[RX8111_REGF_VLOW],
|
||||||
|
®val);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
vlval |= regval ? RTC_VL_BACKUP_LOW : 0;
|
||||||
|
|
||||||
return put_user(vlval, (typeof(vlval) __user *)arg);
|
return put_user(vlval, (typeof(vlval) __user *)arg);
|
||||||
default:
|
default:
|
||||||
return -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
|
Loading…
Reference in New Issue
Block a user