Re: battery switch-over detection on pcf2127
From: Alexandre Belloni
Date: Tue May 05 2020 - 18:14:50 EST
On 05/05/2020 23:01:19+0200, Rasmus Villemoes wrote:
> Thanks for the quick replies, both. Unfortunately, being able to read BF
> from linux is not relevant to us - all the handling happens early in the
> bootloader (including clearing BF, so that we can detect that the
> previous boot failed only because of power fail - hence whether the
> linux driver clears BF or not is not relevant). We really just want
> linux to not touch the bits in CTRL3 at all.
>
Well, in that case, Linux doesn't touch the BF bit anymore unless
userspace uses the ioctls so you should be ok using it from your
bootloader.
> Hm, wait. Re-reading the above suggests that BF can get set even if BTSE
> is not, and a quick experiment shows that is true - I must have misread
> the data sheet. While I think that's fine for now (currently I only
> print the time of last switch-over as a diagnostic), I did have some use
> case in mind for comparing that timestamp to the current time and make
> decisions based on that. But until I figure out exactly what I want to
> use it for, and until we actually upgrade to 5.4+, there's no rush.
>
Configuring the timestamps is something else I want to do but I still
didn't finish to design the proper interface.
It is definitively on the todo list.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com