lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <506a4702-9a28-4dd6-8e62-feec1ee9f83f@axis.com>
Date: Tue, 3 Feb 2026 15:26:03 +0100
From: Fredrik M Olsson <fredriol@...s.com>
To: Alexandre Belloni <alexandre.belloni@...tlin.com>,
 Fredrik M Olsson <fredrik.m.olsson@...s.com>
Cc: Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>,
 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@...l.toshiba>,
 linux-rtc@...r.kernel.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org, kernel@...s.com
Subject: Re: [PATCH 4/4] rtc: ds1307: Add support for reading RX8901CE battery
 VL status

On 1/31/26 01:05, Alexandre Belloni wrote:
> [Some people who received this message don't often get email from alexandre.belloni@...tlin.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> 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@...s.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, &regflag);
>> +             if (ret)
>> +                     return ret;
>> +
>> +             if (regflag & RX8901_REG_INTF_VLF)
>> +                     tmp |= RTC_VL_DATA_INVALID;
>> +
>> +             ret = regmap_read(ds1307->regmap, RX8901_REG_BUF_INTF, &regflag);
>> +             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.
> 

Okay I will squash this change into patch 3 for v2.

> 
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com


-- 
/Fredrik

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