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

Commit 3de5425f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3-msm: Get otg_xceiv directly from dwc3_otg"

parents e2e81580 6c9a4bac
Loading
Loading
Loading
Loading
+10 −25
Original line number Diff line number Diff line
@@ -2345,8 +2345,8 @@ static int dwc3_msm_probe(struct platform_device *pdev)
{
	struct device_node *node = pdev->dev.of_node, *dwc3_node;
	struct device	*dev = &pdev->dev;
	struct usb_phy	*usb2_xceiv;
	struct dwc3_msm *mdwc;
	struct dwc3	*dwc;
	struct resource *res;
	void __iomem *tcsr;
	unsigned long flags;
@@ -2616,17 +2616,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
		}
	}

	usb2_xceiv = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
	if (node) {
		/* 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) {
			dev_err(&pdev->dev,
@@ -2639,14 +2629,14 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	dwc3_node = of_get_next_available_child(node, NULL);
	if (!dwc3_node) {
		dev_err(&pdev->dev, "failed to find dwc3 child\n");
		goto put_otg;
		goto put_psupply;
	}

	mdwc->dwc3 = of_find_device_by_node(dwc3_node);
	of_node_put(dwc3_node);
	if (!mdwc->dwc3) {
		dev_err(&pdev->dev, "failed to get dwc3 platform device\n");
		goto put_otg;
		goto put_psupply;
	}

	mdwc->hs_phy = devm_usb_get_phy_by_phandle(&mdwc->dwc3->dev,
@@ -2677,13 +2667,12 @@ static int dwc3_msm_probe(struct platform_device *pdev)
			dev_err(&pdev->dev, "Failed to vote for bus scaling\n");
	}

	mdwc->otg_xceiv = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
	if (IS_ERR(mdwc->otg_xceiv))
		mdwc->otg_xceiv = NULL;
	dwc = platform_get_drvdata(mdwc->dwc3);
	if (dwc && dwc->dotg)
		mdwc->otg_xceiv = dwc->dotg->otg.phy;

	/* Register with OTG if present, ignore USB2 OTG using other PHY */
	if (mdwc->otg_xceiv &&
			!(mdwc->otg_xceiv->flags & ENABLE_SECONDARY_PHY)) {
	/* Register with OTG if present */
	if (mdwc->otg_xceiv) {
		/* Skip charger detection for simulator targets */
		if (!mdwc->charger.skip_chg_detect) {
			mdwc->charger.start_detection = dwc3_start_chg_det;
@@ -2721,8 +2710,8 @@ static int dwc3_msm_probe(struct platform_device *pdev)
				dev_err(&pdev->dev, "Failed to enable vbus_otg\n");
			}
		}
		mdwc->otg_xceiv = NULL;
	}

	if (mdwc->ext_xceiv.otg_capability && mdwc->charger.start_detection) {
		ret = dwc3_msm_setup_cdev(mdwc);
		if (ret)
@@ -2745,8 +2734,6 @@ static int dwc3_msm_probe(struct platform_device *pdev)

put_dwc3:
	platform_device_put(mdwc->dwc3);
put_otg:
	dwc3_otg_deregister_phys(pdev);
put_psupply:
	if (mdwc->usb_psy.dev)
		power_supply_unregister(&mdwc->usb_psy);
@@ -2789,10 +2776,8 @@ static int dwc3_msm_remove(struct platform_device *pdev)
		qpnp_adc_tm_usbid_end(mdwc->adc_tm_dev);
	if (dwc3_debugfs_root)
		debugfs_remove_recursive(dwc3_debugfs_root);
	if (mdwc->otg_xceiv) {
	if (mdwc->otg_xceiv)
		dwc3_start_chg_det(&mdwc->charger, false);
		dwc3_otg_deregister_phys(pdev);
	}
	if (mdwc->usb_psy.dev)
		power_supply_unregister(&mdwc->usb_psy);
	if (mdwc->vbus_otg)
+14 −41
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ static int max_chgr_retry_count = MAX_INVALID_CHRGR_RETRY;
module_param(max_chgr_retry_count, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(max_chgr_retry_count, "Max invalid charger retry count");

static struct dwc3_otg *the_dotg;

static void dwc3_otg_reset(struct dwc3_otg *dotg);
static int dwc3_otg_set_host(struct usb_otg *otg, struct usb_bus *host);
static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode);
@@ -930,66 +928,41 @@ static void dwc3_otg_reset(struct dwc3_otg *dotg)
				DWC3_OEVTEN_OTGBDEVVBUSCHNGEVNT);
}

