From 3fcbb078c8bf287e901ddf367e78dced4e1fdcb1 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Thu, 6 Jul 2017 17:03:00 -0700 Subject: qpnp-smb2: Ignore status 7 register while qnovo is enabled status7 register will indicate all the charger bits are cleared during the rest or discharge phase of a Qnovo pulse. Moreover those bits remain cleared after a pulse train is done and before a new pulse train is issued. Hence when Qnovo is active ignore status 7 register bits. Change-Id: Ice61f8a49625081ffbf1aacaac844b929715e818 Signed-off-by: Abhijeet Dharmapurikar --- drivers/power/supply/qcom/smb-lib.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c index ab6ba03e3556..227edd76c632 100644 --- a/drivers/power/supply/qcom/smb-lib.c +++ b/drivers/power/supply/qcom/smb-lib.c @@ -1551,8 +1551,8 @@ 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; + bool usb_online, dc_online, qnovo_en; + u8 stat, pt_en_cmd; int rc; rc = smblib_get_prop_usb_online(chg, &pval); @@ -1620,11 +1620,22 @@ int smblib_get_prop_batt_status(struct smb_charger *chg, smblib_err(chg, "Couldn't read BATTERY_CHARGER_STATUS_2 rc=%d\n", rc); return rc; - } + } stat &= ENABLE_TRICKLE_BIT | ENABLE_PRE_CHARGING_BIT | ENABLE_FAST_CHARGING_BIT | ENABLE_FULLON_MODE_BIT; - if (!stat) + + rc = smblib_read(chg, QNOVO_PT_ENABLE_CMD_REG, &pt_en_cmd); + if (rc < 0) { + smblib_err(chg, "Couldn't read QNOVO_PT_ENABLE_CMD_REG rc=%d\n", + rc); + return rc; + } + + qnovo_en = (bool)(pt_en_cmd & QNOVO_PT_ENABLE_CMD_BIT); + + /* ignore stat7 when qnovo is enabled */ + if (!qnovo_en && !stat) val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; return 0; -- cgit v1.2.3