Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Honour regulator-enable-ramp-delay



details:   https://anonhg.NetBSD.org/src/rev/11069736cda7
branches:  trunk
changeset: 451566:11069736cda7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon May 27 23:18:33 2019 +0000

description:
Honour regulator-enable-ramp-delay

diffstat:

 sys/dev/fdt/fdt_regulator.c |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r 3c7cc0c51389 -r 11069736cda7 sys/dev/fdt/fdt_regulator.c
--- a/sys/dev/fdt/fdt_regulator.c       Mon May 27 21:36:07 2019 +0000
+++ b/sys/dev/fdt/fdt_regulator.c       Mon May 27 23:18:33 2019 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
        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 @@
 {
        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 @@
 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



Home | Main Index | Thread Index | Old Index