power: supply: ab8500: Standardize termination current
authorLinus Walleij <linus.walleij@linaro.org>
Sat, 20 Nov 2021 15:53:21 +0000 (16:53 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 22 Nov 2021 16:16:25 +0000 (17:16 +0100)
The AB8500 custom termination current can be replaced by the
corresponding struct power_supply_battery_info field.

Remove the struct member and amend the code to use the
standard property.

Add *_ua suffix for clarity and to make sure we have
changed all code sites using this member.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/ab8500-bm.h
drivers/power/supply/ab8500_bmdata.c
drivers/power/supply/ab8500_chargalg.c

index 7e00f480756b60377f95d2523a351118eb8cd7c8..4bc932109f6399009ec799044997493776dd8e90 100644 (file)
@@ -374,7 +374,6 @@ struct ab8500_maxim_parameters {
  * struct ab8500_battery_type - different batteries supported
  * @resis_high:                        battery upper resistance limit
  * @resis_low:                 battery lower resistance limit
- * @termination_curr           battery charging termination current in mA
  * @recharge_cap               battery capacity limit that will trigger a new
  *                             full charging cycle in the case where maintenan-
  *                             -ce charging has been disabled
@@ -398,7 +397,6 @@ struct ab8500_maxim_parameters {
 struct ab8500_battery_type {
        int resis_high;
        int resis_low;
-       int termination_curr;
        int recharge_cap;
        int normal_cur_lvl;
        int normal_vol_lvl;
index 981003105af69621737c8ddd7a255659dccdd678..cd1fc288314eb4927fa774a81aa3862d9b996ce6 100644 (file)
@@ -83,7 +83,6 @@ static const struct batres_vs_temp temp_to_batres_tbl_thermistor[] = {
 static struct ab8500_battery_type bat_type_thermistor_unknown = {
        .resis_high = 0,
        .resis_low = 0,
-       .termination_curr = 200,
        .recharge_cap = 95,
        .normal_cur_lvl = 400,
        .normal_vol_lvl = 4100,
@@ -203,6 +202,10 @@ int ab8500_bm_of_probe(struct power_supply *psy,
                bi->overvoltage_limit_uv = 4050000;
        }
 
+       if (bi->charge_term_current_ua)
+               /* Charging stops when we drop below this current */
+               bi->charge_term_current_ua = 200000;
+
        if (bi->factory_internal_resistance_uohm < 0)
                bi->factory_internal_resistance_uohm = 300000;
 
index dd9cad63e37ea1c66c0a6dfa7492237c7f79badb..49e7167d03623a292c4a55daed399f0e2c5547d9 100644 (file)
@@ -87,7 +87,7 @@ struct ab8500_chargalg_current_step_status {
 struct ab8500_chargalg_battery_data {
        int temp;
        int volt_uv;
-       int avg_curr;
+       int avg_curr_ua;
        int inst_curr;
        int percent;
 };
@@ -795,9 +795,9 @@ static void ab8500_chargalg_end_of_charge(struct ab8500_chargalg *di)
                !di->maintenance_chg && (di->batt_data.volt_uv >=
                di->bm->bi.overvoltage_limit_uv ||
                di->events.usb_cv_active || di->events.ac_cv_active) &&
-               di->batt_data.avg_curr <
-               di->bm->bat_type->termination_curr &&
-               di->batt_data.avg_curr > 0) {
+               di->batt_data.avg_curr_ua <
+               di->bm->bi.charge_term_current_ua &&
+               di->batt_data.avg_curr_ua > 0) {
                if (++di->eoc_cnt >= EOC_COND_CNT) {
                        di->eoc_cnt = 0;
                        di->charge_status = POWER_SUPPLY_STATUS_FULL;
@@ -1237,7 +1237,7 @@ static int ab8500_chargalg_get_ext_psy_data(struct device *dev, void *data)
                case POWER_SUPPLY_PROP_CURRENT_AVG:
                        switch (ext->desc->type) {
                        case POWER_SUPPLY_TYPE_BATTERY:
-                               di->batt_data.avg_curr = ret.intval / 1000;
+                               di->batt_data.avg_curr_ua = ret.intval;
                                break;
                        case POWER_SUPPLY_TYPE_USB:
                                if (ret.intval)
@@ -1398,7 +1398,7 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di)
                "AC_online %d USB_online %d AC_CV %d USB_CV %d AC_I %d "
                "USB_I %d AC_Vset %d AC_Iset %d USB_Vset %d USB_Iset %d\n",
                di->batt_data.volt_uv,
-               di->batt_data.avg_curr,
+               di->batt_data.avg_curr_ua,
                di->batt_data.inst_curr,
                di->batt_data.temp,
                di->batt_data.percent,