power: pm8921-bms: Prevent SOC jumps while charging

The BMS driver scales the SOC while charging based on the charge
current. It does not scale when it sees that the battery voltage at
terminals have fallen 10mV below the max current, the reason being a
current spike that causes the voltage to droop.

However there is a corner case when the voltage could droop but not by
10mV. In this case the BMS will report a higher SOC value, since the
charge current most likely has reduced.  This is incorrect.

Fix this behavior by showing the previous SOC value under severe system
load while charging. Note that when the vdd max adjusting algorithm in
charger reduces the vdd max value, the battery terminal voltage reduces
causing this scheme to treat it as a current spike. This is fine as it
will scale SOC correctly the next time it does a calculation.

Change-Id: I48ba7382b06ed90fb253dfbbaa4a406c1b8ce6eb
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
1 file changed