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

Commit d6a59d03 authored by Pratham Pratap's avatar Pratham Pratap Committed by Gerrit - the friendly Code Review server
Browse files

usb: dwc3-msm: Fix float cable detection



In case of float cable connected charger driver expects
-ETIMEOUT from USB driver. If suspend happens before detection
timeout then dwc3 driver notifies current as 2mA and charger
driver marks psy_type as USB instead of FLOAT even if float
cable is connected. To fix this do not notify charger driver
for any current if float cable is connected and suspend happened.

Change-Id: I6d5ad3dcd9c9ba02c3f56cad61fac38aae3abab2
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent 8ca6d749
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -4259,6 +4259,14 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA)

	psy_type = get_psy_type(mdwc);
	if (psy_type == POWER_SUPPLY_TYPE_USB_FLOAT) {
		/*
		 * Do not notify charger driver for any current and
		 * bail out if suspend happened with float cable
		 * connected
		 */
		if (mA == 2)
			return 0;

		if (!mA)
			pval.intval = -ETIMEDOUT;
		else
@@ -4269,11 +4277,11 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA)
	if (mdwc->max_power == mA || psy_type != 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;

set_prop:
	dev_info(mdwc->dev, "Avail curr from USB = %u\n", mA);
	ret = power_supply_set_property(mdwc->usb_psy,
				POWER_SUPPLY_PROP_SDP_CURRENT_MAX, &pval);
	if (ret) {