summaryrefslogtreecommitdiff
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2017-04-22 21:47:41 +0000
committerjmcneill <jmcneill@NetBSD.org>2017-04-22 21:47:41 +0000
commit2c8688644e0c35f71d4dca4e91eafce0c0556c40 (patch)
tree919d0a2a4b53f404ac230f9357677f9f8f01298d /sys/dev/fdt
parent2d28cc84d5be946992fd42233620fb30bbad20ab (diff)
Add regulator APIs for setting and getting voltage.
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/fdt_regulator.c27
-rw-r--r--sys/dev/fdt/fdtvar.h8
2 files changed, 32 insertions, 3 deletions
diff --git a/sys/dev/fdt/fdt_regulator.c b/sys/dev/fdt/fdt_regulator.c
index 83b41fc963e..1b5bc6f7323 100644
--- a/sys/dev/fdt/fdt_regulator.c
+++ b/sys/dev/fdt/fdt_regulator.c
@@ -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>
@@ -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 @@ fdtbus_regulator_disable(struct fdtbus_regulator *reg)
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 --git a/sys/dev/fdt/fdtvar.h b/sys/dev/fdt/fdtvar.h
index 6e0bc50fa8e..7c4ed9bdbe4 100644
--- a/sys/dev/fdt/fdtvar.h
+++ b/sys/dev/fdt/fdtvar.h
@@ -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>
@@ -96,6 +96,8 @@ struct fdtbus_regulator_controller_func {
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 @@ struct fdtbus_regulator *fdtbus_regulator_acquire(int, const char *);
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);