diff --git a/sys/dev/fdt/gpioregulator.c b/sys/dev/fdt/gpioregulator.c index 481d05b82d23..d5491458fe20 100644 --- a/sys/dev/fdt/gpioregulator.c +++ b/sys/dev/fdt/gpioregulator.c @@ -1,4 +1,4 @@ -/* $NetBSD: gpioregulator.c,v 1.1 2017/08/13 18:27:31 jmcneill Exp $ */ +/* $NetBSD: gpioregulator.c,v 1.2 2019/01/19 20:51:12 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gpioregulator.c,v 1.1 2017/08/13 18:27:31 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gpioregulator.c,v 1.2 2019/01/19 20:51:12 jmcneill Exp $"); #include #include @@ -100,6 +100,7 @@ gpioregulator_attach(device_t parent, device_t self, void *aux) const int phandle = faa->faa_phandle; const uint32_t *pstates; uint32_t mask; + u_int gpios_states; char *name; int len, n; @@ -163,6 +164,14 @@ gpioregulator_attach(device_t parent, device_t self, void *aux) } } + /* "gpios-states" property */ + if (of_getprop_uint32(phandle, "gpios-states", &gpios_states) != 0) + gpios_states = 0; + + /* Set initial state */ + for (n = 0; n < sc->sc_npins; n++) + fdtbus_gpio_write(sc->sc_pins[n], (gpios_states >> n) & 1); + fdtbus_register_regulator_controller(self, phandle, &gpioregulator_funcs);