All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/21] regulator: switch core to GPIO descriptors
@ 2018-02-12 13:16 Linus Walleij
  2018-02-12 13:16 ` [PATCH 01/21] regulator: core: Support passing an initialized GPIO enable descriptor Linus Walleij
                   ` (20 more replies)
  0 siblings, 21 replies; 73+ messages in thread
From: Linus Walleij @ 2018-02-12 13:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel, linux-gpio, Linus Walleij

While the regulator core mostly use GPIO descriptors
there are some rough edges we need to chisel down:

- The fixed regulator still passes a "ena_gpio" number
  from the global GPIO numberspace. This we want to get
  rid of. We do this by allowing drivers to pass in a
  descriptor instead, converting all drivers and platform
  data over and then only allowing that.

- The fixed regulator also has special platform data or
  device tree properties for handling polarity inversion
  or open drain. We have pulled these special semantics
  into gpiolib in
  commit a603a2b8d86ee93ee2107da8ca75fd854fd4ff32
  "gpio: of: Add special quirk to parse regulator flags"
  so we can now move all drivers over to using only
  descriptors for this as well.

- The GPIO regulator has a similar complicated relationship
  to the global GPIO numberspace. We have merged helpers
  and convert these users too.

Some drivers needed to get a GPIO from an opaque DT node
i.e. a DT node without a corresponding device. For this
case we have added devm_gpiod_get_from_of_node() in the
v4.16-rc1 kernel so we can proceed with the conversion.

I have tried to loop in maintainers of the board files
affected as much as I can. It is uncertain if they even
care in some cases, with some PalmPilot-PDA-type ARM
devices I'm really starting to wonder if they are really
maintained and tested anymore, but I've still done my
best to not accidentally break them.

The patches can also be grabbed from this branch:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/log/?h=gpio-descriptors-regulator

I.e.
git pull git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git gpio-descriptors-regulator

to test it with any pet system.

Some ACKs and Tested-by's would be nice! I really don't
want to break anything if I can avoid it.

All patches have been boiled through the zeroday build
system so at least everything builds, but runtime testing
is paramount.

Linus Walleij (21):
  regulator: core: Support passing an initialized GPIO enable descriptor
  regulator: fixed: Convert to use GPIO descriptor only
  regulator: gpio: Get enable GPIO using GPIO descriptor
  regulator: da9055: Pass descriptor instead of GPIO number
  regulator: arizona-ldo1: Look up a descriptor and pass to the core
  regulator: da9211: Pass descriptors instead of GPIO numbers
  regulator: max8973: Pass descriptor instead of GPIO number
  regulator: max77686: Pass descriptor instead of GPIO number
  regulator: lm363x: Pass descriptor instead of GPIO number
  regulator: lp8788-ldo: Pass descriptor instead of GPIO number
  regulator: max8952: Pass descriptor instead of GPIO number
  regulator: pfuze100: Delete reference to ena_gpio
  regulator: s2mps11: Pass descriptor instead of GPIO number
  regulator: s5m8767: Pass descriptor instead of GPIO number
  regulator: tps65090: Pass descriptor instead of GPIO number
  regulator: wm8994: Pass descriptor instead of GPIO number
  regulator: core: Only support passing enable GPIO descriptors
  regulator: fixed/gpio: Pull inversion/OD into gpiolib
  regulator: fixed/gpio: Update device tree bindings
  regulator: gpio: Convert to fully use descriptors
  regulator: gpio: Simplify probe path

 .../bindings/regulator/fixed-regulator.txt         |  13 +-
 .../bindings/regulator/gpio-regulator.txt          |   4 +
 arch/arm/mach-imx/mach-mx21ads.c                   |  14 +-
 arch/arm/mach-imx/mach-mx27ads.c                   |  12 +-
 arch/arm/mach-mmp/brownstone.c                     |  13 +-
 arch/arm/mach-omap1/board-ams-delta.c              |  15 +-
 arch/arm/mach-omap2/pdata-quirks.c                 |  17 +-
 arch/arm/mach-pxa/em-x270.c                        |   2 -
 arch/arm/mach-pxa/ezx.c                            |  34 ++--
 arch/arm/mach-pxa/hx4700.c                         |  23 ++-
 arch/arm/mach-pxa/magician.c                       |  25 ++-
 arch/arm/mach-pxa/raumfeld.c                       |  13 +-
 arch/arm/mach-pxa/zeus.c                           |  24 ++-
 arch/arm/mach-s3c64xx/mach-crag6410-module.c       |  18 +-
 arch/arm/mach-s3c64xx/mach-crag6410.c              |   1 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c              |   1 -
 arch/blackfin/mach-bf537/boards/stamp.c            |  15 +-
 arch/sh/boards/mach-ecovec24/setup.c               |  29 +++-
 .../intel-mid/device_libs/platform_bcm43xx.c       |  20 ++-
 drivers/mfd/wm8994-core.c                          |   9 -
 drivers/regulator/arizona-ldo1.c                   |  19 +-
 drivers/regulator/core.c                           |  33 +---
 drivers/regulator/da9055-regulator.c               |   5 +-
 drivers/regulator/da9211-regulator.c               |  23 ++-
 drivers/regulator/fixed-helper.c                   |   1 -
 drivers/regulator/fixed.c                          |  43 ++---
 drivers/regulator/gpio-regulator.c                 | 193 ++++++++-------------
 drivers/regulator/lm363x-regulator.c               |  20 +--
 drivers/regulator/lp8788-ldo.c                     |  32 ++--
 drivers/regulator/max77686-regulator.c             |  19 +-
 drivers/regulator/max8952.c                        |  18 +-
 drivers/regulator/max8973-regulator.c              |  54 +++---
 drivers/regulator/pfuze100-regulator.c             |   1 -
 drivers/regulator/s2mps11.c                        |  46 ++---
 drivers/regulator/s5m8767.c                        |  26 +--
 drivers/regulator/tps65090-regulator.c             |  50 +++---
 drivers/regulator/wm8994-regulator.c               |  19 +-
 include/linux/mfd/da9055/pdata.h                   |   5 +-
 include/linux/mfd/lp8788.h                         |  16 --
 include/linux/mfd/samsung/core.h                   |   4 +-
 include/linux/mfd/tps65090.h                       |   8 +-
 include/linux/mfd/wm8994/pdata.h                   |   3 -
 include/linux/regulator/arizona-ldo1.h             |   3 -
 include/linux/regulator/da9211.h                   |   4 +-
 include/linux/regulator/driver.h                   |  11 +-
 include/linux/regulator/fixed.h                    |  13 --
 include/linux/regulator/gpio-regulator.h           |  18 +-
 include/linux/regulator/max8952.h                  |   1 -
 48 files changed, 519 insertions(+), 471 deletions(-)

