*/
#include <common.h>
+#include <clk.h>
#include <log.h>
#include <usb.h>
#include <errno.h>
{
int ret;
- enable_usboh3_clk(1);
- mdelay(1);
-
/* Do board specific initialization */
ret = board_ehci_hcd_init(index);
if (ret)
}
}
+ enable_usboh3_clk(1);
+ mdelay(1);
+
ret = ehci_mx6_common_init(ehci, index);
if (ret)
return ret;
struct ehci_ctrl ctrl;
struct usb_ehci *ehci;
struct udevice *vbus_supply;
+ struct clk clk;
enum usb_init_type init_type;
int portnr;
};
priv->portnr = dev_seq(dev);
priv->init_type = type;
+#if CONFIG_IS_ENABLED(CLK)
+ ret = clk_get_by_index(dev, 0, &priv->clk);
+ if (ret < 0)
+ return ret;
+
+ ret = clk_enable(&priv->clk);
+ if (ret)
+ return ret;
+#else
+ /* Compatibility with DM_USB and !CLK */
+ enable_usboh3_clk(1);
+ mdelay(1);
+#endif
+
#if CONFIG_IS_ENABLED(DM_REGULATOR)
ret = device_get_supply_regulator(dev, "vbus-supply",
&priv->vbus_supply);
#endif
ret = ehci_mx6_common_init(ehci, priv->portnr);
if (ret)
- return ret;
+ goto err_clk;
#if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->vbus_supply) {
false : true);
if (ret && ret != -ENOSYS) {
printf("Error enabling VBUS supply (ret=%i)\n", ret);
- return ret;
+ goto err_clk;
}
}
#endif
#if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->vbus_supply)
regulator_set_enable(priv->vbus_supply, false);
+#endif
+err_clk:
+#if CONFIG_IS_ENABLED(CLK)
+ clk_disable(&priv->clk);
+#else
+ /* Compatibility with DM_USB and !CLK */
+ enable_usboh3_clk(0);
#endif
return ret;
}
regulator_set_enable(priv->vbus_supply, false);
#endif
+#if CONFIG_IS_ENABLED(CLK)
+ clk_disable(&priv->clk);
+#endif
+
return 0;
}