diff mbox series

[05/21] regulator: arizona-ldo1: Look up a descriptor and pass to the core

Message ID 20180212131717.27193-6-linus.walleij@linaro.org
State New
Headers show
Series regulator: switch core to GPIO descriptors | expand

Commit Message

Linus Walleij Feb. 12, 2018, 1:17 p.m. UTC
Instead of passing a global GPIO number, pass a descriptor looked
up with the standard devm_gpiod_get_optional() call.

We have augmented the GPIO core to look up the regulator special
GPIO "wlf,ldoena" in a separate patch.

Cc: patches@opensource.cirrus.com
Cc: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/regulator/arizona-ldo1.c       | 19 ++++++-------------
 include/linux/regulator/arizona-ldo1.h |  3 ---
 2 files changed, 6 insertions(+), 16 deletions(-)

-- 
2.14.3

Comments

Linus Walleij April 19, 2018, 1:43 p.m. UTC | #1
On Tue, Feb 13, 2018 at 12:06 PM, Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:
> On Mon, Feb 12, 2018 at 02:17:01PM +0100, Linus Walleij wrote:

>> Instead of passing a global GPIO number, pass a descriptor looked

>> up with the standard devm_gpiod_get_optional() call.

>>

>> We have augmented the GPIO core to look up the regulator special

>> GPIO "wlf,ldoena" in a separate patch.

>>

>> Cc: patches@opensource.cirrus.com

>> Cc: Richard Fitzgerald <rf@opensource.cirrus.com>

>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

>> ---

>>  drivers/regulator/arizona-ldo1.c       | 19 ++++++-------------

>>  include/linux/regulator/arizona-ldo1.h |  3 ---

>>  2 files changed, 6 insertions(+), 16 deletions(-)

>>

>

> Does this patch not also need to update the hookups in

> arch/arm/mach-s3c64xx/mach-crag6410-module.c? There is

> wm5102_reva_pdata and wm5102_pdata both of which use the ldoena

> you are removing here?


OK fixed this!

> Also looking at this more you will need to you

> devm_gpio_get_from_of_node here since the device tree binding is

> for wlf,ldoena not wlf,ldoena-gpio. So this patch currently

> breaks the binding.


Actually not, because I fixed that in  the special quirk patch
6a537d48461d
"gpio: of: Support regulator nonstandard GPIO properties"
as mentioned in the commit message. (Will clarify.)

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 96fddfff5dc4..f6d6a4ad9e8a 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -17,12 +17,11 @@ 
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>
-#include <linux/gpio.h>
 #include <linux/slab.h>
 
 #include <linux/regulator/arizona-ldo1.h>
@@ -198,16 +197,6 @@  static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
 	struct device_node *init_node, *dcvdd_node;
 	struct regulator_init_data *init_data;
 
-	pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
-	if (pdata->ldoena < 0) {
-		dev_warn(config->dev,
-			 "LDOENA GPIO property missing/malformed: %d\n",
-			 pdata->ldoena);
-		pdata->ldoena = 0;
-	} else {
-		config->ena_gpio_initialized = true;
-	}
-
 	init_node = of_get_child_by_name(np, "ldo1");
 	dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0);
 
@@ -264,7 +253,11 @@  static int arizona_ldo1_common_init(struct platform_device *pdev,
 		}
 	}
 
-	config.ena_gpio = pdata->ldoena;
+	/* We assume that high output = regulator off */
+	config.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "wlf,ldoena",
+						   GPIOD_OUT_HIGH);
+	if (IS_ERR(config.ena_gpiod))
+		return PTR_ERR(config.ena_gpiod);
 
 	if (pdata->init_data)
 		config.init_data = pdata->init_data;
diff --git a/include/linux/regulator/arizona-ldo1.h b/include/linux/regulator/arizona-ldo1.h
index c685f1277c63..fe74ab9990e6 100644
--- a/include/linux/regulator/arizona-ldo1.h
+++ b/include/linux/regulator/arizona-ldo1.h
@@ -14,9 +14,6 @@ 
 struct regulator_init_data;
 
 struct arizona_ldo1_pdata {
-	/** GPIO controlling LDOENA, if any */
-	int ldoena;
-
 	/** Regulator configuration for LDO1 */
 	const struct regulator_init_data *init_data;
 };