From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Fredrik M Olsson <fredrik.m.olsson@axis.com>
Cc: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>,
linux-rtc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel@axis.com
Subject: Re: [PATCH 4/4] rtc: ds1307: Add support for reading RX8901CE battery VL status
Date: Sat, 31 Jan 2026 01:05:49 +0100 [thread overview]
Message-ID: <20260131000549071abafa@mail.local> (raw)
In-Reply-To: <20251219-ds1307-rx8901-add-v1-4-b13f346ebe93@axis.com>
On 19/12/2025 13:10:38+0100, Fredrik M Olsson wrote:
> Adds support for:
> - Reading the battery voltage low status using the RTC_VL_READ ioctl,
> which also reports invalid time information if the VLF flag is set.
>
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@axis.com>
> ---
> drivers/rtc/rtc-ds1307.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 99d95e520108..ca062ed0c867 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -133,8 +133,11 @@ enum ds_type {
> #define RX8901_REG_INTF 0x0e
> #define RX8901_REG_INTF_VLF BIT(1)
> #define RX8901_REG_PWSW_CFG 0x37
> +#define RX8901_REG_PWSW_CFG_VBATLDETEN BIT(4)
> #define RX8901_REG_PWSW_CFG_INIEN BIT(6)
> #define RX8901_REG_PWSW_CFG_CHGEN BIT(7)
> +#define RX8901_REG_BUF_INTF 0x46
> +#define RX8901_REG_BUF_INTF_VBATLF BIT(3)
>
> #define MCP794XX_REG_CONTROL 0x07
> # define MCP794XX_BIT_ALM0_EN 0x10
> @@ -458,6 +461,39 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
> return 0;
> }
>
> +#ifdef CONFIG_RTC_INTF_DEV
> +static int rx8901_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
> +{
> + struct ds1307 *ds1307 = dev_get_drvdata(dev);
> + unsigned int regflag, tmp = 0;
> + int ret = 0;
> +
> + switch (cmd) {
> + case RTC_VL_READ:
> + ret = regmap_read(ds1307->regmap, RX8901_REG_INTF, ®flag);
> + if (ret)
> + return ret;
> +
> + if (regflag & RX8901_REG_INTF_VLF)
> + tmp |= RTC_VL_DATA_INVALID;
> +
> + ret = regmap_read(ds1307->regmap, RX8901_REG_BUF_INTF, ®flag);
> + if (ret)
> + return ret;
> +
> + if (regflag & RX8901_REG_BUF_INTF_VBATLF)
> + tmp |= RTC_VL_BACKUP_LOW;
> +
> + return put_user(tmp, (unsigned int __user *)arg);
> + default:
> + return -ENOIOCTLCMD;
> + }
> + return ret;
> +}
> +#else
> +#define rx8901_ioctl NULL
> +#endif
> +
> static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
> {
> struct ds1307 *ds1307 = dev_get_drvdata(dev);
> @@ -599,10 +635,13 @@ static u8 do_trickle_setup_rx8130(struct ds1307 *ds1307, u32 ohms, bool diode)
> return setup;
> }
>
> -static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms, bool diode)
> +static u8 do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms __always_unused, bool diode)
> {
> - /* make sure that the backup battery is enabled */
> - u8 setup = RX8901_REG_PWSW_CFG_INIEN;
> + /*
> + * make sure that the backup battery is enabled and that battery
> + * voltage detection is performed
> + */
> + u8 setup = RX8901_REG_PWSW_CFG_INIEN | RX8901_REG_PWSW_CFG_VBATLDETEN;
>
> if (diode)
> setup |= RX8901_REG_PWSW_CFG_CHGEN;
> @@ -1005,6 +1044,7 @@ static const struct rtc_class_ops rx8130_rtc_ops = {
> static const struct rtc_class_ops rx8901_rtc_ops = {
> .read_time = ds1307_get_time,
> .set_time = ds1307_set_time,
> + .ioctl = rx8901_ioctl,
> };
>
This seems to be an unrelated changed that hasn't been squashed in the
proper patch.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-01-31 0:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 12:10 [PATCH 0/4] rtc: ds1307: Add support for Epson RX8901CE Fredrik M Olsson
2025-12-19 12:10 ` [PATCH 1/4] dt-bindings: rtc: ds1307: Add epson,rx8901 Fredrik M Olsson
2025-12-20 8:59 ` Krzysztof Kozlowski
2025-12-24 5:04 ` nobuhiro.iwamatsu.x90
2025-12-19 12:10 ` [PATCH 2/4] rtc: ds1307: Fix off-by-one issue with wday for rx8130 Fredrik M Olsson
2025-12-24 5:06 ` nobuhiro.iwamatsu.x90
2025-12-19 12:10 ` [PATCH 3/4] rtc: ds1307: Add Driver for Epson RX8901CE Fredrik M Olsson
2025-12-24 5:05 ` nobuhiro.iwamatsu.x90
2026-01-31 0:03 ` Alexandre Belloni
2026-02-03 14:23 ` Fredrik M Olsson
2025-12-19 12:10 ` [PATCH 4/4] rtc: ds1307: Add support for reading RX8901CE battery VL status Fredrik M Olsson
2025-12-24 5:07 ` nobuhiro.iwamatsu.x90
2026-01-31 0:05 ` Alexandre Belloni [this message]
2026-02-03 14:26 ` Fredrik M Olsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260131000549071abafa@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fredrik.m.olsson@axis.com \
--cc=kernel@axis.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=nobuhiro.iwamatsu.x90@mail.toshiba \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox