summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorJack Pham <jackp@codeaurora.org>2016-05-23 11:15:15 -0700
committerKyle Yan <kyan@codeaurora.org>2016-05-26 15:27:09 -0700
commit3aff97c7a3edd1dfe51f3e0d24a4fc36197bfbe0 (patch)
treeef42854c2fa27ace27d981dd5b68b7ac6adbb7b8 /drivers/power
parent090978665c83f6e271556569c113b15e4f028d60 (diff)
qcom-charger: Don't automatically set USB_PD type when PD_ACTIVE=1
The POWER_SUPPLY_PROP_PD_ACTIVE property is intended to be a flag set whenever the PD PHY is in use. But this includes attempts to establish communication, which may involve trying to perform a hard reset to see if the port partner responds. Thus updating the psy_desc.type field to 'USB_PD' right when PD_ACTIVE=1 is premature as the port partner may not be PD-capable and it could be un-set. Instead allow the PD driver to directly update POWER_SUPPLY_PROP_TYPE only after it is sure PD communication has succeeded. Change-Id: Iae6804bcb3121e0852ec5d14d0939623b97a6e67 Signed-off-by: Jack Pham <jackp@codeaurora.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/qcom-charger/qpnp-smb2.c8
-rw-r--r--drivers/power/qcom-charger/smb-lib.c12
2 files changed, 11 insertions, 9 deletions
diff --git a/drivers/power/qcom-charger/qpnp-smb2.c b/drivers/power/qcom-charger/qpnp-smb2.c
index 7d5b03b654cf..ab4ab0c31e08 100644
--- a/drivers/power/qcom-charger/qpnp-smb2.c
+++ b/drivers/power/qcom-charger/qpnp-smb2.c
@@ -209,6 +209,14 @@ static int smb2_usb_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CURRENT_MAX:
rc = smblib_set_prop_usb_current_max(chg, val);
break;
+ case POWER_SUPPLY_PROP_TYPE:
+ if (chg->pd_active && val->intval == POWER_SUPPLY_TYPE_USB_PD) {
+ chg->usb_psy_desc.type = val->intval;
+ } else {
+ pr_err("set type %d not allowed\n", val->intval);
+ rc = -EINVAL;
+ }
+ break;
case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
rc = smblib_set_prop_typec_power_role(chg, val);
break;
diff --git a/drivers/power/qcom-charger/smb-lib.c b/drivers/power/qcom-charger/smb-lib.c
index 1e66507f013b..ebbc8e15f2b8 100644
--- a/drivers/power/qcom-charger/smb-lib.c
+++ b/drivers/power/qcom-charger/smb-lib.c
@@ -256,10 +256,9 @@ static int smblib_update_usb_type(struct smb_charger *chg)
int rc = 0;
const struct apsd_result *apsd_result;
- if (chg->pd_active) {
- chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_USB_PD;
+ /* if PD is active, APSD is disabled so won't have a valid result */
+ if (chg->pd_active)
return rc;
- }
apsd_result = smblib_get_apsd_result(chg);
chg->usb_psy_desc.type = apsd_result->pst;
@@ -271,12 +270,7 @@ static int smblib_detach_usb(struct smb_charger *chg)
int rc;
cancel_delayed_work_sync(&chg->hvdcp_detect_work);
-
- rc = smblib_update_usb_type(chg);
- if (rc < 0) {
- dev_err(chg->dev, "Couldn't update usb type rc=%d\n", rc);
- return rc;
- }
+ chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN;
/* reconfigure allowed voltage for HVDCP */
rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG,