aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamakrishna Pallala <ramakrishna.pallala@intel.com>2010-12-09 10:41:39 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-09 10:41:39 +0000
commit6f538dea85eed5328cc88ff483b772628a23f28d (patch)
treed9b556ce328ec1f04a788254a198763469805d8b
parent58ae8bb283431899ee36660838c073fe14439da4 (diff)
downloadmrst-s0i3-test-6f538dea85eed5328cc88ff483b772628a23f28d.tar.gz
mrst-s0i3-test-6f538dea85eed5328cc88ff483b772628a23f28d.tar.xz
mrst-s0i3-test-6f538dea85eed5328cc88ff483b772628a23f28d.zip
Emergency Call Charging Fix
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Alan Cox <alan@linux.intel.com>
-rw-r--r--drivers/power/intel_mdf_battery.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/power/intel_mdf_battery.c b/drivers/power/intel_mdf_battery.c
index 7a24eebcfaa..d08cd035000 100644
--- a/drivers/power/intel_mdf_battery.c
+++ b/drivers/power/intel_mdf_battery.c
@@ -466,6 +466,7 @@ struct msic_power_module_info {
int batt_event;
int charging_mode;
int emrg_chrg_enbl; /* Emergency call charge enable */
+ int refresh_charger; /* Refresh charger parameters */
/* Worker to monitor status and faluts */
struct delayed_work chr_status_monitor;
@@ -994,7 +995,7 @@ static unsigned int chrg_to_vol_lookup(unsigned int chrg)
return 0;
}
- if (chrg == dischargeCurve[i][1])
+ if ((i == 0) || (chrg == dischargeCurve[i][1]))
return dischargeCurve[i][0];
/* Linear approximation of the charge to voltage */
@@ -1218,8 +1219,14 @@ static ssize_t set_emrg_chrg(struct device *dev,
mbi->emrg_chrg_enbl = true;
else
mbi->emrg_chrg_enbl = false;
+ mbi->refresh_charger = 1;
spin_unlock(&mbi->event_lock);
+ /* As the emrgency charging state is changed
+ * execute the worker as early as possible
+ * if the worker is pending on timer.
+ */
+ flush_delayed_work(&mbi->connect_handler);
return count;
}
static ssize_t get_emrg_chrg(struct device *dev,
@@ -1710,20 +1717,18 @@ static void msic_batt_temp_charging(struct work_struct *work)
charge_param.vinilmt = mbi->ch_params.vinilmt;
charge_param.chrg_type = mbi->ch_params.chrg_type;
- mutex_lock(&mbi->usb_chrg_lock);
- if (mbi->usb_chrg_props.charger_type ==
- POWER_SUPPLY_CHARGE_TYPE_UNKNOWN ||
- mbi->usb_chrg_props.charger_type ==
- POWER_SUPPLY_CHARGE_TYPE_NONE) {
+ spin_lock(&mbi->event_lock);
+ if (mbi->refresh_charger) {
/*
* If the the charger type is unknown or None
* better start the charging again and compute
* the properties again.
*/
+ mbi->refresh_charger = 0;
iprev = -1;
is_chrg_enbl = false;
}
- mutex_unlock(&mbi->usb_chrg_lock);
+ spin_unlock(&mbi->event_lock);
ret = mdf_read_adc_regs(MSIC_ADC_TEMP_IDX, mbi);
/* mdf_read_adc_regs returns in milli Centigrade */
@@ -1936,13 +1941,13 @@ static int msic_charger_callback(void *arg, int event, struct otg_bc_cap *cap)
mbi->ch_params.chrg_type = cap->chrg_type;
dev_dbg(msic_dev, "CHRG TYPE:%d %d\n",
cap->chrg_type, cap->mA);
-
- schedule_delayed_work(&mbi->connect_handler, 0);
-
spin_lock(&mbi->event_lock);
- mbi->charging_mode = BATT_CHARGING_MODE_NORMAL;
+ mbi->refresh_charger = 1;
+ if (mbi->charging_mode == BATT_CHARGING_MODE_NONE)
+ mbi->charging_mode = BATT_CHARGING_MODE_NORMAL;
spin_unlock(&mbi->event_lock);
+ schedule_delayed_work(&mbi->connect_handler, 0);
break;
case USBCHRG_EVENT_DISCONN:
case USBCHRG_EVENT_SUSPEND:
@@ -1951,6 +1956,7 @@ static int msic_charger_callback(void *arg, int event, struct otg_bc_cap *cap)
schedule_delayed_work(&mbi->disconn_handler, 0);
spin_lock(&mbi->event_lock);
+ mbi->refresh_charger = 0;
mbi->charging_mode = BATT_CHARGING_MODE_NONE;
spin_unlock(&mbi->event_lock);
if (!pm_runtime_suspended(&mbi->pdev->dev))