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

Commit e1e8f22e authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa
Browse files

USB: dwc3: Clear USB2PHY_SUSP bit during disconnect



Currently GUSB2PHY_SUSP bit is set in GUSB2PHYCFG(0) register
as part of initialization sequence and not clearing that bit
after that. If this bit is set during charger detection, it is
causing issues with VDP_SRC and IDM_SINK like VDP_SRC is not getting
applied within time, IDM_SINK is not large enough, due to which
battery charging complaince tests are failing with complaince test
device. Hence set this bit during peripheral/host start and clear
the bit while stopping peripheral/host role.

Also reduce the debouncing delay which should be in range [0-120]msec
for VBUS. Otherwise seeing battery charging complaince tests fail
due to bigger delay.

CRs-Fixed: 543926
Change-Id: I9ea87a19b43ce7804748dd3735ac436f77cdf933
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent a2f5ccad
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1897,8 +1897,12 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy,
		if (mdwc->otg_xceiv && !mdwc->ext_inuse &&
		    (mdwc->ext_xceiv.otg_capability || !init)) {
			mdwc->ext_xceiv.bsv = val->intval;
			/*
			 * Set debouncing delay to 120ms. Otherwise battery
			 * charging CDP complaince test fails if delay > 120ms.
			 */
			queue_delayed_work(system_nrt_wq,
							&mdwc->resume_work, 20);
							&mdwc->resume_work, 12);

			if (!init)
				init = true;
+17 −0
Original line number Diff line number Diff line
@@ -96,6 +96,19 @@ static int dwc3_otg_set_suspend(struct usb_phy *phy, int suspend)
	return 0;
}

static void dwc3_otg_set_hsphy_auto_suspend(struct dwc3_otg *dotg, bool susp)
{
	struct dwc3 *dwc = dotg->dwc;
	u32 reg;

	reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
	if (susp)
		reg |= DWC3_GUSB2PHYCFG_SUSPHY;
	else
		reg &= ~(DWC3_GUSB2PHYCFG_SUSPHY);
	dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
}

/**
 * dwc3_otg_set_host_power - Enable port power control for host operation
 *
@@ -197,6 +210,7 @@ static int dwc3_otg_start_host(struct usb_otg *otg, int on)
		 * remove_hcd, But we may not use standard set_host method
		 * anymore.
		 */
		dwc3_otg_set_hsphy_auto_suspend(dotg, true);
		dwc3_otg_set_host_regs(dotg);
		/*
		 * FIXME If micro A cable is disconnected during system suspend,
@@ -245,6 +259,7 @@ static int dwc3_otg_start_host(struct usb_otg *otg, int on)
						ext_xceiv->ext_block_reset)
			ext_xceiv->ext_block_reset(ext_xceiv, true);

		dwc3_otg_set_hsphy_auto_suspend(dotg, false);
		dwc3_otg_set_peripheral_regs(dotg);

		/* re-init core and OTG registers as block reset clears these */
@@ -315,6 +330,7 @@ static int dwc3_otg_start_peripheral(struct usb_otg *otg, int on)
						ext_xceiv->ext_block_reset)
			ext_xceiv->ext_block_reset(ext_xceiv, false);

		dwc3_otg_set_hsphy_auto_suspend(dotg, true);
		dwc3_otg_set_peripheral_regs(dotg);
		usb_gadget_vbus_connect(otg->gadget);
	} else {
@@ -323,6 +339,7 @@ static int dwc3_otg_start_peripheral(struct usb_otg *otg, int on)
		usb_gadget_vbus_disconnect(otg->gadget);
		usb_phy_notify_disconnect(dotg->dwc->usb2_phy, USB_SPEED_HIGH);
		usb_phy_notify_disconnect(dotg->dwc->usb3_phy, USB_SPEED_SUPER);
		dwc3_otg_set_hsphy_auto_suspend(dotg, false);
	}

	return 0;
+5 −1
Original line number Diff line number Diff line
@@ -3099,7 +3099,11 @@ int dwc3_gadget_init(struct dwc3 *dwc)

	/* Enable USB2 LPM and automatic phy suspend only on recent versions */
	if (dwc->revision >= DWC3_REVISION_194A) {
		dwc3_gadget_usb2_phy_suspend(dwc, true);
		/*
		 * Clear autosuspend bit in dwc3 register for USB2. It will be
		 * enabled before setting run/stop bit.
		 */
		dwc3_gadget_usb2_phy_suspend(dwc, false);
		dwc3_gadget_usb3_phy_suspend(dwc, true);
	}