From 7a50869d709ce4fdf99a191c4464c855cb80c2ab Mon Sep 17 00:00:00 2001 From: Ramakrishna Pallala Date: Fri, 6 Jan 2012 04:15:32 +0530 Subject: [PATCH] [PORT FROM R2]Battery: limit input current in case of vbus regulation interrupt BZ: 18115 This patch limits the input current to 500mA in case vbus input voltgae regulation interrupt. Change-Id: I2020bb16a9f437c3050da67242ca11ff5f425a52 Signed-off-by: Ramakrishna Pallala Reviewed-on: http://android.intel.com:8080/32755 Reviewed-by: Mendi, EduardoX Tested-by: Mendi, EduardoX Reviewed-by: buildbot Tested-by: buildbot --- drivers/power/intel_mdf_battery.c | 19 +++++++++++++++++-- drivers/power/intel_mdf_charger.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/power/intel_mdf_battery.c b/drivers/power/intel_mdf_battery.c index 205cea1..f212dd1 100644 --- a/drivers/power/intel_mdf_battery.c +++ b/drivers/power/intel_mdf_battery.c @@ -1010,12 +1010,19 @@ static void msic_handle_exception(struct msic_power_module_info *mbi, exception = MSIC_EVENT_WEAKVIN_EXCPT; msic_log_exception_event(exception); } + mutex_unlock(&mbi->usb_chrg_lock); + + mutex_lock(&mbi->event_lock); if (CHRINT1_reg_value & MSIC_BATT_CHR_VINREGMINT_MASK) { - mbi->usb_chrg_props.charger_health = POWER_SUPPLY_HEALTH_DEAD; + /* change input current limit to 500mA + * to recover from VINREG condition + */ + mbi->in_cur_lmt = CHRCNTL_VINLMT_500; + mbi->refresh_charger = 1; exception = MSIC_EVENT_USB_VINREG_EXCPT; msic_log_exception_event(exception); } - mutex_unlock(&mbi->usb_chrg_lock); + mutex_unlock(&mbi->event_lock); } /** @@ -1547,6 +1554,12 @@ static void msic_batt_temp_charging(struct work_struct *work) else vinlimit = CHRCNTL_VINLMT_100; } + + /* input current limit can be changed + * due to VINREG or weakVIN conditions + */ + if (mbi->in_cur_lmt < vinlimit) + vinlimit = mbi->in_cur_lmt; /* * Check for Charge full condition and set the battery * properties accordingly. Also check for charging mode @@ -1904,6 +1917,7 @@ static int msic_event_handler(void *arg, int event, struct otg_bc_cap *cap) */ cancel_delayed_work_sync(&mbi->connect_handler); mbi->ch_params.vinilmt = cap->mA; + mbi->in_cur_lmt = CHRCNTL_VINLMT_NOLMT; mbi->ch_params.chrg_type = cap->chrg_type; dev_dbg(msic_dev, "CHRG TYPE:%d %d\n", cap->chrg_type, cap->mA); mutex_lock(&mbi->event_lock); @@ -2395,6 +2409,7 @@ static void init_batt_props(struct msic_power_module_info *mbi) mbi->batt_event = USBCHRG_EVENT_DISCONN; mbi->charging_mode = BATT_CHARGING_MODE_NONE; mbi->usr_chrg_enbl = USER_SET_CHRG_NOLMT; + mbi->in_cur_lmt = CHRCNTL_VINLMT_NOLMT; mbi->batt_props.status = POWER_SUPPLY_STATUS_DISCHARGING; mbi->batt_props.health = POWER_SUPPLY_HEALTH_GOOD; diff --git a/drivers/power/intel_mdf_charger.h b/drivers/power/intel_mdf_charger.h index 4165dff..133c55f 100644 --- a/drivers/power/intel_mdf_charger.h +++ b/drivers/power/intel_mdf_charger.h @@ -481,5 +481,6 @@ struct msic_power_module_info { /* interrupt masks*/ uint8_t chrint_mask, chrint1_mask; + int in_cur_lmt; /* input current limit level */ }; #endif -- 2.7.4