Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8caff358 authored by Jack Pham's avatar Jack Pham Committed by Mayank Rana
Browse files

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: default avatarJack Pham <jackp@codeaurora.org>
parent 633dc339
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -3154,7 +3154,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 int mA)
{
	union power_supply_propval pval = {1000 * mA};
	union power_supply_propval pval = {0};
	int ret;

	if (mdwc->charging_disabled)
@@ -3171,9 +3171,14 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int 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) {