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

Commit 64d654ab authored by Manu Gautam's avatar Manu Gautam Committed by Stephen Boyd
Browse files

USB: dwc3-msm: Use no-op USB PHYs for host only mode



DWC3 core driver requires USB PHYs to be present during init.
For this purpose dwc3-msm glue driver registers these PHYs
before adding dwc3 core device. But, USB2/3 PHY may not be
registered by dwc3-msm if it is operating in HOST only mode
when USB2 is running in OTG already. For this purpose DWC3
core driver should use no-op USB PHYs in host_only_mode.

Change-Id: Ic08864d1e4486b8951bc626f1f3c438c4335978e
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent 2b3501cb
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -543,12 +543,30 @@ static int dwc3_probe(struct platform_device *pdev)
		return -ENOMEM;
	}

	dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
	host_only_mode = of_property_read_bool(node, "host-only-mode");

	/* host only mode doesnt use PHY xcvr; define nop ones */
	if (host_only_mode) {
		dwc->usb2_phy = devm_kzalloc(&pdev->dev, sizeof(struct usb_phy),
								GFP_KERNEL);
		if (!dwc->usb2_phy) {
			dev_err(&pdev->dev, "unable to allocate dwc3nop phy\n");
			return -ENOMEM;
		}
		dwc->usb3_phy = dwc->usb2_phy;
	} else {
		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);
			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);
		} 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);
			dwc->usb2_phy =
				devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
			dwc->usb3_phy =
				devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
		}
	}

	if (IS_ERR(dwc->usb2_phy)) {
@@ -606,9 +624,6 @@ static int dwc3_probe(struct platform_device *pdev)
	else
		dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;

	dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
	host_only_mode = of_property_read_bool(node, "host-only-mode");

	pm_runtime_no_callbacks(dev);
	pm_runtime_set_active(dev);
	pm_runtime_enable(dev);
+12 −6
Original line number Diff line number Diff line
@@ -2656,6 +2656,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
{
	struct device_node *node = pdev->dev.of_node;
	struct device	*dev = &pdev->dev;
	struct usb_phy	*usb2_xceiv;
	struct dwc3_msm *mdwc;
	struct resource *res;
	void __iomem *tcsr;
@@ -2997,14 +2998,16 @@ static int dwc3_msm_probe(struct platform_device *pdev)
		}
	}

	usb2_xceiv = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
	if (node) {

		/* Register USB2/3 PHYs before DWC3 init */
		/* Register USB PHYs before DWC3 init if DWC3 running as OTG */
		if (IS_ERR(usb2_xceiv)) {
			ret = dwc3_otg_register_phys(pdev);
			if (ret) {
				dev_err(&pdev->dev, "failed to register dwc3 phys\n");
				goto put_psupply;
			}
		}

		ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
		if (ret) {
@@ -3027,6 +3030,9 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	}

	mdwc->otg_xceiv = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
	if (IS_ERR(mdwc->otg_xceiv))
		mdwc->otg_xceiv = NULL;

	/* Register with OTG if present, ignore USB2 OTG using other PHY */
	if (mdwc->otg_xceiv &&
			!(mdwc->otg_xceiv->flags & ENABLE_SECONDARY_PHY)) {