public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
* Question about PCF85063A invalid state
@ 2021-10-13  9:48 Phil Elwell
  2021-10-13 20:14 ` Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Elwell @ 2021-10-13  9:48 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, linux-rtc

Hi,

We're using the PCF85063A on our Compute Module 4 I/O board, and a number of 
users have experienced problems with invalid state after inserting a backup 
battery. So far the problem has been confined to EXT_TEST (bit 7 of CTRL_1) 
being set, but there are a number of registers for which the driver only 
modifies a subset of the bits.

I can think of a number of ways to clear this invalid state, none of which are 
difficult - force a software reset whenever certain bits of certain registers 
have certain values, always specifically force some bits to known values, etc. -
but are there any preferences or pitfalls to be aware of?

Thanks for your input,

Phil Elwell, Raspberry Pi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about PCF85063A invalid state
  2021-10-13  9:48 Question about PCF85063A invalid state Phil Elwell
@ 2021-10-13 20:14 ` Alexandre Belloni
  2021-10-15  9:07   ` Phil Elwell
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2021-10-13 20:14 UTC (permalink / raw)
  To: Phil Elwell; +Cc: Alessandro Zummo, linux-rtc

Hello,

On 13/10/2021 10:48:48+0100, Phil Elwell wrote:
> Hi,
> 
> We're using the PCF85063A on our Compute Module 4 I/O board, and a number of
> users have experienced problems with invalid state after inserting a backup
> battery. So far the problem has been confined to EXT_TEST (bit 7 of CTRL_1)
> being set, but there are a number of registers for which the driver only
> modifies a subset of the bits.
> 
> I can think of a number of ways to clear this invalid state, none of which
> are difficult - force a software reset whenever certain bits of certain
> registers have certain values, always specifically force some bits to known
> values, etc. -
> but are there any preferences or pitfalls to be aware of?
> 

This is a very difficult topic because contrary to most of the other
IPs, the RTC is still running while Linux is not and it is expected that
it will retain its configuration across reboots (well, this is exactly
what the RTC is for).

This means that you may have some code (bootloader, firmware) running
before Linux configuring the RTC and so setting or clearing bits in
registers that are never touched by Linux. So, it is not possible to go
and change random bits because they don't have the default value or the
value we expect. Instead it is usually necessary to provide a way to
set those bits.

However, for EXT_TEST, I would assume the RTC lost its time once it is
set so I would treat it just like OS: if it is set, then leave it that
way until .set_time is called and return -EINVAL in .read_time.

I didn't try but if OS is always set by the RTC when EXT_TEST is set,
then maybe we don't need to check in .read_time.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about PCF85063A invalid state
  2021-10-13 20:14 ` Alexandre Belloni
@ 2021-10-15  9:07   ` Phil Elwell
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Elwell @ 2021-10-15  9:07 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Alessandro Zummo, linux-rtc

Alexandre,

On 13/10/2021 21:14, Alexandre Belloni wrote:
> Hello,
> 
> On 13/10/2021 10:48:48+0100, Phil Elwell wrote:
>> Hi,
>>
>> We're using the PCF85063A on our Compute Module 4 I/O board, and a number of
>> users have experienced problems with invalid state after inserting a backup
>> battery. So far the problem has been confined to EXT_TEST (bit 7 of CTRL_1)
>> being set, but there are a number of registers for which the driver only
>> modifies a subset of the bits.
>>
>> I can think of a number of ways to clear this invalid state, none of which
>> are difficult - force a software reset whenever certain bits of certain
>> registers have certain values, always specifically force some bits to known
>> values, etc. -
>> but are there any preferences or pitfalls to be aware of?
>>
> 
> This is a very difficult topic because contrary to most of the other
> IPs, the RTC is still running while Linux is not and it is expected that
> it will retain its configuration across reboots (well, this is exactly
> what the RTC is for).
> 
> This means that you may have some code (bootloader, firmware) running
> before Linux configuring the RTC and so setting or clearing bits in
> registers that are never touched by Linux. So, it is not possible to go
> and change random bits because they don't have the default value or the
> value we expect. Instead it is usually necessary to provide a way to
> set those bits.
> 
> However, for EXT_TEST, I would assume the RTC lost its time once it is
> set so I would treat it just like OS: if it is set, then leave it that
> way until .set_time is called and return -EINVAL in .read_time.
> 
> I didn't try but if OS is always set by the RTC when EXT_TEST is set,
> then maybe we don't need to check in .read_time.

I think your suggestion can be summarised as:

The existing code probably already detects EXT_TEST because it will cause
the OS bit to be set. All that is required is to clear the EXT_TEST bit
as part of the usual .set_time handler.

I will do it that way.

Many thanks,

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-15  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-13  9:48 Question about PCF85063A invalid state Phil Elwell
2021-10-13 20:14 ` Alexandre Belloni
2021-10-15  9:07   ` Phil Elwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox