Module Name: src Committed By: jmcneill Date: Mon May 27 23:18:33 UTC 2019
Modified Files: src/sys/dev/fdt: fdt_regulator.c Log Message: Honour regulator-enable-ramp-delay To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/fdt/fdt_regulator.c 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.7 src/sys/dev/fdt/fdt_regulator.c:1.8 --- src/sys/dev/fdt/fdt_regulator.c:1.7 Wed Jan 2 18:38:43 2019 +++ src/sys/dev/fdt/fdt_regulator.c Mon May 27 23:18:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_regulator.c,v 1.7 2019/01/02 18:38:43 jmcneill Exp $ */ +/* $NetBSD: fdt_regulator.c,v 1.8 2019/05/27 23:18:33 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.7 2019/01/02 18:38:43 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.c,v 1.8 2019/05/27 23:18:33 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -42,6 +42,8 @@ struct fdtbus_regulator_controller { int rc_phandle; const struct fdtbus_regulator_controller_func *rc_funcs; + u_int rc_enable_ramp_delay; + LIST_ENTRY(fdtbus_regulator_controller) rc_next; }; @@ -54,11 +56,13 @@ fdtbus_register_regulator_controller(dev { struct fdtbus_regulator_controller *rc; - rc = kmem_alloc(sizeof(*rc), KM_SLEEP); + rc = kmem_zalloc(sizeof(*rc), KM_SLEEP); rc->rc_dev = dev; rc->rc_phandle = phandle; rc->rc_funcs = funcs; + of_getprop_uint32(phandle, "regulator-enable-ramp-delay", &rc->rc_enable_ramp_delay); + LIST_INSERT_HEAD(&fdtbus_regulator_controllers, rc, rc_next); return 0; @@ -121,8 +125,16 @@ int fdtbus_regulator_enable(struct fdtbus_regulator *reg) { struct fdtbus_regulator_controller *rc = reg->reg_rc; + int error; - return rc->rc_funcs->enable(rc->rc_dev, true); + error = rc->rc_funcs->enable(rc->rc_dev, true); + if (error != 0) + return error; + + if (rc->rc_enable_ramp_delay != 0) + delay(rc->rc_enable_ramp_delay); + + return 0; } int