mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fredrik M Olsson <fredriol@axis.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	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 3/4] rtc: ds1307: Add Driver for Epson RX8901CE
Date: Tue, 3 Feb 2026 15:23:59 +0100	[thread overview]
Message-ID: <b547a09c-6a4d-46f1-a855-95d561e18ac1@axis.com> (raw)
In-Reply-To: <20260131000350d1fac76c@mail.local>

On 1/31/26 01:03, Alexandre Belloni wrote:
> [Some people who received this message don't often get email from alexandre.belloni@bootlin.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Hello,
> 
> On 19/12/2025 13:10:37+0100, Fredrik M Olsson wrote:
>>   #define MCP794XX_REG_CONTROL         0x07
>>   #    define MCP794XX_BIT_ALM0_EN     0x10
>>   #    define MCP794XX_BIT_ALM1_EN     0x20
>> @@ -226,6 +233,19 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
>>                        dev_warn_once(dev, "oscillator failed, set time!\n");
>>                        return -EINVAL;
>>                }
>> +     } else if (ds1307->type == rx_8901) {
>> +             unsigned int regflag;
>> +
>> +             ret = regmap_read(ds1307->regmap, RX8901_REG_INTF, &regflag);
>> +             if (ret) {
>> +                     dev_err(dev, "%s error %d\n", "read", ret);
> 
> The multiple dev_err you are adding should be dev_dbg as there is no
> other actions for the user than to restart the operation when it fails
> so there is not actual value apart when debugging.
> 

Okay thanks I will update that for v2.

>> +                     return ret;
>> +             }
>> +
>> +             if (regflag & RX8901_REG_INTF_VLF) {
>> +                     dev_warn_once(dev, "oscillator failed, set time!\n");
>> +                     return -EINVAL;
>> +             }
>>        }
>>
>>        /* read the RTC date and time registers all at once */
>> @@ -307,7 +327,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
>>        tmp = regs[DS1307_REG_HOUR] & 0x3f;
>>        t->tm_hour = bcd2bin(tmp);
>>        /* rx8130 is bit position, not BCD */
>> -     if (ds1307->type == rx_8130)
>> +     if (ds1307->type == rx_8130 || ds1307->type == rx_8901)
>>                t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f) - 1;
>>        else
>>                t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1;
>> @@ -358,7 +378,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
>>        regs[DS1307_REG_MIN] = bin2bcd(t->tm_min);
>>        regs[DS1307_REG_HOUR] = bin2bcd(t->tm_hour);
>>        /* rx8130 is bit position, not BCD */
>> -     if (ds1307->type == rx_8130)
>> +     if (ds1307->type == rx_8130 || ds1307->type == rx_8901)
>>                regs[DS1307_REG_WDAY] = 1 << t->tm_wday;
>>        else
>>                regs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1);
>> @@ -422,6 +442,17 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
>>                        dev_err(dev, "%s error %d\n", "write", result);
>>                        return result;
>>                }
>> +     } else if (ds1307->type == rx_8901) {
>> +             /*
>> +              * clear Voltage Loss Flag as data is available now (writing 1
>> +              * to the other bits in the INTF register has no effect)
>> +              */
>> +             result = regmap_write(ds1307->regmap, RX8901_REG_INTF,
>> +                                   0xff ^ RX8901_REG_INTF_VLF);
>> +             if (result) {
>> +                     dev_err(dev, "%s error %d\n", "write", result);
>> +                     return result;
>> +             }
>>        }
>>
>>        return 0;
>> @@ -568,6 +599,17 @@ 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)
>> +{
>> +     /* make sure that the backup battery is enabled */
>> +     u8 setup = RX8901_REG_PWSW_CFG_INIEN;
> 
> You can't do this as this will cause issues in the future for people
> wanting to keep this bit disabled (the main reason being that you don't
> want to draw power from the battery while your device sits on a shelf).
> You have to handle the RTC_PARAM_BACKUP_SWITCH_MODE parameter and then
> switch it from userspace.

Here my intention was to do something similar to what was done before 
for the rx8130 device [1], which as I understand it require similar 
setup initialization as the rx8901 device does. Is using the 
RTC_PARAM_BACKUP_SWITCH_MODE the new way of performing this initialization?

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


[1] 0026f1604c9b (rtc: ds1307: enable rx8130's backup battery, make it 
chargeable optionally)


-- 
/Fredrik

  reply	other threads:[~2026-02-03 14:24 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 " 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 [this message]
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
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=b547a09c-6a4d-46f1-a855-95d561e18ac1@axis.com \
    --to=fredriol@axis.com \
    --cc=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

all inboxes | Powered by JetHome®