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

Commit c865ae26 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3-msm: Do not powerdown SSPHY if auto suspend is disabled"

parents 42270f30 bebc6b63
Loading
Loading
Loading
Loading
+74 −1
Original line number Diff line number Diff line
@@ -232,6 +232,13 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
		return ret;
	}

	ret = usb_phy_init(dwc->usb2_phy1);
	if (ret) {
		pr_err("%s: usb_phy_init(dwc->usb2_phy1) returned %d\n",
				__func__, ret);
		return ret;
	}

	if (dwc->maximum_speed >= USB_SPEED_SUPER) {
		ret = usb_phy_init(dwc->usb3_phy);
		if (ret == -EBUSY) {
@@ -245,6 +252,19 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
					__func__, ret);
			return ret;
		}

		ret = usb_phy_init(dwc->usb3_phy1);
		if (ret == -EBUSY) {
			/*
			 * Setting Max speed as high when USB3 PHY initialiation
			 * is failing and USB superspeed can't be supported.
			 */
			dwc->maximum_speed = USB_SPEED_HIGH;
		} else if (ret) {
			pr_err("%s: usb_phy_init(dwc->usb3_phy1) returned %d\n",
					__func__, ret);
			return ret;
		}
	}

	ret = phy_init(dwc->usb2_generic_phy);
@@ -593,6 +613,10 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
	u32 reg;

	reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
	if (dwc->dual_port) {
		if (reg != dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(1)))
			dev_warn(dwc->dev, "Reset values of pipectl registers are different!\n");
	}

	/*
	 * Make sure UX_EXIT_PX is cleared as that causes issues with some
@@ -644,8 +668,14 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
			DWC3_GUSB3PIPECTL_P3EXSIGP2);

	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
	if (dwc->dual_port)
		dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(1), reg);

	reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
	if (dwc->dual_port) {
		if (reg != dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(1)))
			dev_warn(dwc->dev, "Reset values of usb2phycfg registers are different!\n");
	}

	/* Select the HS PHY interface */
	switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
