power: supply: ab8500: Swap max and overvoltage

We should terminate charging when we reach the voltage_max_design_uv
not overvoltage_limit_uv, this is an abuse of that struct member.

The overvoltage limit is actually not configurable on the AB8500,
it is fixed to 4.75 V so drop a comment about that in the code.

Fixes: 2a5f41830a ("power: supply: ab8500: Standardize voltages")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Linus Walleij 2022-01-29 01:49:16 +01:00 committed by Sebastian Reichel
parent d58964be64
commit d662a7df36
3 changed files with 11 additions and 7 deletions

View File

@ -186,13 +186,11 @@ int ab8500_bm_of_probe(struct power_supply *psy,
* fall back to safe defaults.
*/
if ((bi->voltage_min_design_uv < 0) ||
(bi->voltage_max_design_uv < 0) ||
(bi->overvoltage_limit_uv < 0)) {
(bi->voltage_max_design_uv < 0)) {
/* Nominal voltage is 3.7V for unknown batteries */
bi->voltage_min_design_uv = 3700000;
bi->voltage_max_design_uv = 3700000;
/* Termination voltage (overcharge limit) 4.05V */
bi->overvoltage_limit_uv = 4050000;
/* Termination voltage 4.05V */
bi->voltage_max_design_uv = 4050000;
}
if (bi->constant_charge_current_max_ua < 0)

View File

@ -802,7 +802,7 @@ static void ab8500_chargalg_end_of_charge(struct ab8500_chargalg *di)
if (di->charge_status == POWER_SUPPLY_STATUS_CHARGING &&
di->charge_state == STATE_NORMAL &&
!di->maintenance_chg && (di->batt_data.volt_uv >=
di->bm->bi->overvoltage_limit_uv ||
di->bm->bi->voltage_max_design_uv ||
di->events.usb_cv_active || di->events.ac_cv_active) &&
di->batt_data.avg_curr_ua <
di->bm->bi->charge_term_current_ua &&

View File

@ -2263,7 +2263,13 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di)
{
int ret;
/* Set VBAT OVV threshold */
/*
* Set VBAT OVV (overvoltage) threshold to 4.75V (typ) this is what
* the hardware supports, nothing else can be configured in hardware.
* See this as an "outer limit" where the charger will certainly
* shut down. Other (lower) overvoltage levels need to be implemented
* in software.
*/
ret = abx500_mask_and_set_register_interruptible(di->dev,
AB8500_CHARGER,
AB8500_BATT_OVV,