[rtems-libbsd commit] imx6_usbphy: Add regulator (vbus-supply).

Christian Mauderer christianm at rtems.org
Wed Apr 15 15:13:21 UTC 2020


Module:    rtems-libbsd
Branch:    5-freebsd-12
Commit:    b3da96ceb8b9b8ea5c865ecdbc88aa8d67b42dfe
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=b3da96ceb8b9b8ea5c865ecdbc88aa8d67b42dfe

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Thu Mar  5 14:33:30 2020 +0100

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 ad54560..7df2e12 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 <arm/freescale/imx/imx_ccmvar.h>
 #include <arm/freescale/imx/imx6_anatopreg.h>
 #include <arm/freescale/imx/imx6_anatopvar.h>
+#ifdef __rtems__
+#include <dev/extres/regulator/regulator.h>
+#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



More information about the vc mailing list