[U-Boot] [PATCH v5 11/11] usb: host: ohci-generic: add generic PHY support

patrice.chotard at st.com patrice.chotard at st.com
Thu Jun 1 11:36:22 UTC 2017


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

Extend ohci-generic driver with generic PHY framework

Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
v5:	_ none

v4:     _ use generic_phy_valid() before generic_phy_exit() call

v3:     _ extract in this patch the PHY support add-on from previous patch 5

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

diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 182f022..9b3592e 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -6,6 +6,8 @@
 
 #include <common.h>
 #include <clk.h>
+#include <fdtdec.h>
+#include <generic-phy.h>
 #include <dm.h>
 #include <reset.h>
 #include "ohci.h"
@@ -18,6 +20,7 @@ struct generic_ohci {
 	ohci_t ohci;
 	struct clk *clocks;
 	struct reset_ctl *resets;
+	struct phy phy;
 	int clock_count;
 	int reset_count;
 };
@@ -84,10 +87,30 @@ static int ohci_usb_probe(struct udevice *dev)
 		}
 	}
 
+	err = generic_phy_get_by_index(dev, 0, &priv->phy);
+	if (err) {
+		if (err != -ENOENT) {
+			error("failed to get usb phy\n");
+			goto reset_err;
+		}
+	} else {
+		err = generic_phy_init(&priv->phy);
+		if (err) {
+			error("failed to init usb phy\n");
+			goto reset_err;
+		}
+	}
+
 	err = ohci_register(dev, regs);
 	if (!err)
 		return err;
 
+	if (generic_phy_valid(&priv->phy)) {
+		ret = generic_phy_exit(&priv->phy);
+		if (ret)
+			return ret;
+	}
+
 reset_err:
 	ret = reset_assert_all(priv->resets, priv->reset_count);
 	if (ret)
@@ -109,6 +132,12 @@ static int ohci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	if (generic_phy_valid(&priv->phy)) {
+		ret = generic_phy_exit(&priv->phy);
+		if (ret)
+			return ret;
+	}
+
 	ret = reset_assert_all(priv->resets, priv->reset_count);
 	if (ret)
 		return ret;
-- 
1.9.1



More information about the U-Boot mailing list