diff options
author | 2021-11-20 16:53:13 +0100 | |
---|---|---|
committer | 2021-11-22 17:16:25 +0100 | |
commit | 6252c706cdb003da0046ced1a088b9f31af1fd9b (patch) | |
tree | 1c747054bca99530f432f1fa660ec6feb7d94929 /drivers/power/supply/ab8500_chargalg.c | |
parent | power: supply: ab8500: Sink current tables into charger code (diff) | |
download | linux-dev-6252c706cdb003da0046ced1a088b9f31af1fd9b.tar.xz linux-dev-6252c706cdb003da0046ced1a088b9f31af1fd9b.zip |
power: supply: ab8500: Standardize operating temperature
Instead of storing the temperature limits in our custom
struct struct ab8500_bm_data, make struct power_supply_battery_info
a member of this and store the min and max temperatures inside
that struct as the temp_min/temp_max and
temp_alert_min/temp_alert_max respectively.
The values can be assigned from the device tree, but if
not present will be set to the same defaults as are currently
in the code.
This way we start to move over to using
struct power_supply_battery_info and make it possible to move
the data over to the device tree and we will move piece by
piece toward using the standard info struct.
Temperature hysteresis is currently not supported by the
standard struct but we move the assignment here as well so
that we have all parameterization in one spot.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply/ab8500_chargalg.c')
-rw-r--r-- | drivers/power/supply/ab8500_chargalg.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c index ff4b26b1ceca..9196434393e8 100644 --- a/drivers/power/supply/ab8500_chargalg.c +++ b/drivers/power/supply/ab8500_chargalg.c @@ -722,27 +722,29 @@ static void ab8500_chargalg_start_charging(struct ab8500_chargalg *di, */ static void ab8500_chargalg_check_temp(struct ab8500_chargalg *di) { - if (di->batt_data.temp > (di->bm->temp_low + di->t_hyst_norm) && - di->batt_data.temp < (di->bm->temp_high - di->t_hyst_norm)) { + struct power_supply_battery_info *bi = &di->bm->bi; + + if (di->batt_data.temp > (bi->temp_alert_min + di->t_hyst_norm) && + di->batt_data.temp < (bi->temp_alert_max - di->t_hyst_norm)) { /* Temp OK! */ di->events.btemp_underover = false; di->events.btemp_lowhigh = false; di->t_hyst_norm = 0; di->t_hyst_lowhigh = 0; } else { - if (((di->batt_data.temp >= di->bm->temp_high) && + if (((di->batt_data.temp >= bi->temp_alert_max) && (di->batt_data.temp < - (di->bm->temp_over - di->t_hyst_lowhigh))) || + (bi->temp_max - di->t_hyst_lowhigh))) || ((di->batt_data.temp > - (di->bm->temp_under + di->t_hyst_lowhigh)) && - (di->batt_data.temp <= di->bm->temp_low))) { + (bi->temp_min + di->t_hyst_lowhigh)) && + (di->batt_data.temp <= bi->temp_alert_min))) { /* TEMP minor!!!!! */ di->events.btemp_underover = false; di->events.btemp_lowhigh = true; di->t_hyst_norm = di->bm->temp_hysteresis; di->t_hyst_lowhigh = 0; - } else if (di->batt_data.temp <= di->bm->temp_under || - di->batt_data.temp >= di->bm->temp_over) { + } else if (di->batt_data.temp <= bi->temp_min || + di->batt_data.temp >= bi->temp_max) { /* TEMP major!!!!! */ di->events.btemp_underover = true; di->events.btemp_lowhigh = false; @@ -1722,7 +1724,7 @@ static int ab8500_chargalg_get_property(struct power_supply *psy, if (di->events.batt_ovv) { val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; } else if (di->events.btemp_underover) { - if (di->batt_data.temp <= di->bm->temp_under) + if (di->batt_data.temp <= di->bm->bi.temp_min) val->intval = POWER_SUPPLY_HEALTH_COLD; else val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; |