diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c index dedc7370b27..2360294ddfa 100644 --- a/drivers/power/pm8921-charger.c +++ b/drivers/power/pm8921-charger.c @@ -283,6 +283,7 @@ struct pm8921_chg_chip { bool host_mode; u8 active_path; int recent_reported_soc; + unsigned int ext_warm_i_limit; int ext_batt_health; int ext_batt_temp_monitor; }; @@ -1823,6 +1824,11 @@ int pm8921_set_max_battery_charge_current(int ma) pr_err("called before init\n"); return -EINVAL; } + + if (thermal_mitigation != 0 && the_chip->thermal_mitigation) + ma = min((unsigned int)ma, + the_chip->thermal_mitigation[thermal_mitigation]); + return pm_chg_ibatmax_set(the_chip, ma); } EXPORT_SYMBOL(pm8921_set_max_battery_charge_current); @@ -1990,16 +1996,18 @@ int set_wireless_power_supply_control(int value) EXPORT_SYMBOL(set_wireless_power_supply_control); #endif -int pm8921_set_ext_battery_health(int health) +int pm8921_set_ext_battery_health(int health, int i_limit) { if (!the_chip) { pr_err("called before init\n"); return -EINVAL; } - the_chip->ext_batt_health = health; + the_chip->ext_batt_health = health; + the_chip->ext_warm_i_limit = i_limit; - pr_debug("health = %d\n", the_chip->ext_batt_health); + pr_debug("health = %d i_decrease = %d\n", the_chip->ext_batt_health, + the_chip->ext_warm_i_limit); return 0; } EXPORT_SYMBOL(pm8921_set_ext_battery_health); @@ -3252,6 +3260,9 @@ static void set_appropriate_battery_current(struct pm8921_chg_chip *chip) if (chip->is_bat_warm) chg_current = min(chg_current, chip->warm_bat_chg_current); + if (chip->ext_warm_i_limit && chip->ext_batt_temp_monitor) + chg_current = min(chg_current, chip->ext_warm_i_limit); + if (thermal_mitigation != 0 && chip->thermal_mitigation) chg_current = min(chg_current, chip->thermal_mitigation[thermal_mitigation]); diff --git a/include/linux/mfd/pm8xxx/pm8921-charger.h b/include/linux/mfd/pm8xxx/pm8921-charger.h index 2e931b18471..f2b732d7d67 100644 --- a/include/linux/mfd/pm8xxx/pm8921-charger.h +++ b/include/linux/mfd/pm8xxx/pm8921-charger.h @@ -295,7 +295,7 @@ int pm8921_is_batfet_closed(void); int set_wireless_power_supply_control(int value); #endif -int pm8921_set_ext_battery_health(int health); +int pm8921_set_ext_battery_health(int health, int i_limit); #else static inline void pm8921_charger_vbus_draw(unsigned int mA)