[U-Boot] [PATCH v3 4/7] usb: host: ehci-generic: add generic PHY support

patrice.chotard at st.com patrice.chotard at st.com
Wed May 17 13:34:05 UTC 2017


From: Patrice Chotard <patrice.chotard at st.com>

Extend ehci-generic driver with generic PHY framework

Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---

v3:	_ test return value on generic_phy_get_by_index() and
	  generic_phy_init()

 drivers/usb/host/ehci-generic.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index d281218..c360666 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -6,6 +6,8 @@
 
 #include <common.h>
 #include <clk.h>
+#include <fdtdec.h>
+#include <generic-phy.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <dm.h>
@@ -30,6 +32,7 @@ struct generic_ehci {
 	struct ehci_ctrl ctrl;
 	struct list_head clks;
 	struct list_head resets;
+	struct phy phy;
 };
 
 static int ehci_release_resets(struct generic_ehci *priv)
@@ -161,6 +164,18 @@ static int ehci_usb_probe(struct udevice *dev)
 		list_add(&ehci_reset->list, &priv->resets);
 	}
 
+	ret = generic_phy_get_by_index(dev, 0, &priv->phy);
+	if (ret) {
+		error("failed to get usb phy\n");
+		goto reset_err;
+	}
+
+	ret = generic_phy_init(&priv->phy);
+	if (ret) {
+		error("failed to init usb phy\n");
+		goto reset_err;
+	}
+
 	hccr = map_physmem(dev_get_addr(dev), 0x100, MAP_NOCACHE);
 	hcor = (struct ehci_hcor *)((uintptr_t)hccr +
 				    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
@@ -169,6 +184,10 @@ static int ehci_usb_probe(struct udevice *dev)
 	if (!ret)
 		return ret;
 
+	ret = generic_phy_exit(&priv->phy);
+	if (ret)
+		return ret;
+
 reset_err:
 	ret = ehci_release_resets(priv);
 	if (ret)
@@ -186,6 +205,10 @@ static int ehci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	ret = generic_phy_exit(&priv->phy);
+	if (ret)
+		return ret;
+
 	ret = ehci_release_resets(priv);
 	if (ret)
 		return ret;
-- 
1.9.1



More information about the U-Boot mailing list