power: qpnp-bms: implement workarounds for coupling issue

On certain PMICs there is a coupling issue which causes bad calibration
values that reports a high current value even when the BATFET is open.
This coupling issue happens regardless of an internal/external rsense
configuration.

The suggested workaround is to repeatedly calibrate until we get values
that result in less than 3mA of current.

Expose the BATFET open/closed as battery's ONLINE property. It is
reasonable use of this property since PRESENT suggests a battery is
actually present in the device and ONLINE suggests if it is connected to
the system via BATFET.

The BATFET can open when a charger is present and
* the battery is fully charged
* the battery is hot/cold
(Note that if charger is disabled the buck will not operate
and we don't have coupling issue)
The fully charged notifications trickle down to BMS driver,
since battery psy supplies to "bms", use it to check if the
BATFET has opened.
The hot/cold interrupt is not yet registered to, add it so we can notify
the BMS driver if the battery goes hot or cold. Since the battery can
go hot or cold while the device is sleeping, we need to wakeup for
calibration workaround.

The BATFET can close when
* the charger is removed
* the battery recovers form hot/cold conditions when charger is present
These notifications too trickle down to the BMS driver and can be used to
check if the BATFET has closed.

Also once good calibration values are detected above use them until BATFET
closes i.e. do NOT calibrate until the BATFET closes. Update the code
that periodically calculates SOC to skip calibrations as long as BATFET
is open. On the same lines ask the iadc driver to skip auto calibrations
until BATFET closes.

CRs-Fixed: 509620
Change-Id: I89b521368304d7171d75e462cf15f2f1daa55cdc
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
4 files changed