summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijeet Dharmapurikar <adharmap@codeaurora.org>2017-01-17 20:00:08 -0800
committerVic Wei <vwei@codeaurora.org>2017-01-23 16:21:02 -0800
commit7cbc0c21593a58a80a24de40752007f97576804e (patch)
treec7fd0b740b9732ae3a8d690075ffcaf0047efde5
parent1f1d94408446043289fe0126897f98af2dce0ecd (diff)
smb-lib: report discharging when charger is absent
Currently, the code reports whatever is in the BATTERY_CHARGING_STATUS_1 register for the battery status. We have seen that the register continues to report FAST charging even when the chg_ok pin could be low or dc path is in collapsed state (collapsed state is treated as dc not online). This unexpected report of charging while it is not really charging breaks certain features. Fix it by checking for usb_online and dc_online. But make sure that if the battery is full it continues to report so. Change-Id: I732c916b4f63f9ff0fd8d9c77ce5253c309698a4 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
-rw-r--r--drivers/power/supply/qcom/smb-lib.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c
index d3f7e43ea10e..28387a180118 100644
--- a/drivers/power/supply/qcom/smb-lib.c
+++ b/drivers/power/supply/qcom/smb-lib.c
@@ -1329,17 +1329,48 @@ int smblib_get_prop_batt_capacity(struct smb_charger *chg,
int smblib_get_prop_batt_status(struct smb_charger *chg,
union power_supply_propval *val)
{
+ union power_supply_propval pval = {0, };
+ bool usb_online, dc_online;
u8 stat;
int rc;
+ rc = smblib_get_prop_usb_online(chg, &pval);
+ if (rc < 0) {
+ smblib_err(chg, "Couldn't get usb online property rc=%d\n",
+ rc);
+ return rc;
+ }
+ usb_online = (bool)pval.intval;
+
+ rc = smblib_get_prop_dc_online(chg, &pval);
+ if (rc < 0) {
+ smblib_err(chg, "Couldn't get dc online property rc=%d\n",
+ rc);
+ return rc;
+ }
+ dc_online = (bool)pval.intval;
+
rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
if (rc < 0) {
smblib_err(chg, "Couldn't read BATTERY_CHARGER_STATUS_1 rc=%d\n",
rc);
return rc;
}
-
stat = stat & BATTERY_CHARGER_STATUS_MASK;
+
+ if (!usb_online && !dc_online) {
+ switch (stat) {
+ case TERMINATE_CHARGE:
+ case INHIBIT_CHARGE:
+ val->intval = POWER_SUPPLY_STATUS_FULL;
+ break;
+ default:
+ val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+ break;
+ }
+ return rc;
+ }
+
switch (stat) {
case TRICKLE_CHARGE:
case PRE_CHARGE: