[PATCH 16/19] usb: ehci-mx6: Add generic EHCI PHY support

Marek Vasut marex at denx.de
Fri Apr 2 14:48:09 CEST 2021


In case PHY support is enabled, use the generic EHCI PHY support
to start and stop the PHY.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Stefano Babic <sbabic at denx.de>
Cc: Ye Li <ye.li at nxp.com>
Cc: uboot-imx <uboot-imx at nxp.com>
---
 drivers/usb/host/ehci-mx6.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index b1cc62fcc37..855a1bdaaa2 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -413,6 +413,7 @@ struct ehci_mx6_priv_data {
 	struct usb_ehci *ehci;
 	struct udevice *vbus_supply;
 	struct clk clk;
+	struct phy phy;
 	enum usb_init_type init_type;
 #if !defined(CONFIG_PHY)
 	/* Legacy iMX6/iMX7/iMX7ULP compat, they do not use PHY framework yet */
@@ -676,16 +677,26 @@ static int ehci_usb_probe(struct udevice *dev)
 
 	mdelay(10);
 
+#if defined(CONFIG_PHY)
+	ret = ehci_setup_phy(dev, &priv->phy, 0);
+	if (ret)
+		goto err_regulator;
+#endif
+
 	hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
 	hcor = (struct ehci_hcor *)((uint32_t)hccr +
 			HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
 	ret = ehci_register(dev, hccr, hcor, &mx6_ehci_ops, 0, priv->init_type);
 	if (ret)
-		goto err_regulator;
+		goto err_phy;
 
 	return ret;
 
+err_phy:
+#if defined(CONFIG_PHY)
+	ehci_shutdown_phy(dev, &priv->phy);
+#endif
 err_regulator:
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	if (priv->vbus_supply)
@@ -707,6 +718,10 @@ int ehci_usb_remove(struct udevice *dev)
 
 	ehci_deregister(dev);
 
+#if defined(CONFIG_PHY)
+	ehci_shutdown_phy(dev, &priv->phy);
+#endif
+
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	if (priv->vbus_supply)
 		regulator_set_enable(priv->vbus_supply, false);
-- 
2.30.2



More information about the U-Boot mailing list