[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250604-s2mpg1x-regulators-v1-12-6038740f49ae@linaro.org>
Date: Wed, 04 Jun 2025 16:25:51 +0100
From: André Draszik <andre.draszik@...aro.org>
To: Tudor Ambarus <tudor.ambarus@...aro.org>, Rob Herring <robh@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Krzysztof Kozlowski <krzk@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Lee Jones <lee@...nel.org>, Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>
Cc: Peter Griffin <peter.griffin@...aro.org>,
Will McVicker <willmcvicker@...gle.com>, kernel-team@...roid.com,
linux-kernel@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
devicetree@...r.kernel.org, linux-gpio@...r.kernel.org,
André Draszik <andre.draszik@...aro.org>
Subject: [PATCH 12/17] regulator: s2mps11: refactor handling of external
rail control
Refactor s2mps14_pmic_enable_ext_control() and s2mps11_of_parse_cb()
slightly as a preparation for adding S2MPG10 and S2MPG11 support, as
both of those PMICs also support control of rails via GPIOs.
Signed-off-by: André Draszik <andre.draszik@...aro.org>
---
drivers/regulator/s2mps11.c | 86 ++++++++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 29 deletions(-)
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index d3739526add3c966eb2979b9be2e543b5ad9d89a..ff9124c998c685d9c598570148dca074e671a99b 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -328,27 +328,13 @@ static int s2mps11_regulator_set_suspend_disable(struct regulator_dev *rdev)
rdev->desc->enable_mask, state);
}
-static int s2mps11_of_parse_cb(struct device_node *np,
- const struct regulator_desc *desc,
- struct regulator_config *config)
+static int s2mps11_of_parse_gpiod(struct device_node *np,
+ const struct regulator_desc *desc,
+ struct regulator_config *config)
{
- const struct s2mps11_info *s2mps11 = config->driver_data;
struct gpio_desc *ena_gpiod;
int ret;
- if (s2mps11->dev_type == S2MPS14X)
- switch (desc->id) {
- case S2MPS14_LDO10:
- case S2MPS14_LDO11:
- case S2MPS14_LDO12:
- break;
-
- default:
- return 0;
- }
- else
- return 0;
-
ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np),
"samsung,ext-control", 0,
GPIOD_OUT_HIGH |
@@ -380,6 +366,28 @@ static int s2mps11_of_parse_cb(struct device_node *np,
return 0;
}
+static int s2mps11_of_parse_cb(struct device_node *np,
+ const struct regulator_desc *desc,
+ struct regulator_config *config)
+{
+ const struct s2mps11_info *s2mps11 = config->driver_data;
+
+ if (s2mps11->dev_type == S2MPS14X)
+ switch (desc->id) {
+ case S2MPS14_LDO10:
+ case S2MPS14_LDO11:
+ case S2MPS14_LDO12:
+ break;
+
+ default:
+ return 0;
+ }
+ else
+ return 0;
+
+ return s2mps11_of_parse_gpiod(np, desc, config);
+}
+
static const struct regulator_ops s2mps11_ldo_ops = {
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
@@ -903,10 +911,16 @@ static const struct regulator_desc s2mps15_regulators[] = {
};
static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11,
- struct regulator_dev *rdev)
+ struct regulator_dev *rdev)
{
- return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
- rdev->desc->enable_mask, S2MPS14_ENABLE_EXT_CONTROL);
+ int ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
+ rdev->desc->enable_mask,
+ S2MPS14_ENABLE_EXT_CONTROL);
+ if (ret < 0)
+ return dev_err_probe(rdev_get_dev(rdev), ret,
+ "failed to enable GPIO control over %d/%s\n",
+ rdev->desc->id, rdev->desc->name);
+ return 0;
}
static int s2mpu02_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
@@ -1244,6 +1258,26 @@ static const struct regulator_desc s2mpu05_regulators[] = {
regulator_desc_s2mpu05_buck45(5),
};
+static int s2mps11_handle_ext_control(struct s2mps11_info *s2mps11,
+ struct regulator_dev *rdev)
+{
+ int ret;
+
+ switch (s2mps11->dev_type) {
+ case S2MPS14X:
+ if (!rdev->ena_pin)
+ return 0;
+
+ ret = s2mps14_pmic_enable_ext_control(s2mps11, rdev);
+ break;
+
+ default:
+ return 0;
+ }
+
+ return ret;
+}
+
static int s2mps11_pmic_probe(struct platform_device *pdev)
{
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
@@ -1314,15 +1348,9 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
regulators[i].id,
regulators[i].name);
- if (regulator->ena_pin) {
- ret = s2mps14_pmic_enable_ext_control(s2mps11,
- regulator);
- if (ret < 0)
- return dev_err_probe(&pdev->dev, ret,
- "failed to enable GPIO control over %d/%s\n",
- regulator->desc->id,
- regulator->desc->name);
- }
+ ret = s2mps11_handle_ext_control(s2mps11, regulator);
+ if (ret < 0)
+ return ret;
}
return 0;
--
2.49.0.1204.g71687c7c1d-goog
Powered by blists - more mailing lists