Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt If either "regulator-boot-on" or "regulator-alwa...
details: https://anonhg.NetBSD.org/src/rev/a9ba2f8a6da3
branches: trunk
changeset: 345914:a9ba2f8a6da3
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Jun 15 13:13:40 2016 +0000
description:
If either "regulator-boot-on" or "regulator-always-on" properties are true,
explicitly enable the regulator at attach time. In addition, if the
"startup-delay-us" property is present, delay after enabling the regulator.
diffstat:
sys/dev/fdt/fixedregulator.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diffs (79 lines):
diff -r 8ae8823c65c7 -r a9ba2f8a6da3 sys/dev/fdt/fixedregulator.c
--- a/sys/dev/fdt/fixedregulator.c Wed Jun 15 12:10:18 2016 +0000
+++ b/sys/dev/fdt/fixedregulator.c Wed Jun 15 13:13:40 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fixedregulator.c,v 1.3 2015/12/22 22:19:07 jmcneill Exp $ */
+/* $NetBSD: fixedregulator.c,v 1.4 2016/06/15 13:13:40 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.3 2015/12/22 22:19:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.4 2016/06/15 13:13:40 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -57,7 +57,9 @@
struct fdtbus_gpio_pin *sc_pin;
bool sc_always_on;
+ bool sc_boot_on;
bool sc_enable_val;
+ uint32_t sc_delay;
};
CFATTACH_DECL_NEW(fregulator, sizeof(struct fixedregulator_softc),
@@ -104,13 +106,24 @@
gpioflags |= GPIO_PIN_OPENDRAIN;
sc->sc_always_on = of_getprop_bool(phandle, "regulator-always-on");
+ sc->sc_boot_on = of_getprop_bool(phandle, "regulator-boot-on");
+ sc->sc_enable_val = of_getprop_bool(phandle, "enable-active-high");
+ if (of_getprop_uint32(phandle, "startup-delay-us", &sc->sc_delay) != 0)
+ sc->sc_delay = 0;
+
sc->sc_pin = fdtbus_gpio_acquire(phandle, "gpio", gpioflags);
if (sc->sc_pin == NULL)
sc->sc_always_on = true;
- sc->sc_enable_val = of_getprop_bool(phandle, "enable-active-high");
fdtbus_register_regulator_controller(self, phandle,
&fixedregulator_funcs);
+
+ /*
+ * If the regulator is flagged as always on or enabled at boot,
+ * ensure that it is enabled
+ */
+ if (sc->sc_always_on || sc->sc_boot_on)
+ fixedregulator_enable(self, true);
}
static int
@@ -130,18 +143,14 @@
struct fixedregulator_softc * const sc = device_private(dev);
if (enable) {
- if (sc->sc_always_on) {
- return 0;
- } else {
+ if (sc->sc_pin != NULL)
fdtbus_gpio_write_raw(sc->sc_pin, sc->sc_enable_val);
- return 0;
- }
+ if (sc->sc_delay > 0)
+ delay(sc->sc_delay);
} else {
- if (sc->sc_always_on) {
+ if (sc->sc_always_on)
return EIO;
- } else {
- fdtbus_gpio_write_raw(sc->sc_pin, !sc->sc_enable_val);
- return 0;
- }
+ fdtbus_gpio_write_raw(sc->sc_pin, !sc->sc_enable_val);
}
+ return 0;
}
Home |
Main Index |
Thread Index |
Old Index