Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c Adjust regulator voltage at attach time to be be...



details:   https://anonhg.NetBSD.org/src/rev/3c7cc0c51389
branches:  trunk
changeset: 451565:3c7cc0c51389
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon May 27 21:36:07 2019 +0000

description:
Adjust regulator voltage at attach time to be between the min and max values specified in the dts

diffstat:

 sys/dev/i2c/axppmic.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 17a1ee29c0d3 -r 3c7cc0c51389 sys/dev/i2c/axppmic.c
--- a/sys/dev/i2c/axppmic.c     Mon May 27 21:19:55 2019 +0000
+++ b/sys/dev/i2c/axppmic.c     Mon May 27 21:36:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.19 2019/05/27 21:10:44 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.20 2019/05/27 21:36:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.19 2019/05/27 21:10:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.20 2019/05/27 21:36:07 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -998,6 +998,7 @@
        struct axpreg_attach_args *aaa = aux;
        const int phandle = aaa->reg_phandle;
        const char *name;
+       u_int uvol, min_uvol, max_uvol;
 
        sc->sc_dev = self;
        sc->sc_i2c = aaa->reg_i2c;
@@ -1013,6 +1014,15 @@
                aprint_normal(": %s\n", name);
        else
                aprint_normal("\n");
+
+       axpreg_get_voltage(self, &uvol);
+       if (of_getprop_uint32(phandle, "regulator-min-microvolt", &min_uvol) == 0 &&
+           of_getprop_uint32(phandle, "regulator-max-microvolt", &max_uvol) == 0) {
+               if (uvol < min_uvol || uvol > max_uvol) {
+                       aprint_debug_dev(self, "fix voltage %u uV -> %u/%u uV\n", uvol, min_uvol, max_uvol);
+                       axpreg_set_voltage(self, min_uvol, max_uvol);
+               }
+       }
 }
 
 CFATTACH_DECL_NEW(axppmic, sizeof(struct axppmic_softc),



Home | Main Index | Thread Index | Old Index