power: pm8921-bms: backup average current along with shutdown soc
When a phone shuts down because of 0% State of charge (soc) while it is
under heavy load, the unusable charge value is very high. The unusable
charge value is based on load.
When the device restarts, that load has significantly decreased
causing uuc value to reduce. This in turn increases the soc. In certain
cases the increase is so large that it falls beyond the shutdown soc
limit checks and a higher soc value is reported. That is unacceptable.
This problem can be addressed if we can remember the load used to
calculate uuc between restarts. Use the lower nibble of register 0x105
to store the average current. Since we want finer resolution towards higher
current let the first step be 500mA and then each increment be 50mA steps.
Also since we are saving the range of load between restarts fill up all
the load samples in uuc calculation with this value. This emulates a
low pass filter on current changes and increases/decreases uuc
gradually.
Change-Id: I4f2ab27865756243d023f48798cc002ff12a9d31
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
1 file changed