Set initial regulator states at attach time
This commit is contained in:
parent
50f51e36d6
commit
77ff9a803a
|
@ -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 <jmcneill@invisible.ca>
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__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 <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue