power: qpnp-fg-gen3: update SOC masking algorithm

Currently, FULL_SOC and MONOTONIC_SOC registers are updated
multiple times when the recharge SOC threshold is close enough to
trigger the recharging frequently. This was leading to a SOC
fluctuation when SOC masking algorithm is enabled.

Rearrange charge_full_update used in SOC masking algorithm such
that FULL_SOC and MONOTONIC_SOC registers are updated just once
when the charge_full flag is cleared.

Also, when the device is rebooted/shutdown and if charge_full
flag is set, write to FULL_SOC with battery_soc and a full value
to MONOTONIC_SOC registers. This helps to maintain the same SOC
across a device reboot.

Change-Id: I95afa90f27e4c0f948f301ff8d6a1f84ae422ef0
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
1 file changed