* [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control
@ 2014-04-30 8:40 Krzysztof Kozlowski
2014-04-30 8:40 ` [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14 Krzysztof Kozlowski
2014-05-01 17:53 ` [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2014-04-30 8:40 UTC (permalink / raw)
To: Sangbeom Kim, Liam Girdwood, Mark Brown, linux-kernel
Cc: Sachin Kamat, Kyungmin Park, Marek Szyprowski,
Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski
GPIO 0 is a valid GPIO so allow using it as external control for
regulator.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/regulator/s5m8767.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 5daa06626f16..c79af943a5c0 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -528,16 +528,6 @@ static int s5m8767_pmic_dt_parse_ds_gpio(struct sec_pmic_dev *iodev,
return 0;
}
-static void s5m8767_pmic_dt_parse_ext_control_gpio(struct sec_pmic_dev *iodev,
- struct sec_regulator_data *rdata,
- struct device_node *reg_np)
-{
- rdata->ext_control_gpio = of_get_named_gpio(reg_np,
- "s5m8767,pmic-ext-control-gpios", 0);
- if (!gpio_is_valid(rdata->ext_control_gpio))
- rdata->ext_control_gpio = 0;
-}
-
static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
struct sec_platform_data *pdata)
{
@@ -586,7 +576,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
continue;
}
- s5m8767_pmic_dt_parse_ext_control_gpio(iodev, rdata, reg_np);
+ rdata->ext_control_gpio = of_get_named_gpio(reg_np,
+ "s5m8767,pmic-ext-control-gpios", 0);
rdata->id = i;
rdata->initdata = of_get_regulator_init_data(
@@ -959,8 +950,9 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
config.driver_data = s5m8767;
config.regmap = iodev->regmap_pmic;
config.of_node = pdata->regulators[i].reg_node;
- config.ena_gpio = config.ena_gpio_flags = 0;
- if (pdata->regulators[i].ext_control_gpio)
+ config.ena_gpio = -EINVAL;
+ config.ena_gpio_flags = 0;
+ if (gpio_is_valid(pdata->regulators[i].ext_control_gpio))
s5m8767_regulator_config_ext_control(s5m8767,
&pdata->regulators[i], &config);
@@ -973,7 +965,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
return ret;
}
- if (pdata->regulators[i].ext_control_gpio) {
+ if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) {
ret = s5m8767_enable_ext_control(s5m8767, rdev);
if (ret < 0) {
dev_err(s5m8767->dev,
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14
2014-04-30 8:40 [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Krzysztof Kozlowski
@ 2014-04-30 8:40 ` Krzysztof Kozlowski
2014-05-01 17:53 ` Mark Brown
2014-05-01 17:53 ` [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2014-04-30 8:40 UTC (permalink / raw)
To: Sangbeom Kim, Liam Girdwood, Mark Brown, linux-kernel
Cc: Sachin Kamat, Kyungmin Park, Marek Szyprowski,
Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski
GPIO 0 is a valid GPIO so allow using it as external control for
S2MPS14 regulators.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/regulator/s2mps11.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 6dad0aa74a47..1583d4eaf911 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -412,7 +412,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
val = S2MPS14_ENABLE_SUSPEND;
- else if (s2mps11->ext_control_gpio[rdev_get_id(rdev)])
+ else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
val = S2MPS14_ENABLE_EXT_CONTROL;
else
val = rdev->desc->enable_mask;
@@ -593,9 +593,7 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
gpio[reg] = of_get_named_gpio(rdata[reg].of_node,
"samsung,ext-control-gpios", 0);
- if (!gpio_is_valid(gpio[reg]))
- gpio[reg] = 0;
- else
+ if (gpio_is_valid(gpio[reg]))
dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n",
gpio[reg], reg, rdata[reg].name);
}
@@ -658,6 +656,12 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
GFP_KERNEL);
if (!s2mps11->ext_control_gpio)
return -ENOMEM;
+ /*
+ * 0 is a valid GPIO so initialize all GPIO-s to negative value
+ * to indicate that external control won't be used for this regulator.
+ */
+ for (i = 0; i < s2mps11->rdev_num; i++)
+ s2mps11->ext_control_gpio[i] = -EINVAL;
if (!iodev->dev->of_node) {
if (iodev->pdata) {
@@ -687,6 +691,7 @@ common_reg:
config.dev = &pdev->dev;
config.regmap = iodev->regmap_pmic;
config.driver_data = s2mps11;
+ config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
for (i = 0; i < s2mps11->rdev_num; i++) {
struct regulator_dev *regulator;
@@ -697,12 +702,7 @@ common_reg:
config.init_data = rdata[i].init_data;
config.of_node = rdata[i].of_node;
}
-
- if (s2mps11->ext_control_gpio[i]) {
- config.ena_gpio = s2mps11->ext_control_gpio[i];
- config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
- } else
- config.ena_gpio = config.ena_gpio_flags = 0;
+ config.ena_gpio = s2mps11->ext_control_gpio[i];
regulator = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
@@ -713,7 +713,7 @@ common_reg:
goto out;
}
- if (s2mps11->ext_control_gpio[i]) {
+ if (gpio_is_valid(s2mps11->ext_control_gpio[i])) {
ret = s2mps14_pmic_enable_ext_control(s2mps11,
regulator);
if (ret < 0) {
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control
2014-04-30 8:40 [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Krzysztof Kozlowski
2014-04-30 8:40 ` [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14 Krzysztof Kozlowski
@ 2014-05-01 17:53 ` Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-05-01 17:53 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Sangbeom Kim, Liam Girdwood, linux-kernel, Sachin Kamat,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
On Wed, Apr 30, 2014 at 10:40:41AM +0200, Krzysztof Kozlowski wrote:
> GPIO 0 is a valid GPIO so allow using it as external control for
> regulator.
Applied, thanks. This is only safe because we don't have any actual
users of platform data - if we do have users of platform data then
things get a bit more tricky since the expectation with platform data is
that zero is the default/do nothing case.
Really if this is an issue it is better to fix things so that GPIO 0
doesn't get used for anything, with DT there's no need to do that since
the numbers are all dynamic but it does get a little more tricky in the
platform data case sadly.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14
2014-04-30 8:40 ` [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14 Krzysztof Kozlowski
@ 2014-05-01 17:53 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-05-01 17:53 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Sangbeom Kim, Liam Girdwood, linux-kernel, Sachin Kamat,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz
[-- Attachment #1: Type: text/plain, Size: 176 bytes --]
On Wed, Apr 30, 2014 at 10:40:42AM +0200, Krzysztof Kozlowski wrote:
> GPIO 0 is a valid GPIO so allow using it as external control for
> S2MPS14 regulators.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-01 18:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 8:40 [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Krzysztof Kozlowski
2014-04-30 8:40 ` [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14 Krzysztof Kozlowski
2014-05-01 17:53 ` Mark Brown
2014-05-01 17:53 ` [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®