From 2a73bea3e85f63f9fd282e143b4ae8c337e8899e Mon Sep 17 00:00:00 2001 From: jmcneill Date: Thu, 26 May 2016 10:50:39 +0000 Subject: Enable USB PHY regulators when requested by the host controller driver. Previously the USB PHY driver would enable all regulators at attach time. This prevented boards from booting when powered by the USB OTG port, as it didn't take VBUS presence into consideration. --- sys/dev/usb/controller/generic_ohci.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/generic_ohci.c b/sys/dev/usb/controller/generic_ohci.c index 5d00c52..9656c8f 100644 --- a/sys/dev/usb/controller/generic_ohci.c +++ b/sys/dev/usb/controller/generic_ohci.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #ifdef EXT_RESOURCES #include #include +#include #endif #include "generic_usb_if.h" @@ -76,6 +77,7 @@ struct generic_ohci_softc { #ifdef EXT_RESOURCES hwreset_t rst; + phy_t phy; TAILQ_HEAD(, clk_list) clk_list; #endif }; @@ -180,6 +182,15 @@ generic_ohci_attach(device_t dev) goto error; } } + + /* Enable phy */ + if (phy_get_by_ofw_name(dev, "usb", &sc->phy) == 0) { + err = phy_enable(dev, sc->phy); + if (err != 0) { + device_printf(dev, "Could not enable phy\n"); + goto error; + } + } #endif if (GENERIC_USB_INIT(dev) != 0) { @@ -253,6 +264,14 @@ generic_ohci_detach(device_t dev) usb_bus_mem_free_all(&sc->ohci_sc.sc_bus, &ohci_iterate_hw_softc); #ifdef EXT_RESOURCES + /* Disable phy */ + if (sc->phy) { + err = phy_disable(dev, sc->phy); + if (err != 0) + device_printf(dev, "Could not disable phy\n"); + phy_release(sc->phy); + } + /* Disable clock */ TAILQ_FOREACH_SAFE(clk, &sc->clk_list, next, clk_tmp) { err = clk_disable(clk->clk); -- cgit v1.1