Module Name: src Committed By: jmcneill Date: Sat Apr 22 21:47:41 UTC 2017
Modified Files: src/sys/dev/fdt: fdt_regulator.c fdtvar.h Log Message: Add regulator APIs for setting and getting voltage. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_regulator.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/fdt/fdtvar.h 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/fdt_regulator.c diff -u src/sys/dev/fdt/fdt_regulator.c:1.2 src/sys/dev/fdt/fdt_regulator.c:1.3 --- src/sys/dev/fdt/fdt_regulator.c:1.2 Wed Dec 16 12:17:45 2015 +++ src/sys/dev/fdt/fdt_regulator.c Sat Apr 22 21:47:41 2017 @@ -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 <jmcne...@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_r 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); +} Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.11 src/sys/dev/fdt/fdtvar.h:1.12 --- src/sys/dev/fdt/fdtvar.h:1.11 Sat Apr 22 13:24:20 2017 +++ src/sys/dev/fdt/fdtvar.h Sat Apr 22 21:47:41 2017 @@ -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 <jmcne...@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_regulato 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);