power: qpnp-bms: estimate OCVs based on temperature

The BMS driver will throw out the hardware taken open circuit voltage
(OCV) if there has been a warm reset and the PMIC did not go through
the power on sequence. This is to throw out the stale OCVs from the
last boot.

However, if there is no shutdown SOC stored, the BMS driver must
estimate an OCV. When estimating an OCV, there is no information about
the battery state of charge yet, so the default battery resistance is
used to do the estimation. However, this only works in cases where the
battery temperature is not cold.

When the battery temperature is cold, the real rbatt will be much larger
than the default rbatt. If the default rbatt is used, the estimated OCV
will most likely be much too low, and a faulty SOC will be used. This
issue is exacerbated by the fact that the shutdown SOC is thrown out
when the battery is cold, so this situation can arise much more
frequently.

Fix this by estimating the battery OCV based on temperature and just
using a default rbatt SOC of 50%.

Change-Id: Ibc89fcd74a295bb2196be2d8c977e8b1b8598d7a
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
1 file changed