-- 
2.14.3

^ permalink raw reply	[flat|nested] 73+ messages in thread
* Applied "regulator: s2mps11: Pass descriptor instead of GPIO number" to the regulator tree
@ 2018-11-15 19:47 Mark Brown
  0 siblings, 0 replies; 73+ messages in thread
From: Mark Brown @ 2018-11-15 19:47 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Sangbeom Kim, Chanwoo Choi, Bartlomiej Zolnierkiewicz,
	Krzysztof Kozlowski, Krzysztof Kozlowski, Mark Brown,
	linux-kernel

The patch

   regulator: s2mps11: Pass descriptor instead of GPIO number

has been applied to the regulator tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 1c984942f0a480ed41635528234b8bc672f6bac7 Mon Sep 17 00:00:00 2001
From: Linus Walleij <linus.walleij@linaro.org>
Date: Thu, 15 Nov 2018 09:01:17 +0100
Subject: [PATCH] regulator: s2mps11: Pass descriptor instead of GPIO number

Instead of passing a global GPIO number for the enable GPIO, pass
a descriptor looked up with the standard devm_gpiod_get_optional()
call.

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.

Tested on Odroid XU3 (with s2mps11 although not using any GPIOs
for regulators, so at least default paths are not broken).

Cc: Sangbeom Kim <sbkim73@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Tested-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/s2mps11.c | 46 ++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 5bb6f4ca48db..6fec45897194 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -5,7 +5,7 @@
 
 #include <linux/bug.h>
 #include <linux/err.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -14,7 +14,6 @@
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>
-#include <linux/of_gpio.h>
 #include <linux/mfd/samsung/core.h>
 #include <linux/mfd/samsung/s2mps11.h>
 #include <linux/mfd/samsung/s2mps13.h>
@@ -44,7 +43,7 @@ struct s2mps11_info {
 	 * Array (size: number of regulators) with GPIO-s for external
 	 * sleep control.
 	 */
-	int *ext_control_gpio;
+	struct gpio_desc **ext_control_gpiod;
 };
 
 static int get_ramp_delay(int ramp_delay)
@@ -511,7 +510,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
 	case S2MPS14X:
 		if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
 			val = S2MPS14_ENABLE_SUSPEND;
-		else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
+		else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)])
 			val = S2MPS14_ENABLE_EXT_CONTROL;
 		else
 			val = rdev->desc->enable_mask;
