From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
If the RTC is not linked to any battery, the oscillator is stopped at
startup and a SW reset command is generated to the PCF85063 RTC.
Manually start the oscillator in case the PCF85063 RTC is not battery
backed.
Co-developed-by: Larisa Grigore <larisa.grigore@nxp.com>
Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com>
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
---
drivers/rtc/rtc-pcf85063.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 4fa5c4ecdd5a..6de7344d2469 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -590,6 +590,14 @@ static int pcf85063_probe(struct i2c_client *client)
i2c_set_clientdata(client, pcf85063);
+ if (of_property_read_bool(client->dev.of_node, "no-battery")) {
+ err = regmap_update_bits(pcf85063->regmap, PCF85063_REG_SC,
+ PCF85063_REG_SC_OS, 0);
+ if (err)
+ return dev_err_probe(&client->dev, err,
+ "Failed to start the oscillator\n");
+ }
+
err = regmap_read(pcf85063->regmap, PCF85063_REG_SC, &tmp);
if (err)
return dev_err_probe(&client->dev, err, "RTC chip is not present\n");
--
2.45.2
On 10/04/2025 11:25:48+0300, Ciprian Costea wrote:
> From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
>
> If the RTC is not linked to any battery, the oscillator is stopped at
> startup and a SW reset command is generated to the PCF85063 RTC.
> Manually start the oscillator in case the PCF85063 RTC is not battery
> backed.
>
No, there is no point in starting the oscillator with a know wrong
time/date. The oscillator must only be started once the time is known
good, that is in .set_time
> Co-developed-by: Larisa Grigore <larisa.grigore@nxp.com>
> Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com>
> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
> ---
> drivers/rtc/rtc-pcf85063.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
> index 4fa5c4ecdd5a..6de7344d2469 100644
> --- a/drivers/rtc/rtc-pcf85063.c
> +++ b/drivers/rtc/rtc-pcf85063.c
> @@ -590,6 +590,14 @@ static int pcf85063_probe(struct i2c_client *client)
>
> i2c_set_clientdata(client, pcf85063);
>
> + if (of_property_read_bool(client->dev.of_node, "no-battery")) {
> + err = regmap_update_bits(pcf85063->regmap, PCF85063_REG_SC,
> + PCF85063_REG_SC_OS, 0);
> + if (err)
> + return dev_err_probe(&client->dev, err,
> + "Failed to start the oscillator\n");
> + }
> +
> err = regmap_read(pcf85063->regmap, PCF85063_REG_SC, &tmp);
> if (err)
> return dev_err_probe(&client->dev, err, "RTC chip is not present\n");
> --
> 2.45.2
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
On 4/10/2025 12:17 PM, Alexandre Belloni wrote:
> On 10/04/2025 11:25:48+0300, Ciprian Costea wrote:
>> From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
>>
>> If the RTC is not linked to any battery, the oscillator is stopped at
>> startup and a SW reset command is generated to the PCF85063 RTC.
>> Manually start the oscillator in case the PCF85063 RTC is not battery
>> backed.
>>
>
> No, there is no point in starting the oscillator with a know wrong
> time/date. The oscillator must only be started once the time is known
> good, that is in .set_time
>
Hello Alexandre,
Thanks for your review.
You are correct, please disregard this patchset. I've looked into the
'set_time' callback and indeed the oscillator is being started here [1].
I've tested, so even with no battery provided for the PCF85036 RTC,
after setting the hardware clock from userspace, the RTC works as
expected because of the manual starting of the oscillator from 'set_time'.
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/rtc/rtc-pcf85063.c#n129
Ciprian
>> Co-developed-by: Larisa Grigore <larisa.grigore@nxp.com>
>> Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com>
>> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
>> ---
>> drivers/rtc/rtc-pcf85063.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
>> index 4fa5c4ecdd5a..6de7344d2469 100644
>> --- a/drivers/rtc/rtc-pcf85063.c
>> +++ b/drivers/rtc/rtc-pcf85063.c
>> @@ -590,6 +590,14 @@ static int pcf85063_probe(struct i2c_client *client)
>>
>> i2c_set_clientdata(client, pcf85063);
>>
>> + if (of_property_read_bool(client->dev.of_node, "no-battery")) {
>> + err = regmap_update_bits(pcf85063->regmap, PCF85063_REG_SC,
>> + PCF85063_REG_SC_OS, 0);
>> + if (err)
>> + return dev_err_probe(&client->dev, err,
>> + "Failed to start the oscillator\n");
>> + }
>> +
>> err = regmap_read(pcf85063->regmap, PCF85063_REG_SC, &tmp);
>> if (err)
>> return dev_err_probe(&client->dev, err, "RTC chip is not present\n");
>> --
>> 2.45.2
>>
>
© 2016 - 2025 Red Hat, Inc.