summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubbaraman Narayanamurthy <subbaram@codeaurora.org>2016-10-04 17:08:42 -0700
committerSubbaraman Narayanamurthy <subbaram@codeaurora.org>2016-10-06 14:55:15 -0700
commit166e851cfda93ef05954816a04246b053955c472 (patch)
tree1a57a48c9cec511da99e4407edfdcc9caef96918
parent40af50ac19b45542698983089321ec4e28764496 (diff)
qpnp-smb2: smb-lib: add charge_done property
Currently, charging status is shown as full for both the charge termination and inhibit cases. However, there is a need to know when the charge termination really happens. Add charge_done property to qpnp-smb2 driver so that the clients can read that property to distinguish termination and inhibit. Change-Id: If2bd750af412adf1eea7b913caed9a3eb3b763db Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
-rw-r--r--drivers/power/qcom-charger/qpnp-smb2.c7
-rw-r--r--drivers/power/qcom-charger/smb-lib.c5
-rw-r--r--drivers/power/qcom-charger/smb-lib.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/drivers/power/qcom-charger/qpnp-smb2.c b/drivers/power/qcom-charger/qpnp-smb2.c
index 522c89d3bb67..8fa4fe301676 100644
--- a/drivers/power/qcom-charger/qpnp-smb2.c
+++ b/drivers/power/qcom-charger/qpnp-smb2.c
@@ -605,6 +605,7 @@ static enum power_supply_property smb2_batt_props[] = {
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED,
POWER_SUPPLY_PROP_STEP_CHARGING_STEP,
+ POWER_SUPPLY_PROP_CHARGE_DONE,
};
static int smb2_batt_get_prop(struct power_supply *psy,
@@ -662,6 +663,9 @@ static int smb2_batt_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_TECHNOLOGY:
val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
break;
+ case POWER_SUPPLY_PROP_CHARGE_DONE:
+ val->intval = chg->chg_done;
+ break;
default:
pr_err("batt power supply prop %d not supported\n", psp);
return -EINVAL;
@@ -692,6 +696,9 @@ static int smb2_batt_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CAPACITY:
rc = smblib_set_prop_batt_capacity(chg, val);
break;
+ case POWER_SUPPLY_PROP_CHARGE_DONE:
+ chg->chg_done = val->intval;
+ break;
default:
rc = -EINVAL;
}
diff --git a/drivers/power/qcom-charger/smb-lib.c b/drivers/power/qcom-charger/smb-lib.c
index 9d2ed3f454bb..a869fc592474 100644
--- a/drivers/power/qcom-charger/smb-lib.c
+++ b/drivers/power/qcom-charger/smb-lib.c
@@ -888,7 +888,6 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
u8 stat;
int rc;
-
rc = smblib_get_prop_usb_online(chg, &pval);
if (rc < 0) {
dev_err(chg->dev, "Couldn't get usb online property rc=%d\n",
@@ -1717,6 +1716,7 @@ static void smblib_pl_handle_chg_state_change(struct smb_charger *chg, u8 stat)
irqreturn_t smblib_handle_chg_state_change(int irq, void *data)
{
+ union power_supply_propval pval = {0, };
struct smb_irq_data *irq_data = data;
struct smb_charger *chg = irq_data->parent_data;
u8 stat;
@@ -1733,6 +1733,9 @@ irqreturn_t smblib_handle_chg_state_change(int irq, void *data)
stat = stat & BATTERY_CHARGER_STATUS_MASK;
smblib_pl_handle_chg_state_change(chg, stat);
+ pval.intval = (stat == TERMINATE_CHARGE);
+ power_supply_set_property(chg->batt_psy, POWER_SUPPLY_PROP_CHARGE_DONE,
+ &pval);
power_supply_changed(chg->batt_psy);
return IRQ_HANDLED;
}
diff --git a/drivers/power/qcom-charger/smb-lib.h b/drivers/power/qcom-charger/smb-lib.h
index f5d9dda8330a..1f2457e04ed6 100644
--- a/drivers/power/qcom-charger/smb-lib.h
+++ b/drivers/power/qcom-charger/smb-lib.h
@@ -163,6 +163,7 @@ struct smb_charger {
bool step_chg_enabled;
bool is_hdc;
+ bool chg_done;
/* workaround flag */
u32 wa_flags;