power: supply: ab8500: Swap max and overvoltage
authorLinus Walleij <linus.walleij@linaro.org>
Sat, 29 Jan 2022 00:49:16 +0000 (01:49 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Fri, 11 Feb 2022 19:24:53 +0000 (20:24 +0100)
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: 2a5f41830aad ("power: supply: ab8500: Standardize voltages")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/ab8500_bmdata.c
drivers/power/supply/ab8500_chargalg.c
drivers/power/supply/ab8500_fg.c

index 7133cce6a25a8211862b145f1ce5b87cc855bdcc..62b63f0437dda7db430ec0767c70f70341477a3f 100644 (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)
index c4a2fe07126c34ca6e13749f992c6e26065694ab..bcf85ae6828e034eefbc5f372048bb82c2b7d9c6 100644 (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 &&
index b0919a6a6587867ef25e82c583a66d415f07c150..236fd9f9d6f142d1d8b7b81d192dd4509d17496c 100644 (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,