@@ -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;
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@linaro.org> --- drivers/regulator/s2mps11.c | 86 ++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 29 deletions(-)