fixed regulators might rely on other regulators specified by "vin-supply"
authordlg <dlg@openbsd.org>
Sat, 15 Apr 2023 03:19:43 +0000 (03:19 +0000)
committerdlg <dlg@openbsd.org>
Sat, 15 Apr 2023 03:19:43 +0000 (03:19 +0000)
when turning a fixed regulator on, turn on the regulator specified
in vin-supply too.

kettenis agrees we should do this.

sys/dev/ofw/ofw_regulator.c

index e58b3a6..027cb65 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ofw_regulator.c,v 1.18 2023/04/07 06:18:26 dlg Exp $  */
+/*     $OpenBSD: ofw_regulator.c,v 1.19 2023/04/15 03:19:43 dlg Exp $  */
 /*
  * Copyright (c) 2016 Mark Kettenis
  *
@@ -108,6 +108,14 @@ regulator_fixed_set(int node, int enable)
        int len;
        char *prop = "gpio";
 
+       /*
+        * This regulator may rely on another. That "parent" regulator
+        * may be used by multiple other devices/regulators, so unless
+        * we refcnt use of a regulator we can only turn it on.
+        */
+       if (enable)
+               regulator_enable(OF_getpropint(node, "vin-supply", 0));
+
        pinctrl_byname(node, "default");
 
        /* The "gpio"/"gpios" property is optional. */