Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Allow set_voltage/get_voltage to succeed on a fi...



details:   https://anonhg.NetBSD.org/src/rev/ffca69950ce3
branches:  trunk
changeset: 829392:ffca69950ce3
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jan 28 18:21:52 2018 +0000

description:
Allow set_voltage/get_voltage to succeed on a fixed regulator so long as
the requested range overlaps with the fixed rate defined in the devicetree.

diffstat:

 sys/dev/fdt/fixedregulator.c |  35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diffs (78 lines):

diff -r ca8d5a00e42e -r ffca69950ce3 sys/dev/fdt/fixedregulator.c
--- a/sys/dev/fdt/fixedregulator.c      Sun Jan 28 16:32:43 2018 +0000
+++ b/sys/dev/fdt/fixedregulator.c      Sun Jan 28 18:21:52 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fixedregulator.c,v 1.5 2017/04/24 10:55:26 jmcneill Exp $ */
+/* $NetBSD: fixedregulator.c,v 1.6 2018/01/28 18:21:52 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.5 2017/04/24 10:55:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.6 2018/01/28 18:21:52 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -44,11 +44,15 @@
 static int     fixedregulator_acquire(device_t);
 static void    fixedregulator_release(device_t);
 static int     fixedregulator_enable(device_t, bool);
+static int     fixedregulator_set_voltage(device_t, u_int, u_int);
+static int     fixedregulator_get_voltage(device_t, u_int *);
 
 struct fdtbus_regulator_controller_func fixedregulator_funcs = {
        .acquire = fixedregulator_acquire,
        .release = fixedregulator_release,
-       .enable = fixedregulator_enable
+       .enable = fixedregulator_enable,
+       .set_voltage = fixedregulator_set_voltage,
+       .get_voltage = fixedregulator_get_voltage,
 };
 
 struct fixedregulator_softc {
@@ -60,6 +64,8 @@
        bool            sc_boot_on;
        bool            sc_enable_val;
        uint32_t        sc_delay;
+       uint32_t        sc_min_uvol;
+       uint32_t        sc_max_uvol;
 
        int             sc_gpioflags;
        bool            sc_deferred;
@@ -113,6 +119,8 @@
        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;
+       of_getprop_uint32(phandle, "regulator-min-microvolt", &sc->sc_min_uvol);
+       of_getprop_uint32(phandle, "regulator-max-microvolt", &sc->sc_max_uvol);
 
        sc->sc_pin = fdtbus_gpio_acquire(phandle, "gpio", sc->sc_gpioflags);
        if (sc->sc_pin == NULL)
@@ -166,3 +174,24 @@
        }
        return 0;
 }
+
+static int
+fixedregulator_set_voltage(device_t dev, u_int min_uvol, u_int max_uvol)
+{
+       struct fixedregulator_softc * const sc = device_private(dev);
+
+       if (sc->sc_min_uvol > max_uvol || sc->sc_max_uvol < min_uvol)
+               return EINVAL;
+
+       return 0;
+}
+
+static int
+fixedregulator_get_voltage(device_t dev, u_int *uvol)
+{
+       struct fixedregulator_softc * const sc = device_private(dev);
+
+       *uvol = sc->sc_min_uvol;
+
+       return 0;
+}



Home | Main Index | Thread Index | Old Index