summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Yang <harryy@codeaurora.org>2016-02-26 10:08:13 -0800
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-25 16:02:32 -0700
commitfe96617b875d6d0d52be41133ae46222e4e85f61 (patch)
tree0290a40bf0a96092936a23172f201d622dff1aa1
parentc35b73cf03157f8de4d6681d43abe9c3fdfbc906 (diff)
power: qpnp-smbcharger: return UNKNOWN in case of no charger present
POWER_SUPPLY_TYPE_USB_DCP type is returned in read_usb_type() if no charger is connected, which might cause APSD to unnecessarily rerun. To fix it, POWER_SUPPLY_TYPE_UNKNOWN should be returned instead. A bug is also fixed by returning right after IDEV_STS register read error in this function . CRs-fixed: 963745 Change-Id: Ia399e05fe8d0ad13c2f1f272c6737e8798177174 Signed-off-by: Harry Yang <harryy@codeaurora.org>
-rw-r--r--drivers/power/qpnp-smbcharger.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/power/qpnp-smbcharger.c b/drivers/power/qpnp-smbcharger.c
index 500838dadaa3..fbb163908c03 100644
--- a/drivers/power/qpnp-smbcharger.c
+++ b/drivers/power/qpnp-smbcharger.c
@@ -845,17 +845,38 @@ static inline enum power_supply_type get_usb_supply_type(int type)
return usb_type_enum[type];
}
+static bool is_src_detect_high(struct smbchg_chip *chip)
+{
+ int rc;
+ u8 reg;
+
+ rc = smbchg_read(chip, &reg, chip->usb_chgpth_base + RT_STS, 1);
+ if (rc < 0) {
+ dev_err(chip->dev, "Couldn't read usb rt status rc = %d\n", rc);
+ return false;
+ }
+ return reg &= USBIN_SRC_DET_BIT;
+}
+
static void read_usb_type(struct smbchg_chip *chip, char **usb_type_name,
enum power_supply_type *usb_supply_type)
{
int rc, type;
u8 reg;
+ if (!is_src_detect_high(chip)) {
+ pr_smb(PR_MISC, "src det low\n");
+ *usb_type_name = "Absent";
+ *usb_supply_type = POWER_SUPPLY_TYPE_UNKNOWN;
+ return;
+ }
+
rc = smbchg_read(chip, &reg, chip->misc_base + IDEV_STS, 1);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read status 5 rc = %d\n", rc);
*usb_type_name = "Other";
*usb_supply_type = POWER_SUPPLY_TYPE_UNKNOWN;
+ return;
}
type = get_type(reg);
*usb_type_name = get_usb_type_name(type);
@@ -4552,19 +4573,6 @@ static void handle_usb_removal(struct smbchg_chip *chip)
restore_from_hvdcp_detection(chip);
}
-static bool is_src_detect_high(struct smbchg_chip *chip)
-{
- int rc;
- u8 reg;
-
- rc = smbchg_read(chip, &reg, chip->usb_chgpth_base + RT_STS, 1);
- if (rc < 0) {
- dev_err(chip->dev, "Couldn't read usb rt status rc = %d\n", rc);
- return false;
- }
- return reg &= USBIN_SRC_DET_BIT;
-}
-
static bool is_usbin_uv_high(struct smbchg_chip *chip)
{
int rc;