What is the proper way to read RTC battery voltage

Lei YU mine260309 at gmail.com
Mon Aug 6 15:51:23 AEST 2018


> > 3. We could use gpio-mux and io-channel-mux driver, that let kernel to
> >     automatically pull the GPIO while reading the sensor. (See
> >     https://github.com/mine260309/linux/commit/8e60647389e5400a85c705685ca2f6b875856c99
> >     for example).
> >     However, it requires some delay between GPIO pulled high and reading the ADC
> >     channel, if the delay is too small, the ADC channel reading becomes
> >     incorrect, e.g. it gets 0 or a lower value than expected.
> >
>
> This sounds like a cleaner solution, but more difficult to execute in
> practice.  I think either 2 or 3 would solve it.  Is there an easy way
> to delay in the driver without blocking?  It doesn't need to be terribly
> deterministic to work correctly.

I did not know a way to delay without blocking, I was thinking:
1. Is it reasonable to do udelay/mdelay in driver?
2. If yes, which driver should use the delay? The io-channel-mux driver,
   or adc driver?

> Another thing to note is that even with this, your battery life is
> affected by how often you poll the voltage, so in general we reduce the
> scan rate of the battery voltage readings compared to other sensors to
> keep the battery life more sustainable over the long term.

Yup, current phosphor-hwmon is able to config the sensor read interval, in
practice we probably read the battery voltage once every day.


More information about the openbmc mailing list