@@ -708,6 +738,8 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
		reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;

	dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
	if (dwc->dual_port)
		dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(1), reg);

	return 0;
}
@@ -716,12 +748,16 @@ static void dwc3_core_exit(struct dwc3 *dwc)
{
	dwc3_event_buffers_cleanup(dwc);

	usb_phy_shutdown(dwc->usb2_phy1);
	usb_phy_shutdown(dwc->usb2_phy);
	usb_phy_shutdown(dwc->usb3_phy1);
	usb_phy_shutdown(dwc->usb3_phy);
	phy_exit(dwc->usb2_generic_phy);
	phy_exit(dwc->usb3_generic_phy);

	usb_phy_set_suspend(dwc->usb2_phy1, 1);
	usb_phy_set_suspend(dwc->usb2_phy, 1);
	usb_phy_set_suspend(dwc->usb3_phy1, 1);
	usb_phy_set_suspend(dwc->usb3_phy, 1);
	phy_power_off(dwc->usb2_generic_phy);
	phy_power_off(dwc->usb3_generic_phy);
@@ -995,8 +1031,11 @@ int dwc3_core_init(struct dwc3 *dwc)
	dwc3_set_incr_burst_type(dwc);

	usb_phy_set_suspend(dwc->usb2_phy, 0);
	if (dwc->maximum_speed >= USB_SPEED_SUPER)
	usb_phy_set_suspend(dwc->usb2_phy1, 0);
	if (dwc->maximum_speed >= USB_SPEED_SUPER) {
		usb_phy_set_suspend(dwc->usb3_phy, 0);
		usb_phy_set_suspend(dwc->usb3_phy1, 0);
	}

	ret = phy_power_on(dwc->usb2_generic_phy);
	if (ret < 0)
@@ -1125,11 +1164,15 @@ int dwc3_core_init(struct dwc3 *dwc)
	phy_power_off(dwc->usb2_generic_phy);

err2:
	usb_phy_set_suspend(dwc->usb2_phy1, 1);
	usb_phy_set_suspend(dwc->usb3_phy1, 1);
	usb_phy_set_suspend(dwc->usb2_phy, 1);
	usb_phy_set_suspend(dwc->usb3_phy, 1);
	dwc3_free_scratch_buffers(dwc);

err1:
	usb_phy_shutdown(dwc->usb2_phy1);
	usb_phy_shutdown(dwc->usb3_phy1);
	usb_phy_shutdown(dwc->usb2_phy);
	usb_phy_shutdown(dwc->usb3_phy);
	phy_exit(dwc->usb2_generic_phy);
@@ -1152,6 +1195,12 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
	if (node) {
		dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
		dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
		if (dwc->dual_port) {
			dwc->usb2_phy1 = devm_usb_get_phy_by_phandle(dev,
								"usb-phy", 2);
			dwc->usb3_phy1 = devm_usb_get_phy_by_phandle(dev,
								"usb-phy", 3);
		}
	} else {
		dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
		dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
@@ -1181,6 +1230,30 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
		}
	}

	if (dwc->dual_port) {
		if (IS_ERR(dwc->usb2_phy1)) {
			ret = PTR_ERR(dwc->usb2_phy1);
			if (ret == -ENXIO || ret == -ENODEV) {
				dwc->usb2_phy1 = NULL;
			} else {
				if (ret != -EPROBE_DEFER)
					dev_err(dev, "no usb2 phy1 configured\n");
				return ret;
			}
		}

		if (IS_ERR(dwc->usb3_phy1)) {
			ret = PTR_ERR(dwc->usb3_phy1);
			if (ret == -ENXIO || ret == -ENODEV) {
				dwc->usb3_phy1 = NULL;
			} else {
				if (ret != -EPROBE_DEFER)
					dev_err(dev, "no usb3 phy1 configured\n");
				return ret;
			}
		}
	}

	dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy");
	if (IS_ERR(dwc->usb2_generic_phy)) {
		ret = PTR_ERR(dwc->usb2_generic_phy);
+9 −5
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@
#define GEN2_U3_EXIT_RSP_RX_CLK_MASK	GEN2_U3_EXIT_RSP_RX_CLK(0xff)
#define GEN1_U3_EXIT_RSP_RX_CLK(n)	(n)
#define GEN1_U3_EXIT_RSP_RX_CLK_MASK	GEN1_U3_EXIT_RSP_RX_CLK(0xff)
#define DWC31_LINK_GDBGLTSSM	0xd050
#define DWC31_LINK_GDBGLTSSM(n)		(0xd050 + ((n) * 0x80))

/* DWC 3.1 Tx De-emphasis Registers */
#define DWC31_LCSR_TX_DEEMPH(n)	(0xd060 + ((n) * 0x80))
@@ -1056,8 +1056,10 @@ struct dwc3_scratchpad_array {
 * @role_sw: usb_role_switch handle
 * @role_switch_default_mode: default operation mode of controller while
 *			usb role is USB_ROLE_NONE.
 * @usb2_phy: pointer to USB2 PHY
 * @usb3_phy: pointer to USB3 PHY
 * @usb2_phy: pointer to USB2 PHY 0
 * @usb2_phy1: pointer to USB2 PHY 1
 * @usb3_phy: pointer to USB3 PHY 0
 * @usb3_phy: pointer to USB3 PHY 1
 * @usb2_generic_phy: pointer to USB2 PHY
 * @usb3_generic_phy: pointer to USB3 PHY
 * @phys_ready: flag to indicate that PHYs are ready
@@ -1161,6 +1163,7 @@ struct dwc3_scratchpad_array {
 * @is_remote_wakeup_enabled: remote wakeup status from host perspective
 * @wait_linkstate: waitqueue for waiting LINK to move into required state
 * @remote_wakeup_work: use to perform remote wakeup from this context
 * @dual_port: If true, this core supports two ports
 */
struct dwc3 {
	struct work_struct	drd_work;
@@ -1194,8 +1197,8 @@ struct dwc3 {

	struct reset_control	*reset;

	struct usb_phy		*usb2_phy;
	struct usb_phy		*usb3_phy;
	struct usb_phy		*usb2_phy, *usb2_phy1;
	struct usb_phy		*usb3_phy, *usb3_phy1;

	struct phy		*usb2_generic_phy;
	struct phy		*usb3_generic_phy;
@@ -1412,6 +1415,7 @@ struct dwc3 {
	bool			is_remote_wakeup_enabled;
	wait_queue_head_t	wait_linkstate;
	struct work_struct	remote_wakeup_work;
	bool			dual_port;
};

#define INCRX_BURST_MODE 0
+392 −46

File changed.

Preview size limit exceeded, changes collapsed.