[PATCH v2 07/11] regulator: wm831x: support software node in platform data
From: Dmitry Torokhov
Date: Thu Jul 09 2026 - 00:54:23 EST
Allow passing a software node via platform data to the wm831x buckv
regulators. This is useful for non-DT/non-ACPI platforms that want to
associate device properties (like DVS GPIOs) with the regulator devices
using software nodes.
If the software node is present, the driver will also attempt to read
DVS configuration ("wlf,dvs-init-state" and "wlf,dvs-control-src") from
it, falling back to legacy platform data fields if properties are missing.
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/regulator/wm831x-dcdc.c | 24 +++++++++++++++++++++---
include/linux/mfd/wm831x/pdata.h | 2 ++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 834d7c181971..ce43c51c0170 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -16,6 +16,7 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/gpio/consumer.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/mfd/wm831x/core.h>
@@ -332,14 +333,26 @@ static void wm831x_buckv_dvs_init(struct platform_device *pdev,
struct wm831x *wm831x = dcdc->wm831x;
int ret;
u16 ctrl;
+ int dvs_control_src;
+ u32 val;
if (!pdata)
return;
+ if (pdata->swnode) {
+ struct fwnode_handle *fwnode = software_node_fwnode(pdata->swnode);
+
+ if (fwnode)
+ device_set_node(&pdev->dev, fwnode);
+ }
+
/* gpiolib won't let us read the GPIO status so pick the higher
* of the two existing voltages so we take it as platform data.
*/
- dcdc->dvs_gpio_state = pdata->dvs_init_state;
+ if (device_property_read_u32(&pdev->dev, "wlf,dvs-init-state", &val) == 0)
+ dcdc->dvs_gpio_state = val;
+ else
+ dcdc->dvs_gpio_state = pdata->dvs_init_state;
dcdc->dvs_gpiod = devm_gpiod_get(&pdev->dev, "dvs",
dcdc->dvs_gpio_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
@@ -349,7 +362,12 @@ static void wm831x_buckv_dvs_init(struct platform_device *pdev,
return;
}
- switch (pdata->dvs_control_src) {
+ if (device_property_read_u32(&pdev->dev, "wlf,dvs-control-src", &val) == 0)
+ dvs_control_src = val;
+ else
+ dvs_control_src = pdata->dvs_control_src;
+
+ switch (dvs_control_src) {
case 1:
ctrl = 2 << WM831X_DC1_DVS_SRC_SHIFT;
break;
@@ -358,7 +376,7 @@ static void wm831x_buckv_dvs_init(struct platform_device *pdev,
break;
default:
dev_err(wm831x->dev, "Invalid DVS control source %d for %s\n",
- pdata->dvs_control_src, dcdc->name);
+ dvs_control_src, dcdc->name);
return;
}
diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h
index 75aa94dadf1c..d73a04c82ca1 100644
--- a/include/linux/mfd/wm831x/pdata.h
+++ b/include/linux/mfd/wm831x/pdata.h
@@ -12,6 +12,7 @@
struct wm831x;
struct regulator_init_data;
+struct software_node;
struct wm831x_backlight_pdata {
int isink; /** ISINK to use, 1 or 2 */
@@ -50,6 +51,7 @@ struct wm831x_buckv_pdata {
int dvs_control_src; /** Hardware DVS source to use (1 or 2) */
int dvs_init_state; /** DVS state to expect on startup */
int dvs_state_gpio; /** CPU GPIO to use for monitoring status */
+ const struct software_node *swnode; /** Software node for properties */
};
/* Sources for status LED configuration. Values are register values
--
2.55.0.795.g602f6c329a-goog