From c0f6606d477af0c531160f73f2d8c194f01b6489 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Thu, 5 Mar 2020 14:33:30 +0100 Subject: imx6_usbphy: Add regulator (vbus-supply). Update #3869. --- freebsd/sys/arm/freescale/imx/imx6_usbphy.c | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/freebsd/sys/arm/freescale/imx/imx6_usbphy.c b/freebsd/sys/arm/freescale/imx/imx6_usbphy.c index ad545601..7df2e124 100644 --- a/freebsd/sys/arm/freescale/imx/imx6_usbphy.c +++ b/freebsd/sys/arm/freescale/imx/imx6_usbphy.c @@ -52,6 +52,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef __rtems__ +#include +#endif /* __rtems__ */ /* * Hardware register defines. @@ -70,6 +73,9 @@ struct usbphy_softc { device_t dev; struct resource *mem_res; u_int phy_num; +#ifdef __rtems__ + regulator_t supply_vbus; +#endif /* __rtems__ */ }; static struct ofw_compat_data compat_data[] = { @@ -107,6 +113,10 @@ usbphy_attach(device_t dev) { struct usbphy_softc *sc; int err, regoff, rid; +#ifdef __rtems__ + int rv; + phandle_t node; +#endif /* __rtems__ */ sc = device_get_softc(dev); err = 0; @@ -121,6 +131,27 @@ usbphy_attach(device_t dev) goto out; } +#ifdef __rtems__ + node = ofw_bus_get_node(dev); + if (OF_hasprop(node, "vbus-supply")) { + rv = regulator_get_by_ofw_property(sc->dev, 0, "vbus-supply", + &sc->supply_vbus); + if (rv != 0) { + device_printf(sc->dev, + "Cannot get \"vbus\" regulator\n"); + err = ENXIO; + goto out; + } + rv = regulator_enable(sc->supply_vbus); + if (rv != 0) { + device_printf(sc->dev, + "Cannot enable \"vbus\" regulator\n"); + err = ENXIO; + goto out; + } + } + +#endif /* __rtems__ */ /* * XXX Totally lame way to get the unit number (but not quite as lame as * adding an ad-hoc property to the fdt data). This works as long as -- cgit v1.2.3