From 99bc5744e966911e706b857feba7cd877ec3ccb4 Mon Sep 17 00:00:00 2001 From: Victor Krawiec Date: Thu, 23 Jul 2026 11:40:01 +0200 Subject: regulator: fan53555: Add support for mode operations on Silergy devices Make the PWM mode configurable from devicetree. Some boards require forced PWM mode to keep the supply ripple within acceptable limits under light load conditions Support is restricted to Silergy manufacturer as it is the only one currently tested. Signed-off-by: Victor Krawiec Link: https://patch.msgid.link/20260723094001.120264-5-victor.krawiec@arturia.com Signed-off-by: Mark Brown --- drivers/regulator/fan53555.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index c282236959b1..85f46874eb49 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Voltage setting */ #define FAN53555_VSEL0 0x00 @@ -389,6 +390,18 @@ static int rk8602_voltages_setup_rockchip(struct fan53555_device_info *di) return 0; } +static inline unsigned int fan53555_map_mode(unsigned int mode) +{ + switch (mode) { + case FAN53555_REGULATOR_MODE_FORCE_PWM: + return REGULATOR_MODE_FAST; + case FAN53555_REGULATOR_MODE_AUTO: + return REGULATOR_MODE_NORMAL; + default: + return REGULATOR_MODE_INVALID; + } +} + static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di) { /* Init voltage range and step */ @@ -586,6 +599,17 @@ static int fan53555_device_setup(struct fan53555_device_info *di, return ret; } +static void fan53555_device_mode_map_setup(struct fan53555_device_info *di) +{ + switch (di->vendor) { + case FAN53555_VENDOR_SILERGY: + di->desc.of_map_mode = fan53555_map_mode; + break; + default: + break; + } +} + static int fan53555_regulator_register(struct fan53555_device_info *di, struct regulator_config *config) { @@ -686,6 +710,10 @@ static int fan53555_regulator_probe(struct i2c_client *client) if (!di) return -ENOMEM; + di->vendor = (uintptr_t)i2c_get_match_data(client); + + fan53555_device_mode_map_setup(di); + pdata = dev_get_platdata(&client->dev); if (!pdata) pdata = fan53555_parse_dt(&client->dev, np, &di->desc); @@ -695,7 +723,6 @@ static int fan53555_regulator_probe(struct i2c_client *client) "Platform data not found!\n"); di->regulator = pdata->regulator; - di->vendor = (uintptr_t)i2c_get_match_data(client); if (!dev_fwnode(&client->dev)) { /* if no ramp constraint set, get the pdata ramp_delay */ if (!di->regulator->constraints.ramp_delay) { -- cgit v1.2.3