
Add the ability to enable/disable whatever USB PHY's are passed to the AT91 OHCI driver through DT.
Signed-off-by: Sergiu Moga sergiu.moga@microchip.com Tested-by: Mihai Sain mihai.sain@microchip.com ---
v1 -> v2: - use *_bulk API's
v2 -> v3: - use if (CONFIG_IS_ENABLED(...))
drivers/usb/host/ohci-at91.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 92d0ab7184..171245ef6e 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -73,6 +73,7 @@ int usb_cpu_init_fail(void) #include <asm/gpio.h> #include <usb.h> #include "ohci.h" +#include <generic-phy.h>
#define AT91_MAX_USBH_PORTS 3
@@ -90,15 +91,32 @@ struct at91_usbh_data { struct ohci_at91_priv { ohci_t ohci; struct clk_bulk clks; + struct phy_bulk phys; };
static int at91_start_clock(struct ohci_at91_priv *ohci_at91) { + if (CONFIG_IS_ENABLED(PHY_MICROCHIP_SAMA7_USB)) { + int ret; + + ret = generic_phy_power_on_bulk(&ohci_at91->phys); + if (ret) + return ret; + } + return clk_enable_bulk(&ohci_at91->clks); }
static int at91_stop_clock(struct ohci_at91_priv *ohci_at91) { + if (CONFIG_IS_ENABLED(PHY_MICROCHIP_SAMA7_USB)) { + int ret; + + ret = generic_phy_power_off_bulk(&ohci_at91->phys); + if (ret) + return ret; + } + return clk_disable_bulk(&ohci_at91->clks); }
@@ -185,6 +203,16 @@ static int ohci_atmel_probe(struct udevice *dev) if (ret) goto fail;
+ if (CONFIG_IS_ENABLED(PHY_MICROCHIP_SAMA7_USB)) { + ret = generic_phy_get_bulk(dev, &ohci_at91->phys); + if (ret) + goto fail; + + ret = generic_phy_init_bulk(&ohci_at91->phys); + if (ret) + goto fail; + } + ret = at91_start_hc(dev); if (ret) goto fail;