Module Name:    src
Committed By:   jmcneill
Date:           Sat Jan 19 20:51:12 UTC 2019

Modified Files:
        src/sys/dev/fdt: gpioregulator.c

Log Message:
Set initial regulator states at attach time


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/gpioregulator.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/fdt/gpioregulator.c
diff -u src/sys/dev/fdt/gpioregulator.c:1.1 src/sys/dev/fdt/gpioregulator.c:1.2
--- src/sys/dev/fdt/gpioregulator.c:1.1	Sun Aug 13 18:27:31 2017
+++ src/sys/dev/fdt/gpioregulator.c	Sat Jan 19 20:51:12 2019
@@ -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 <[email protected]>
@@ -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, de
 	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, de
 		}
 	}
 
+	/* "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);
 

Reply via email to