int dwc3_otg_register_phys(struct platform_device *pdev)
/**
 * dwc3_otg_init - Initializes otg related registers
 * @dwc: Pointer to out controller context structure
 *
 * Returns 0 on success otherwise negative errno.
 */
int dwc3_otg_init(struct dwc3 *dwc)
{
	u32	reg;
	int ret = 0;
	struct dwc3_otg *dotg;

	dev_dbg(&pdev->dev, "dwc3_otg_register_phys\n");
	dev_dbg(dwc->dev, "dwc3_otg_init\n");

	/* Allocate and init otg instance */
	dotg = devm_kzalloc(&pdev->dev, sizeof(struct dwc3_otg), GFP_KERNEL);
	dotg = devm_kzalloc(dwc->dev, sizeof(struct dwc3_otg), GFP_KERNEL);
	if (!dotg) {
		dev_err(&pdev->dev, "unable to allocate dwc3_otg\n");
		dev_err(dwc->dev, "unable to allocate dwc3_otg\n");
		return -ENOMEM;
	}
	the_dotg = dotg;

	dotg->otg.phy = devm_kzalloc(&pdev->dev, sizeof(struct usb_phy),
	dotg->otg.phy = devm_kzalloc(dwc->dev, sizeof(struct usb_phy),
							GFP_KERNEL);
	if (!dotg->otg.phy) {
		dev_err(&pdev->dev, "unable to allocate dwc3_otg.phy\n");
		dev_err(dwc->dev, "unable to allocate dwc3_otg.phy\n");
		return -ENOMEM;
	}

	dotg->otg.phy->otg = &dotg->otg;
	dotg->otg.phy->dev = &pdev->dev;
	dotg->otg.phy->dev = dwc->dev;
	dotg->otg.phy->set_power = dwc3_otg_set_power;
	dotg->otg.set_peripheral = dwc3_otg_set_peripheral;
	dotg->otg.set_host = dwc3_otg_set_host;

	ret = usb_add_phy(dotg->otg.phy, USB_PHY_TYPE_USB2);
	if (ret) {
		dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
			ret);
		return ret;
	}
	dotg->otg.phy->state = OTG_STATE_UNDEFINED;

	return ret;
}

void dwc3_otg_deregister_phys(struct platform_device *pdev)
{
	dev_dbg(&pdev->dev, "dwc3_otg_deregister_phys\n");

	usb_remove_phy(the_dotg->otg.phy);
}

/**
 * dwc3_otg_init - Initializes otg related registers
 * @dwc: Pointer to out controller context structure
 *
 * Returns 0 on success otherwise negative errno.
 */
int dwc3_otg_init(struct dwc3 *dwc)
{
	u32	reg;
	int ret = 0;
	struct dwc3_otg *dotg = the_dotg;

	dev_dbg(dwc->dev, "dwc3_otg_init\n");

	/*
	 * GHWPARAMS6[10] bit is SRPSupport.
	 * This bit also reflects DWC_USB3_EN_OTG
+0 −4
Original line number Diff line number Diff line
@@ -122,8 +122,4 @@ struct dwc3_ext_xceiv {
extern int dwc3_set_ext_xceiv(struct usb_otg *otg,
				struct dwc3_ext_xceiv *ext_xceiv);

/* for registering USB3, USB2 PHYs */
int dwc3_otg_register_phys(struct platform_device *pdev);

void dwc3_otg_deregister_phys(struct platform_device *pdev);
#endif /* __LINUX_USB_DWC3_OTG_H */