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

Commit b24bdfda authored by Jack Pham's avatar Jack Pham
Browse files

usb: dwc3-msm: Fix host-only mode support



Remove creation of no-op USB PHYs since the core is already
required to have actual PHYs registered. This fixes host-only
mode so that it can properly communicate with the HS & SS PHYs.

This effectively reverts commit 64d654ab ("USB: dwc3-msm: Use
no-op USB PHYs for host only mode").

Also, allow the dwc3-msm glue layer to directly query the dwc3
device tree node for the 'host-only-mode' property instead of
just relying on OTG xceiv being NULL.

Change-Id: I5198a46b66f1585539865b06d39bbd0e8e5f9ab0
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 6c9a4bac
Loading
Loading
Loading
Loading
+5 −20
Original line number Diff line number Diff line
@@ -545,27 +545,12 @@ static int dwc3_probe(struct platform_device *pdev)
	host_only_mode = of_property_read_bool(node, "host-only-mode");
	dwc->maximum_speed = of_usb_get_maximum_speed(node);

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

	/* default to superspeed if no maximum_speed passed */
+8 −1
Original line number Diff line number Diff line
@@ -2350,6 +2350,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	struct resource *res;
	void __iomem *tcsr;
	unsigned long flags;
	bool host_mode;
	int ret = 0;

	mdwc = devm_kzalloc(&pdev->dev, sizeof(*mdwc), GFP_KERNEL);
@@ -2632,6 +2633,8 @@ static int dwc3_msm_probe(struct platform_device *pdev)
		goto put_psupply;
	}

	host_mode = of_property_read_bool(dwc3_node, "host-only-mode");

	mdwc->dwc3 = of_find_device_by_node(dwc3_node);
	of_node_put(dwc3_node);
	if (!mdwc->dwc3) {
@@ -2695,7 +2698,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
									ret);
			goto put_dwc3;
		}
	} else {
	} else if (host_mode) {
		dev_dbg(&pdev->dev, "No OTG, DWC3 running in host only mode\n");
		mdwc->scope = POWER_SUPPLY_SCOPE_SYSTEM;
		mdwc->hs_phy->flags |= PHY_HOST_MODE;
@@ -2710,6 +2713,10 @@ static int dwc3_msm_probe(struct platform_device *pdev)
				dev_err(&pdev->dev, "Failed to enable vbus_otg\n");
			}
		}
	} else {
		dev_err(&pdev->dev, "DWC3 device-only mode not supported\n");
		ret = -ENODEV;
		goto put_dwc3;
	}

	if (mdwc->ext_xceiv.otg_capability && mdwc->charger.start_detection) {