What is the proper way to read RTC battery voltage

Ed Tanous ed.tanous at intel.com
Sat Aug 4 03:26:15 AEST 2018


On 08/02/2018 11:14 PM, Lei YU wrote:
> 
> 2. We could leave the GPIO for user space to control, e.g. let phosphor-hwmon
>     to control the GPIO while reading a sensor, it resolves the problem.
>     This is done by Google and the patch for phosphor-hwmon is at
>     (https://gerrit.openbmc-project.xyz/#/c/openbmc/phosphor-hwmon/+/11697/)

In previous codebases, this is the option we've gone with.  In practice, 
there is some lag time so some sleeps are needed to wait for the FET to 
charge the line before initiating the reading on the ADC.  In the past 
we've simply done this with blocking sleeps, but there are likely better 
options.

> 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.


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.


More information about the openbmc mailing list