@@ -805,7 +804,7 @@ static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11,
 static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 		struct of_regulator_match *rdata, struct s2mps11_info *s2mps11)
 {
-	int *gpio = s2mps11->ext_control_gpio;
+	struct gpio_desc **gpio = s2mps11->ext_control_gpiod;
 	unsigned int i;
 	unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11,
 		S2MPS14_LDO12 };
@@ -816,11 +815,20 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 		if (!rdata[reg].init_data || !rdata[reg].of_node)
 			continue;
 
-		gpio[reg] = of_get_named_gpio(rdata[reg].of_node,
-				"samsung,ext-control-gpios", 0);
-		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);
+		gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev,
+				rdata[reg].of_node,
+				"samsung,ext-control-gpios",
+				0,
+				GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
+				"s2mps11-regulator");
+		if (IS_ERR(gpio[reg])) {
+			dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n",
+				reg, rdata[reg].name);
+			continue;
+		}
+		if (gpio[reg])
+			dev_dbg(&pdev->dev, "Using GPIO for ext-control over %d/%s\n",
+				reg, rdata[reg].name);
 	}
 }
 
@@ -1126,17 +1134,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	s2mps11->ext_control_gpio = devm_kmalloc_array(&pdev->dev,
-			rdev_num, sizeof(*s2mps11->ext_control_gpio),
+	s2mps11->ext_control_gpiod = devm_kmalloc_array(&pdev->dev,
+			rdev_num, sizeof(*s2mps11->ext_control_gpiod),
 			GFP_KERNEL);
-	if (!s2mps11->ext_control_gpio)
+	if (!s2mps11->ext_control_gpiod)
 		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 < rdev_num; i++)
