From 4e4f4dabfd08e2f1332e259b70023cdb322e87ec Mon Sep 17 00:00:00 2001 From: "choongryeol.lee" Date: Sat, 25 Aug 2012 00:15:42 -0700 Subject: [PATCH] power: pm8921: consideration of ibat max overwrite The thermal mitigation and battery temp control can overwrite the ibat max value each other. So this patch remove the possibility of overwrite ibat max value by mitigation and battery temp control. Change-Id: Ib0f7bf2b8bd2e474d1d9c76bd5100b05310cb048 --- drivers/power/pm8921-charger.c | 17 ++++++++++++++--- include/linux/mfd/pm8xxx/pm8921-charger.h | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) 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)