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

Commit 4e855797 authored by Jack Pham's avatar Jack Pham
Browse files

usb: dwc3: Remove toggling of HSPHY autosuspend



There have been issues related to having the GUSB2PHYCFG_SUSPHY bit
set which may cause problems with controller commands timing out in
both peripheral and host modes. Instead of working around this by
toggling it off and on as needed, simply disable it whenever the
controller is not in low power mode. The only place where it will be
set is just prior to entering suspend and cleared just after exiting.

This patch effectively reverts the following:
commit e1e8f22e "USB: dwc3: Clear USB2PHY_SUSP bit during disconnect"
commit 02b09d2b "USB: dwc3: msm: Fix stop endpoint command timeout issue"
commit 438c0416 "usb: dwc3: Add support to disable hsphy auto suspend
feature"

Change-Id: Iaa5274dbfaf2d3ab243e030f09510bdbad72616e
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 3511ae2a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ Optional properties:
	is used. By default, the half-full setting is used.
 - snps,core-reset-after-phy-init: If present, PHY reset and initialization is
   performed before core reset.
 - snps,hsphy-auto-suspend-disable: If present, auto suspend feature is not enabled with hsusb phy.
 - snps,ssphy-clear-auto-suspend-on-disconnect: If present, clear auto suspend feaure with ssusb phy
   during cable disconnect.
 - snps,usb3-u1u2-disable: If present, disable u1u2 low power modes for DWC3 core controller in SS mode.
+0 −7
Original line number Diff line number Diff line
@@ -108,11 +108,6 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
		reg |= DWC3_GUSB3PIPECTL_SUSPHY;
		dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
	}
	if (!dwc->hsphy_auto_suspend_disable) {
		reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
		reg |= DWC3_GUSB2PHYCFG_SUSPHY;
		dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
	}
}

/**
@@ -628,8 +623,6 @@ static int dwc3_probe(struct platform_device *pdev)

	dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
	host_only_mode = of_property_read_bool(node, "snps,host-only-mode");
	dwc->hsphy_auto_suspend_disable = of_property_read_bool(node,
						"snps,hsphy-auto-suspend-disable");
	dwc->ssphy_clear_auto_suspend_on_disconnect =
						of_property_read_bool(node,
						"snps,ssphy-clear-auto-suspend-on-disconnect");
+3 −1
Original line number Diff line number Diff line
@@ -890,7 +890,6 @@ struct dwc3 {
	bool			nominal_elastic_buffer;
	bool			core_reset_after_phy_init;
	bool			err_evt_seen;
	bool			hsphy_auto_suspend_disable;
	bool			ssphy_clear_auto_suspend_on_disconnect;
	bool			usb3_u1u2_disable;
	bool			enable_bus_suspend;
@@ -1071,6 +1070,7 @@ int dwc3_gadget_prepare(struct dwc3 *dwc);
void dwc3_gadget_complete(struct dwc3 *dwc);
int dwc3_gadget_suspend(struct dwc3 *dwc);
int dwc3_gadget_resume(struct dwc3 *dwc);
void dwc3_gadget_usb3_phy_suspend(struct dwc3 *dwc, int suspend);
#else
static inline int dwc3_gadget_prepare(struct dwc3 *dwc)
{
@@ -1090,6 +1090,8 @@ static inline int dwc3_gadget_resume(struct dwc3 *dwc)
{
	return 0;
}

static void dwc3_gadget_usb3_phy_suspend(struct dwc3 *dwc, int suspend) { }
#endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */

void dwc3_gadget_restart(struct dwc3 *dwc);
+0 −22
Original line number Diff line number Diff line
@@ -2742,27 +2742,6 @@ unreg_chrdev:
	return ret;
}

static int msm_dwc3_hsphy_autosuspend(struct usb_phy *x, struct device *dev,
				int enable_autosuspend)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dev->parent->parent);
	struct dwc3 *dwc = dev_get_drvdata(dev->parent);
	u32 reg;

	if (dwc->hsphy_auto_suspend_disable)
		return 0;

	reg = dwc3_msm_read_reg(mdwc->base, DWC3_GUSB2PHYCFG(0));
	if (enable_autosuspend)
		reg |= DWC3_GUSB2PHYCFG_SUSPHY;
	else
		reg &= ~(DWC3_GUSB2PHYCFG_SUSPHY);

	dwc3_msm_write_reg(mdwc->base, DWC3_GUSB2PHYCFG(0), reg);

	return 0;
}

static int dwc3_msm_probe(struct platform_device *pdev)
{
	struct device_node *node = pdev->dev.of_node, *dwc3_node;
@@ -3158,7 +3137,6 @@ static int dwc3_msm_probe(struct platform_device *pdev)
		ret = PTR_ERR(mdwc->hs_phy);
		goto put_dwc3;
	}
	mdwc->hs_phy->set_phy_autosuspend = msm_dwc3_hsphy_autosuspend;

	mdwc->ss_phy = devm_usb_get_phy_by_phandle(&mdwc->dwc3->dev,
							"usb-phy", 1);
+7 −39
Original line number Diff line number Diff line
@@ -75,38 +75,6 @@ static void dwc3_otg_set_host_regs(struct dwc3_otg *dotg)
	}
}

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

	if (dotg->dwc->hsphy_auto_suspend_disable)
		return;

	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);
}

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

	if (!dwc->ssphy_clear_auto_suspend_on_disconnect)
		return;

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

/**
 * dwc3_otg_set_host_power - Enable port power control for host operation
 *
@@ -207,6 +175,9 @@ static int dwc3_otg_start_host(struct usb_otg *otg, int on)
			return ret;
		}

		if (dwc->ssphy_clear_auto_suspend_on_disconnect)
			dwc3_gadget_usb3_phy_suspend(dwc, true);

		/*
		 * This should be revisited for more testing post-silicon.
		 * In worst case we may need to disconnect the root hub
@@ -217,8 +188,6 @@ 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_ssphy_auto_suspend(dotg, true);
		dwc3_otg_set_host_regs(dotg);
		/*
		 * FIXME If micro A cable is disconnected during system suspend,
@@ -267,8 +236,8 @@ 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_ssphy_auto_suspend(dotg, false);
		if (dwc->ssphy_clear_auto_suspend_on_disconnect)
			dwc3_gadget_usb3_phy_suspend(dwc, false);
		dwc3_otg_set_peripheral_regs(dotg);

		/* re-init core and OTG registers as block reset clears these */
@@ -340,7 +309,6 @@ 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 {
@@ -349,8 +317,8 @@ 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);
		dwc3_otg_set_ssphy_auto_suspend(dotg, false);
		if (dotg->dwc->ssphy_clear_auto_suspend_on_disconnect)
			dwc3_gadget_usb3_phy_suspend(dotg->dwc, false);
	}

	return 0;
Loading