Commit 9ae5cc75 authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown

regulator: s5m8767: Pass descriptor instead of GPIO number

Instead of passing a global GPIO number for the enable GPIO, pass
a descriptor looked up from the device tree node for the
regulator.

This regulator supports passing platform data, but enable/sleep
regulators are looked up from the device tree exclusively, so
we can need not touch other files.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5389ac0a
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
...@@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, ...@@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767,
return; return;
} }
if (!gpio_is_valid(rdata->ext_control_gpio)) { if (!rdata->ext_control_gpiod) {
dev_warn(s5m8767->dev, dev_warn(s5m8767->dev,
"ext-control for %s: GPIO not valid, ignoring\n", "ext-control for %s: GPIO not valid, ignoring\n",
rdata->reg_node->name); rdata->reg_node->name);
return; return;
} }
config->ena_gpio = rdata->ext_control_gpio; config->ena_gpiod = rdata->ext_control_gpiod;
config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
} }
/* /*
...@@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, ...@@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
continue; continue;
} }
rdata->ext_control_gpio = of_get_named_gpio(reg_np, rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(&pdev->dev,
"s5m8767,pmic-ext-control-gpios", 0); reg_np,
"s5m8767,pmic-ext-control-gpios",
0,
GPIOD_OUT_HIGH,
"s5m8767");
if (IS_ERR(rdata->ext_control_gpiod))
return PTR_ERR(rdata->ext_control_gpiod);
rdata->id = i; rdata->id = i;
rdata->initdata = of_get_regulator_init_data( rdata->initdata = of_get_regulator_init_data(
...@@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) ...@@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
config.driver_data = s5m8767; config.driver_data = s5m8767;
config.regmap = iodev->regmap_pmic; config.regmap = iodev->regmap_pmic;
config.of_node = pdata->regulators[i].reg_node; config.of_node = pdata->regulators[i].reg_node;
config.ena_gpio = -EINVAL; config.ena_gpiod = NULL;
config.ena_gpio_flags = 0; if (pdata->regulators[i].ext_control_gpiod)
config.ena_gpio_initialized = true;
if (gpio_is_valid(pdata->regulators[i].ext_control_gpio))
s5m8767_regulator_config_ext_control(s5m8767, s5m8767_regulator_config_ext_control(s5m8767,
&pdata->regulators[i], &config); &pdata->regulators[i], &config);
...@@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) ...@@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
return ret; return ret;
} }
if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { if (pdata->regulators[i].ext_control_gpiod) {
ret = s5m8767_enable_ext_control(s5m8767, rdev); ret = s5m8767_enable_ext_control(s5m8767, rdev);
if (ret < 0) { if (ret < 0) {
dev_err(s5m8767->dev, dev_err(s5m8767->dev,
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#define STEP_12_5_MV 12500 #define STEP_12_5_MV 12500
#define STEP_6_25_MV 6250 #define STEP_6_25_MV 6250
struct gpio_desc;
enum sec_device_type { enum sec_device_type {
S5M8751X, S5M8751X,
S5M8763X, S5M8763X,
...@@ -151,7 +153,7 @@ struct sec_regulator_data { ...@@ -151,7 +153,7 @@ struct sec_regulator_data {
int id; int id;
struct regulator_init_data *initdata; struct regulator_init_data *initdata;
struct device_node *reg_node; struct device_node *reg_node;
int ext_control_gpio; struct gpio_desc *ext_control_gpiod;
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment