Re: battery switch-over detection on pcf2127

Bruno Thomsen
2020-05-05T20:38:32Z

Hi Rasmus

Den tir. 5. maj 2020 kl. 22.07 skrev Alexandre Belloni
<alexandre.belloni@bootlin.com>:
>
> On 05/05/2020 21:54:47+0200, Rasmus Villemoes wrote:
> > Hi Bruno
> >
> > I just noticed your "rtc: pcf2127: add tamper detection support"
> > (03623b4b04) from 5.4. Unfortunately, clearing the BTSE bit breaks a use
> > case of ours:
> >
> > We rely on the battery switch-over detection to distinguish a powerfail
> > during boot from a PORESET by the external watchdog (in the latter case,
> > the RTC is still powered throughout, meaning there is no battery
> > switch-over event). OTOH, we do not use the tamper detection - in fact,
> > the TS signal is unconnected on our board.
> >
> > We're currently still on 4.19, but we will eventually upgrade to a
> > kernel containing the above commit. So I was wondering if we could
> > figure out a way that would work for both of us - either some CONFIG
> > knob, or perhaps something in the device-tree. Any ideas?
> >
>
> Yes, I was working on a patch series last week allowing to read BF. I'm
> not sure clearing BTSE is your issue but clearing BF is.
>
> I'm going to send it tonight, I'll copy you, let me now if that works
> for you. You can then read BF using the RTC_VL_READ ioctl. The
> RTC_VL_BACKUP_SWITCH flag will be set if a switchover happened.
> The RTC_VL_CLR ioctl can be used to clear the flag.
>
> I think clearing BTSE is still the right thing to do.

I think your use case is valid and it sounds like Alexandre solution will
solve it as you just need to know if a battery switch-over has happened
not when exactly it happened.

I can help test the patches too. Now without google auto html..

Bruno