aboutsummaryrefslogtreecommitdiff
path: root/drivers/power/supply
diff options
context:
space:
mode:
authorGravatar Linus Walleij <linus.walleij@linaro.org> 2021-11-20 16:53:21 +0100
committerGravatar Sebastian Reichel <sebastian.reichel@collabora.com> 2021-11-22 17:16:25 +0100
commit9c20899da46b85ed00e6f3b935b4bd9c9b34a571 (patch)
tree0a751c5bae9acf6ddb4010100ffb5e3e80992867 /drivers/power/supply
parentpower: supply: ab8500: Standardize internal resistance (diff)
downloadlinux-9c20899da46b85ed00e6f3b935b4bd9c9b34a571.tar.gz
linux-9c20899da46b85ed00e6f3b935b4bd9c9b34a571.tar.bz2
linux-9c20899da46b85ed00e6f3b935b4bd9c9b34a571.zip
power: supply: ab8500: Standardize termination current
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>
Diffstat (limited to 'drivers/power/supply')
-rw-r--r--drivers/power/supply/ab8500-bm.h2
-rw-r--r--drivers/power/supply/ab8500_bmdata.c5
-rw-r--r--drivers/power/supply/ab8500_chargalg.c12
3 files changed, 10 insertions, 9 deletions
diff --git a/drivers/power/supply/ab8500-bm.h b/drivers/power/supply/ab8500-bm.h
index 7e00f480756b..4bc932109f63 100644
--- a/drivers/power/supply/ab8500-bm.h
+++ b/drivers/power/supply/ab8500-bm.h
@@ -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;
diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c
index 981003105af6..cd1fc288314e 100644
--- a/drivers/power/supply/ab8500_bmdata.c
+++ b/drivers/power/supply/ab8500_bmdata.c
@@ -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;
diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c
index dd9cad63e37e..49e7167d0362 100644
--- a/drivers/power/supply/ab8500_chargalg.c
+++ b/drivers/power/supply/ab8500_chargalg.c
@@ -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,