power: pm8921-bms: use termination battery resistance

Unusable Charge(UUC) is based on battery resistance and average load. Since
battery resistance is based on temperature and state of charge, UUC
is essentially based on temperature, state of charge and the load.

The purpose of UUC is to prevent the battery from falling below the
cutoff voltage. In the current implementation, since UUC is dependent
on SOC, it is small when SOC is high and gets bigger as SOC approaches
zero. This increase however is not linear which causes huge jumps in
SOC.

Remove the dependence of UUC on SOC. Simply use the resistance value
which would have been used when SOC = 0.

To find this resistance value, loop from SOC = 0 towards 100 and at each
step calculate/interpolate open circuit voltage, resistance and the
corresponding unusable voltage. The interpolated resistance value where
unusable voltage equals open circuit voltage is the termination
resistance. Use this resistance value for calculation of UUC. Note that
this resistance value is not dependent on the current SOC and will be
constant as long as the load and temperature remain the same.

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