Disallow setting the voltage of coupled regulators for now. Some RK3588
authorkettenis <kettenis@openbsd.org>
Fri, 14 Jun 2024 20:00:32 +0000 (20:00 +0000)
committerkettenis <kettenis@openbsd.org>
Fri, 14 Jun 2024 20:00:32 +0000 (20:00 +0000)
boards use different regulators for CPU core voltage and memory interface
voltage.  But the two have to be kept synchronized.  So the devicetree for
these boards marks these regulators as coupled.  We have no support for
coupled regulators yet and letting the DVFS code set just the CPU core
voltage would probably lead to strange crashes.

ok mlarkin@

sys/dev/ofw/ofw_regulator.c
sys/dev/ofw/ofw_regulator.h

index 027cb65..343689a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ofw_regulator.c,v 1.19 2023/04/15 03:19:43 dlg Exp $  */
+/*     $OpenBSD: ofw_regulator.c,v 1.20 2024/06/14 20:00:32 kettenis Exp $     */
 /*
  * Copyright (c) 2016 Mark Kettenis
  *
@@ -56,6 +56,11 @@ regulator_register(struct regulator_device *rd)
        rd->rd_ramp_delay =
            OF_getpropint(rd->rd_node, "regulator-ramp-delay", 0);
 
+       rd->rd_coupled =
+           OF_getpropint(rd->rd_node, "regulator-coupled-with", 0);
+       rd->rd_max_spread =
+           OF_getpropint(rd->rd_node, "regulator-coupled-max-spread", 0);
+
        if (rd->rd_get_voltage && rd->rd_set_voltage) {
                uint32_t voltage = rd->rd_get_voltage(rd->rd_cookie);
                if (voltage < rd->rd_volt_min)
@@ -249,6 +254,10 @@ regulator_set_voltage(uint32_t phandle, uint32_t voltage)
        if (rd && (voltage < rd->rd_volt_min || voltage > rd->rd_volt_max))
                return EINVAL;
 
+       /* XXX Coupled regulators are unsupported for now. */
+       if (rd && rd->rd_coupled)
+               return ENOTSUP;
+
        if (rd && rd->rd_set_voltage) {
                regulator_do_notify(rd->rd_phandle, voltage);
 
index 5d893b9..598e429 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ofw_regulator.h,v 1.8 2023/04/01 08:37:23 kettenis Exp $      */
+/*     $OpenBSD: ofw_regulator.h,v 1.9 2024/06/14 20:00:32 kettenis Exp $      */
 /*
  * Copyright (c) 2016 Mark Kettenis
  *
@@ -31,6 +31,9 @@ struct regulator_device {
        uint32_t rd_amp_min, rd_amp_max;
        uint32_t rd_ramp_delay;
 
+       uint32_t rd_coupled;
+       uint32_t rd_max_spread;
+
        LIST_ENTRY(regulator_device) rd_list;
        uint32_t rd_phandle;
 };