[U-Boot] [PATCH 2/2] usb: extend generic OHCI with CLOCK, RESET and PHY
patrice.chotard at st.com
patrice.chotard at st.com
Fri May 12 13:13:58 UTC 2017
From: Patrice Chotard <patrice.chotard at st.com>
Add CLOCK, RESET and generic PHY frameworks support
Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---
drivers/usb/host/ohci-generic.c | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index f3307f4..c9d8b74 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -5,7 +5,12 @@
*/
#include <common.h>
+#include <clk.h>
#include <dm.h>
+#include <fdtdec.h>
+#include <generic-phy.h>
+#include <reset.h>
+
#include "ohci.h"
#if !defined(CONFIG_USB_OHCI_NEW)
@@ -19,13 +24,36 @@ struct generic_ohci {
static int ohci_usb_probe(struct udevice *dev)
{
struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
+ struct phy usb_phy;
+ int i, ret;
- return ohci_register(dev, regs);
-}
+ for (i = 0; ; i++) {
+ struct clk clk;
-static int ohci_usb_remove(struct udevice *dev)
-{
- return ohci_deregister(dev);
+ ret = clk_get_by_index(dev, i, &clk);
+ if (ret < 0)
+ break;
+ if (clk_enable(&clk))
+ error("failed to enable clock %d\n", i);
+ clk_free(&clk);
+ }
+
+ for (i = 0; ; i++) {
+ struct reset_ctl reset;
+
+ ret = reset_get_by_index(dev, i, &reset);
+ if (ret < 0)
+ break;
+ if (reset_deassert(&reset))
+ error("failed to deassert reset %d\n", i);
+ reset_free(&reset);
+ }
+
+ if (!generic_phy_get_by_index(dev, 0, &usb_phy))
+ if (generic_phy_init(&usb_phy))
+ error("failed to init usb phy %d\n", i);
+
+ return ohci_register(dev, regs);
}
static const struct udevice_id ohci_usb_ids[] = {
@@ -38,7 +66,7 @@ U_BOOT_DRIVER(ohci_generic) = {
.id = UCLASS_USB,
.of_match = ohci_usb_ids,
.probe = ohci_usb_probe,
- .remove = ohci_usb_remove,
+ .remove = ohci_deregister,
.ops = &ohci_usb_ops,
.priv_auto_alloc_size = sizeof(struct generic_ohci),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
--
1.9.1
More information about the U-Boot
mailing list