power: step-chg-jeita: Clip voltages higher than max allowed

Currently, if the current battery voltage is out of bounds of the Step
Charge ranges, the step charging voter is disabled. In tapered charging
situations where Vbatt sometimes exceeds the highest allowed voltage,
this leads to a sudden change in the charging current due to the MIN
voter mechanism selecting the next minimum value out of all the votes,
which is undesirable.

Fix this by choosing highest possible range value for battery voltage
when the observed value exceeds the range of acceptable values. This
results in the step charge voter remaining enabled and retaining its
vote, which, in turn, ensures that the charging current remains the same
even when the battery voltage exceeds the maximum allowed value
(assuming battery temperature is unchanged).

The current behaviour is retained for those situations where the
observed value is lesser than the minimum acceptable range value.

Also enable this behaviour for JEITA functionality as well.

CRs-Fixed: 2255514
Change-Id: I3c33c76306f0290005fe9bbe0345c76b284c56e6
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
1 file changed