Battery: Fix for reporting charger health DEAD when VBUS is low
authorGurumurthy Gowdar <gurumurthyx.gowdar@intel.com>
Thu, 8 Mar 2012 17:57:00 +0000 (23:27 +0530)
committerbuildbot <buildbot@intel.com>
Tue, 13 Mar 2012 13:11:27 +0000 (06:11 -0700)
BZ: 22487

This patch reports charger health as DEAD,when VBUS voltage is low
connected through DCP using external power supply

Change-Id: I4e8039fad2ecc6716d83d303a4baa091eb89d0b3
Signed-off-by: Gurumurthy Gowdar <gurumurthyx.gowdar@intel.com>
Reviewed-on: http://android.intel.com:8080/37981
Reviewed-by: Tc, Jenny <jenny.tc@intel.com>
Reviewed-by: Kuppuswamy, Sathyanarayanan <sathyanarayanan.kuppuswamy@intel.com>
Reviewed-by: Jena, TapanX <tapanx.jena@intel.com>
Tested-by: Gugwad, SantoshX <santoshx.gugwad@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/power/intel_mdf_battery.c

index b3a9b4e..27f1b71 100644 (file)
@@ -1486,6 +1486,7 @@ static void msic_batt_temp_charging(struct work_struct *work)
        static int iprev = -1, is_chrg_enbl;
        short int cv = 0, cc = 0, vinlimit = 0, cvref;
        int adc_temp, adc_vol;
+       int vbus_voltage;
        struct charge_params charge_param;
        struct msic_power_module_info *mbi =
            container_of(work, struct msic_power_module_info,
@@ -1520,10 +1521,19 @@ static void msic_batt_temp_charging(struct work_struct *work)
        /* get charger status */
        is_chrg_flt = is_charger_fault();
 
+       if (mdf_read_adc_regs(MSIC_ADC_USB_VOL_IDX, &vbus_voltage, mbi)) {
+               dev_warn(msic_dev, "Error in reading charger"
+                                       " voltage:%s\n", __func__);
+               goto lbl_sched_work;
+       }
+
        /* change to fix buffer overflow issue */
        if (i >= ((sfi_table->temp_mon_ranges < SFI_TEMP_NR_RNG) ?
                        sfi_table->temp_mon_ranges : SFI_TEMP_NR_RNG) ||
-                                                       is_chrg_flt) {
+                                                       is_chrg_flt ||
+                               vbus_voltage < WEAKVIN_VOLTAGE_LEVEL) {
+
+
                if ((adc_temp > batt_thrshlds->temp_high) ||
                        (adc_temp < batt_thrshlds->temp_low)) {
                        dev_warn(msic_dev,
@@ -1540,6 +1550,14 @@ static void msic_batt_temp_charging(struct work_struct *work)
                                        POWER_SUPPLY_STATUS_NOT_CHARGING;
                        mutex_unlock(&mbi->batt_lock);
                }
+
+               if (vbus_voltage < WEAKVIN_VOLTAGE_LEVEL) {
+                       mutex_lock(&mbi->usb_chrg_lock);
+                               mbi->usb_chrg_props.charger_health =
+                                               POWER_SUPPLY_HEALTH_DEAD;
+                       mutex_unlock(&mbi->usb_chrg_lock);
+               }
+
                dump_registers(MSIC_CHRG_REG_DUMP_EVENT);
                /*
                 * If we are in middle of charge cycle is safer to Reset WDT