power: pm8921-bms: remember soc between restarts
Currently the code does not have a mechanism to remember the soc
reported just before shutting down and upon restarting the new
soc reported is off from the previous soc value reported.
This change introduces
- a method to save soc in an unused coincell back register: ssbi address
0x107 is not used on 8921 and serves the purpose of storing the soc.
The driver reads this value and uses it to scale the reported soc.
- a method to detect that a battery was removed and perhaps replaced by a
different one. If the battery is found replaced the driver is notified
of the change and it disregards the soc value it read from the backup
register. The charger driver has a battery backed bit (force vref
therm) which it sets in its initialization sequence. Once set the
value remains between restarts, unless the battery is removed. The
default value of this bit is 0. Hence if a zero is detected before
writing to it, battery was removed between restarts - this mechanism
is used to notify the BMS to disregard the soc read from the backup
register.
Note that for this to work correctly the bootloader needs to be updated to
not overwrite register 0x107 upon restart.
CRs-Fixed: 370287
Change-Id: If7d098552d36eb27a396ee7d37f78d3629861f6e
Signed-off-by:
Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Loading
Please register or sign in to comment