summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorJack Pham <jackp@codeaurora.org>2016-08-19 16:33:55 -0700
committerJack Pham <jackp@codeaurora.org>2016-08-19 16:55:05 -0700
commitffedac17171fd35396bfdf76447cbe68da62ac14 (patch)
tree0ec71083a50f6a9d2cdeade5674bcd15ac24b481 /drivers/usb
parent0c8cf716fa02d0f6b6ef2ef1446f9f4819fc83dd (diff)
usb: dwc3-msm: Only set vbus_draw for SDP type
When gadget driver sets VBUS current draw, this should only be applicable if the charger type is SDP. For other downstream types, such as CDP, it can draw up up to the maximum (1.5A) without having to follow the rules of configured/suspended current limits. Further, with Power Delivery role swap supported, it's possible the gadget (UFP) is a power source, so vbus_draw() should be no-op'ed. Change-Id: If7f8233a0eb2644e5534a51a4a4f65212d448382 Signed-off-by: Jack Pham <jackp@codeaurora.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/dwc3/dwc3-msm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index 37a3c954a1dd..650761cfd49d 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -3191,7 +3191,7 @@ static int dwc3_otg_start_peripheral(struct dwc3_msm *mdwc, int on)
static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned mA)
{
- union power_supply_propval pval = {1000 * mA};
+ union power_supply_propval pval = {0};
int ret;
if (mdwc->charging_disabled)
@@ -3208,9 +3208,14 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned mA)
}
}
+ power_supply_get_property(mdwc->usb_psy, POWER_SUPPLY_PROP_TYPE, &pval);
+ if (pval.intval != POWER_SUPPLY_TYPE_USB)
+ return 0;
+
dev_info(mdwc->dev, "Avail curr from USB = %u\n", mA);
/* Set max current limit in uA */
+ pval.intval = 1000 * mA;
ret = power_supply_set_property(mdwc->usb_psy,
POWER_SUPPLY_PROP_CURRENT_MAX, &pval);
if (ret) {