@@ -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;