From adf16401905cf40504aacdb4326a02f7a66e5abb Mon Sep 17 00:00:00 2001 From: kettenis Date: Fri, 14 Jun 2024 20:00:32 +0000 Subject: [PATCH] Disallow setting the voltage of coupled regulators for now. Some RK3588 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 | 11 ++++++++++- sys/dev/ofw/ofw_regulator.h | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/dev/ofw/ofw_regulator.c b/sys/dev/ofw/ofw_regulator.c index 027cb65da37..343689a8190 100644 --- a/sys/dev/ofw/ofw_regulator.c +++ b/sys/dev/ofw/ofw_regulator.c @@ -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); diff --git a/sys/dev/ofw/ofw_regulator.h b/sys/dev/ofw/ofw_regulator.h index 5d893b9b948..598e429aae3 100644 --- a/sys/dev/ofw/ofw_regulator.h +++ b/sys/dev/ofw/ofw_regulator.h @@ -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; }; -- 2.20.1