-		s2mps11->ext_control_gpio[i] = -EINVAL;
 
 	if (!iodev->dev->of_node) {
 		if (iodev->pdata) {
@@ -1166,8 +1168,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
 	config.dev = &pdev->dev;
 	config.regmap = iodev->regmap_pmic;
 	config.driver_data = s2mps11;
-	config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
-	config.ena_gpio_initialized = true;
 	for (i = 0; i < rdev_num; i++) {
 		struct regulator_dev *regulator;
 
@@ -1178,7 +1178,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
 			config.init_data = rdata[i].init_data;
 			config.of_node = rdata[i].of_node;
 		}
-		config.ena_gpio = s2mps11->ext_control_gpio[i];
+		config.ena_gpiod = s2mps11->ext_control_gpiod[i];
 
 		regulator = devm_regulator_register(&pdev->dev,
 						&regulators[i], &config);
@@ -1189,7 +1189,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
 			goto out;
 		}
 
-		if (gpio_is_valid(s2mps11->ext_control_gpio[i])) {
+		if (s2mps11->ext_control_gpiod[i]) {
 			ret = s2mps14_pmic_enable_ext_control(s2mps11,
 					regulator);
 			if (ret < 0) {
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2018-11-15 19:47 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 13:16 [PATCH 00/21] regulator: switch core to GPIO descriptors Linus Walleij
2018-02-12 13:16 ` [PATCH 01/21] regulator: core: Support passing an initialized GPIO enable descriptor Linus Walleij
2018-02-16 17:12   ` Applied "regulator: core: Support passing an initialized GPIO enable descriptor" to the regulator tree Mark Brown
2018-02-16 17:12     ` Mark Brown
2018-02-12 13:16 ` [PATCH 02/21] regulator: fixed: Convert to use GPIO descriptor only Linus Walleij
2018-02-12 15:13   ` Andy Shevchenko
2018-04-19 12:36     ` Linus Walleij
2018-02-12 13:16 ` [PATCH 03/21] regulator: gpio: Get enable GPIO using GPIO descriptor Linus Walleij
2018-05-29 14:59   ` Applied "regulator: gpio: Get enable GPIO using GPIO descriptor" to the regulator tree Mark Brown
2018-05-29 14:59     ` Mark Brown
2018-02-12 13:17 ` [PATCH 04/21] regulator: da9055: Pass descriptor instead of GPIO number Linus Walleij
2018-02-12 14:59   ` Lee Jones
2018-02-16 17:12   ` Applied "regulator: da9055: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-02-16 17:12     ` Mark Brown
2018-02-12 13:17 ` [PATCH 05/21] regulator: arizona-ldo1: Look up a descriptor and pass to the core Linus Walleij
2018-02-13 11:06   ` Charles Keepax
2018-02-13 11:06     ` Charles Keepax
2018-04-19 13:43     ` Linus Walleij
2018-04-19 15:02       ` Charles Keepax
2018-04-19 15:02         ` Charles Keepax
2018-02-13 11:51   ` Charles Keepax
2018-02-13 11:51     ` Charles Keepax
2018-02-12 13:17 ` [PATCH 06/21] regulator: da9211: Pass descriptors instead of GPIO numbers Linus Walleij
2018-02-16 17:12   ` Applied "regulator: da9211: Pass descriptors instead of GPIO numbers" to the regulator tree Mark Brown
2018-02-16 17:12     ` Mark Brown
2018-02-12 13:17 ` [PATCH 07/21] regulator: max8973: Pass descriptor instead of GPIO number Linus Walleij
2018-05-24 19:14   ` Applied "regulator: max8973: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-24 19:14     ` Mark Brown
2018-02-12 13:17 ` [PATCH 08/21] regulator: max77686: Pass descriptor instead of GPIO number Linus Walleij
2018-02-12 13:37   ` Krzysztof Kozlowski
2018-02-12 13:17 ` [PATCH 09/21] regulator: lm363x: " Linus Walleij
2018-05-24 19:14   ` Applied "regulator: lm363x: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-24 19:14     ` Mark Brown
2018-02-12 13:17 ` [PATCH 10/21] regulator: lp8788-ldo: Pass descriptor instead of GPIO number Linus Walleij
2018-02-12 14:59   ` Lee Jones
2018-05-24 19:14   ` Applied "regulator: lp8788-ldo: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-24 19:14     ` Mark Brown
2018-02-12 13:17 ` [PATCH 11/21] regulator: max8952: Pass descriptor instead of GPIO number Linus Walleij
2018-05-24 19:14   ` Applied "regulator: max8952: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-24 19:14     ` Mark Brown
2018-02-12 13:17 ` [PATCH 12/21] regulator: pfuze100: Delete reference to ena_gpio Linus Walleij
2018-05-24 19:14   ` Applied "regulator: pfuze100: Delete reference to ena_gpio" to the regulator tree Mark Brown
2018-05-24 19:14     ` Mark Brown
2018-02-12 13:17 ` [PATCH 13/21] regulator: s2mps11: Pass descriptor instead of GPIO number Linus Walleij
2018-05-17 16:41   ` Applied "regulator: s2mps11: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-17 16:41     ` Mark Brown
2018-02-12 13:17 ` [PATCH 14/21] regulator: s5m8767: Pass descriptor instead of GPIO number Linus Walleij
2018-02-12 14:58   ` Lee Jones
2018-05-24 19:13   ` Applied "regulator: s5m8767: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-24 19:13     ` Mark Brown
2018-02-12 13:17 ` [PATCH 15/21] regulator: tps65090: Pass descriptor instead of GPIO number Linus Walleij
2018-02-12 14:58   ` Lee Jones
2018-05-24 19:13   ` Applied "regulator: tps65090: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown
2018-05-24 19:13     ` Mark Brown
2018-02-12 13:17 ` [PATCH 16/21] regulator: wm8994: Pass descriptor instead of GPIO number Linus Walleij
2018-02-12 14:58   ` Lee Jones
2018-02-13 11:11   ` Charles Keepax
2018-02-13 11:11     ` Charles Keepax
2018-04-19 13:55     ` Linus Walleij
2018-04-19 14:05       ` Mark Brown
2018-04-19 15:01       ` [PATCH] ARM: s3c64xx: Tidy up handling of regulator GPIO lookups Charles Keepax
2018-04-19 15:01         ` Charles Keepax
2018-05-14  5:54         ` Linus Walleij
2018-02-13 11:52   ` [PATCH 16/21] regulator: wm8994: Pass descriptor instead of GPIO number Charles Keepax
2018-02-13 11:52     ` Charles Keepax
2018-02-12 13:17 ` [PATCH 17/21] regulator: core: Only support passing enable GPIO descriptors Linus Walleij
2018-02-12 13:17 ` [PATCH 18/21] regulator: fixed/gpio: Pull inversion/OD into gpiolib Linus Walleij
2018-02-17  9:59   ` Robert Jarzmik
2018-02-12 13:17 ` [PATCH 19/21] regulator: fixed/gpio: Update device tree bindings Linus Walleij
2018-02-19  2:41   ` Rob Herring
2018-02-12 13:17 ` [PATCH 20/21] regulator: gpio: Convert to fully use descriptors Linus Walleij
2018-02-12 13:17 ` [PATCH 21/21] regulator: gpio: Simplify probe path Linus Walleij
2018-11-15 19:47 Applied "regulator: s2mps11: Pass descriptor instead of GPIO number" to the regulator tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.