mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-30 15:11:43 +01:00
usb: host: ehci-generic: add generic PHY support
Extend ehci-generic driver with generic PHY framework Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a1cee8e808
commit
0d0ba1a73d
@ -7,6 +7,7 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
#include <dm/ofnode.h>
|
#include <dm/ofnode.h>
|
||||||
|
#include <generic-phy.h>
|
||||||
#include <reset.h>
|
#include <reset.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
@ -21,6 +22,7 @@ struct generic_ehci {
|
|||||||
struct ehci_ctrl ctrl;
|
struct ehci_ctrl ctrl;
|
||||||
struct clk *clocks;
|
struct clk *clocks;
|
||||||
struct reset_ctl *resets;
|
struct reset_ctl *resets;
|
||||||
|
struct phy phy;
|
||||||
int clock_count;
|
int clock_count;
|
||||||
int reset_count;
|
int reset_count;
|
||||||
};
|
};
|
||||||
@ -91,16 +93,37 @@ static int ehci_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = generic_phy_init(&priv->phy);
|
||||||
|
if (err) {
|
||||||
|
error("failed to init usb phy\n");
|
||||||
|
goto reset_err;
|
||||||
|
}
|
||||||
|
|
||||||
hccr = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE);
|
hccr = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE);
|
||||||
hcor = (struct ehci_hcor *)((uintptr_t)hccr +
|
hcor = (struct ehci_hcor *)((uintptr_t)hccr +
|
||||||
HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
|
HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
|
||||||
|
|
||||||
err = ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
|
err = ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
|
||||||
if (err)
|
if (err)
|
||||||
goto reset_err;
|
goto phy_err;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
phy_err:
|
||||||
|
if (generic_phy_valid(&priv->phy)) {
|
||||||
|
ret = generic_phy_exit(&priv->phy);
|
||||||
|
if (ret)
|
||||||
|
error("failed to release phy\n");
|
||||||
|
}
|
||||||
|
|
||||||
reset_err:
|
reset_err:
|
||||||
ret = reset_release_all(priv->resets, priv->reset_count);
|
ret = reset_release_all(priv->resets, priv->reset_count);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -122,6 +145,12 @@ static int ehci_usb_remove(struct udevice *dev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (generic_phy_valid(&priv->phy)) {
|
||||||
|
ret = generic_phy_exit(&priv->phy);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = reset_release_all(priv->resets, priv->reset_count);
|
ret = reset_release_all(priv->resets, priv->reset_count);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user