Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Add regulator APIs for setting and getting voltage.



details:   https://anonhg.NetBSD.org/src/rev/a221b918571f
branches:  trunk
changeset: 353181:a221b918571f
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Apr 22 21:47:41 2017 +0000

description:
Add regulator APIs for setting and getting voltage.

diffstat:

 sys/dev/fdt/fdt_regulator.c |  27 +++++++++++++++++++++++++--
 sys/dev/fdt/fdtvar.h        |   8 +++++++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diffs (74 lines):

diff -r 660f196e0b26 -r a221b918571f sys/dev/fdt/fdt_regulator.c
--- a/sys/dev/fdt/fdt_regulator.c       Sat Apr 22 20:32:35 2017 +0000
+++ b/sys/dev/fdt/fdt_regulator.c       Sat Apr 22 21:47:41 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_regulator.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
+/* $NetBSD: fdt_regulator.c,v 1.3 2017/04/22 21:47:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.c,v 1.3 2017/04/22 21:47:41 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -131,3 +131,26 @@
 
        return rc->rc_funcs->enable(rc->rc_dev, false);
 }
+
+int
+fdtbus_regulator_set_voltage(struct fdtbus_regulator *reg, u_int min_uvol,
+    u_int max_uvol)
+{
+       struct fdtbus_regulator_controller *rc = reg->reg_rc;
+
+       if (rc->rc_funcs->set_voltage == NULL)
+               return EINVAL;
+
+       return rc->rc_funcs->set_voltage(rc->rc_dev, min_uvol, max_uvol);
+}
+
+int
+fdtbus_regulator_get_voltage(struct fdtbus_regulator *reg, u_int *puvol)
+{
+       struct fdtbus_regulator_controller *rc = reg->reg_rc;
+
+       if (rc->rc_funcs->set_voltage == NULL)
+               return EINVAL;
+
+       return rc->rc_funcs->get_voltage(rc->rc_dev, puvol);
+}
diff -r 660f196e0b26 -r a221b918571f sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Sat Apr 22 20:32:35 2017 +0000
+++ b/sys/dev/fdt/fdtvar.h      Sat Apr 22 21:47:41 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.11 2017/04/22 13:24:20 jmcneill Exp $ */
+/* $NetBSD: fdtvar.h,v 1.12 2017/04/22 21:47:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -96,6 +96,8 @@
        int     (*acquire)(device_t);
        void    (*release)(device_t);
        int     (*enable)(device_t, bool);
+       int     (*set_voltage)(device_t, u_int, u_int);
+       int     (*get_voltage)(device_t, u_int *);
 };
 
 struct fdtbus_clock_controller_func {
@@ -151,6 +153,10 @@
 void           fdtbus_regulator_release(struct fdtbus_regulator *);
 int            fdtbus_regulator_enable(struct fdtbus_regulator *);
 int            fdtbus_regulator_disable(struct fdtbus_regulator *);
+int            fdtbus_regulator_set_voltage(struct fdtbus_regulator *,
+                   u_int, u_int);
+int            fdtbus_regulator_get_voltage(struct fdtbus_regulator *,
+                   u_int *);
 
 struct clk *   fdtbus_clock_get(int, const char *);
 struct clk *   fdtbus_clock_get_index(int, u_int);



Home | Main Index | Thread Index | Old Index