Skip to content

Commit 92695b7

Browse files
author
Al Stone
committed
power: supply: ab8500: Standardize alert mode charging
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071846 Tested: This is one of a series of patch sets to enable Arm SystemReady IR support in the kernel for NXP i.MX8 platforms. This set updates the power subsystem. This set has been tested via simple boot tests and the CI loop. Conflicts: drivers/power/supply/ab8500-bm.h drivers/power/supply/ab8500_bmdata.c drivers/power/supply/abx500_chargalg.c This is not a supported device so these portions of the patch have been dropped. commit 0e8b903 Author: Linus Walleij <linus.walleij@linaro.org> Date: Sat Feb 26 00:27:56 2022 +0100 power: supply: ab8500: Standardize alert mode charging The AB8500 code is using a special current and voltage setting when the battery is in "alert mode", i.e. when it is starting to go outside normal operating conditions so it is too cold or too hot. This makes sense as a way for the charging algorithm to deal with hostile environments. Add the needed members to the struct power_supply_battery_info, and switch the AB8500 charging code over to using this. Reviewed-by: Matti Vaittineen <matti.vaittinen@fi.rohmeurope.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> (cherry picked from commit 0e8b903) Signed-off-by: Al Stone <ahs3@redhat.com>
1 parent 89f64a0 commit 92695b7

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

drivers/power/supply/ab8500_bmdata.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ static struct abx500_battery_type bat_type_thermistor[] = {
246246
.v_to_cap_tbl = cap_tbl_a_thermistor,
247247
.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
248248
.batres_tbl = temp_to_batres_tbl_thermistor,
249-
250249
},
251250
{
252251
.name = POWER_SUPPLY_TECHNOLOGY_LIPO,
@@ -281,8 +280,8 @@ static struct abx500_battery_type bat_type_ext_thermistor[] = {
281280
[BATTERY_UNKNOWN] = {
282281
/* First element always represent the UNKNOWN battery */
283282
.name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN,
284-
.resis_high = 0,
285-
.resis_low = 0,
283+
.resis_high = 0,
284+
.resis_low = 0,
286285
.battery_resistance = 300,
287286
.charge_full_design = 612,
288287
.nominal_voltage = 3700,
@@ -297,8 +296,8 @@ static struct abx500_battery_type bat_type_ext_thermistor[] = {
297296
.maint_b_cur_lvl = 400,
298297
.maint_b_vol_lvl = 4000,
299298
.maint_b_chg_timer_h = 200,
300-
.low_high_cur_lvl = 300,
301-
.low_high_vol_lvl = 4000,
299+
.low_high_cur_lvl = 300,
300+
.low_high_vol_lvl = 4000,
302301
.n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
303302
.r_to_t_tbl = temp_tbl,
304303
.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),

drivers/power/supply/abx500_chargalg.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -731,12 +731,12 @@ static void abx500_chargalg_check_temp(struct abx500_chargalg *di)
731731
di->t_hyst_norm = 0;
732732
di->t_hyst_lowhigh = 0;
733733
} else {
734-
if (((di->batt_data.temp >= di->bm->temp_high) &&
734+
if (((di->batt_data.temp >= bi->temp_alert_max) &&
735735
(di->batt_data.temp <
736-
(di->bm->temp_over - di->t_hyst_lowhigh))) ||
736+
(bi->temp_max - di->t_hyst_lowhigh))) ||
737737
((di->batt_data.temp >
738-
(di->bm->temp_under + di->t_hyst_lowhigh)) &&
739-
(di->batt_data.temp <= di->bm->temp_low))) {
738+
(bi->temp_min + di->t_hyst_lowhigh)) &&
739+
(di->batt_data.temp <= bi->temp_alert_min))) {
740740
/* TEMP minor!!!!! */
741741
di->events.btemp_underover = false;
742742
di->events.btemp_lowhigh = true;
@@ -1589,12 +1589,10 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
15891589
break;
15901590

15911591
case STATE_TEMP_LOWHIGH_INIT:
1592-
abx500_chargalg_start_charging(di,
1593-
di->bm->bat_type[
1594-
di->bm->batt_id].low_high_vol_lvl,
1595-
di->bm->bat_type[
1596-
di->bm->batt_id].low_high_cur_lvl);
1597-
abx500_chargalg_stop_maintenance_timer(di);
1592+
ab8500_chargalg_start_charging(di,
1593+
di->bm->bat_type->low_high_vol_lvl,
1594+
di->bm->bat_type->low_high_cur_lvl);
1595+
ab8500_chargalg_stop_maintenance_timer(di);
15981596
di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
15991597
abx500_chargalg_state_to(di, STATE_TEMP_LOWHIGH);
16001598
power_supply_changed(di->chargalg_psy);

drivers/power/supply/power_supply_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@ int power_supply_get_battery_info(struct power_supply *psy,
596596
info->charge_restart_voltage_uv = -EINVAL;
597597
info->overvoltage_limit_uv = -EINVAL;
598598
info->maintenance_charge = NULL;
599+
info->alert_low_temp_charge_current_ua = -EINVAL;
600+
info->alert_low_temp_charge_voltage_uv = -EINVAL;
601+
info->alert_high_temp_charge_current_ua = -EINVAL;
602+
info->alert_high_temp_charge_voltage_uv = -EINVAL;
599603
info->temp_ambient_alert_min = INT_MIN;
600604
info->temp_ambient_alert_max = INT_MAX;
601605
info->temp_alert_min = INT_MIN;

include/linux/power_supply.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,19 @@ struct power_supply_maintenance_charge_table {
444444
* after the main CC/CV charging phase is complete.
445445
* @maintenance_charge_size: the number of maintenance charging settings in
446446
* maintenance_charge.
447+
* @alert_low_temp_charge_current_ua: The charging current to use if the battery
448+
* enters low alert temperature, i.e. if the internal temperature is between
449+
* temp_alert_min and temp_min. No matter the charging phase, this
450+
* and alert_high_temp_charge_voltage_uv will be applied.
451+
* @alert_low_temp_charge_voltage_uv: Same as alert_low_temp_charge_current_ua,
452+
* but for the charging voltage.
453+
* @alert_high_temp_charge_current_ua: The charging current to use if the
454+
* battery enters high alert temperature, i.e. if the internal temperature is
455+
* between temp_alert_max and temp_max. No matter the charging phase, this
456+
* and alert_high_temp_charge_voltage_uv will be applied, usually lowering
457+
* the charging current as an evasive manouver.
458+
* @alert_high_temp_charge_voltage_uv: Same as
459+
* alert_high_temp_charge_current_ua, but for the charging voltage.
447460
* @factory_internal_resistance_uohm: the internal resistance of the battery
448461
* at fabrication time, expressed in microohms. This resistance will vary
449462
* depending on the lifetime and charge of the battery, so this is just a
@@ -595,6 +608,10 @@ struct power_supply_battery_info {
595608
int constant_charge_voltage_max_uv;
596609
struct power_supply_maintenance_charge_table *maintenance_charge;
597610
int maintenance_charge_size;
611+
int alert_low_temp_charge_current_ua;
612+
int alert_low_temp_charge_voltage_uv;
613+
int alert_high_temp_charge_current_ua;
614+
int alert_high_temp_charge_voltage_uv;
598615
int factory_internal_resistance_uohm;
599616
int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];
600617
int temp_ambient_alert_min;

0 commit comments

Comments
 (0)