power: max77665: pass CHGIN_ILIM to update_status
Sivaram Nair [Mon, 14 Jan 2013 14:11:39 +0000 (16:11 +0200)]
This is a WAR for problems mentioned in the bug report (see below).
Instead of passing true, the charging limit (a non-zero) value is passed
into the update_status callback function. This will be exploited by the
fuel guage driver in order to calculate the battery depletion values.

Bug 1214607

Change-Id: I16bdcd99aafd1e03d0377cb6849352dbaa1e2ad9
Signed-off-by: Sivaram Nair <sivaramn@nvidia.com>
(cherry picked from commit bf9d20d92ae4c2b5c4796260bc34901f4f5e9cb1)
Reviewed-on: http://git-master/r/191636
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

drivers/power/max77665-charger.c

index 6270fc1..52331b4 100644 (file)
@@ -302,6 +302,14 @@ error:
 static int max77665_enable_charger(struct max77665_charger *charger)
 {
        int ret = 0;
+       uint32_t val = 0;
+       int ilim;
+
+       ret = max77665_read_reg(charger, MAX77665_CHG_CNFG_09, &val);
+       if (ret)
+               goto error;
+       val &= 0x7F;
+       ilim = max_t(int, 60, val * 20);
 
        if (charger->plat_data->update_status)
                        charger->plat_data->update_status(false);
@@ -316,7 +324,7 @@ static int max77665_enable_charger(struct max77665_charger *charger)
                power_supply_changed(&charger->usb);
                charger->plat_data->curr_lim = 500;
                if (charger->plat_data->update_status)
-                       charger->plat_data->update_status(true);
+                       charger->plat_data->update_status(ilim);
        }
 
        if (extcon_get_cable_state(charger->edev, "USB-Host")) {
@@ -333,7 +341,7 @@ static int max77665_enable_charger(struct max77665_charger *charger)
                charger->ac_online = 1;
                power_supply_changed(&charger->ac);
                if (charger->plat_data->update_status)
-                       charger->plat_data->update_status(true);
+                       charger->plat_data->update_status(ilim);
        }
 
        ret = max77665_charger_init(charger);