All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] add pinmuxing support for pins in AXP209 and AXP813 PMICs
@ 2017-09-26 12:17 ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

The AXP209 and AXP813 PMICs have several pins (respectively 3 and 2) that can
be used either as GPIOs or for other purposes (ADC or LDO here).

We already have a GPIO driver for the GPIO use of those pins on the AXP209.
Let's "upgrade" this driver to support all the functions these pins can have.

Then we add support to this driver for the AXP813 which is slighlty different
(basically a different offset in a register and one less pin).

This is a v2 to a first version that was sent in November 2016.

v2:
  - add support for AXP813 pins,
  - split into more patches so it is easier to follow the modifications,
  - reorder of some patches,
  - register all pins within the same range instead of a range per pin,

Thanks,
Quentin

Maxime Ripard (1):
  ARM: dts: add dtsi for AXP813 PMIC

Quentin Schulz (9):
  pinctrl: move gpio-axp209 to pinctrl
  pinctrl: axp209: add pinctrl features
  pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  pinctrl: axp209: rename everything from gpio to pctl
  pinctrl: axp209: add programmable gpio_status_offset
  pinctrl: axp209: add support for AXP813 GPIOs
  mfd: axp20x: add pinctrl cell for AXP813
  ARM: dts: sun8i: a711: include axp813 dtsi
  ARM: dts: sun8i: bananapi-m3: include axp813 dtsi

 Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  67 +-
 arch/arm/boot/dts/axp813.dtsi                                |  58 +-
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts                 |   4 +-
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts                    |   2 +-
 drivers/gpio/Kconfig                                         |   6 +-
 drivers/gpio/Makefile                                        |   1 +-
 drivers/gpio/gpio-axp209.c                                   | 188 +--
 drivers/mfd/axp20x.c                                         |   3 +-
 drivers/pinctrl/Kconfig                                      |   6 +-
 drivers/pinctrl/Makefile                                     |   1 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 610 +++++++-
 12 files changed, 750 insertions(+), 226 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
 create mode 100644 arch/arm/boot/dts/axp813.dtsi
 delete mode 100644 drivers/gpio/gpio-axp209.c
 create mode 100644 drivers/pinctrl/pinctrl-axp209.c

base-commit: 73527316e3fdde8a210b8ab66c1bf48538cf6b09
-- 
git-series 0.9.1

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

* [PATCH v2 00/10] add pinmuxing support for pins in AXP209 and AXP813 PMICs
@ 2017-09-26 12:17 ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

The AXP209 and AXP813 PMICs have several pins (respectively 3 and 2) that can
be used either as GPIOs or for other purposes (ADC or LDO here).

We already have a GPIO driver for the GPIO use of those pins on the AXP209.
Let's "upgrade" this driver to support all the functions these pins can have.

Then we add support to this driver for the AXP813 which is slighlty different
(basically a different offset in a register and one less pin).

This is a v2 to a first version that was sent in November 2016.

v2:
  - add support for AXP813 pins,
  - split into more patches so it is easier to follow the modifications,
  - reorder of some patches,
  - register all pins within the same range instead of a range per pin,

Thanks,
Quentin

Maxime Ripard (1):
  ARM: dts: add dtsi for AXP813 PMIC

Quentin Schulz (9):
  pinctrl: move gpio-axp209 to pinctrl
  pinctrl: axp209: add pinctrl features
  pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  pinctrl: axp209: rename everything from gpio to pctl
  pinctrl: axp209: add programmable gpio_status_offset
  pinctrl: axp209: add support for AXP813 GPIOs
  mfd: axp20x: add pinctrl cell for AXP813
  ARM: dts: sun8i: a711: include axp813 dtsi
  ARM: dts: sun8i: bananapi-m3: include axp813 dtsi

 Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  67 +-
 arch/arm/boot/dts/axp813.dtsi                                |  58 +-
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts                 |   4 +-
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts                    |   2 +-
 drivers/gpio/Kconfig                                         |   6 +-
 drivers/gpio/Makefile                                        |   1 +-
 drivers/gpio/gpio-axp209.c                                   | 188 +--
 drivers/mfd/axp20x.c                                         |   3 +-
 drivers/pinctrl/Kconfig                                      |   6 +-
 drivers/pinctrl/Makefile                                     |   1 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 610 +++++++-
 12 files changed, 750 insertions(+), 226 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
 create mode 100644 arch/arm/boot/dts/axp813.dtsi
 delete mode 100644 drivers/gpio/gpio-axp209.c
 create mode 100644 drivers/pinctrl/pinctrl-axp209.c

base-commit: 73527316e3fdde8a210b8ab66c1bf48538cf6b09
-- 
git-series 0.9.1

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

To prepare the driver for the upcoming pinctrl features, move the GPIO
driver AXP209 from GPIO to pinctrl subsystem.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  30 +-
 drivers/gpio/Kconfig                                         |   6 +-
 drivers/gpio/Makefile                                        |   1 +-
 drivers/gpio/gpio-axp209.c                                   | 188 +-------
 drivers/pinctrl/Kconfig                                      |   6 +-
 drivers/pinctrl/Makefile                                     |   1 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 188 +++++++-
 8 files changed, 225 insertions(+), 225 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
 delete mode 100644 drivers/gpio/gpio-axp209.c
 create mode 100644 drivers/pinctrl/pinctrl-axp209.c

diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
deleted file mode 100644
index a661130..0000000
--- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-AXP209 GPIO controller
-
-This driver follows the usual GPIO bindings found in
-Documentation/devicetree/bindings/gpio/gpio.txt
-
-Required properties:
-- compatible: Should be "x-powers,axp209-gpio"
-- #gpio-cells: Should be two. The first cell is the pin number and the
-  second is the GPIO flags.
-- gpio-controller: Marks the device node as a GPIO controller.
-
-This node must be a subnode of the axp20x PMIC, documented in
-Documentation/devicetree/bindings/mfd/axp20x.txt
-
-Example:
-
-axp209: pmic@34 {
-	compatible = "x-powers,axp209";
-	reg = <0x34>;
-	interrupt-parent = <&nmi_intc>;
-	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
-	interrupt-controller;
-	#interrupt-cells = <1>;
-
-	axp_gpio: gpio {
-		compatible = "x-powers,axp209-gpio";
-		gpio-controller;
-		#gpio-cells = <2>;
-	};
-};
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
new file mode 100644
index 0000000..a661130
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -0,0 +1,30 @@
+AXP209 GPIO controller
+
+This driver follows the usual GPIO bindings found in
+Documentation/devicetree/bindings/gpio/gpio.txt
+
+Required properties:
+- compatible: Should be "x-powers,axp209-gpio"
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+- gpio-controller: Marks the device node as a GPIO controller.
+
+This node must be a subnode of the axp20x PMIC, documented in
+Documentation/devicetree/bindings/mfd/axp20x.txt
+
+Example:
+
+axp209: pmic@34 {
+	compatible = "x-powers,axp209";
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	axp_gpio: gpio {
+		compatible = "x-powers,axp209-gpio";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+};
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 3f80f16..ad88178 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -122,12 +122,6 @@ config GPIO_ATH79
 	  Select this option to enable GPIO driver for
 	  Atheros AR71XX/AR724X/AR913X SoC devices.
 
-config GPIO_AXP209
-	tristate "X-Powers AXP209 PMIC GPIO Support"
-	depends on MFD_AXP20X
-	help
-	  Say yes to enable GPIO support for the AXP209 PMIC
-
 config GPIO_BCM_KONA
 	bool "Broadcom Kona GPIO"
 	depends on OF_GPIO && (ARCH_BCM_MOBILE || COMPILE_TEST)
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index aeb70e9..f63631a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_GPIO_AMDPT)	+= gpio-amdpt.o
 obj-$(CONFIG_GPIO_ARIZONA)	+= gpio-arizona.o
 obj-$(CONFIG_GPIO_ATH79)	+= gpio-ath79.o
 obj-$(CONFIG_GPIO_ASPEED)	+= gpio-aspeed.o
-obj-$(CONFIG_GPIO_AXP209)	+= gpio-axp209.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BD9571MWV)	+= gpio-bd9571mwv.o
 obj-$(CONFIG_GPIO_BRCMSTB)	+= gpio-brcmstb.o
diff --git a/drivers/gpio/gpio-axp209.c b/drivers/gpio/gpio-axp209.c
deleted file mode 100644
index 4a346b7..0000000
--- a/drivers/gpio/gpio-axp209.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * AXP20x GPIO driver
- *
- * Copyright (C) 2016 Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/bitops.h>
-#include <linux/device.h>
-#include <linux/gpio/driver.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/mfd/axp20x.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/platform_device.h>
-#include <linux/regmap.h>
-#include <linux/slab.h>
-
-#define AXP20X_GPIO_FUNCTIONS		0x7
-#define AXP20X_GPIO_FUNCTION_OUT_LOW	0
-#define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
-#define AXP20X_GPIO_FUNCTION_INPUT	2
-
-struct axp20x_gpio {
-	struct gpio_chip	chip;
-	struct regmap		*regmap;
-};
-
-static int axp20x_gpio_get_reg(unsigned offset)
-{
-	switch (offset) {
-	case 0:
-		return AXP20X_GPIO0_CTRL;
-	case 1:
-		return AXP20X_GPIO1_CTRL;
-	case 2:
-		return AXP20X_GPIO2_CTRL;
-	}
-
-	return -EINVAL;
-}
-
-static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  AXP20X_GPIO_FUNCTION_INPUT);
-}
-
-static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	unsigned int val;
-	int ret;
-
-	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
-	if (ret)
-		return ret;
-
-	return !!(val & BIT(offset + 4));
-}
-
-static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	unsigned int val;
-	int reg, ret;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	ret = regmap_read(gpio->regmap, reg, &val);
-	if (ret)
-		return ret;
-
-	/*
-	 * This shouldn't really happen if the pin is in use already,
-	 * or if it's not in use yet, it doesn't matter since we're
-	 * going to change the value soon anyway. Default to output.
-	 */
-	if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
-		return 0;
-
-	/*
-	 * The GPIO directions are the three lowest values.
-	 * 2 is input, 0 and 1 are output
-	 */
-	return val & 2;
-}
-
-static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
-			      int value)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
-				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
-}
-
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
-			    int value)
-{
-	axp20x_gpio_output(chip, offset, value);
-}
-
-static int axp20x_gpio_probe(struct platform_device *pdev)
-{
-	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-	struct axp20x_gpio *gpio;
-	int ret;
-
-	if (!of_device_is_available(pdev->dev.of_node))
-		return -ENODEV;
-
-	if (!axp20x) {
-		dev_err(&pdev->dev, "Parent drvdata not set\n");
-		return -EINVAL;
-	}
-
-	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
-	if (!gpio)
-		return -ENOMEM;
-
-	gpio->chip.base			= -1;
-	gpio->chip.can_sleep		= true;
-	gpio->chip.parent		= &pdev->dev;
-	gpio->chip.label		= dev_name(&pdev->dev);
-	gpio->chip.owner		= THIS_MODULE;
-	gpio->chip.get			= axp20x_gpio_get;
-	gpio->chip.get_direction	= axp20x_gpio_get_direction;
-	gpio->chip.set			= axp20x_gpio_set;
-	gpio->chip.direction_input	= axp20x_gpio_input;
-	gpio->chip.direction_output	= axp20x_gpio_output;
-	gpio->chip.ngpio		= 3;
-
-	gpio->regmap = axp20x->regmap;
-
-	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
-		return ret;
-	}
-
-	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
-
-	return 0;
-}
-
-static const struct of_device_id axp20x_gpio_match[] = {
-	{ .compatible = "x-powers,axp209-gpio" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
-
-static struct platform_driver axp20x_gpio_driver = {
-	.probe		= axp20x_gpio_probe,
-	.driver = {
-		.name		= "axp20x-gpio",
-		.of_match_table	= axp20x_gpio_match,
-	},
-};
-
-module_platform_driver(axp20x_gpio_driver);
-
-MODULE_AUTHOR("Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
-MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 1778cf4..b125a21 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -63,6 +63,12 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_AXP209
+	tristate "X-Powers AXP209 PMIC pinctrl and GPIO Support"
+	depends on MFD_AXP20X
+	help
+	  Say yes to enable pinctrl and GPIO support for the AXP209 PMIC
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index c16e279..9f621e5 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_ARTPEC6)	+= pinctrl-artpec6.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_AXP209)	+= pinctrl-axp209.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
new file mode 100644
index 0000000..4a346b7
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -0,0 +1,188 @@
+/*
+ * AXP20x GPIO driver
+ *
+ * Copyright (C) 2016 Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/bitops.h>
+#include <linux/device.h>
+#include <linux/gpio/driver.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define AXP20X_GPIO_FUNCTIONS		0x7
+#define AXP20X_GPIO_FUNCTION_OUT_LOW	0
+#define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
+#define AXP20X_GPIO_FUNCTION_INPUT	2
+
+struct axp20x_gpio {
+	struct gpio_chip	chip;
+	struct regmap		*regmap;
+};
+
+static int axp20x_gpio_get_reg(unsigned offset)
+{
+	switch (offset) {
+	case 0:
+		return AXP20X_GPIO0_CTRL;
+	case 1:
+		return AXP20X_GPIO1_CTRL;
+	case 2:
+		return AXP20X_GPIO2_CTRL;
+	}
+
+	return -EINVAL;
+}
+
+static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	return regmap_update_bits(gpio->regmap, reg,
+				  AXP20X_GPIO_FUNCTIONS,
+				  AXP20X_GPIO_FUNCTION_INPUT);
+}
+
+static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
+	if (ret)
+		return ret;
+
+	return !!(val & BIT(offset + 4));
+}
+
+static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	unsigned int val;
+	int reg, ret;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	ret = regmap_read(gpio->regmap, reg, &val);
+	if (ret)
+		return ret;
+
+	/*
+	 * This shouldn't really happen if the pin is in use already,
+	 * or if it's not in use yet, it doesn't matter since we're
+	 * going to change the value soon anyway. Default to output.
+	 */
+	if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
+		return 0;
+
+	/*
+	 * The GPIO directions are the three lowest values.
+	 * 2 is input, 0 and 1 are output
+	 */
+	return val & 2;
+}
+
+static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
+			      int value)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	return regmap_update_bits(gpio->regmap, reg,
+				  AXP20X_GPIO_FUNCTIONS,
+				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
+				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
+}
+
+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
+			    int value)
+{
+	axp20x_gpio_output(chip, offset, value);
+}
+
+static int axp20x_gpio_probe(struct platform_device *pdev)
+{
+	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	struct axp20x_gpio *gpio;
+	int ret;
+
+	if (!of_device_is_available(pdev->dev.of_node))
+		return -ENODEV;
+
+	if (!axp20x) {
+		dev_err(&pdev->dev, "Parent drvdata not set\n");
+		return -EINVAL;
+	}
+
+	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
+	if (!gpio)
+		return -ENOMEM;
+
+	gpio->chip.base			= -1;
+	gpio->chip.can_sleep		= true;
+	gpio->chip.parent		= &pdev->dev;
+	gpio->chip.label		= dev_name(&pdev->dev);
+	gpio->chip.owner		= THIS_MODULE;
+	gpio->chip.get			= axp20x_gpio_get;
+	gpio->chip.get_direction	= axp20x_gpio_get_direction;
+	gpio->chip.set			= axp20x_gpio_set;
+	gpio->chip.direction_input	= axp20x_gpio_input;
+	gpio->chip.direction_output	= axp20x_gpio_output;
+	gpio->chip.ngpio		= 3;
+
+	gpio->regmap = axp20x->regmap;
+
+	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
+		return ret;
+	}
+
+	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
+
+	return 0;
+}
+
+static const struct of_device_id axp20x_gpio_match[] = {
+	{ .compatible = "x-powers,axp209-gpio" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
+
+static struct platform_driver axp20x_gpio_driver = {
+	.probe		= axp20x_gpio_probe,
+	.driver = {
+		.name		= "axp20x-gpio",
+		.of_match_table	= axp20x_gpio_match,
+	},
+};
+
+module_platform_driver(axp20x_gpio_driver);
+
+MODULE_AUTHOR("Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
+MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
+MODULE_LICENSE("GPL");
-- 
git-series 0.9.1

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

To prepare the driver for the upcoming pinctrl features, move the GPIO
driver AXP209 from GPIO to pinctrl subsystem.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  30 +-
 drivers/gpio/Kconfig                                         |   6 +-
 drivers/gpio/Makefile                                        |   1 +-
 drivers/gpio/gpio-axp209.c                                   | 188 +-------
 drivers/pinctrl/Kconfig                                      |   6 +-
 drivers/pinctrl/Makefile                                     |   1 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 188 +++++++-
 8 files changed, 225 insertions(+), 225 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
 delete mode 100644 drivers/gpio/gpio-axp209.c
 create mode 100644 drivers/pinctrl/pinctrl-axp209.c

diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
deleted file mode 100644
index a661130..0000000
--- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-AXP209 GPIO controller
-
-This driver follows the usual GPIO bindings found in
-Documentation/devicetree/bindings/gpio/gpio.txt
-
-Required properties:
-- compatible: Should be "x-powers,axp209-gpio"
-- #gpio-cells: Should be two. The first cell is the pin number and the
-  second is the GPIO flags.
-- gpio-controller: Marks the device node as a GPIO controller.
-
-This node must be a subnode of the axp20x PMIC, documented in
-Documentation/devicetree/bindings/mfd/axp20x.txt
-
-Example:
-
-axp209: pmic@34 {
-	compatible = "x-powers,axp209";
-	reg = <0x34>;
-	interrupt-parent = <&nmi_intc>;
-	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
-	interrupt-controller;
-	#interrupt-cells = <1>;
-
-	axp_gpio: gpio {
-		compatible = "x-powers,axp209-gpio";
-		gpio-controller;
-		#gpio-cells = <2>;
-	};
-};
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
new file mode 100644
index 0000000..a661130
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -0,0 +1,30 @@
+AXP209 GPIO controller
+
+This driver follows the usual GPIO bindings found in
+Documentation/devicetree/bindings/gpio/gpio.txt
+
+Required properties:
+- compatible: Should be "x-powers,axp209-gpio"
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+- gpio-controller: Marks the device node as a GPIO controller.
+
+This node must be a subnode of the axp20x PMIC, documented in
+Documentation/devicetree/bindings/mfd/axp20x.txt
+
+Example:
+
+axp209: pmic@34 {
+	compatible = "x-powers,axp209";
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	axp_gpio: gpio {
+		compatible = "x-powers,axp209-gpio";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+};
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 3f80f16..ad88178 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -122,12 +122,6 @@ config GPIO_ATH79
 	  Select this option to enable GPIO driver for
 	  Atheros AR71XX/AR724X/AR913X SoC devices.
 
-config GPIO_AXP209
-	tristate "X-Powers AXP209 PMIC GPIO Support"
-	depends on MFD_AXP20X
-	help
-	  Say yes to enable GPIO support for the AXP209 PMIC
-
 config GPIO_BCM_KONA
 	bool "Broadcom Kona GPIO"
 	depends on OF_GPIO && (ARCH_BCM_MOBILE || COMPILE_TEST)
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index aeb70e9..f63631a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_GPIO_AMDPT)	+= gpio-amdpt.o
 obj-$(CONFIG_GPIO_ARIZONA)	+= gpio-arizona.o
 obj-$(CONFIG_GPIO_ATH79)	+= gpio-ath79.o
 obj-$(CONFIG_GPIO_ASPEED)	+= gpio-aspeed.o
-obj-$(CONFIG_GPIO_AXP209)	+= gpio-axp209.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BD9571MWV)	+= gpio-bd9571mwv.o
 obj-$(CONFIG_GPIO_BRCMSTB)	+= gpio-brcmstb.o
diff --git a/drivers/gpio/gpio-axp209.c b/drivers/gpio/gpio-axp209.c
deleted file mode 100644
index 4a346b7..0000000
--- a/drivers/gpio/gpio-axp209.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * AXP20x GPIO driver
- *
- * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/bitops.h>
-#include <linux/device.h>
-#include <linux/gpio/driver.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/mfd/axp20x.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/platform_device.h>
-#include <linux/regmap.h>
-#include <linux/slab.h>
-
-#define AXP20X_GPIO_FUNCTIONS		0x7
-#define AXP20X_GPIO_FUNCTION_OUT_LOW	0
-#define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
-#define AXP20X_GPIO_FUNCTION_INPUT	2
-
-struct axp20x_gpio {
-	struct gpio_chip	chip;
-	struct regmap		*regmap;
-};
-
-static int axp20x_gpio_get_reg(unsigned offset)
-{
-	switch (offset) {
-	case 0:
-		return AXP20X_GPIO0_CTRL;
-	case 1:
-		return AXP20X_GPIO1_CTRL;
-	case 2:
-		return AXP20X_GPIO2_CTRL;
-	}
-
-	return -EINVAL;
-}
-
-static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  AXP20X_GPIO_FUNCTION_INPUT);
-}
-
-static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	unsigned int val;
-	int ret;
-
-	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
-	if (ret)
-		return ret;
-
-	return !!(val & BIT(offset + 4));
-}
-
-static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	unsigned int val;
-	int reg, ret;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	ret = regmap_read(gpio->regmap, reg, &val);
-	if (ret)
-		return ret;
-
-	/*
-	 * This shouldn't really happen if the pin is in use already,
-	 * or if it's not in use yet, it doesn't matter since we're
-	 * going to change the value soon anyway. Default to output.
-	 */
-	if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
-		return 0;
-
-	/*
-	 * The GPIO directions are the three lowest values.
-	 * 2 is input, 0 and 1 are output
-	 */
-	return val & 2;
-}
-
-static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
-			      int value)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
-				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
-}
-
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
-			    int value)
-{
-	axp20x_gpio_output(chip, offset, value);
-}
-
-static int axp20x_gpio_probe(struct platform_device *pdev)
-{
-	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-	struct axp20x_gpio *gpio;
-	int ret;
-
-	if (!of_device_is_available(pdev->dev.of_node))
-		return -ENODEV;
-
-	if (!axp20x) {
-		dev_err(&pdev->dev, "Parent drvdata not set\n");
-		return -EINVAL;
-	}
-
-	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
-	if (!gpio)
-		return -ENOMEM;
-
-	gpio->chip.base			= -1;
-	gpio->chip.can_sleep		= true;
-	gpio->chip.parent		= &pdev->dev;
-	gpio->chip.label		= dev_name(&pdev->dev);
-	gpio->chip.owner		= THIS_MODULE;
-	gpio->chip.get			= axp20x_gpio_get;
-	gpio->chip.get_direction	= axp20x_gpio_get_direction;
-	gpio->chip.set			= axp20x_gpio_set;
-	gpio->chip.direction_input	= axp20x_gpio_input;
-	gpio->chip.direction_output	= axp20x_gpio_output;
-	gpio->chip.ngpio		= 3;
-
-	gpio->regmap = axp20x->regmap;
-
-	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
-		return ret;
-	}
-
-	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
-
-	return 0;
-}
-
-static const struct of_device_id axp20x_gpio_match[] = {
-	{ .compatible = "x-powers,axp209-gpio" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
-
-static struct platform_driver axp20x_gpio_driver = {
-	.probe		= axp20x_gpio_probe,
-	.driver = {
-		.name		= "axp20x-gpio",
-		.of_match_table	= axp20x_gpio_match,
-	},
-};
-
-module_platform_driver(axp20x_gpio_driver);
-
-MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
-MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 1778cf4..b125a21 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -63,6 +63,12 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_AXP209
+	tristate "X-Powers AXP209 PMIC pinctrl and GPIO Support"
+	depends on MFD_AXP20X
+	help
+	  Say yes to enable pinctrl and GPIO support for the AXP209 PMIC
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index c16e279..9f621e5 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_ARTPEC6)	+= pinctrl-artpec6.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_AXP209)	+= pinctrl-axp209.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
new file mode 100644
index 0000000..4a346b7
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -0,0 +1,188 @@
+/*
+ * AXP20x GPIO driver
+ *
+ * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/bitops.h>
+#include <linux/device.h>
+#include <linux/gpio/driver.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define AXP20X_GPIO_FUNCTIONS		0x7
+#define AXP20X_GPIO_FUNCTION_OUT_LOW	0
+#define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
+#define AXP20X_GPIO_FUNCTION_INPUT	2
+
+struct axp20x_gpio {
+	struct gpio_chip	chip;
+	struct regmap		*regmap;
+};
+
+static int axp20x_gpio_get_reg(unsigned offset)
+{
+	switch (offset) {
+	case 0:
+		return AXP20X_GPIO0_CTRL;
+	case 1:
+		return AXP20X_GPIO1_CTRL;
+	case 2:
+		return AXP20X_GPIO2_CTRL;
+	}
+
+	return -EINVAL;
+}
+
+static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	return regmap_update_bits(gpio->regmap, reg,
+				  AXP20X_GPIO_FUNCTIONS,
+				  AXP20X_GPIO_FUNCTION_INPUT);
+}
+
+static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
+	if (ret)
+		return ret;
+
+	return !!(val & BIT(offset + 4));
+}
+
+static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	unsigned int val;
+	int reg, ret;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	ret = regmap_read(gpio->regmap, reg, &val);
+	if (ret)
+		return ret;
+
+	/*
+	 * This shouldn't really happen if the pin is in use already,
+	 * or if it's not in use yet, it doesn't matter since we're
+	 * going to change the value soon anyway. Default to output.
+	 */
+	if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
+		return 0;
+
+	/*
+	 * The GPIO directions are the three lowest values.
+	 * 2 is input, 0 and 1 are output
+	 */
+	return val & 2;
+}
+
+static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
+			      int value)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	return regmap_update_bits(gpio->regmap, reg,
+				  AXP20X_GPIO_FUNCTIONS,
+				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
+				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
+}
+
+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
+			    int value)
+{
+	axp20x_gpio_output(chip, offset, value);
+}
+
+static int axp20x_gpio_probe(struct platform_device *pdev)
+{
+	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	struct axp20x_gpio *gpio;
+	int ret;
+
+	if (!of_device_is_available(pdev->dev.of_node))
+		return -ENODEV;
+
+	if (!axp20x) {
+		dev_err(&pdev->dev, "Parent drvdata not set\n");
+		return -EINVAL;
+	}
+
+	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
+	if (!gpio)
+		return -ENOMEM;
+
+	gpio->chip.base			= -1;
+	gpio->chip.can_sleep		= true;
+	gpio->chip.parent		= &pdev->dev;
+	gpio->chip.label		= dev_name(&pdev->dev);
+	gpio->chip.owner		= THIS_MODULE;
+	gpio->chip.get			= axp20x_gpio_get;
+	gpio->chip.get_direction	= axp20x_gpio_get_direction;
+	gpio->chip.set			= axp20x_gpio_set;
+	gpio->chip.direction_input	= axp20x_gpio_input;
+	gpio->chip.direction_output	= axp20x_gpio_output;
+	gpio->chip.ngpio		= 3;
+
+	gpio->regmap = axp20x->regmap;
+
+	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
+		return ret;
+	}
+
+	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
+
+	return 0;
+}
+
+static const struct of_device_id axp20x_gpio_match[] = {
+	{ .compatible = "x-powers,axp209-gpio" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
+
+static struct platform_driver axp20x_gpio_driver = {
+	.probe		= axp20x_gpio_probe,
+	.driver = {
+		.name		= "axp20x-gpio",
+		.of_match_table	= axp20x_gpio_match,
+	},
+};
+
+module_platform_driver(axp20x_gpio_driver);
+
+MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
+MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
+MODULE_LICENSE("GPL");
-- 
git-series 0.9.1

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

To prepare the driver for the upcoming pinctrl features, move the GPIO
driver AXP209 from GPIO to pinctrl subsystem.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  30 +-
 drivers/gpio/Kconfig                                         |   6 +-
 drivers/gpio/Makefile                                        |   1 +-
 drivers/gpio/gpio-axp209.c                                   | 188 +-------
 drivers/pinctrl/Kconfig                                      |   6 +-
 drivers/pinctrl/Makefile                                     |   1 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 188 +++++++-
 8 files changed, 225 insertions(+), 225 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
 delete mode 100644 drivers/gpio/gpio-axp209.c
 create mode 100644 drivers/pinctrl/pinctrl-axp209.c

diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
deleted file mode 100644
index a661130..0000000
--- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-AXP209 GPIO controller
-
-This driver follows the usual GPIO bindings found in
-Documentation/devicetree/bindings/gpio/gpio.txt
-
-Required properties:
-- compatible: Should be "x-powers,axp209-gpio"
-- #gpio-cells: Should be two. The first cell is the pin number and the
-  second is the GPIO flags.
-- gpio-controller: Marks the device node as a GPIO controller.
-
-This node must be a subnode of the axp20x PMIC, documented in
-Documentation/devicetree/bindings/mfd/axp20x.txt
-
-Example:
-
-axp209: pmic at 34 {
-	compatible = "x-powers,axp209";
-	reg = <0x34>;
-	interrupt-parent = <&nmi_intc>;
-	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
-	interrupt-controller;
-	#interrupt-cells = <1>;
-
-	axp_gpio: gpio {
-		compatible = "x-powers,axp209-gpio";
-		gpio-controller;
-		#gpio-cells = <2>;
-	};
-};
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
new file mode 100644
index 0000000..a661130
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -0,0 +1,30 @@
+AXP209 GPIO controller
+
+This driver follows the usual GPIO bindings found in
+Documentation/devicetree/bindings/gpio/gpio.txt
+
+Required properties:
+- compatible: Should be "x-powers,axp209-gpio"
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+- gpio-controller: Marks the device node as a GPIO controller.
+
+This node must be a subnode of the axp20x PMIC, documented in
+Documentation/devicetree/bindings/mfd/axp20x.txt
+
+Example:
+
+axp209: pmic at 34 {
+	compatible = "x-powers,axp209";
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	axp_gpio: gpio {
+		compatible = "x-powers,axp209-gpio";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+};
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 3f80f16..ad88178 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -122,12 +122,6 @@ config GPIO_ATH79
 	  Select this option to enable GPIO driver for
 	  Atheros AR71XX/AR724X/AR913X SoC devices.
 
-config GPIO_AXP209
-	tristate "X-Powers AXP209 PMIC GPIO Support"
-	depends on MFD_AXP20X
-	help
-	  Say yes to enable GPIO support for the AXP209 PMIC
-
 config GPIO_BCM_KONA
 	bool "Broadcom Kona GPIO"
 	depends on OF_GPIO && (ARCH_BCM_MOBILE || COMPILE_TEST)
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index aeb70e9..f63631a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_GPIO_AMDPT)	+= gpio-amdpt.o
 obj-$(CONFIG_GPIO_ARIZONA)	+= gpio-arizona.o
 obj-$(CONFIG_GPIO_ATH79)	+= gpio-ath79.o
 obj-$(CONFIG_GPIO_ASPEED)	+= gpio-aspeed.o
-obj-$(CONFIG_GPIO_AXP209)	+= gpio-axp209.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BD9571MWV)	+= gpio-bd9571mwv.o
 obj-$(CONFIG_GPIO_BRCMSTB)	+= gpio-brcmstb.o
diff --git a/drivers/gpio/gpio-axp209.c b/drivers/gpio/gpio-axp209.c
deleted file mode 100644
index 4a346b7..0000000
--- a/drivers/gpio/gpio-axp209.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * AXP20x GPIO driver
- *
- * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/bitops.h>
-#include <linux/device.h>
-#include <linux/gpio/driver.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/mfd/axp20x.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/platform_device.h>
-#include <linux/regmap.h>
-#include <linux/slab.h>
-
-#define AXP20X_GPIO_FUNCTIONS		0x7
-#define AXP20X_GPIO_FUNCTION_OUT_LOW	0
-#define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
-#define AXP20X_GPIO_FUNCTION_INPUT	2
-
-struct axp20x_gpio {
-	struct gpio_chip	chip;
-	struct regmap		*regmap;
-};
-
-static int axp20x_gpio_get_reg(unsigned offset)
-{
-	switch (offset) {
-	case 0:
-		return AXP20X_GPIO0_CTRL;
-	case 1:
-		return AXP20X_GPIO1_CTRL;
-	case 2:
-		return AXP20X_GPIO2_CTRL;
-	}
-
-	return -EINVAL;
-}
-
-static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  AXP20X_GPIO_FUNCTION_INPUT);
-}
-
-static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	unsigned int val;
-	int ret;
-
-	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
-	if (ret)
-		return ret;
-
-	return !!(val & BIT(offset + 4));
-}
-
-static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	unsigned int val;
-	int reg, ret;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	ret = regmap_read(gpio->regmap, reg, &val);
-	if (ret)
-		return ret;
-
-	/*
-	 * This shouldn't really happen if the pin is in use already,
-	 * or if it's not in use yet, it doesn't matter since we're
-	 * going to change the value soon anyway. Default to output.
-	 */
-	if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
-		return 0;
-
-	/*
-	 * The GPIO directions are the three lowest values.
-	 * 2 is input, 0 and 1 are output
-	 */
-	return val & 2;
-}
-
-static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
-			      int value)
-{
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
-				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
-}
-
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
-			    int value)
-{
-	axp20x_gpio_output(chip, offset, value);
-}
-
-static int axp20x_gpio_probe(struct platform_device *pdev)
-{
-	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-	struct axp20x_gpio *gpio;
-	int ret;
-
-	if (!of_device_is_available(pdev->dev.of_node))
-		return -ENODEV;
-
-	if (!axp20x) {
-		dev_err(&pdev->dev, "Parent drvdata not set\n");
-		return -EINVAL;
-	}
-
-	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
-	if (!gpio)
-		return -ENOMEM;
-
-	gpio->chip.base			= -1;
-	gpio->chip.can_sleep		= true;
-	gpio->chip.parent		= &pdev->dev;
-	gpio->chip.label		= dev_name(&pdev->dev);
-	gpio->chip.owner		= THIS_MODULE;
-	gpio->chip.get			= axp20x_gpio_get;
-	gpio->chip.get_direction	= axp20x_gpio_get_direction;
-	gpio->chip.set			= axp20x_gpio_set;
-	gpio->chip.direction_input	= axp20x_gpio_input;
-	gpio->chip.direction_output	= axp20x_gpio_output;
-	gpio->chip.ngpio		= 3;
-
-	gpio->regmap = axp20x->regmap;
-
-	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
-		return ret;
-	}
-
-	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
-
-	return 0;
-}
-
-static const struct of_device_id axp20x_gpio_match[] = {
-	{ .compatible = "x-powers,axp209-gpio" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
-
-static struct platform_driver axp20x_gpio_driver = {
-	.probe		= axp20x_gpio_probe,
-	.driver = {
-		.name		= "axp20x-gpio",
-		.of_match_table	= axp20x_gpio_match,
-	},
-};
-
-module_platform_driver(axp20x_gpio_driver);
-
-MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
-MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 1778cf4..b125a21 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -63,6 +63,12 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_AXP209
+	tristate "X-Powers AXP209 PMIC pinctrl and GPIO Support"
+	depends on MFD_AXP20X
+	help
+	  Say yes to enable pinctrl and GPIO support for the AXP209 PMIC
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index c16e279..9f621e5 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_ARTPEC6)	+= pinctrl-artpec6.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_AXP209)	+= pinctrl-axp209.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
new file mode 100644
index 0000000..4a346b7
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -0,0 +1,188 @@
+/*
+ * AXP20x GPIO driver
+ *
+ * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/bitops.h>
+#include <linux/device.h>
+#include <linux/gpio/driver.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define AXP20X_GPIO_FUNCTIONS		0x7
+#define AXP20X_GPIO_FUNCTION_OUT_LOW	0
+#define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
+#define AXP20X_GPIO_FUNCTION_INPUT	2
+
+struct axp20x_gpio {
+	struct gpio_chip	chip;
+	struct regmap		*regmap;
+};
+
+static int axp20x_gpio_get_reg(unsigned offset)
+{
+	switch (offset) {
+	case 0:
+		return AXP20X_GPIO0_CTRL;
+	case 1:
+		return AXP20X_GPIO1_CTRL;
+	case 2:
+		return AXP20X_GPIO2_CTRL;
+	}
+
+	return -EINVAL;
+}
+
+static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	return regmap_update_bits(gpio->regmap, reg,
+				  AXP20X_GPIO_FUNCTIONS,
+				  AXP20X_GPIO_FUNCTION_INPUT);
+}
+
+static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
+	if (ret)
+		return ret;
+
+	return !!(val & BIT(offset + 4));
+}
+
+static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	unsigned int val;
+	int reg, ret;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	ret = regmap_read(gpio->regmap, reg, &val);
+	if (ret)
+		return ret;
+
+	/*
+	 * This shouldn't really happen if the pin is in use already,
+	 * or if it's not in use yet, it doesn't matter since we're
+	 * going to change the value soon anyway. Default to output.
+	 */
+	if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
+		return 0;
+
+	/*
+	 * The GPIO directions are the three lowest values.
+	 * 2 is input, 0 and 1 are output
+	 */
+	return val & 2;
+}
+
+static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
+			      int value)
+{
+	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
+		return reg;
+
+	return regmap_update_bits(gpio->regmap, reg,
+				  AXP20X_GPIO_FUNCTIONS,
+				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
+				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
+}
+
+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
+			    int value)
+{
+	axp20x_gpio_output(chip, offset, value);
+}
+
+static int axp20x_gpio_probe(struct platform_device *pdev)
+{
+	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	struct axp20x_gpio *gpio;
+	int ret;
+
+	if (!of_device_is_available(pdev->dev.of_node))
+		return -ENODEV;
+
+	if (!axp20x) {
+		dev_err(&pdev->dev, "Parent drvdata not set\n");
+		return -EINVAL;
+	}
+
+	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
+	if (!gpio)
+		return -ENOMEM;
+
+	gpio->chip.base			= -1;
+	gpio->chip.can_sleep		= true;
+	gpio->chip.parent		= &pdev->dev;
+	gpio->chip.label		= dev_name(&pdev->dev);
+	gpio->chip.owner		= THIS_MODULE;
+	gpio->chip.get			= axp20x_gpio_get;
+	gpio->chip.get_direction	= axp20x_gpio_get_direction;
+	gpio->chip.set			= axp20x_gpio_set;
+	gpio->chip.direction_input	= axp20x_gpio_input;
+	gpio->chip.direction_output	= axp20x_gpio_output;
+	gpio->chip.ngpio		= 3;
+
+	gpio->regmap = axp20x->regmap;
+
+	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
+		return ret;
+	}
+
+	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
+
+	return 0;
+}
+
+static const struct of_device_id axp20x_gpio_match[] = {
+	{ .compatible = "x-powers,axp209-gpio" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
+
+static struct platform_driver axp20x_gpio_driver = {
+	.probe		= axp20x_gpio_probe,
+	.driver = {
+		.name		= "axp20x-gpio",
+		.of_match_table	= axp20x_gpio_match,
+	},
+};
+
+module_platform_driver(axp20x_gpio_driver);
+
+MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
+MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
+MODULE_LICENSE("GPL");
-- 
git-series 0.9.1

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

The X-Powers AXP209 has 3 GPIOs. GPIO0/1 can each act either as a GPIO,
an ADC or a LDO regulator. GPIO2 can only act as a GPIO.

This adds the pinctrl features to the driver so GPIO0/1 can be used as
ADC or LDO regulator.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  28 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 462 ++++++-
 2 files changed, 468 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
index a661130..a5bfe87 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -1,4 +1,4 @@
-AXP209 GPIO controller
+AXP209 GPIO & pinctrl controller
 
 This driver follows the usual GPIO bindings found in
 Documentation/devicetree/bindings/gpio/gpio.txt
@@ -28,3 +28,29 @@ axp209: pmic@34 {
 		#gpio-cells = <2>;
 	};
 };
+
+The GPIOs can be muxed to other functions and therefore, must be a subnode of
+axp_gpio.
+
+Example:
+
+&axp_gpio {
+	gpio0_adc: gpio0_adc {
+		pin = "GPIO0";
+		function = "adc";
+	};
+};
+
+&example_node {
+	pinctrl-names = "default";
+	pinctrl-0 = <&gpio0_adc>;
+};
+
+GPIOs and their functions
+-------------------------
+
+GPIO	|	Functions
+------------------------
+GPIO0	|	gpio_in, gpio_out, ldo, adc
+GPIO1	|	gpio_in, gpio_out, ldo, adc
+GPIO2	|	gpio_in, gpio_out
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4a346b7..b35e8dd 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -1,7 +1,8 @@
 /*
- * AXP20x GPIO driver
+ * AXP20x pinctrl and GPIO driver
  *
  * Copyright (C) 2016 Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
+ * Copyright (C) 201 Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under  the terms of the GNU General  Public License as published by the
@@ -22,14 +23,92 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>
+
 #define AXP20X_GPIO_FUNCTIONS		0x7
 #define AXP20X_GPIO_FUNCTION_OUT_LOW	0
 #define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
 #define AXP20X_GPIO_FUNCTION_INPUT	2
 
+#define AXP20X_PINCTRL_PIN(_pin_num, _pin)			\
+	{							\
+		.number = _pin_num,				\
+		.name = _pin,					\
+	}
+
+#define AXP20X_PIN(_pin, ...)					\
+	{							\
+		.pin = _pin,					\
+		.functions = (struct axp20x_desc_function[]) {	\
+			      __VA_ARGS__, { } },		\
+	}
+
+#define AXP20X_FUNCTION(_val, _name)				\
+	{							\
+		.name = _name,					\
+		.muxval = _val,					\
+	}
+
+struct axp20x_desc_function {
+	const char	*name;
+	u8		muxval;
+};
+
+struct axp20x_desc_pin {
+	struct pinctrl_pin_desc		pin;
+	struct axp20x_desc_function	*functions;
+};
+
+struct axp20x_pinctrl_desc {
+	const struct axp20x_desc_pin	*pins;
+	int				npins;
+};
+
+struct axp20x_pinctrl_group {
+	const char	*name;
+	unsigned long	config;
+	unsigned int	pin;
+};
+
+struct axp20x_pinctrl_function {
+	const char	*name;
+	const char	**groups;
+	unsigned int	ngroups;
+};
+
 struct axp20x_gpio {
 	struct gpio_chip	chip;
 	struct regmap		*regmap;
+	struct pinctrl_dev			*pctl_dev;
+	struct device				*dev;
+	const struct axp20x_pinctrl_desc	*desc;
+	struct axp20x_pinctrl_group		*groups;
+	unsigned int				ngroups;
+	struct axp20x_pinctrl_function		*functions;
+	unsigned int				nfunctions;
+};
+
+static const struct axp20x_desc_pin axp209_pins[] = {
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in")),
+};
+
+static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
+	.pins	= axp209_pins,
+	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
 static int axp20x_gpio_get_reg(unsigned offset)
@@ -48,16 +127,7 @@ static int axp20x_gpio_get_reg(unsigned offset)
 
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  AXP20X_GPIO_FUNCTION_INPUT);
+	return pinctrl_gpio_direction_input(chip->base + offset);
 }
 
 static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -105,30 +175,334 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
 			      int value)
 {
+	chip->set(chip, offset, value);
+
+	return 0;
+}
+
+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
+			    int value)
+{
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
 	int reg;
 
 	reg = axp20x_gpio_get_reg(offset);
 	if (reg < 0)
+		return;
+
+	regmap_update_bits(gpio->regmap, reg,
+			   AXP20X_GPIO_FUNCTIONS,
+			   value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
+			   AXP20X_GPIO_FUNCTION_OUT_LOW);
+}
+
+static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
+			  u8 config)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
 		return reg;
 
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
-				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
+	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+				  config);
 }
 
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
-			    int value)
+static int axp20x_pmx_func_cnt(struct pinctrl_dev *pctldev)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->nfunctions;
+}
+
+static const char *axp20x_pmx_func_name(struct pinctrl_dev *pctldev,
+					unsigned int selector)
 {
-	axp20x_gpio_output(chip, offset, value);
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->functions[selector].name;
+}
+
+static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
+				  unsigned int selector,
+				  const char * const **groups,
+				  unsigned int *num_groups)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	*groups = gpio->functions[selector].groups;
+	*num_groups = gpio->functions[selector].ngroups;
+
+	return 0;
+}
+
+static struct axp20x_desc_function *
+axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
+				      const char *group, const char *func)
+{
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *desc_func;
+	int i;
+
+	for (i = 0; i < gpio->desc->npins; i++) {
+		pin = &gpio->desc->pins[i];
+
+		if (!strcmp(pin->pin.name, group)) {
+			desc_func = pin->functions;
+
+			while (desc_func->name) {
+				if (!strcmp(desc_func->name, func))
+					return desc_func;
+				desc_func++;
+			}
+
+			/*
+			 * Pins are uniquely named. Groups are named after one
+			 * pin name. If one pin matches group name but its
+			 * function cannot be found, no other pin will match
+			 * group name.
+			 */
+			return NULL;
+		}
+	}
+
+	return NULL;
+}
+
+static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
+			      unsigned int function, unsigned int group)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = gpio->groups + group;
+	struct axp20x_pinctrl_function *func = gpio->functions + function;
+	struct axp20x_desc_function *desc_func =
+		axp20x_pinctrl_desc_find_func_by_name(gpio, g->name,
+						      func->name);
+	if (!desc_func)
+		return -EINVAL;
+
+	return axp20x_pmx_set(pctldev, g->pin, desc_func->muxval);
+}
+
+static struct axp20x_desc_function *
+axp20x_pctl_desc_find_func_by_pin(struct axp20x_gpio *gpio, unsigned int offset,
+				  const char *func)
+{
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *desc_func;
+	int i;
+
+	for (i = 0; i < gpio->desc->npins; i++) {
+		pin = &gpio->desc->pins[i];
+
+		if (pin->pin.number == offset) {
+			desc_func = pin->functions;
+
+			while (desc_func->name) {
+				if (!strcmp(desc_func->name, func))
+					return desc_func;
+
+				desc_func++;
+			}
+		}
+	}
+
+	return NULL;
+}
+
+static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
+					 struct pinctrl_gpio_range *range,
+					 unsigned int offset, bool input)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_desc_function *desc_func;
+	const char *func;
+
+	if (input)
+		func = "gpio_in";
+	else
+		func = "gpio_out";
+
+	desc_func = axp20x_pctl_desc_find_func_by_pin(gpio, offset, func);
+	if (!desc_func)
+		return -EINVAL;
+
+	return axp20x_pmx_set(pctldev, offset, desc_func->muxval);
+}
+
+static const struct pinmux_ops axp20x_pmx_ops = {
+	.get_functions_count	= axp20x_pmx_func_cnt,
+	.get_function_name	= axp20x_pmx_func_name,
+	.get_function_groups	= axp20x_pmx_func_groups,
+	.set_mux		= axp20x_pmx_set_mux,
+	.gpio_set_direction	= axp20x_pmx_gpio_set_direction,
+	.strict			= true,
+};
+
+static int axp20x_groups_cnt(struct pinctrl_dev *pctldev)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->ngroups;
+}
+
+static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
+			     const unsigned int **pins, unsigned int *num_pins)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = gpio->groups + selector;
+
+	*pins = (unsigned int *)&g->pin;
+	*num_pins = 1;
+
+	return 0;
+}
+
+static const char *axp20x_group_name(struct pinctrl_dev *pctldev,
+				     unsigned int selector)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->groups[selector].name;
+}
+
+static const struct pinctrl_ops axp20x_pctrl_ops = {
+	.dt_node_to_map		= pinconf_generic_dt_node_to_map_group,
+	.dt_free_map		= pinconf_generic_dt_free_map,
+	.get_groups_count	= axp20x_groups_cnt,
+	.get_group_name		= axp20x_group_name,
+	.get_group_pins		= axp20x_group_pins,
+};
+
+static struct axp20x_pinctrl_function *
+axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
+{
+	struct axp20x_pinctrl_function *func = gpio->functions;
+
+	while (func->name) {
+		if (!strcmp(func->name, name))
+			return func;
+		func++;
+	}
+
+	return NULL;
+}
+
+static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
+				       const char *name)
+{
+	struct axp20x_pinctrl_function *func = gpio->functions;
+
+	while (func->name) {
+		if (!strcmp(func->name, name)) {
+			func->ngroups++;
+			return -EEXIST;
+		}
+
+		func++;
+	}
+
+	func->name = name;
+	func->ngroups = 1;
+
+	gpio->nfunctions++;
+
+	return 0;
+}
+
+static int axp20x_attach_group_function(struct platform_device *pdev,
+					const struct axp20x_desc_pin *pin)
+{
+	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	struct axp20x_desc_function *desc_func = pin->functions;
+	struct axp20x_pinctrl_function *func;
+	const char **func_grp;
+
+	while (desc_func->name) {
+		func = axp20x_pinctrl_function_by_name(gpio, desc_func->name);
+		if (!func)
+			return -EINVAL;
+
+		if (!func->groups) {
+			func->groups = devm_kzalloc(&pdev->dev,
+						    func->ngroups * sizeof(const char *),
+						    GFP_KERNEL);
+			if (!func->groups)
+				return -ENOMEM;
+		}
+
+		func_grp = func->groups;
+		while (*func_grp)
+			func_grp++;
+
+		*func_grp = pin->pin.name;
+		desc_func++;
+	}
+
+	return 0;
+}
+
+static int axp20x_build_state(struct platform_device *pdev)
+{
+	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	unsigned int npins = gpio->desc->npins;
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *func;
+	int i, ret;
+
+	gpio->ngroups = npins;
+	gpio->groups = devm_kzalloc(&pdev->dev,
+				    gpio->ngroups * sizeof(*gpio->groups),
+				    GFP_KERNEL);
+	if (!gpio->groups)
+		return -ENOMEM;
+
+	for (i = 0; i < npins; i++) {
+		gpio->groups[i].name = gpio->desc->pins[i].pin.name;
+		gpio->groups[i].pin = gpio->desc->pins[i].pin.number;
+	}
+
+	/* We assume 4 functions per pin should be enough as a default max */
+	gpio->functions = devm_kzalloc(&pdev->dev,
+				       npins * 4 * sizeof(*gpio->functions),
+				       GFP_KERNEL);
+	if (!gpio->functions)
+		return -ENOMEM;
+
+	/* Create a list of uniquely named functions */
+	for (i = 0; i < npins; i++) {
+		pin = &gpio->desc->pins[i];
+		func = pin->functions;
+
+		while (func->name) {
+			axp20x_pinctrl_add_function(gpio, func->name);
+			func++;
+		}
+	}
+
+	gpio->functions = krealloc(gpio->functions,
+				   gpio->nfunctions * sizeof(*gpio->functions),
+				   GFP_KERNEL);
+
+	for (i = 0; i < npins; i++) {
+		pin = &gpio->desc->pins[i];
+		ret = axp20x_attach_group_function(pdev, pin);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 static int axp20x_gpio_probe(struct platform_device *pdev)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct axp20x_gpio *gpio;
-	int ret;
+	struct pinctrl_desc *pctrl_desc;
+	struct pinctrl_pin_desc *pins;
+	int ret, i;
 
 	if (!of_device_is_available(pdev->dev.of_node))
 		return -ENODEV;
@@ -144,6 +518,8 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 
 	gpio->chip.base			= -1;
 	gpio->chip.can_sleep		= true;
+	gpio->chip.request		= gpiochip_generic_request;
+	gpio->chip.free			= gpiochip_generic_free;
 	gpio->chip.parent		= &pdev->dev;
 	gpio->chip.label		= dev_name(&pdev->dev);
 	gpio->chip.owner		= THIS_MODULE;
@@ -156,13 +532,56 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 
 	gpio->regmap = axp20x->regmap;
 
+	gpio->desc = &axp20x_pinctrl_data;
+	gpio->dev = &pdev->dev;
+
+	platform_set_drvdata(pdev, gpio);
+
+	ret = axp20x_build_state(pdev);
+	if (ret)
+		return ret;
+
+	pins = devm_kzalloc(&pdev->dev, gpio->desc->npins * sizeof(*pins),
+			    GFP_KERNEL);
+	if (!pins)
+		return -ENOMEM;
+
+	for (i = 0; i < gpio->desc->npins; i++)
+		pins[i] = gpio->desc->pins[i].pin;
+
+	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
+	if (!pctrl_desc)
+		return -ENOMEM;
+
+	pctrl_desc->name = dev_name(&pdev->dev);
+	pctrl_desc->owner = THIS_MODULE;
+	pctrl_desc->pins = pins;
+	pctrl_desc->npins = gpio->desc->npins;
+	pctrl_desc->pctlops = &axp20x_pctrl_ops;
+	pctrl_desc->pmxops = &axp20x_pmx_ops;
+
+	gpio->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, gpio);
+	if (IS_ERR(gpio->pctl_dev)) {
+		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
+		return PTR_ERR(gpio->pctl_dev);
+	}
+
 	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
 		return ret;
 	}
 
-	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
+	ret = gpiochip_add_pin_range(&gpio->chip, dev_name(&pdev->dev),
+				     gpio->desc->pins->pin.number,
+				     gpio->desc->pins->pin.number,
+				     gpio->desc->npins);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add pin range\n");
+		return ret;
+	}
+
+	dev_info(&pdev->dev, "AXP209 pinctrl and GPIO driver loaded\n");
 
 	return 0;
 }
@@ -184,5 +603,6 @@ static struct platform_driver axp20x_gpio_driver = {
 module_platform_driver(axp20x_gpio_driver);
 
 MODULE_AUTHOR("Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
-MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
+MODULE_AUTHOR("Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
+MODULE_DESCRIPTION("AXP20x PMIC pinctrl and GPIO driver");
 MODULE_LICENSE("GPL");
-- 
git-series 0.9.1

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

The X-Powers AXP209 has 3 GPIOs. GPIO0/1 can each act either as a GPIO,
an ADC or a LDO regulator. GPIO2 can only act as a GPIO.

This adds the pinctrl features to the driver so GPIO0/1 can be used as
ADC or LDO regulator.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  28 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 462 ++++++-
 2 files changed, 468 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
index a661130..a5bfe87 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -1,4 +1,4 @@
-AXP209 GPIO controller
+AXP209 GPIO & pinctrl controller
 
 This driver follows the usual GPIO bindings found in
 Documentation/devicetree/bindings/gpio/gpio.txt
@@ -28,3 +28,29 @@ axp209: pmic@34 {
 		#gpio-cells = <2>;
 	};
 };
+
+The GPIOs can be muxed to other functions and therefore, must be a subnode of
+axp_gpio.
+
+Example:
+
+&axp_gpio {
+	gpio0_adc: gpio0_adc {
+		pin = "GPIO0";
+		function = "adc";
+	};
+};
+
+&example_node {
+	pinctrl-names = "default";
+	pinctrl-0 = <&gpio0_adc>;
+};
+
+GPIOs and their functions
+-------------------------
+
+GPIO	|	Functions
+------------------------
+GPIO0	|	gpio_in, gpio_out, ldo, adc
+GPIO1	|	gpio_in, gpio_out, ldo, adc
+GPIO2	|	gpio_in, gpio_out
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4a346b7..b35e8dd 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -1,7 +1,8 @@
 /*
- * AXP20x GPIO driver
+ * AXP20x pinctrl and GPIO driver
  *
  * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
+ * Copyright (C) 201 Quentin Schulz <quentin.schulz@free-electrons.com>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under  the terms of the GNU General  Public License as published by the
@@ -22,14 +23,92 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>
+
 #define AXP20X_GPIO_FUNCTIONS		0x7
 #define AXP20X_GPIO_FUNCTION_OUT_LOW	0
 #define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
 #define AXP20X_GPIO_FUNCTION_INPUT	2
 
+#define AXP20X_PINCTRL_PIN(_pin_num, _pin)			\
+	{							\
+		.number = _pin_num,				\
+		.name = _pin,					\
+	}
+
+#define AXP20X_PIN(_pin, ...)					\
+	{							\
+		.pin = _pin,					\
+		.functions = (struct axp20x_desc_function[]) {	\
+			      __VA_ARGS__, { } },		\
+	}
+
+#define AXP20X_FUNCTION(_val, _name)				\
+	{							\
+		.name = _name,					\
+		.muxval = _val,					\
+	}
+
+struct axp20x_desc_function {
+	const char	*name;
+	u8		muxval;
+};
+
+struct axp20x_desc_pin {
+	struct pinctrl_pin_desc		pin;
+	struct axp20x_desc_function	*functions;
+};
+
+struct axp20x_pinctrl_desc {
+	const struct axp20x_desc_pin	*pins;
+	int				npins;
+};
+
+struct axp20x_pinctrl_group {
+	const char	*name;
+	unsigned long	config;
+	unsigned int	pin;
+};
+
+struct axp20x_pinctrl_function {
+	const char	*name;
+	const char	**groups;
+	unsigned int	ngroups;
+};
+
 struct axp20x_gpio {
 	struct gpio_chip	chip;
 	struct regmap		*regmap;
+	struct pinctrl_dev			*pctl_dev;
+	struct device				*dev;
+	const struct axp20x_pinctrl_desc	*desc;
+	struct axp20x_pinctrl_group		*groups;
+	unsigned int				ngroups;
+	struct axp20x_pinctrl_function		*functions;
+	unsigned int				nfunctions;
+};
+
+static const struct axp20x_desc_pin axp209_pins[] = {
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in")),
+};
+
+static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
+	.pins	= axp209_pins,
+	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
 static int axp20x_gpio_get_reg(unsigned offset)
@@ -48,16 +127,7 @@ static int axp20x_gpio_get_reg(unsigned offset)
 
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  AXP20X_GPIO_FUNCTION_INPUT);
+	return pinctrl_gpio_direction_input(chip->base + offset);
 }
 
 static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -105,30 +175,334 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
 			      int value)
 {
+	chip->set(chip, offset, value);
+
+	return 0;
+}
+
+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
+			    int value)
+{
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
 	int reg;
 
 	reg = axp20x_gpio_get_reg(offset);
 	if (reg < 0)
+		return;
+
+	regmap_update_bits(gpio->regmap, reg,
+			   AXP20X_GPIO_FUNCTIONS,
+			   value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
+			   AXP20X_GPIO_FUNCTION_OUT_LOW);
+}
+
+static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
+			  u8 config)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
 		return reg;
 
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
-				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
+	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+				  config);
 }
 
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
-			    int value)
+static int axp20x_pmx_func_cnt(struct pinctrl_dev *pctldev)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->nfunctions;
+}
+
+static const char *axp20x_pmx_func_name(struct pinctrl_dev *pctldev,
+					unsigned int selector)
 {
-	axp20x_gpio_output(chip, offset, value);
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->functions[selector].name;
+}
+
+static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
+				  unsigned int selector,
+				  const char * const **groups,
+				  unsigned int *num_groups)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	*groups = gpio->functions[selector].groups;
+	*num_groups = gpio->functions[selector].ngroups;
+
+	return 0;
+}
+
+static struct axp20x_desc_function *
+axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
+				      const char *group, const char *func)
+{
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *desc_func;
+	int i;
+
+	for (i = 0; i < gpio->desc->npins; i++) {
+		pin = &gpio->desc->pins[i];
+
+		if (!strcmp(pin->pin.name, group)) {
+			desc_func = pin->functions;
+
+			while (desc_func->name) {
+				if (!strcmp(desc_func->name, func))
+					return desc_func;
+				desc_func++;
+			}
+
+			/*
+			 * Pins are uniquely named. Groups are named after one
+			 * pin name. If one pin matches group name but its
+			 * function cannot be found, no other pin will match
+			 * group name.
+			 */
+			return NULL;
+		}
+	}
+
+	return NULL;
+}
+
+static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
+			      unsigned int function, unsigned int group)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = gpio->groups + group;
+	struct axp20x_pinctrl_function *func = gpio->functions + function;
+	struct axp20x_desc_function *desc_func =
+		axp20x_pinctrl_desc_find_func_by_name(gpio, g->name,
+						      func->name);
+	if (!desc_func)
+		return -EINVAL;
+
+	return axp20x_pmx_set(pctldev, g->pin, desc_func->muxval);
+}
+
+static struct axp20x_desc_function *
+axp20x_pctl_desc_find_func_by_pin(struct axp20x_gpio *gpio, unsigned int offset,
+				  const char *func)
+{
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *desc_func;
+	int i;
+
+	for (i = 0; i < gpio->desc->npins; i++) {
+		pin = &gpio->desc->pins[i];
+
+		if (pin->pin.number == offset) {
+			desc_func = pin->functions;
+
+			while (desc_func->name) {
+				if (!strcmp(desc_func->name, func))
+					return desc_func;
+
+				desc_func++;
+			}
+		}
+	}
+
+	return NULL;
+}
+
+static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
+					 struct pinctrl_gpio_range *range,
+					 unsigned int offset, bool input)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_desc_function *desc_func;
+	const char *func;
+
+	if (input)
+		func = "gpio_in";
+	else
+		func = "gpio_out";
+
+	desc_func = axp20x_pctl_desc_find_func_by_pin(gpio, offset, func);
+	if (!desc_func)
+		return -EINVAL;
+
+	return axp20x_pmx_set(pctldev, offset, desc_func->muxval);
+}
+
+static const struct pinmux_ops axp20x_pmx_ops = {
+	.get_functions_count	= axp20x_pmx_func_cnt,
+	.get_function_name	= axp20x_pmx_func_name,
+	.get_function_groups	= axp20x_pmx_func_groups,
+	.set_mux		= axp20x_pmx_set_mux,
+	.gpio_set_direction	= axp20x_pmx_gpio_set_direction,
+	.strict			= true,
+};
+
+static int axp20x_groups_cnt(struct pinctrl_dev *pctldev)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->ngroups;
+}
+
+static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
+			     const unsigned int **pins, unsigned int *num_pins)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = gpio->groups + selector;
+
+	*pins = (unsigned int *)&g->pin;
+	*num_pins = 1;
+
+	return 0;
+}
+
+static const char *axp20x_group_name(struct pinctrl_dev *pctldev,
+				     unsigned int selector)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->groups[selector].name;
+}
+
+static const struct pinctrl_ops axp20x_pctrl_ops = {
+	.dt_node_to_map		= pinconf_generic_dt_node_to_map_group,
+	.dt_free_map		= pinconf_generic_dt_free_map,
+	.get_groups_count	= axp20x_groups_cnt,
+	.get_group_name		= axp20x_group_name,
+	.get_group_pins		= axp20x_group_pins,
+};
+
+static struct axp20x_pinctrl_function *
+axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
+{
+	struct axp20x_pinctrl_function *func = gpio->functions;
+
+	while (func->name) {
+		if (!strcmp(func->name, name))
+			return func;
+		func++;
+	}
+
+	return NULL;
+}
+
+static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
+				       const char *name)
+{
+	struct axp20x_pinctrl_function *func = gpio->functions;
+
+	while (func->name) {
+		if (!strcmp(func->name, name)) {
+			func->ngroups++;
+			return -EEXIST;
+		}
+
+		func++;
+	}
+
+	func->name = name;
+	func->ngroups = 1;
+
+	gpio->nfunctions++;
+
+	return 0;
+}
+
+static int axp20x_attach_group_function(struct platform_device *pdev,
+					const struct axp20x_desc_pin *pin)
+{
+	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	struct axp20x_desc_function *desc_func = pin->functions;
+	struct axp20x_pinctrl_function *func;
+	const char **func_grp;
+
+	while (desc_func->name) {
+		func = axp20x_pinctrl_function_by_name(gpio, desc_func->name);
+		if (!func)
+			return -EINVAL;
+
+		if (!func->groups) {
+			func->groups = devm_kzalloc(&pdev->dev,
+						    func->ngroups * sizeof(const char *),
+						    GFP_KERNEL);
+			if (!func->groups)
+				return -ENOMEM;
+		}
+
+		func_grp = func->groups;
+		while (*func_grp)
+			func_grp++;
+
+		*func_grp = pin->pin.name;
+		desc_func++;
+	}
+
+	return 0;
+}
+
+static int axp20x_build_state(struct platform_device *pdev)
+{
+	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	unsigned int npins = gpio->desc->npins;
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *func;
+	int i, ret;
+
+	gpio->ngroups = npins;
+	gpio->groups = devm_kzalloc(&pdev->dev,
+				    gpio->ngroups * sizeof(*gpio->groups),
+				    GFP_KERNEL);
+	if (!gpio->groups)
+		return -ENOMEM;
+
+	for (i = 0; i < npins; i++) {
+		gpio->groups[i].name = gpio->desc->pins[i].pin.name;
+		gpio->groups[i].pin = gpio->desc->pins[i].pin.number;
+	}
+
+	/* We assume 4 functions per pin should be enough as a default max */
+	gpio->functions = devm_kzalloc(&pdev->dev,
+				       npins * 4 * sizeof(*gpio->functions),
+				       GFP_KERNEL);
+	if (!gpio->functions)
+		return -ENOMEM;
+
+	/* Create a list of uniquely named functions */
+	for (i = 0; i < npins; i++) {
+		pin = &gpio->desc->pins[i];
+		func = pin->functions;
+
+		while (func->name) {
+			axp20x_pinctrl_add_function(gpio, func->name);
+			func++;
+		}
+	}
+
+	gpio->functions = krealloc(gpio->functions,
+				   gpio->nfunctions * sizeof(*gpio->functions),
+				   GFP_KERNEL);
+
+	for (i = 0; i < npins; i++) {
+		pin = &gpio->desc->pins[i];
+		ret = axp20x_attach_group_function(pdev, pin);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 static int axp20x_gpio_probe(struct platform_device *pdev)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct axp20x_gpio *gpio;
-	int ret;
+	struct pinctrl_desc *pctrl_desc;
+	struct pinctrl_pin_desc *pins;
+	int ret, i;
 
 	if (!of_device_is_available(pdev->dev.of_node))
 		return -ENODEV;
@@ -144,6 +518,8 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 
 	gpio->chip.base			= -1;
 	gpio->chip.can_sleep		= true;
+	gpio->chip.request		= gpiochip_generic_request;
+	gpio->chip.free			= gpiochip_generic_free;
 	gpio->chip.parent		= &pdev->dev;
 	gpio->chip.label		= dev_name(&pdev->dev);
 	gpio->chip.owner		= THIS_MODULE;
@@ -156,13 +532,56 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 
 	gpio->regmap = axp20x->regmap;
 
+	gpio->desc = &axp20x_pinctrl_data;
+	gpio->dev = &pdev->dev;
+
+	platform_set_drvdata(pdev, gpio);
+
+	ret = axp20x_build_state(pdev);
+	if (ret)
+		return ret;
+
+	pins = devm_kzalloc(&pdev->dev, gpio->desc->npins * sizeof(*pins),
+			    GFP_KERNEL);
+	if (!pins)
+		return -ENOMEM;
+
+	for (i = 0; i < gpio->desc->npins; i++)
+		pins[i] = gpio->desc->pins[i].pin;
+
+	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
+	if (!pctrl_desc)
+		return -ENOMEM;
+
+	pctrl_desc->name = dev_name(&pdev->dev);
+	pctrl_desc->owner = THIS_MODULE;
+	pctrl_desc->pins = pins;
+	pctrl_desc->npins = gpio->desc->npins;
+	pctrl_desc->pctlops = &axp20x_pctrl_ops;
+	pctrl_desc->pmxops = &axp20x_pmx_ops;
+
+	gpio->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, gpio);
+	if (IS_ERR(gpio->pctl_dev)) {
+		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
+		return PTR_ERR(gpio->pctl_dev);
+	}
+
 	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
 		return ret;
 	}
 
-	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
+	ret = gpiochip_add_pin_range(&gpio->chip, dev_name(&pdev->dev),
+				     gpio->desc->pins->pin.number,
+				     gpio->desc->pins->pin.number,
+				     gpio->desc->npins);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add pin range\n");
+		return ret;
+	}
+
+	dev_info(&pdev->dev, "AXP209 pinctrl and GPIO driver loaded\n");
 
 	return 0;
 }
@@ -184,5 +603,6 @@ static struct platform_driver axp20x_gpio_driver = {
 module_platform_driver(axp20x_gpio_driver);
 
 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
-MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
+MODULE_AUTHOR("Quentin Schulz <quentin.schulz@free-electrons.com>");
+MODULE_DESCRIPTION("AXP20x PMIC pinctrl and GPIO driver");
 MODULE_LICENSE("GPL");
-- 
git-series 0.9.1

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

The X-Powers AXP209 has 3 GPIOs. GPIO0/1 can each act either as a GPIO,
an ADC or a LDO regulator. GPIO2 can only act as a GPIO.

This adds the pinctrl features to the driver so GPIO0/1 can be used as
ADC or LDO regulator.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  28 +-
 drivers/pinctrl/pinctrl-axp209.c                             | 462 ++++++-
 2 files changed, 468 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
index a661130..a5bfe87 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -1,4 +1,4 @@
-AXP209 GPIO controller
+AXP209 GPIO & pinctrl controller
 
 This driver follows the usual GPIO bindings found in
 Documentation/devicetree/bindings/gpio/gpio.txt
@@ -28,3 +28,29 @@ axp209: pmic at 34 {
 		#gpio-cells = <2>;
 	};
 };
+
+The GPIOs can be muxed to other functions and therefore, must be a subnode of
+axp_gpio.
+
+Example:
+
+&axp_gpio {
+	gpio0_adc: gpio0_adc {
+		pin = "GPIO0";
+		function = "adc";
+	};
+};
+
+&example_node {
+	pinctrl-names = "default";
+	pinctrl-0 = <&gpio0_adc>;
+};
+
+GPIOs and their functions
+-------------------------
+
+GPIO	|	Functions
+------------------------
+GPIO0	|	gpio_in, gpio_out, ldo, adc
+GPIO1	|	gpio_in, gpio_out, ldo, adc
+GPIO2	|	gpio_in, gpio_out
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4a346b7..b35e8dd 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -1,7 +1,8 @@
 /*
- * AXP20x GPIO driver
+ * AXP20x pinctrl and GPIO driver
  *
  * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
+ * Copyright (C) 201 Quentin Schulz <quentin.schulz@free-electrons.com>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under  the terms of the GNU General  Public License as published by the
@@ -22,14 +23,92 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>
+
 #define AXP20X_GPIO_FUNCTIONS		0x7
 #define AXP20X_GPIO_FUNCTION_OUT_LOW	0
 #define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
 #define AXP20X_GPIO_FUNCTION_INPUT	2
 
+#define AXP20X_PINCTRL_PIN(_pin_num, _pin)			\
+	{							\
+		.number = _pin_num,				\
+		.name = _pin,					\
+	}
+
+#define AXP20X_PIN(_pin, ...)					\
+	{							\
+		.pin = _pin,					\
+		.functions = (struct axp20x_desc_function[]) {	\
+			      __VA_ARGS__, { } },		\
+	}
+
+#define AXP20X_FUNCTION(_val, _name)				\
+	{							\
+		.name = _name,					\
+		.muxval = _val,					\
+	}
+
+struct axp20x_desc_function {
+	const char	*name;
+	u8		muxval;
+};
+
+struct axp20x_desc_pin {
+	struct pinctrl_pin_desc		pin;
+	struct axp20x_desc_function	*functions;
+};
+
+struct axp20x_pinctrl_desc {
+	const struct axp20x_desc_pin	*pins;
+	int				npins;
+};
+
+struct axp20x_pinctrl_group {
+	const char	*name;
+	unsigned long	config;
+	unsigned int	pin;
+};
+
+struct axp20x_pinctrl_function {
+	const char	*name;
+	const char	**groups;
+	unsigned int	ngroups;
+};
+
 struct axp20x_gpio {
 	struct gpio_chip	chip;
 	struct regmap		*regmap;
+	struct pinctrl_dev			*pctl_dev;
+	struct device				*dev;
+	const struct axp20x_pinctrl_desc	*desc;
+	struct axp20x_pinctrl_group		*groups;
+	unsigned int				ngroups;
+	struct axp20x_pinctrl_function		*functions;
+	unsigned int				nfunctions;
+};
+
+static const struct axp20x_desc_pin axp209_pins[] = {
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in")),
+};
+
+static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
+	.pins	= axp209_pins,
+	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
 static int axp20x_gpio_get_reg(unsigned offset)
@@ -48,16 +127,7 @@ static int axp20x_gpio_get_reg(unsigned offset)
 
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
-
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  AXP20X_GPIO_FUNCTION_INPUT);
+	return pinctrl_gpio_direction_input(chip->base + offset);
 }
 
 static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -105,30 +175,334 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
 			      int value)
 {
+	chip->set(chip, offset, value);
+
+	return 0;
+}
+
+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
+			    int value)
+{
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
 	int reg;
 
 	reg = axp20x_gpio_get_reg(offset);
 	if (reg < 0)
+		return;
+
+	regmap_update_bits(gpio->regmap, reg,
+			   AXP20X_GPIO_FUNCTIONS,
+			   value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
+			   AXP20X_GPIO_FUNCTION_OUT_LOW);
+}
+
+static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
+			  u8 config)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	int reg;
+
+	reg = axp20x_gpio_get_reg(offset);
+	if (reg < 0)
 		return reg;
 
-	return regmap_update_bits(gpio->regmap, reg,
-				  AXP20X_GPIO_FUNCTIONS,
-				  value ? AXP20X_GPIO_FUNCTION_OUT_HIGH
-				  : AXP20X_GPIO_FUNCTION_OUT_LOW);
+	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+				  config);
 }
 
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
-			    int value)
+static int axp20x_pmx_func_cnt(struct pinctrl_dev *pctldev)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->nfunctions;
+}
+
+static const char *axp20x_pmx_func_name(struct pinctrl_dev *pctldev,
+					unsigned int selector)
 {
-	axp20x_gpio_output(chip, offset, value);
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->functions[selector].name;
+}
+
+static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
+				  unsigned int selector,
+				  const char * const **groups,
+				  unsigned int *num_groups)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	*groups = gpio->functions[selector].groups;
+	*num_groups = gpio->functions[selector].ngroups;
+
+	return 0;
+}
+
+static struct axp20x_desc_function *
+axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
+				      const char *group, const char *func)
+{
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *desc_func;
+	int i;
+
+	for (i = 0; i < gpio->desc->npins; i++) {
+		pin = &gpio->desc->pins[i];
+
+		if (!strcmp(pin->pin.name, group)) {
+			desc_func = pin->functions;
+
+			while (desc_func->name) {
+				if (!strcmp(desc_func->name, func))
+					return desc_func;
+				desc_func++;
+			}
+
+			/*
+			 * Pins are uniquely named. Groups are named after one
+			 * pin name. If one pin matches group name but its
+			 * function cannot be found, no other pin will match
+			 * group name.
+			 */
+			return NULL;
+		}
+	}
+
+	return NULL;
+}
+
+static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
+			      unsigned int function, unsigned int group)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = gpio->groups + group;
+	struct axp20x_pinctrl_function *func = gpio->functions + function;
+	struct axp20x_desc_function *desc_func =
+		axp20x_pinctrl_desc_find_func_by_name(gpio, g->name,
+						      func->name);
+	if (!desc_func)
+		return -EINVAL;
+
+	return axp20x_pmx_set(pctldev, g->pin, desc_func->muxval);
+}
+
+static struct axp20x_desc_function *
+axp20x_pctl_desc_find_func_by_pin(struct axp20x_gpio *gpio, unsigned int offset,
+				  const char *func)
+{
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *desc_func;
+	int i;
+
+	for (i = 0; i < gpio->desc->npins; i++) {
+		pin = &gpio->desc->pins[i];
+
+		if (pin->pin.number == offset) {
+			desc_func = pin->functions;
+
+			while (desc_func->name) {
+				if (!strcmp(desc_func->name, func))
+					return desc_func;
+
+				desc_func++;
+			}
+		}
+	}
+
+	return NULL;
+}
+
+static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
+					 struct pinctrl_gpio_range *range,
+					 unsigned int offset, bool input)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_desc_function *desc_func;
+	const char *func;
+
+	if (input)
+		func = "gpio_in";
+	else
+		func = "gpio_out";
+
+	desc_func = axp20x_pctl_desc_find_func_by_pin(gpio, offset, func);
+	if (!desc_func)
+		return -EINVAL;
+
+	return axp20x_pmx_set(pctldev, offset, desc_func->muxval);
+}
+
+static const struct pinmux_ops axp20x_pmx_ops = {
+	.get_functions_count	= axp20x_pmx_func_cnt,
+	.get_function_name	= axp20x_pmx_func_name,
+	.get_function_groups	= axp20x_pmx_func_groups,
+	.set_mux		= axp20x_pmx_set_mux,
+	.gpio_set_direction	= axp20x_pmx_gpio_set_direction,
+	.strict			= true,
+};
+
+static int axp20x_groups_cnt(struct pinctrl_dev *pctldev)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->ngroups;
+}
+
+static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
+			     const unsigned int **pins, unsigned int *num_pins)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = gpio->groups + selector;
+
+	*pins = (unsigned int *)&g->pin;
+	*num_pins = 1;
+
+	return 0;
+}
+
+static const char *axp20x_group_name(struct pinctrl_dev *pctldev,
+				     unsigned int selector)
+{
+	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpio->groups[selector].name;
+}
+
+static const struct pinctrl_ops axp20x_pctrl_ops = {
+	.dt_node_to_map		= pinconf_generic_dt_node_to_map_group,
+	.dt_free_map		= pinconf_generic_dt_free_map,
+	.get_groups_count	= axp20x_groups_cnt,
+	.get_group_name		= axp20x_group_name,
+	.get_group_pins		= axp20x_group_pins,
+};
+
+static struct axp20x_pinctrl_function *
+axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
+{
+	struct axp20x_pinctrl_function *func = gpio->functions;
+
+	while (func->name) {
+		if (!strcmp(func->name, name))
+			return func;
+		func++;
+	}
+
+	return NULL;
+}
+
+static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
+				       const char *name)
+{
+	struct axp20x_pinctrl_function *func = gpio->functions;
+
+	while (func->name) {
+		if (!strcmp(func->name, name)) {
+			func->ngroups++;
+			return -EEXIST;
+		}
+
+		func++;
+	}
+
+	func->name = name;
+	func->ngroups = 1;
+
+	gpio->nfunctions++;
+
+	return 0;
+}
+
+static int axp20x_attach_group_function(struct platform_device *pdev,
+					const struct axp20x_desc_pin *pin)
+{
+	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	struct axp20x_desc_function *desc_func = pin->functions;
+	struct axp20x_pinctrl_function *func;
+	const char **func_grp;
+
+	while (desc_func->name) {
+		func = axp20x_pinctrl_function_by_name(gpio, desc_func->name);
+		if (!func)
+			return -EINVAL;
+
+		if (!func->groups) {
+			func->groups = devm_kzalloc(&pdev->dev,
+						    func->ngroups * sizeof(const char *),
+						    GFP_KERNEL);
+			if (!func->groups)
+				return -ENOMEM;
+		}
+
+		func_grp = func->groups;
+		while (*func_grp)
+			func_grp++;
+
+		*func_grp = pin->pin.name;
+		desc_func++;
+	}
+
+	return 0;
+}
+
+static int axp20x_build_state(struct platform_device *pdev)
+{
+	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	unsigned int npins = gpio->desc->npins;
+	const struct axp20x_desc_pin *pin;
+	struct axp20x_desc_function *func;
+	int i, ret;
+
+	gpio->ngroups = npins;
+	gpio->groups = devm_kzalloc(&pdev->dev,
+				    gpio->ngroups * sizeof(*gpio->groups),
+				    GFP_KERNEL);
+	if (!gpio->groups)
+		return -ENOMEM;
+
+	for (i = 0; i < npins; i++) {
+		gpio->groups[i].name = gpio->desc->pins[i].pin.name;
+		gpio->groups[i].pin = gpio->desc->pins[i].pin.number;
+	}
+
+	/* We assume 4 functions per pin should be enough as a default max */
+	gpio->functions = devm_kzalloc(&pdev->dev,
+				       npins * 4 * sizeof(*gpio->functions),
+				       GFP_KERNEL);
+	if (!gpio->functions)
+		return -ENOMEM;
+
+	/* Create a list of uniquely named functions */
+	for (i = 0; i < npins; i++) {
+		pin = &gpio->desc->pins[i];
+		func = pin->functions;
+
+		while (func->name) {
+			axp20x_pinctrl_add_function(gpio, func->name);
+			func++;
+		}
+	}
+
+	gpio->functions = krealloc(gpio->functions,
+				   gpio->nfunctions * sizeof(*gpio->functions),
+				   GFP_KERNEL);
+
+	for (i = 0; i < npins; i++) {
+		pin = &gpio->desc->pins[i];
+		ret = axp20x_attach_group_function(pdev, pin);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 static int axp20x_gpio_probe(struct platform_device *pdev)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct axp20x_gpio *gpio;
-	int ret;
+	struct pinctrl_desc *pctrl_desc;
+	struct pinctrl_pin_desc *pins;
+	int ret, i;
 
 	if (!of_device_is_available(pdev->dev.of_node))
 		return -ENODEV;
@@ -144,6 +518,8 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 
 	gpio->chip.base			= -1;
 	gpio->chip.can_sleep		= true;
+	gpio->chip.request		= gpiochip_generic_request;
+	gpio->chip.free			= gpiochip_generic_free;
 	gpio->chip.parent		= &pdev->dev;
 	gpio->chip.label		= dev_name(&pdev->dev);
 	gpio->chip.owner		= THIS_MODULE;
@@ -156,13 +532,56 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 
 	gpio->regmap = axp20x->regmap;
 
+	gpio->desc = &axp20x_pinctrl_data;
+	gpio->dev = &pdev->dev;
+
+	platform_set_drvdata(pdev, gpio);
+
+	ret = axp20x_build_state(pdev);
+	if (ret)
+		return ret;
+
+	pins = devm_kzalloc(&pdev->dev, gpio->desc->npins * sizeof(*pins),
+			    GFP_KERNEL);
+	if (!pins)
+		return -ENOMEM;
+
+	for (i = 0; i < gpio->desc->npins; i++)
+		pins[i] = gpio->desc->pins[i].pin;
+
+	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
+	if (!pctrl_desc)
+		return -ENOMEM;
+
+	pctrl_desc->name = dev_name(&pdev->dev);
+	pctrl_desc->owner = THIS_MODULE;
+	pctrl_desc->pins = pins;
+	pctrl_desc->npins = gpio->desc->npins;
+	pctrl_desc->pctlops = &axp20x_pctrl_ops;
+	pctrl_desc->pmxops = &axp20x_pmx_ops;
+
+	gpio->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, gpio);
+	if (IS_ERR(gpio->pctl_dev)) {
+		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
+		return PTR_ERR(gpio->pctl_dev);
+	}
+
 	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
 		return ret;
 	}
 
-	dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n");
+	ret = gpiochip_add_pin_range(&gpio->chip, dev_name(&pdev->dev),
+				     gpio->desc->pins->pin.number,
+				     gpio->desc->pins->pin.number,
+				     gpio->desc->npins);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add pin range\n");
+		return ret;
+	}
+
+	dev_info(&pdev->dev, "AXP209 pinctrl and GPIO driver loaded\n");
 
 	return 0;
 }
@@ -184,5 +603,6 @@ static struct platform_driver axp20x_gpio_driver = {
 module_platform_driver(axp20x_gpio_driver);
 
 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
-MODULE_DESCRIPTION("AXP20x PMIC GPIO driver");
+MODULE_AUTHOR("Quentin Schulz <quentin.schulz@free-electrons.com>");
+MODULE_DESCRIPTION("AXP20x PMIC pinctrl and GPIO driver");
 MODULE_LICENSE("GPL");
-- 
git-series 0.9.1

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

Instead of using a function to retrieve each pin's correct control
register, use drv_data within pinctrl_pin_desc to store the ctrl reg.

Remove axp20x_gpio_get_reg and replace every occurrence by a get from
drv_data.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 drivers/pinctrl/pinctrl-axp209.c | 42 +++++++--------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index b35e8dd..4bbcba2 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -32,10 +32,11 @@
 #define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
 #define AXP20X_GPIO_FUNCTION_INPUT	2
 
-#define AXP20X_PINCTRL_PIN(_pin_num, _pin)			\
+#define AXP20X_PINCTRL_PIN(_pin_num, _pin, _regs)		\
 	{							\
 		.number = _pin_num,				\
 		.name = _pin,					\
+		.drv_data = _regs,				\
 	}
 
 #define AXP20X_PIN(_pin, ...)					\
@@ -91,17 +92,17 @@ struct axp20x_gpio {
 };
 
 static const struct axp20x_desc_pin axp209_pins[] = {
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in"),
 		   AXP20X_FUNCTION(0x3, "ldo"),
 		   AXP20X_FUNCTION(0x4, "adc")),
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in"),
 		   AXP20X_FUNCTION(0x3, "ldo"),
 		   AXP20X_FUNCTION(0x4, "adc")),
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2", (void *)AXP20X_GPIO2_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in")),
 };
@@ -111,20 +112,6 @@ static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
 	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
-static int axp20x_gpio_get_reg(unsigned offset)
-{
-	switch (offset) {
-	case 0:
-		return AXP20X_GPIO0_CTRL;
-	case 1:
-		return AXP20X_GPIO1_CTRL;
-	case 2:
-		return AXP20X_GPIO2_CTRL;
-	}
-
-	return -EINVAL;
-}
-
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	return pinctrl_gpio_direction_input(chip->base + offset);
@@ -146,12 +133,9 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 	unsigned int val;
-	int reg, ret;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
+	int ret;
 
 	ret = regmap_read(gpio->regmap, reg, &val);
 	if (ret)
@@ -184,11 +168,7 @@ static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 			    int value)
 {
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return;
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 
 	regmap_update_bits(gpio->regmap, reg,
 			   AXP20X_GPIO_FUNCTIONS,
@@ -200,11 +180,7 @@ static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
 			  u8 config)
 {
 	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 
 	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
 				  config);
-- 
git-series 0.9.1

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

Instead of using a function to retrieve each pin's correct control
register, use drv_data within pinctrl_pin_desc to store the ctrl reg.

Remove axp20x_gpio_get_reg and replace every occurrence by a get from
drv_data.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 42 +++++++--------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index b35e8dd..4bbcba2 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -32,10 +32,11 @@
 #define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
 #define AXP20X_GPIO_FUNCTION_INPUT	2
 
-#define AXP20X_PINCTRL_PIN(_pin_num, _pin)			\
+#define AXP20X_PINCTRL_PIN(_pin_num, _pin, _regs)		\
 	{							\
 		.number = _pin_num,				\
 		.name = _pin,					\
+		.drv_data = _regs,				\
 	}
 
 #define AXP20X_PIN(_pin, ...)					\
@@ -91,17 +92,17 @@ struct axp20x_gpio {
 };
 
 static const struct axp20x_desc_pin axp209_pins[] = {
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in"),
 		   AXP20X_FUNCTION(0x3, "ldo"),
 		   AXP20X_FUNCTION(0x4, "adc")),
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in"),
 		   AXP20X_FUNCTION(0x3, "ldo"),
 		   AXP20X_FUNCTION(0x4, "adc")),
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2", (void *)AXP20X_GPIO2_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in")),
 };
@@ -111,20 +112,6 @@ static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
 	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
-static int axp20x_gpio_get_reg(unsigned offset)
-{
-	switch (offset) {
-	case 0:
-		return AXP20X_GPIO0_CTRL;
-	case 1:
-		return AXP20X_GPIO1_CTRL;
-	case 2:
-		return AXP20X_GPIO2_CTRL;
-	}
-
-	return -EINVAL;
-}
-
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	return pinctrl_gpio_direction_input(chip->base + offset);
@@ -146,12 +133,9 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 	unsigned int val;
-	int reg, ret;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
+	int ret;
 
 	ret = regmap_read(gpio->regmap, reg, &val);
 	if (ret)
@@ -184,11 +168,7 @@ static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 			    int value)
 {
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return;
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 
 	regmap_update_bits(gpio->regmap, reg,
 			   AXP20X_GPIO_FUNCTIONS,
@@ -200,11 +180,7 @@ static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
 			  u8 config)
 {
 	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 
 	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
 				  config);
-- 
git-series 0.9.1

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

Instead of using a function to retrieve each pin's correct control
register, use drv_data within pinctrl_pin_desc to store the ctrl reg.

Remove axp20x_gpio_get_reg and replace every occurrence by a get from
drv_data.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 42 +++++++--------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index b35e8dd..4bbcba2 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -32,10 +32,11 @@
 #define AXP20X_GPIO_FUNCTION_OUT_HIGH	1
 #define AXP20X_GPIO_FUNCTION_INPUT	2
 
-#define AXP20X_PINCTRL_PIN(_pin_num, _pin)			\
+#define AXP20X_PINCTRL_PIN(_pin_num, _pin, _regs)		\
 	{							\
 		.number = _pin_num,				\
 		.name = _pin,					\
+		.drv_data = _regs,				\
 	}
 
 #define AXP20X_PIN(_pin, ...)					\
@@ -91,17 +92,17 @@ struct axp20x_gpio {
 };
 
 static const struct axp20x_desc_pin axp209_pins[] = {
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in"),
 		   AXP20X_FUNCTION(0x3, "ldo"),
 		   AXP20X_FUNCTION(0x4, "adc")),
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in"),
 		   AXP20X_FUNCTION(0x3, "ldo"),
 		   AXP20X_FUNCTION(0x4, "adc")),
-	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2", (void *)AXP20X_GPIO2_CTRL),
 		   AXP20X_FUNCTION(0x0, "gpio_out"),
 		   AXP20X_FUNCTION(0x2, "gpio_in")),
 };
@@ -111,20 +112,6 @@ static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
 	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
-static int axp20x_gpio_get_reg(unsigned offset)
-{
-	switch (offset) {
-	case 0:
-		return AXP20X_GPIO0_CTRL;
-	case 1:
-		return AXP20X_GPIO1_CTRL;
-	case 2:
-		return AXP20X_GPIO2_CTRL;
-	}
-
-	return -EINVAL;
-}
-
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	return pinctrl_gpio_direction_input(chip->base + offset);
@@ -146,12 +133,9 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 	unsigned int val;
-	int reg, ret;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
+	int ret;
 
 	ret = regmap_read(gpio->regmap, reg, &val);
 	if (ret)
@@ -184,11 +168,7 @@ static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 			    int value)
 {
 	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return;
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 
 	regmap_update_bits(gpio->regmap, reg,
 			   AXP20X_GPIO_FUNCTIONS,
@@ -200,11 +180,7 @@ static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
 			  u8 config)
 {
 	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	int reg;
-
-	reg = axp20x_gpio_get_reg(offset);
-	if (reg < 0)
-		return reg;
+	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
 
 	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
 				  config);
-- 
git-series 0.9.1

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

* [PATCH v2 04/10] pinctrl: axp209: rename everything from gpio to pctl
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

This driver used to do only GPIO features of the GPIOs in X-Powers
AXP20X. Now that we have migrated everything to the pinctrl subsystem
and added pinctrl features, rename everything related to pinctrl from
gpio to pctl to ease the understanding of differences between GPIO
and pinctrl features.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 drivers/pinctrl/pinctrl-axp209.c | 198 ++++++++++++++++----------------
 1 file changed, 99 insertions(+), 99 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4bbcba2..4be1aca 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -79,7 +79,7 @@ struct axp20x_pinctrl_function {
 	unsigned int	ngroups;
 };
 
-struct axp20x_gpio {
+struct axp20x_pctl {
 	struct gpio_chip	chip;
 	struct regmap		*regmap;
 	struct pinctrl_dev			*pctl_dev;
@@ -119,11 +119,11 @@ static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 
 static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
 	unsigned int val;
 	int ret;
 
-	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
+	ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val);
 	if (ret)
 		return ret;
 
@@ -132,12 +132,12 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 	unsigned int val;
 	int ret;
 
-	ret = regmap_read(gpio->regmap, reg, &val);
+	ret = regmap_read(pctl->regmap, reg, &val);
 	if (ret)
 		return ret;
 
@@ -167,10 +167,10 @@ static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
 static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 			    int value)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 
-	regmap_update_bits(gpio->regmap, reg,
+	regmap_update_bits(pctl->regmap, reg,
 			   AXP20X_GPIO_FUNCTIONS,
 			   value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
 			   AXP20X_GPIO_FUNCTION_OUT_LOW);
@@ -179,26 +179,26 @@ static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
 			  u8 config)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 
-	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+	return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS,
 				  config);
 }
 
 static int axp20x_pmx_func_cnt(struct pinctrl_dev *pctldev)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->nfunctions;
+	return pctl->nfunctions;
 }
 
 static const char *axp20x_pmx_func_name(struct pinctrl_dev *pctldev,
 					unsigned int selector)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->functions[selector].name;
+	return pctl->functions[selector].name;
 }
 
 static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
@@ -206,24 +206,24 @@ static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
 				  const char * const **groups,
 				  unsigned int *num_groups)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	*groups = gpio->functions[selector].groups;
-	*num_groups = gpio->functions[selector].ngroups;
+	*groups = pctl->functions[selector].groups;
+	*num_groups = pctl->functions[selector].ngroups;
 
 	return 0;
 }
 
 static struct axp20x_desc_function *
-axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
+axp20x_pinctrl_desc_find_func_by_name(struct axp20x_pctl *pctl,
 				      const char *group, const char *func)
 {
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *desc_func;
 	int i;
 
-	for (i = 0; i < gpio->desc->npins; i++) {
-		pin = &gpio->desc->pins[i];
+	for (i = 0; i < pctl->desc->npins; i++) {
+		pin = &pctl->desc->pins[i];
 
 		if (!strcmp(pin->pin.name, group)) {
 			desc_func = pin->functions;
@@ -250,11 +250,11 @@ axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
 static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
 			      unsigned int function, unsigned int group)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	struct axp20x_pinctrl_group *g = gpio->groups + group;
-	struct axp20x_pinctrl_function *func = gpio->functions + function;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = pctl->groups + group;
+	struct axp20x_pinctrl_function *func = pctl->functions + function;
 	struct axp20x_desc_function *desc_func =
-		axp20x_pinctrl_desc_find_func_by_name(gpio, g->name,
+		axp20x_pinctrl_desc_find_func_by_name(pctl, g->name,
 						      func->name);
 	if (!desc_func)
 		return -EINVAL;
@@ -263,15 +263,15 @@ static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
 }
 
 static struct axp20x_desc_function *
-axp20x_pctl_desc_find_func_by_pin(struct axp20x_gpio *gpio, unsigned int offset,
+axp20x_pctl_desc_find_func_by_pin(struct axp20x_pctl *pctl, unsigned int offset,
 				  const char *func)
 {
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *desc_func;
 	int i;
 
-	for (i = 0; i < gpio->desc->npins; i++) {
-		pin = &gpio->desc->pins[i];
+	for (i = 0; i < pctl->desc->npins; i++) {
+		pin = &pctl->desc->pins[i];
 
 		if (pin->pin.number == offset) {
 			desc_func = pin->functions;
@@ -292,7 +292,7 @@ static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 					 struct pinctrl_gpio_range *range,
 					 unsigned int offset, bool input)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 	struct axp20x_desc_function *desc_func;
 	const char *func;
 
@@ -301,7 +301,7 @@ static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 	else
 		func = "gpio_out";
 
-	desc_func = axp20x_pctl_desc_find_func_by_pin(gpio, offset, func);
+	desc_func = axp20x_pctl_desc_find_func_by_pin(pctl, offset, func);
 	if (!desc_func)
 		return -EINVAL;
 
@@ -319,16 +319,16 @@ static const struct pinmux_ops axp20x_pmx_ops = {
 
 static int axp20x_groups_cnt(struct pinctrl_dev *pctldev)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->ngroups;
+	return pctl->ngroups;
 }
 
 static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
 			     const unsigned int **pins, unsigned int *num_pins)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	struct axp20x_pinctrl_group *g = gpio->groups + selector;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = pctl->groups + selector;
 
 	*pins = (unsigned int *)&g->pin;
 	*num_pins = 1;
@@ -339,9 +339,9 @@ static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
 static const char *axp20x_group_name(struct pinctrl_dev *pctldev,
 				     unsigned int selector)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->groups[selector].name;
+	return pctl->groups[selector].name;
 }
 
 static const struct pinctrl_ops axp20x_pctrl_ops = {
@@ -353,9 +353,9 @@ static const struct pinctrl_ops axp20x_pctrl_ops = {
 };
 
 static struct axp20x_pinctrl_function *
-axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
+axp20x_pinctrl_function_by_name(struct axp20x_pctl *pctl, const char *name)
 {
-	struct axp20x_pinctrl_function *func = gpio->functions;
+	struct axp20x_pinctrl_function *func = pctl->functions;
 
 	while (func->name) {
 		if (!strcmp(func->name, name))
@@ -366,10 +366,10 @@ axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
 	return NULL;
 }
 
-static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
+static int axp20x_pinctrl_add_function(struct axp20x_pctl *pctl,
 				       const char *name)
 {
-	struct axp20x_pinctrl_function *func = gpio->functions;
+	struct axp20x_pinctrl_function *func = pctl->functions;
 
 	while (func->name) {
 		if (!strcmp(func->name, name)) {
@@ -383,7 +383,7 @@ static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
 	func->name = name;
 	func->ngroups = 1;
 
-	gpio->nfunctions++;
+	pctl->nfunctions++;
 
 	return 0;
 }
@@ -391,13 +391,13 @@ static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
 static int axp20x_attach_group_function(struct platform_device *pdev,
 					const struct axp20x_desc_pin *pin)
 {
-	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	struct axp20x_pctl *pctl = platform_get_drvdata(pdev);
 	struct axp20x_desc_function *desc_func = pin->functions;
 	struct axp20x_pinctrl_function *func;
 	const char **func_grp;
 
 	while (desc_func->name) {
-		func = axp20x_pinctrl_function_by_name(gpio, desc_func->name);
+		func = axp20x_pinctrl_function_by_name(pctl, desc_func->name);
 		if (!func)
 			return -EINVAL;
 
@@ -422,48 +422,48 @@ static int axp20x_attach_group_function(struct platform_device *pdev,
 
 static int axp20x_build_state(struct platform_device *pdev)
 {
-	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
-	unsigned int npins = gpio->desc->npins;
+	struct axp20x_pctl *pctl = platform_get_drvdata(pdev);
+	unsigned int npins = pctl->desc->npins;
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *func;
 	int i, ret;
 
-	gpio->ngroups = npins;
-	gpio->groups = devm_kzalloc(&pdev->dev,
-				    gpio->ngroups * sizeof(*gpio->groups),
+	pctl->ngroups = npins;
+	pctl->groups = devm_kzalloc(&pdev->dev,
+				    pctl->ngroups * sizeof(*pctl->groups),
 				    GFP_KERNEL);
-	if (!gpio->groups)
+	if (!pctl->groups)
 		return -ENOMEM;
 
 	for (i = 0; i < npins; i++) {
-		gpio->groups[i].name = gpio->desc->pins[i].pin.name;
-		gpio->groups[i].pin = gpio->desc->pins[i].pin.number;
+		pctl->groups[i].name = pctl->desc->pins[i].pin.name;
+		pctl->groups[i].pin = pctl->desc->pins[i].pin.number;
 	}
 
 	/* We assume 4 functions per pin should be enough as a default max */
-	gpio->functions = devm_kzalloc(&pdev->dev,
-				       npins * 4 * sizeof(*gpio->functions),
+	pctl->functions = devm_kzalloc(&pdev->dev,
+				       npins * 4 * sizeof(*pctl->functions),
 				       GFP_KERNEL);
-	if (!gpio->functions)
+	if (!pctl->functions)
 		return -ENOMEM;
 
 	/* Create a list of uniquely named functions */
 	for (i = 0; i < npins; i++) {
-		pin = &gpio->desc->pins[i];
+		pin = &pctl->desc->pins[i];
 		func = pin->functions;
 
 		while (func->name) {
-			axp20x_pinctrl_add_function(gpio, func->name);
+			axp20x_pinctrl_add_function(pctl, func->name);
 			func++;
 		}
 	}
 
-	gpio->functions = krealloc(gpio->functions,
-				   gpio->nfunctions * sizeof(*gpio->functions),
+	pctl->functions = krealloc(pctl->functions,
+				   pctl->nfunctions * sizeof(*pctl->functions),
 				   GFP_KERNEL);
 
 	for (i = 0; i < npins; i++) {
-		pin = &gpio->desc->pins[i];
+		pin = &pctl->desc->pins[i];
 		ret = axp20x_attach_group_function(pdev, pin);
 		if (ret)
 			return ret;
@@ -472,10 +472,10 @@ static int axp20x_build_state(struct platform_device *pdev)
 	return 0;
 }
 
-static int axp20x_gpio_probe(struct platform_device *pdev)
+static int axp20x_pctl_probe(struct platform_device *pdev)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-	struct axp20x_gpio *gpio;
+	struct axp20x_pctl *pctl;
 	struct pinctrl_desc *pctrl_desc;
 	struct pinctrl_pin_desc *pins;
 	int ret, i;
@@ -488,42 +488,42 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
-	if (!gpio)
+	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
+	if (!pctl)
 		return -ENOMEM;
 
-	gpio->chip.base			= -1;
-	gpio->chip.can_sleep		= true;
-	gpio->chip.request		= gpiochip_generic_request;
-	gpio->chip.free			= gpiochip_generic_free;
-	gpio->chip.parent		= &pdev->dev;
-	gpio->chip.label		= dev_name(&pdev->dev);
-	gpio->chip.owner		= THIS_MODULE;
-	gpio->chip.get			= axp20x_gpio_get;
-	gpio->chip.get_direction	= axp20x_gpio_get_direction;
-	gpio->chip.set			= axp20x_gpio_set;
-	gpio->chip.direction_input	= axp20x_gpio_input;
-	gpio->chip.direction_output	= axp20x_gpio_output;
-	gpio->chip.ngpio		= 3;
+	pctl->chip.base			= -1;
+	pctl->chip.can_sleep		= true;
+	pctl->chip.request		= gpiochip_generic_request;
+	pctl->chip.free			= gpiochip_generic_free;
+	pctl->chip.parent		= &pdev->dev;
+	pctl->chip.label		= dev_name(&pdev->dev);
+	pctl->chip.owner		= THIS_MODULE;
+	pctl->chip.get			= axp20x_gpio_get;
+	pctl->chip.get_direction	= axp20x_gpio_get_direction;
+	pctl->chip.set			= axp20x_gpio_set;
+	pctl->chip.direction_input	= axp20x_gpio_input;
+	pctl->chip.direction_output	= axp20x_gpio_output;
+	pctl->chip.ngpio		= 3;
 
-	gpio->regmap = axp20x->regmap;
+	pctl->regmap = axp20x->regmap;
 
-	gpio->desc = &axp20x_pinctrl_data;
-	gpio->dev = &pdev->dev;
+	pctl->desc = &axp20x_pinctrl_data;
+	pctl->dev = &pdev->dev;
 
-	platform_set_drvdata(pdev, gpio);
+	platform_set_drvdata(pdev, pctl);
 
 	ret = axp20x_build_state(pdev);
 	if (ret)
 		return ret;
 
-	pins = devm_kzalloc(&pdev->dev, gpio->desc->npins * sizeof(*pins),
+	pins = devm_kzalloc(&pdev->dev, pctl->desc->npins * sizeof(*pins),
 			    GFP_KERNEL);
 	if (!pins)
 		return -ENOMEM;
 
-	for (i = 0; i < gpio->desc->npins; i++)
-		pins[i] = gpio->desc->pins[i].pin;
+	for (i = 0; i < pctl->desc->npins; i++)
+		pins[i] = pctl->desc->pins[i].pin;
 
 	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
 	if (!pctrl_desc)
@@ -532,26 +532,26 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 	pctrl_desc->name = dev_name(&pdev->dev);
 	pctrl_desc->owner = THIS_MODULE;
 	pctrl_desc->pins = pins;
-	pctrl_desc->npins = gpio->desc->npins;
+	pctrl_desc->npins = pctl->desc->npins;
 	pctrl_desc->pctlops = &axp20x_pctrl_ops;
 	pctrl_desc->pmxops = &axp20x_pmx_ops;
 
-	gpio->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, gpio);
-	if (IS_ERR(gpio->pctl_dev)) {
+	pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl);
+	if (IS_ERR(pctl->pctl_dev)) {
 		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
-		return PTR_ERR(gpio->pctl_dev);
+		return PTR_ERR(pctl->pctl_dev);
 	}
 
-	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
+	ret = devm_gpiochip_add_data(&pdev->dev, &pctl->chip, pctl);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
 		return ret;
 	}
 
-	ret = gpiochip_add_pin_range(&gpio->chip, dev_name(&pdev->dev),
-				     gpio->desc->pins->pin.number,
-				     gpio->desc->pins->pin.number,
-				     gpio->desc->npins);
+	ret = gpiochip_add_pin_range(&pctl->chip, dev_name(&pdev->dev),
+				     pctl->desc->pins->pin.number,
+				     pctl->desc->pins->pin.number,
+				     pctl->desc->npins);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add pin range\n");
 		return ret;
@@ -562,21 +562,21 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id axp20x_gpio_match[] = {
+static const struct of_device_id axp20x_pctl_match[] = {
 	{ .compatible = "x-powers,axp209-gpio" },
 	{ }
 };
-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
+MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
 
-static struct platform_driver axp20x_gpio_driver = {
-	.probe		= axp20x_gpio_probe,
+static struct platform_driver axp20x_pctl_driver = {
+	.probe		= axp20x_pctl_probe,
 	.driver = {
 		.name		= "axp20x-gpio",
-		.of_match_table	= axp20x_gpio_match,
+		.of_match_table	= axp20x_pctl_match,
 	},
 };
 
-module_platform_driver(axp20x_gpio_driver);
+module_platform_driver(axp20x_pctl_driver);
 
 MODULE_AUTHOR("Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
 MODULE_AUTHOR("Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
-- 
git-series 0.9.1

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

* [PATCH v2 04/10] pinctrl: axp209: rename everything from gpio to pctl
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

This driver used to do only GPIO features of the GPIOs in X-Powers
AXP20X. Now that we have migrated everything to the pinctrl subsystem
and added pinctrl features, rename everything related to pinctrl from
gpio to pctl to ease the understanding of differences between GPIO
and pinctrl features.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 198 ++++++++++++++++----------------
 1 file changed, 99 insertions(+), 99 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4bbcba2..4be1aca 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -79,7 +79,7 @@ struct axp20x_pinctrl_function {
 	unsigned int	ngroups;
 };
 
-struct axp20x_gpio {
+struct axp20x_pctl {
 	struct gpio_chip	chip;
 	struct regmap		*regmap;
 	struct pinctrl_dev			*pctl_dev;
@@ -119,11 +119,11 @@ static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 
 static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
 	unsigned int val;
 	int ret;
 
-	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
+	ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val);
 	if (ret)
 		return ret;
 
@@ -132,12 +132,12 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 	unsigned int val;
 	int ret;
 
-	ret = regmap_read(gpio->regmap, reg, &val);
+	ret = regmap_read(pctl->regmap, reg, &val);
 	if (ret)
 		return ret;
 
@@ -167,10 +167,10 @@ static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
 static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 			    int value)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 
-	regmap_update_bits(gpio->regmap, reg,
+	regmap_update_bits(pctl->regmap, reg,
 			   AXP20X_GPIO_FUNCTIONS,
 			   value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
 			   AXP20X_GPIO_FUNCTION_OUT_LOW);
@@ -179,26 +179,26 @@ static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
 			  u8 config)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 
-	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+	return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS,
 				  config);
 }
 
 static int axp20x_pmx_func_cnt(struct pinctrl_dev *pctldev)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->nfunctions;
+	return pctl->nfunctions;
 }
 
 static const char *axp20x_pmx_func_name(struct pinctrl_dev *pctldev,
 					unsigned int selector)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->functions[selector].name;
+	return pctl->functions[selector].name;
 }
 
 static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
@@ -206,24 +206,24 @@ static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
 				  const char * const **groups,
 				  unsigned int *num_groups)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	*groups = gpio->functions[selector].groups;
-	*num_groups = gpio->functions[selector].ngroups;
+	*groups = pctl->functions[selector].groups;
+	*num_groups = pctl->functions[selector].ngroups;
 
 	return 0;
 }
 
 static struct axp20x_desc_function *
-axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
+axp20x_pinctrl_desc_find_func_by_name(struct axp20x_pctl *pctl,
 				      const char *group, const char *func)
 {
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *desc_func;
 	int i;
 
-	for (i = 0; i < gpio->desc->npins; i++) {
-		pin = &gpio->desc->pins[i];
+	for (i = 0; i < pctl->desc->npins; i++) {
+		pin = &pctl->desc->pins[i];
 
 		if (!strcmp(pin->pin.name, group)) {
 			desc_func = pin->functions;
@@ -250,11 +250,11 @@ axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
 static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
 			      unsigned int function, unsigned int group)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	struct axp20x_pinctrl_group *g = gpio->groups + group;
-	struct axp20x_pinctrl_function *func = gpio->functions + function;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = pctl->groups + group;
+	struct axp20x_pinctrl_function *func = pctl->functions + function;
 	struct axp20x_desc_function *desc_func =
-		axp20x_pinctrl_desc_find_func_by_name(gpio, g->name,
+		axp20x_pinctrl_desc_find_func_by_name(pctl, g->name,
 						      func->name);
 	if (!desc_func)
 		return -EINVAL;
@@ -263,15 +263,15 @@ static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
 }
 
 static struct axp20x_desc_function *
-axp20x_pctl_desc_find_func_by_pin(struct axp20x_gpio *gpio, unsigned int offset,
+axp20x_pctl_desc_find_func_by_pin(struct axp20x_pctl *pctl, unsigned int offset,
 				  const char *func)
 {
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *desc_func;
 	int i;
 
-	for (i = 0; i < gpio->desc->npins; i++) {
-		pin = &gpio->desc->pins[i];
+	for (i = 0; i < pctl->desc->npins; i++) {
+		pin = &pctl->desc->pins[i];
 
 		if (pin->pin.number == offset) {
 			desc_func = pin->functions;
@@ -292,7 +292,7 @@ static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 					 struct pinctrl_gpio_range *range,
 					 unsigned int offset, bool input)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 	struct axp20x_desc_function *desc_func;
 	const char *func;
 
@@ -301,7 +301,7 @@ static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 	else
 		func = "gpio_out";
 
-	desc_func = axp20x_pctl_desc_find_func_by_pin(gpio, offset, func);
+	desc_func = axp20x_pctl_desc_find_func_by_pin(pctl, offset, func);
 	if (!desc_func)
 		return -EINVAL;
 
@@ -319,16 +319,16 @@ static const struct pinmux_ops axp20x_pmx_ops = {
 
 static int axp20x_groups_cnt(struct pinctrl_dev *pctldev)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->ngroups;
+	return pctl->ngroups;
 }
 
 static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
 			     const unsigned int **pins, unsigned int *num_pins)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	struct axp20x_pinctrl_group *g = gpio->groups + selector;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = pctl->groups + selector;
 
 	*pins = (unsigned int *)&g->pin;
 	*num_pins = 1;
@@ -339,9 +339,9 @@ static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
 static const char *axp20x_group_name(struct pinctrl_dev *pctldev,
 				     unsigned int selector)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->groups[selector].name;
+	return pctl->groups[selector].name;
 }
 
 static const struct pinctrl_ops axp20x_pctrl_ops = {
@@ -353,9 +353,9 @@ static const struct pinctrl_ops axp20x_pctrl_ops = {
 };
 
 static struct axp20x_pinctrl_function *
-axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
+axp20x_pinctrl_function_by_name(struct axp20x_pctl *pctl, const char *name)
 {
-	struct axp20x_pinctrl_function *func = gpio->functions;
+	struct axp20x_pinctrl_function *func = pctl->functions;
 
 	while (func->name) {
 		if (!strcmp(func->name, name))
@@ -366,10 +366,10 @@ axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
 	return NULL;
 }
 
-static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
+static int axp20x_pinctrl_add_function(struct axp20x_pctl *pctl,
 				       const char *name)
 {
-	struct axp20x_pinctrl_function *func = gpio->functions;
+	struct axp20x_pinctrl_function *func = pctl->functions;
 
 	while (func->name) {
 		if (!strcmp(func->name, name)) {
@@ -383,7 +383,7 @@ static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
 	func->name = name;
 	func->ngroups = 1;
 
-	gpio->nfunctions++;
+	pctl->nfunctions++;
 
 	return 0;
 }
@@ -391,13 +391,13 @@ static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
 static int axp20x_attach_group_function(struct platform_device *pdev,
 					const struct axp20x_desc_pin *pin)
 {
-	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	struct axp20x_pctl *pctl = platform_get_drvdata(pdev);
 	struct axp20x_desc_function *desc_func = pin->functions;
 	struct axp20x_pinctrl_function *func;
 	const char **func_grp;
 
 	while (desc_func->name) {
-		func = axp20x_pinctrl_function_by_name(gpio, desc_func->name);
+		func = axp20x_pinctrl_function_by_name(pctl, desc_func->name);
 		if (!func)
 			return -EINVAL;
 
@@ -422,48 +422,48 @@ static int axp20x_attach_group_function(struct platform_device *pdev,
 
 static int axp20x_build_state(struct platform_device *pdev)
 {
-	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
-	unsigned int npins = gpio->desc->npins;
+	struct axp20x_pctl *pctl = platform_get_drvdata(pdev);
+	unsigned int npins = pctl->desc->npins;
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *func;
 	int i, ret;
 
-	gpio->ngroups = npins;
-	gpio->groups = devm_kzalloc(&pdev->dev,
-				    gpio->ngroups * sizeof(*gpio->groups),
+	pctl->ngroups = npins;
+	pctl->groups = devm_kzalloc(&pdev->dev,
+				    pctl->ngroups * sizeof(*pctl->groups),
 				    GFP_KERNEL);
-	if (!gpio->groups)
+	if (!pctl->groups)
 		return -ENOMEM;
 
 	for (i = 0; i < npins; i++) {
-		gpio->groups[i].name = gpio->desc->pins[i].pin.name;
-		gpio->groups[i].pin = gpio->desc->pins[i].pin.number;
+		pctl->groups[i].name = pctl->desc->pins[i].pin.name;
+		pctl->groups[i].pin = pctl->desc->pins[i].pin.number;
 	}
 
 	/* We assume 4 functions per pin should be enough as a default max */
-	gpio->functions = devm_kzalloc(&pdev->dev,
-				       npins * 4 * sizeof(*gpio->functions),
+	pctl->functions = devm_kzalloc(&pdev->dev,
+				       npins * 4 * sizeof(*pctl->functions),
 				       GFP_KERNEL);
-	if (!gpio->functions)
+	if (!pctl->functions)
 		return -ENOMEM;
 
 	/* Create a list of uniquely named functions */
 	for (i = 0; i < npins; i++) {
-		pin = &gpio->desc->pins[i];
+		pin = &pctl->desc->pins[i];
 		func = pin->functions;
 
 		while (func->name) {
-			axp20x_pinctrl_add_function(gpio, func->name);
+			axp20x_pinctrl_add_function(pctl, func->name);
 			func++;
 		}
 	}
 
-	gpio->functions = krealloc(gpio->functions,
-				   gpio->nfunctions * sizeof(*gpio->functions),
+	pctl->functions = krealloc(pctl->functions,
+				   pctl->nfunctions * sizeof(*pctl->functions),
 				   GFP_KERNEL);
 
 	for (i = 0; i < npins; i++) {
-		pin = &gpio->desc->pins[i];
+		pin = &pctl->desc->pins[i];
 		ret = axp20x_attach_group_function(pdev, pin);
 		if (ret)
 			return ret;
@@ -472,10 +472,10 @@ static int axp20x_build_state(struct platform_device *pdev)
 	return 0;
 }
 
-static int axp20x_gpio_probe(struct platform_device *pdev)
+static int axp20x_pctl_probe(struct platform_device *pdev)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-	struct axp20x_gpio *gpio;
+	struct axp20x_pctl *pctl;
 	struct pinctrl_desc *pctrl_desc;
 	struct pinctrl_pin_desc *pins;
 	int ret, i;
@@ -488,42 +488,42 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
-	if (!gpio)
+	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
+	if (!pctl)
 		return -ENOMEM;
 
-	gpio->chip.base			= -1;
-	gpio->chip.can_sleep		= true;
-	gpio->chip.request		= gpiochip_generic_request;
-	gpio->chip.free			= gpiochip_generic_free;
-	gpio->chip.parent		= &pdev->dev;
-	gpio->chip.label		= dev_name(&pdev->dev);
-	gpio->chip.owner		= THIS_MODULE;
-	gpio->chip.get			= axp20x_gpio_get;
-	gpio->chip.get_direction	= axp20x_gpio_get_direction;
-	gpio->chip.set			= axp20x_gpio_set;
-	gpio->chip.direction_input	= axp20x_gpio_input;
-	gpio->chip.direction_output	= axp20x_gpio_output;
-	gpio->chip.ngpio		= 3;
+	pctl->chip.base			= -1;
+	pctl->chip.can_sleep		= true;
+	pctl->chip.request		= gpiochip_generic_request;
+	pctl->chip.free			= gpiochip_generic_free;
+	pctl->chip.parent		= &pdev->dev;
+	pctl->chip.label		= dev_name(&pdev->dev);
+	pctl->chip.owner		= THIS_MODULE;
+	pctl->chip.get			= axp20x_gpio_get;
+	pctl->chip.get_direction	= axp20x_gpio_get_direction;
+	pctl->chip.set			= axp20x_gpio_set;
+	pctl->chip.direction_input	= axp20x_gpio_input;
+	pctl->chip.direction_output	= axp20x_gpio_output;
+	pctl->chip.ngpio		= 3;
 
-	gpio->regmap = axp20x->regmap;
+	pctl->regmap = axp20x->regmap;
 
-	gpio->desc = &axp20x_pinctrl_data;
-	gpio->dev = &pdev->dev;
+	pctl->desc = &axp20x_pinctrl_data;
+	pctl->dev = &pdev->dev;
 
-	platform_set_drvdata(pdev, gpio);
+	platform_set_drvdata(pdev, pctl);
 
 	ret = axp20x_build_state(pdev);
 	if (ret)
 		return ret;
 
-	pins = devm_kzalloc(&pdev->dev, gpio->desc->npins * sizeof(*pins),
+	pins = devm_kzalloc(&pdev->dev, pctl->desc->npins * sizeof(*pins),
 			    GFP_KERNEL);
 	if (!pins)
 		return -ENOMEM;
 
-	for (i = 0; i < gpio->desc->npins; i++)
-		pins[i] = gpio->desc->pins[i].pin;
+	for (i = 0; i < pctl->desc->npins; i++)
+		pins[i] = pctl->desc->pins[i].pin;
 
 	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
 	if (!pctrl_desc)
@@ -532,26 +532,26 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 	pctrl_desc->name = dev_name(&pdev->dev);
 	pctrl_desc->owner = THIS_MODULE;
 	pctrl_desc->pins = pins;
-	pctrl_desc->npins = gpio->desc->npins;
+	pctrl_desc->npins = pctl->desc->npins;
 	pctrl_desc->pctlops = &axp20x_pctrl_ops;
 	pctrl_desc->pmxops = &axp20x_pmx_ops;
 
-	gpio->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, gpio);
-	if (IS_ERR(gpio->pctl_dev)) {
+	pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl);
+	if (IS_ERR(pctl->pctl_dev)) {
 		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
-		return PTR_ERR(gpio->pctl_dev);
+		return PTR_ERR(pctl->pctl_dev);
 	}
 
-	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
+	ret = devm_gpiochip_add_data(&pdev->dev, &pctl->chip, pctl);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
 		return ret;
 	}
 
-	ret = gpiochip_add_pin_range(&gpio->chip, dev_name(&pdev->dev),
-				     gpio->desc->pins->pin.number,
-				     gpio->desc->pins->pin.number,
-				     gpio->desc->npins);
+	ret = gpiochip_add_pin_range(&pctl->chip, dev_name(&pdev->dev),
+				     pctl->desc->pins->pin.number,
+				     pctl->desc->pins->pin.number,
+				     pctl->desc->npins);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add pin range\n");
 		return ret;
@@ -562,21 +562,21 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id axp20x_gpio_match[] = {
+static const struct of_device_id axp20x_pctl_match[] = {
 	{ .compatible = "x-powers,axp209-gpio" },
 	{ }
 };
-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
+MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
 
-static struct platform_driver axp20x_gpio_driver = {
-	.probe		= axp20x_gpio_probe,
+static struct platform_driver axp20x_pctl_driver = {
+	.probe		= axp20x_pctl_probe,
 	.driver = {
 		.name		= "axp20x-gpio",
-		.of_match_table	= axp20x_gpio_match,
+		.of_match_table	= axp20x_pctl_match,
 	},
 };
 
-module_platform_driver(axp20x_gpio_driver);
+module_platform_driver(axp20x_pctl_driver);
 
 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
 MODULE_AUTHOR("Quentin Schulz <quentin.schulz@free-electrons.com>");
-- 
git-series 0.9.1

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

* [PATCH v2 04/10] pinctrl: axp209: rename everything from gpio to pctl
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

This driver used to do only GPIO features of the GPIOs in X-Powers
AXP20X. Now that we have migrated everything to the pinctrl subsystem
and added pinctrl features, rename everything related to pinctrl from
gpio to pctl to ease the understanding of differences between GPIO
and pinctrl features.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 198 ++++++++++++++++----------------
 1 file changed, 99 insertions(+), 99 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4bbcba2..4be1aca 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -79,7 +79,7 @@ struct axp20x_pinctrl_function {
 	unsigned int	ngroups;
 };
 
-struct axp20x_gpio {
+struct axp20x_pctl {
 	struct gpio_chip	chip;
 	struct regmap		*regmap;
 	struct pinctrl_dev			*pctl_dev;
@@ -119,11 +119,11 @@ static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 
 static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
 	unsigned int val;
 	int ret;
 
-	ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
+	ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val);
 	if (ret)
 		return ret;
 
@@ -132,12 +132,12 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 	unsigned int val;
 	int ret;
 
-	ret = regmap_read(gpio->regmap, reg, &val);
+	ret = regmap_read(pctl->regmap, reg, &val);
 	if (ret)
 		return ret;
 
@@ -167,10 +167,10 @@ static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,
 static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 			    int value)
 {
-	struct axp20x_gpio *gpio = gpiochip_get_data(chip);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = gpiochip_get_data(chip);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 
-	regmap_update_bits(gpio->regmap, reg,
+	regmap_update_bits(pctl->regmap, reg,
 			   AXP20X_GPIO_FUNCTIONS,
 			   value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
 			   AXP20X_GPIO_FUNCTION_OUT_LOW);
@@ -179,26 +179,26 @@ static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,
 static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
 			  u8 config)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	int reg = (int)gpio->desc->pins[offset].pin.drv_data;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	int reg = (int)pctl->desc->pins[offset].pin.drv_data;
 
-	return regmap_update_bits(gpio->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+	return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS,
 				  config);
 }
 
 static int axp20x_pmx_func_cnt(struct pinctrl_dev *pctldev)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->nfunctions;
+	return pctl->nfunctions;
 }
 
 static const char *axp20x_pmx_func_name(struct pinctrl_dev *pctldev,
 					unsigned int selector)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->functions[selector].name;
+	return pctl->functions[selector].name;
 }
 
 static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
@@ -206,24 +206,24 @@ static int axp20x_pmx_func_groups(struct pinctrl_dev *pctldev,
 				  const char * const **groups,
 				  unsigned int *num_groups)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	*groups = gpio->functions[selector].groups;
-	*num_groups = gpio->functions[selector].ngroups;
+	*groups = pctl->functions[selector].groups;
+	*num_groups = pctl->functions[selector].ngroups;
 
 	return 0;
 }
 
 static struct axp20x_desc_function *
-axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
+axp20x_pinctrl_desc_find_func_by_name(struct axp20x_pctl *pctl,
 				      const char *group, const char *func)
 {
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *desc_func;
 	int i;
 
-	for (i = 0; i < gpio->desc->npins; i++) {
-		pin = &gpio->desc->pins[i];
+	for (i = 0; i < pctl->desc->npins; i++) {
+		pin = &pctl->desc->pins[i];
 
 		if (!strcmp(pin->pin.name, group)) {
 			desc_func = pin->functions;
@@ -250,11 +250,11 @@ axp20x_pinctrl_desc_find_func_by_name(struct axp20x_gpio *gpio,
 static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
 			      unsigned int function, unsigned int group)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	struct axp20x_pinctrl_group *g = gpio->groups + group;
-	struct axp20x_pinctrl_function *func = gpio->functions + function;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = pctl->groups + group;
+	struct axp20x_pinctrl_function *func = pctl->functions + function;
 	struct axp20x_desc_function *desc_func =
-		axp20x_pinctrl_desc_find_func_by_name(gpio, g->name,
+		axp20x_pinctrl_desc_find_func_by_name(pctl, g->name,
 						      func->name);
 	if (!desc_func)
 		return -EINVAL;
@@ -263,15 +263,15 @@ static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev,
 }
 
 static struct axp20x_desc_function *
-axp20x_pctl_desc_find_func_by_pin(struct axp20x_gpio *gpio, unsigned int offset,
+axp20x_pctl_desc_find_func_by_pin(struct axp20x_pctl *pctl, unsigned int offset,
 				  const char *func)
 {
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *desc_func;
 	int i;
 
-	for (i = 0; i < gpio->desc->npins; i++) {
-		pin = &gpio->desc->pins[i];
+	for (i = 0; i < pctl->desc->npins; i++) {
+		pin = &pctl->desc->pins[i];
 
 		if (pin->pin.number == offset) {
 			desc_func = pin->functions;
@@ -292,7 +292,7 @@ static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 					 struct pinctrl_gpio_range *range,
 					 unsigned int offset, bool input)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 	struct axp20x_desc_function *desc_func;
 	const char *func;
 
@@ -301,7 +301,7 @@ static int axp20x_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 	else
 		func = "gpio_out";
 
-	desc_func = axp20x_pctl_desc_find_func_by_pin(gpio, offset, func);
+	desc_func = axp20x_pctl_desc_find_func_by_pin(pctl, offset, func);
 	if (!desc_func)
 		return -EINVAL;
 
@@ -319,16 +319,16 @@ static const struct pinmux_ops axp20x_pmx_ops = {
 
 static int axp20x_groups_cnt(struct pinctrl_dev *pctldev)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->ngroups;
+	return pctl->ngroups;
 }
 
 static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
 			     const unsigned int **pins, unsigned int *num_pins)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
-	struct axp20x_pinctrl_group *g = gpio->groups + selector;
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pinctrl_group *g = pctl->groups + selector;
 
 	*pins = (unsigned int *)&g->pin;
 	*num_pins = 1;
@@ -339,9 +339,9 @@ static int axp20x_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
 static const char *axp20x_group_name(struct pinctrl_dev *pctldev,
 				     unsigned int selector)
 {
-	struct axp20x_gpio *gpio = pinctrl_dev_get_drvdata(pctldev);
+	struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
-	return gpio->groups[selector].name;
+	return pctl->groups[selector].name;
 }
 
 static const struct pinctrl_ops axp20x_pctrl_ops = {
@@ -353,9 +353,9 @@ static const struct pinctrl_ops axp20x_pctrl_ops = {
 };
 
 static struct axp20x_pinctrl_function *
-axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
+axp20x_pinctrl_function_by_name(struct axp20x_pctl *pctl, const char *name)
 {
-	struct axp20x_pinctrl_function *func = gpio->functions;
+	struct axp20x_pinctrl_function *func = pctl->functions;
 
 	while (func->name) {
 		if (!strcmp(func->name, name))
@@ -366,10 +366,10 @@ axp20x_pinctrl_function_by_name(struct axp20x_gpio *gpio, const char *name)
 	return NULL;
 }
 
-static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
+static int axp20x_pinctrl_add_function(struct axp20x_pctl *pctl,
 				       const char *name)
 {
-	struct axp20x_pinctrl_function *func = gpio->functions;
+	struct axp20x_pinctrl_function *func = pctl->functions;
 
 	while (func->name) {
 		if (!strcmp(func->name, name)) {
@@ -383,7 +383,7 @@ static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
 	func->name = name;
 	func->ngroups = 1;
 
-	gpio->nfunctions++;
+	pctl->nfunctions++;
 
 	return 0;
 }
@@ -391,13 +391,13 @@ static int axp20x_pinctrl_add_function(struct axp20x_gpio *gpio,
 static int axp20x_attach_group_function(struct platform_device *pdev,
 					const struct axp20x_desc_pin *pin)
 {
-	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
+	struct axp20x_pctl *pctl = platform_get_drvdata(pdev);
 	struct axp20x_desc_function *desc_func = pin->functions;
 	struct axp20x_pinctrl_function *func;
 	const char **func_grp;
 
 	while (desc_func->name) {
-		func = axp20x_pinctrl_function_by_name(gpio, desc_func->name);
+		func = axp20x_pinctrl_function_by_name(pctl, desc_func->name);
 		if (!func)
 			return -EINVAL;
 
@@ -422,48 +422,48 @@ static int axp20x_attach_group_function(struct platform_device *pdev,
 
 static int axp20x_build_state(struct platform_device *pdev)
 {
-	struct axp20x_gpio *gpio = platform_get_drvdata(pdev);
-	unsigned int npins = gpio->desc->npins;
+	struct axp20x_pctl *pctl = platform_get_drvdata(pdev);
+	unsigned int npins = pctl->desc->npins;
 	const struct axp20x_desc_pin *pin;
 	struct axp20x_desc_function *func;
 	int i, ret;
 
-	gpio->ngroups = npins;
-	gpio->groups = devm_kzalloc(&pdev->dev,
-				    gpio->ngroups * sizeof(*gpio->groups),
+	pctl->ngroups = npins;
+	pctl->groups = devm_kzalloc(&pdev->dev,
+				    pctl->ngroups * sizeof(*pctl->groups),
 				    GFP_KERNEL);
-	if (!gpio->groups)
+	if (!pctl->groups)
 		return -ENOMEM;
 
 	for (i = 0; i < npins; i++) {
-		gpio->groups[i].name = gpio->desc->pins[i].pin.name;
-		gpio->groups[i].pin = gpio->desc->pins[i].pin.number;
+		pctl->groups[i].name = pctl->desc->pins[i].pin.name;
+		pctl->groups[i].pin = pctl->desc->pins[i].pin.number;
 	}
 
 	/* We assume 4 functions per pin should be enough as a default max */
-	gpio->functions = devm_kzalloc(&pdev->dev,
-				       npins * 4 * sizeof(*gpio->functions),
+	pctl->functions = devm_kzalloc(&pdev->dev,
+				       npins * 4 * sizeof(*pctl->functions),
 				       GFP_KERNEL);
-	if (!gpio->functions)
+	if (!pctl->functions)
 		return -ENOMEM;
 
 	/* Create a list of uniquely named functions */
 	for (i = 0; i < npins; i++) {
-		pin = &gpio->desc->pins[i];
+		pin = &pctl->desc->pins[i];
 		func = pin->functions;
 
 		while (func->name) {
-			axp20x_pinctrl_add_function(gpio, func->name);
+			axp20x_pinctrl_add_function(pctl, func->name);
 			func++;
 		}
 	}
 
-	gpio->functions = krealloc(gpio->functions,
-				   gpio->nfunctions * sizeof(*gpio->functions),
+	pctl->functions = krealloc(pctl->functions,
+				   pctl->nfunctions * sizeof(*pctl->functions),
 				   GFP_KERNEL);
 
 	for (i = 0; i < npins; i++) {
-		pin = &gpio->desc->pins[i];
+		pin = &pctl->desc->pins[i];
 		ret = axp20x_attach_group_function(pdev, pin);
 		if (ret)
 			return ret;
@@ -472,10 +472,10 @@ static int axp20x_build_state(struct platform_device *pdev)
 	return 0;
 }
 
-static int axp20x_gpio_probe(struct platform_device *pdev)
+static int axp20x_pctl_probe(struct platform_device *pdev)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-	struct axp20x_gpio *gpio;
+	struct axp20x_pctl *pctl;
 	struct pinctrl_desc *pctrl_desc;
 	struct pinctrl_pin_desc *pins;
 	int ret, i;
@@ -488,42 +488,42 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
-	if (!gpio)
+	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
+	if (!pctl)
 		return -ENOMEM;
 
-	gpio->chip.base			= -1;
-	gpio->chip.can_sleep		= true;
-	gpio->chip.request		= gpiochip_generic_request;
-	gpio->chip.free			= gpiochip_generic_free;
-	gpio->chip.parent		= &pdev->dev;
-	gpio->chip.label		= dev_name(&pdev->dev);
-	gpio->chip.owner		= THIS_MODULE;
-	gpio->chip.get			= axp20x_gpio_get;
-	gpio->chip.get_direction	= axp20x_gpio_get_direction;
-	gpio->chip.set			= axp20x_gpio_set;
-	gpio->chip.direction_input	= axp20x_gpio_input;
-	gpio->chip.direction_output	= axp20x_gpio_output;
-	gpio->chip.ngpio		= 3;
+	pctl->chip.base			= -1;
+	pctl->chip.can_sleep		= true;
+	pctl->chip.request		= gpiochip_generic_request;
+	pctl->chip.free			= gpiochip_generic_free;
+	pctl->chip.parent		= &pdev->dev;
+	pctl->chip.label		= dev_name(&pdev->dev);
+	pctl->chip.owner		= THIS_MODULE;
+	pctl->chip.get			= axp20x_gpio_get;
+	pctl->chip.get_direction	= axp20x_gpio_get_direction;
+	pctl->chip.set			= axp20x_gpio_set;
+	pctl->chip.direction_input	= axp20x_gpio_input;
+	pctl->chip.direction_output	= axp20x_gpio_output;
+	pctl->chip.ngpio		= 3;
 
-	gpio->regmap = axp20x->regmap;
+	pctl->regmap = axp20x->regmap;
 
-	gpio->desc = &axp20x_pinctrl_data;
-	gpio->dev = &pdev->dev;
+	pctl->desc = &axp20x_pinctrl_data;
+	pctl->dev = &pdev->dev;
 
-	platform_set_drvdata(pdev, gpio);
+	platform_set_drvdata(pdev, pctl);
 
 	ret = axp20x_build_state(pdev);
 	if (ret)
 		return ret;
 
-	pins = devm_kzalloc(&pdev->dev, gpio->desc->npins * sizeof(*pins),
+	pins = devm_kzalloc(&pdev->dev, pctl->desc->npins * sizeof(*pins),
 			    GFP_KERNEL);
 	if (!pins)
 		return -ENOMEM;
 
-	for (i = 0; i < gpio->desc->npins; i++)
-		pins[i] = gpio->desc->pins[i].pin;
+	for (i = 0; i < pctl->desc->npins; i++)
+		pins[i] = pctl->desc->pins[i].pin;
 
 	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
 	if (!pctrl_desc)
@@ -532,26 +532,26 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 	pctrl_desc->name = dev_name(&pdev->dev);
 	pctrl_desc->owner = THIS_MODULE;
 	pctrl_desc->pins = pins;
-	pctrl_desc->npins = gpio->desc->npins;
+	pctrl_desc->npins = pctl->desc->npins;
 	pctrl_desc->pctlops = &axp20x_pctrl_ops;
 	pctrl_desc->pmxops = &axp20x_pmx_ops;
 
-	gpio->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, gpio);
-	if (IS_ERR(gpio->pctl_dev)) {
+	pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl);
+	if (IS_ERR(pctl->pctl_dev)) {
 		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
-		return PTR_ERR(gpio->pctl_dev);
+		return PTR_ERR(pctl->pctl_dev);
 	}
 
-	ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);
+	ret = devm_gpiochip_add_data(&pdev->dev, &pctl->chip, pctl);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register GPIO chip\n");
 		return ret;
 	}
 
-	ret = gpiochip_add_pin_range(&gpio->chip, dev_name(&pdev->dev),
-				     gpio->desc->pins->pin.number,
-				     gpio->desc->pins->pin.number,
-				     gpio->desc->npins);
+	ret = gpiochip_add_pin_range(&pctl->chip, dev_name(&pdev->dev),
+				     pctl->desc->pins->pin.number,
+				     pctl->desc->pins->pin.number,
+				     pctl->desc->npins);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add pin range\n");
 		return ret;
@@ -562,21 +562,21 @@ static int axp20x_gpio_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id axp20x_gpio_match[] = {
+static const struct of_device_id axp20x_pctl_match[] = {
 	{ .compatible = "x-powers,axp209-gpio" },
 	{ }
 };
-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);
+MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
 
-static struct platform_driver axp20x_gpio_driver = {
-	.probe		= axp20x_gpio_probe,
+static struct platform_driver axp20x_pctl_driver = {
+	.probe		= axp20x_pctl_probe,
 	.driver = {
 		.name		= "axp20x-gpio",
-		.of_match_table	= axp20x_gpio_match,
+		.of_match_table	= axp20x_pctl_match,
 	},
 };
 
-module_platform_driver(axp20x_gpio_driver);
+module_platform_driver(axp20x_pctl_driver);
 
 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
 MODULE_AUTHOR("Quentin Schulz <quentin.schulz@free-electrons.com>");
-- 
git-series 0.9.1

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

* [PATCH v2 05/10] pinctrl: axp209: add programmable gpio_status_offset
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

To prepare for patches that will add support for a new PMIC that has a
different GPIO input status register, add a gpio_status_offset within
axp20x_pctl structure and use it.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 drivers/pinctrl/pinctrl-axp209.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4be1aca..11f871e 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -89,6 +89,7 @@ struct axp20x_pctl {
 	unsigned int				ngroups;
 	struct axp20x_pinctrl_function		*functions;
 	unsigned int				nfunctions;
+	unsigned int				gpio_status_offset;
 };
 
 static const struct axp20x_desc_pin axp209_pins[] = {
@@ -127,7 +128,7 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 	if (ret)
 		return ret;
 
-	return !!(val & BIT(offset + 4));
+	return !!(val & BIT(offset + pctl->gpio_status_offset));
 }
 
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
@@ -509,6 +510,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->regmap = axp20x->regmap;
 
 	pctl->desc = &axp20x_pinctrl_data;
+	pctl->gpio_status_offset = 4;
 	pctl->dev = &pdev->dev;
 
 	platform_set_drvdata(pdev, pctl);
-- 
git-series 0.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 05/10] pinctrl: axp209: add programmable gpio_status_offset
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

To prepare for patches that will add support for a new PMIC that has a
different GPIO input status register, add a gpio_status_offset within
axp20x_pctl structure and use it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4be1aca..11f871e 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -89,6 +89,7 @@ struct axp20x_pctl {
 	unsigned int				ngroups;
 	struct axp20x_pinctrl_function		*functions;
 	unsigned int				nfunctions;
+	unsigned int				gpio_status_offset;
 };
 
 static const struct axp20x_desc_pin axp209_pins[] = {
@@ -127,7 +128,7 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 	if (ret)
 		return ret;
 
-	return !!(val & BIT(offset + 4));
+	return !!(val & BIT(offset + pctl->gpio_status_offset));
 }
 
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
@@ -509,6 +510,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->regmap = axp20x->regmap;
 
 	pctl->desc = &axp20x_pinctrl_data;
+	pctl->gpio_status_offset = 4;
 	pctl->dev = &pdev->dev;
 
 	platform_set_drvdata(pdev, pctl);
-- 
git-series 0.9.1

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

* [PATCH v2 05/10] pinctrl: axp209: add programmable gpio_status_offset
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

To prepare for patches that will add support for a new PMIC that has a
different GPIO input status register, add a gpio_status_offset within
axp20x_pctl structure and use it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 4be1aca..11f871e 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -89,6 +89,7 @@ struct axp20x_pctl {
 	unsigned int				ngroups;
 	struct axp20x_pinctrl_function		*functions;
 	unsigned int				nfunctions;
+	unsigned int				gpio_status_offset;
 };
 
 static const struct axp20x_desc_pin axp209_pins[] = {
@@ -127,7 +128,7 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
 	if (ret)
 		return ret;
 
-	return !!(val & BIT(offset + 4));
+	return !!(val & BIT(offset + pctl->gpio_status_offset));
 }
 
 static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
@@ -509,6 +510,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->regmap = axp20x->regmap;
 
 	pctl->desc = &axp20x_pinctrl_data;
+	pctl->gpio_status_offset = 4;
 	pctl->dev = &pdev->dev;
 
 	platform_set_drvdata(pdev, pctl);
-- 
git-series 0.9.1

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

* [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
regulator.

Moreover, the status bit of the GPIOs when in input mode is not offset
by 4 unlike the AXP209.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
 drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
index a5bfe87..a1d5dec 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
 Documentation/devicetree/bindings/gpio/gpio.txt
 
 Required properties:
-- compatible: Should be "x-powers,axp209-gpio"
+- compatible: Should be one of:
+	- "x-powers,axp209-gpio"
+	- "x-powers,axp813-pctl"
 - #gpio-cells: Should be two. The first cell is the pin number and the
   second is the GPIO flags.
 - gpio-controller: Marks the device node as a GPIO controller.
@@ -49,8 +51,17 @@ Example:
 GPIOs and their functions
 -------------------------
 
+axp209
+------
 GPIO	|	Functions
 ------------------------
 GPIO0	|	gpio_in, gpio_out, ldo, adc
 GPIO1	|	gpio_in, gpio_out, ldo, adc
 GPIO2	|	gpio_in, gpio_out
+
+axp813
+------
+GPIO	|	Functions
+------------------------
+GPIO0	|	gpio_in, gpio_out, ldo, adc
+GPIO1	|	gpio_in, gpio_out, ldo
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 11f871e..500862b 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
 		   AXP20X_FUNCTION(0x2, "gpio_in")),
 };
 
+static const struct axp20x_desc_pin axp813_pins[] = {
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo")),
+};
+
 static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
 	.pins	= axp209_pins,
 	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
+static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
+	.pins	= axp813_pins,
+	.npins	= ARRAY_SIZE(axp813_pins),
+};
+
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	return pinctrl_gpio_direction_input(chip->base + offset);
@@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	struct axp20x_pctl *pctl;
 	struct pinctrl_desc *pctrl_desc;
 	struct pinctrl_pin_desc *pins;
+	struct device_node *np = pdev->dev.of_node;
 	int ret, i;
 
 	if (!of_device_is_available(pdev->dev.of_node))
@@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->chip.set			= axp20x_gpio_set;
 	pctl->chip.direction_input	= axp20x_gpio_input;
 	pctl->chip.direction_output	= axp20x_gpio_output;
-	pctl->chip.ngpio		= 3;
 
 	pctl->regmap = axp20x->regmap;
 
-	pctl->desc = &axp20x_pinctrl_data;
-	pctl->gpio_status_offset = 4;
+	if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
+		pctl->desc = &axp20x_pinctrl_data;
+		pctl->gpio_status_offset = 4;
+	} else {
+		pctl->desc = &axp813_pinctrl_data;
+		pctl->gpio_status_offset = 0;
+	}
 	pctl->dev = &pdev->dev;
+	pctl->chip.ngpio = pctl->desc->npins;
 
 	platform_set_drvdata(pdev, pctl);
 
@@ -566,6 +589,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 
 static const struct of_device_id axp20x_pctl_match[] = {
 	{ .compatible = "x-powers,axp209-gpio" },
+	{ .compatible = "x-powers,axp813-pctl" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
-- 
git-series 0.9.1

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

* [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
regulator.

Moreover, the status bit of the GPIOs when in input mode is not offset
by 4 unlike the AXP209.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
 drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
index a5bfe87..a1d5dec 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
 Documentation/devicetree/bindings/gpio/gpio.txt
 
 Required properties:
-- compatible: Should be "x-powers,axp209-gpio"
+- compatible: Should be one of:
+	- "x-powers,axp209-gpio"
+	- "x-powers,axp813-pctl"
 - #gpio-cells: Should be two. The first cell is the pin number and the
   second is the GPIO flags.
 - gpio-controller: Marks the device node as a GPIO controller.
@@ -49,8 +51,17 @@ Example:
 GPIOs and their functions
 -------------------------
 
+axp209
+------
 GPIO	|	Functions
 ------------------------
 GPIO0	|	gpio_in, gpio_out, ldo, adc
 GPIO1	|	gpio_in, gpio_out, ldo, adc
 GPIO2	|	gpio_in, gpio_out
+
+axp813
+------
+GPIO	|	Functions
+------------------------
+GPIO0	|	gpio_in, gpio_out, ldo, adc
+GPIO1	|	gpio_in, gpio_out, ldo
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 11f871e..500862b 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
 		   AXP20X_FUNCTION(0x2, "gpio_in")),
 };
 
+static const struct axp20x_desc_pin axp813_pins[] = {
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo")),
+};
+
 static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
 	.pins	= axp209_pins,
 	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
+static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
+	.pins	= axp813_pins,
+	.npins	= ARRAY_SIZE(axp813_pins),
+};
+
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	return pinctrl_gpio_direction_input(chip->base + offset);
@@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	struct axp20x_pctl *pctl;
 	struct pinctrl_desc *pctrl_desc;
 	struct pinctrl_pin_desc *pins;
+	struct device_node *np = pdev->dev.of_node;
 	int ret, i;
 
 	if (!of_device_is_available(pdev->dev.of_node))
@@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->chip.set			= axp20x_gpio_set;
 	pctl->chip.direction_input	= axp20x_gpio_input;
 	pctl->chip.direction_output	= axp20x_gpio_output;
-	pctl->chip.ngpio		= 3;
 
 	pctl->regmap = axp20x->regmap;
 
-	pctl->desc = &axp20x_pinctrl_data;
-	pctl->gpio_status_offset = 4;
+	if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
+		pctl->desc = &axp20x_pinctrl_data;
+		pctl->gpio_status_offset = 4;
+	} else {
+		pctl->desc = &axp813_pinctrl_data;
+		pctl->gpio_status_offset = 0;
+	}
 	pctl->dev = &pdev->dev;
+	pctl->chip.ngpio = pctl->desc->npins;
 
 	platform_set_drvdata(pdev, pctl);
 
@@ -566,6 +589,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 
 static const struct of_device_id axp20x_pctl_match[] = {
 	{ .compatible = "x-powers,axp209-gpio" },
+	{ .compatible = "x-powers,axp813-pctl" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
-- 
git-series 0.9.1

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

* [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
regulator.

Moreover, the status bit of the GPIOs when in input mode is not offset
by 4 unlike the AXP209.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
 drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
index a5bfe87..a1d5dec 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
@@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
 Documentation/devicetree/bindings/gpio/gpio.txt
 
 Required properties:
-- compatible: Should be "x-powers,axp209-gpio"
+- compatible: Should be one of:
+	- "x-powers,axp209-gpio"
+	- "x-powers,axp813-pctl"
 - #gpio-cells: Should be two. The first cell is the pin number and the
   second is the GPIO flags.
 - gpio-controller: Marks the device node as a GPIO controller.
@@ -49,8 +51,17 @@ Example:
 GPIOs and their functions
 -------------------------
 
+axp209
+------
 GPIO	|	Functions
 ------------------------
 GPIO0	|	gpio_in, gpio_out, ldo, adc
 GPIO1	|	gpio_in, gpio_out, ldo, adc
 GPIO2	|	gpio_in, gpio_out
+
+axp813
+------
+GPIO	|	Functions
+------------------------
+GPIO0	|	gpio_in, gpio_out, ldo, adc
+GPIO1	|	gpio_in, gpio_out, ldo
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 11f871e..500862b 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
 		   AXP20X_FUNCTION(0x2, "gpio_in")),
 };
 
+static const struct axp20x_desc_pin axp813_pins[] = {
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo"),
+		   AXP20X_FUNCTION(0x4, "adc")),
+	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
+		   AXP20X_FUNCTION(0x0, "gpio_out"),
+		   AXP20X_FUNCTION(0x2, "gpio_in"),
+		   AXP20X_FUNCTION(0x3, "ldo")),
+};
+
 static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
 	.pins	= axp209_pins,
 	.npins	= ARRAY_SIZE(axp209_pins),
 };
 
+static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
+	.pins	= axp813_pins,
+	.npins	= ARRAY_SIZE(axp813_pins),
+};
+
 static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	return pinctrl_gpio_direction_input(chip->base + offset);
@@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	struct axp20x_pctl *pctl;
 	struct pinctrl_desc *pctrl_desc;
 	struct pinctrl_pin_desc *pins;
+	struct device_node *np = pdev->dev.of_node;
 	int ret, i;
 
 	if (!of_device_is_available(pdev->dev.of_node))
@@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->chip.set			= axp20x_gpio_set;
 	pctl->chip.direction_input	= axp20x_gpio_input;
 	pctl->chip.direction_output	= axp20x_gpio_output;
-	pctl->chip.ngpio		= 3;
 
 	pctl->regmap = axp20x->regmap;
 
-	pctl->desc = &axp20x_pinctrl_data;
-	pctl->gpio_status_offset = 4;
+	if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
+		pctl->desc = &axp20x_pinctrl_data;
+		pctl->gpio_status_offset = 4;
+	} else {
+		pctl->desc = &axp813_pinctrl_data;
+		pctl->gpio_status_offset = 0;
+	}
 	pctl->dev = &pdev->dev;
+	pctl->chip.ngpio = pctl->desc->npins;
 
 	platform_set_drvdata(pdev, pctl);
 
@@ -566,6 +589,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 
 static const struct of_device_id axp20x_pctl_match[] = {
 	{ .compatible = "x-powers,axp209-gpio" },
+	{ .compatible = "x-powers,axp813-pctl" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
-- 
git-series 0.9.1

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

* [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
  2017-09-26 12:17 ` Quentin Schulz
@ 2017-09-26 12:17   ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

As pinctrl and GPIO driver now supports AXP813, add a cell for it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/mfd/axp20x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 336de66..a457528 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
 		.name			= "axp221-pek",
 		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
 		.resources		= axp803_pek_resources,
+	}, {
+		.name			= "axp20x-gpio",
+		.of_compatible		= "x-powers,axp813-pctl",
 	}
 };
 
-- 
git-series 0.9.1

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

* [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
@ 2017-09-26 12:17   ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

As pinctrl and GPIO driver now supports AXP813, add a cell for it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/mfd/axp20x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 336de66..a457528 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
 		.name			= "axp221-pek",
 		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
 		.resources		= axp803_pek_resources,
+	}, {
+		.name			= "axp20x-gpio",
+		.of_compatible		= "x-powers,axp813-pctl",
 	}
 };
 
-- 
git-series 0.9.1

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

* [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
include in each board embedding it.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 arch/arm/boot/dts/axp813.dtsi | 58 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+)
 create mode 100644 arch/arm/boot/dts/axp813.dtsi

diff --git a/arch/arm/boot/dts/axp813.dtsi b/arch/arm/boot/dts/axp813.dtsi
new file mode 100644
index 0000000..e7f95e8
--- /dev/null
+++ b/arch/arm/boot/dts/axp813.dtsi
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2017 Free Electrons
+ *
+ * Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * AXP813 Integrated Power Management Chip
+ */
+
+&axp813 {
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	axp_pctl: axp_pctl {
+		compatible = "x-powers,axp813-pctl";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+};
-- 
git-series 0.9.1

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

* [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

From: Maxime Ripard <maxime.ripard@free-electrons.com>

The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
include in each board embedding it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/axp813.dtsi | 58 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+)
 create mode 100644 arch/arm/boot/dts/axp813.dtsi

diff --git a/arch/arm/boot/dts/axp813.dtsi b/arch/arm/boot/dts/axp813.dtsi
new file mode 100644
index 0000000..e7f95e8
--- /dev/null
+++ b/arch/arm/boot/dts/axp813.dtsi
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2017 Free Electrons
+ *
+ * Quentin Schulz <quentin.schulz@free-electrons.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * AXP813 Integrated Power Management Chip
+ */
+
+&axp813 {
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	axp_pctl: axp_pctl {
+		compatible = "x-powers,axp813-pctl";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+};
-- 
git-series 0.9.1

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

* [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Maxime Ripard <maxime.ripard@free-electrons.com>

The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
include in each board embedding it.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/axp813.dtsi | 58 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+)
 create mode 100644 arch/arm/boot/dts/axp813.dtsi

diff --git a/arch/arm/boot/dts/axp813.dtsi b/arch/arm/boot/dts/axp813.dtsi
new file mode 100644
index 0000000..e7f95e8
--- /dev/null
+++ b/arch/arm/boot/dts/axp813.dtsi
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2017 Free Electrons
+ *
+ * Quentin Schulz <quentin.schulz@free-electrons.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * AXP813 Integrated Power Management Chip
+ */
+
+&axp813 {
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	axp_pctl: axp_pctl {
+		compatible = "x-powers,axp813-pctl";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+};
-- 
git-series 0.9.1

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

* [PATCH v2 09/10] ARM: dts: sun8i: a711: include axp813 dtsi
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

This board has an AXP813 PMIC so let's include its dtsi.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
index 723641f..d9f8ed3 100644
--- a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
@@ -179,6 +179,8 @@
 
 };
 
+#include "axp813.dtsi"
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
-- 
git-series 0.9.1

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

* [PATCH v2 09/10] ARM: dts: sun8i: a711: include axp813 dtsi
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

This board has an AXP813 PMIC so let's include its dtsi.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
index 723641f..d9f8ed3 100644
--- a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
@@ -179,6 +179,8 @@
 
 };
 
+#include "axp813.dtsi"
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
-- 
git-series 0.9.1

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

* [PATCH v2 09/10] ARM: dts: sun8i: a711: include axp813 dtsi
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

This board has an AXP813 PMIC so let's include its dtsi.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
index 723641f..d9f8ed3 100644
--- a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
@@ -179,6 +179,8 @@
 
 };
 
+#include "axp813.dtsi"
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
-- 
git-series 0.9.1

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

* [PATCH v2 10/10] ARM: dts: sun8i: bananapi-m3: include axp813 dtsi
  2017-09-26 12:17 ` Quentin Schulz
  (?)
@ 2017-09-26 12:17     ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

This board has an AXP813 PMIC so let's include its dtsi.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
index 2bafd7e..0bf04a3 100644
--- a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
@@ -91,7 +91,7 @@
 &r_rsb {
 	status = "okay";
 
-	axp81x: pmic@3a3 {
+	axp813: pmic@3a3 {
 		compatible = "x-powers,axp813";
 		reg = <0x3a3>;
 		interrupt-parent = <&r_intc>;
@@ -123,6 +123,8 @@
 	};
 };
 
+#include "axp813.dtsi"
+
 &reg_usb1_vbus {
 	gpio = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
 	status = "okay";
-- 
git-series 0.9.1

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

* [PATCH v2 10/10] ARM: dts: sun8i: bananapi-m3: include axp813 dtsi
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linus.walleij, robh+dt, mark.rutland, wens, linux, maxime.ripard,
	lee.jones
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

This board has an AXP813 PMIC so let's include its dtsi.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
index 2bafd7e..0bf04a3 100644
--- a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
@@ -91,7 +91,7 @@
 &r_rsb {
 	status = "okay";
 
-	axp81x: pmic@3a3 {
+	axp813: pmic@3a3 {
 		compatible = "x-powers,axp813";
 		reg = <0x3a3>;
 		interrupt-parent = <&r_intc>;
@@ -123,6 +123,8 @@
 	};
 };
 
+#include "axp813.dtsi"
+
 &reg_usb1_vbus {
 	gpio = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
 	status = "okay";
-- 
git-series 0.9.1

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

* [PATCH v2 10/10] ARM: dts: sun8i: bananapi-m3: include axp813 dtsi
@ 2017-09-26 12:17     ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

This board has an AXP813 PMIC so let's include its dtsi.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
index 2bafd7e..0bf04a3 100644
--- a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
@@ -91,7 +91,7 @@
 &r_rsb {
 	status = "okay";
 
-	axp81x: pmic at 3a3 {
+	axp813: pmic at 3a3 {
 		compatible = "x-powers,axp813";
 		reg = <0x3a3>;
 		interrupt-parent = <&r_intc>;
@@ -123,6 +123,8 @@
 	};
 };
 
+#include "axp813.dtsi"
+
 &reg_usb1_vbus {
 	gpio = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
 	status = "okay";
-- 
git-series 0.9.1

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

* Re: [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
  2017-09-26 12:17     ` Quentin Schulz
  (?)
@ 2017-09-26 12:55         ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 12:55 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
> To prepare the driver for the upcoming pinctrl features, move the GPIO
> driver AXP209 from GPIO to pinctrl subsystem.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

I'm not sure we actually need to do this. Can't we just keep the
driver here?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-09-26 12:55         ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 12:55 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 457 bytes --]

On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
> To prepare the driver for the upcoming pinctrl features, move the GPIO
> driver AXP209 from GPIO to pinctrl subsystem.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

I'm not sure we actually need to do this. Can't we just keep the
driver here?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-09-26 12:55         ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 12:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
> To prepare the driver for the upcoming pinctrl features, move the GPIO
> driver AXP209 from GPIO to pinctrl subsystem.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

I'm not sure we actually need to do this. Can't we just keep the
driver here?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/e37b8e87/attachment-0001.sig>

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

* Re: [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
  2017-09-26 12:55         ` Maxime Ripard
@ 2017-09-26 12:59           ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:59 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 667 bytes --]

Hi Maxime,

On 26/09/2017 14:55, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
>> To prepare the driver for the upcoming pinctrl features, move the GPIO
>> driver AXP209 from GPIO to pinctrl subsystem.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> 
> I'm not sure we actually need to do this. Can't we just keep the
> driver here?
> 

That's not what I understood from:
https://lkml.org/lkml/2016/11/24/360 and the following answers from
Linus on the first version.

Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-09-26 12:59           ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Maxime,

On 26/09/2017 14:55, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
>> To prepare the driver for the upcoming pinctrl features, move the GPIO
>> driver AXP209 from GPIO to pinctrl subsystem.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> 
> I'm not sure we actually need to do this. Can't we just keep the
> driver here?
> 

That's not what I understood from:
https://lkml.org/lkml/2016/11/24/360 and the following answers from
Linus on the first version.

Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/d1d18c30/attachment.sig>

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
  2017-09-26 12:17     ` Quentin Schulz
  (?)
@ 2017-09-26 13:00         ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:00 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]

On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> +static const struct axp20x_desc_pin axp209_pins[] = {
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> +};

If all the functions are the same, and at the same offset, can't we
just hardcode it, instead of having (and duplicate) all the logic
below?

> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
> +	if (!pctrl_desc)
> +		return -ENOMEM;
> +
> +	pctrl_desc->name = dev_name(&pdev->dev);
> +	pctrl_desc->owner = THIS_MODULE;
> +	pctrl_desc->pins = pins;
> +	pctrl_desc->npins = gpio->desc->npins;
> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
> +	pctrl_desc->pmxops = &axp20x_pmx_ops;

The strict flag needs to be set too in order to avoid concurrent uses
of GPIO and other functions.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:00         ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:00 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]

On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> +static const struct axp20x_desc_pin axp209_pins[] = {
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> +};

If all the functions are the same, and at the same offset, can't we
just hardcode it, instead of having (and duplicate) all the logic
below?

> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
> +	if (!pctrl_desc)
> +		return -ENOMEM;
> +
> +	pctrl_desc->name = dev_name(&pdev->dev);
> +	pctrl_desc->owner = THIS_MODULE;
> +	pctrl_desc->pins = pins;
> +	pctrl_desc->npins = gpio->desc->npins;
> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
> +	pctrl_desc->pmxops = &axp20x_pmx_ops;

The strict flag needs to be set too in order to avoid concurrent uses
of GPIO and other functions.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:00         ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> +static const struct axp20x_desc_pin axp209_pins[] = {
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> +};

If all the functions are the same, and at the same offset, can't we
just hardcode it, instead of having (and duplicate) all the logic
below?

> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
> +	if (!pctrl_desc)
> +		return -ENOMEM;
> +
> +	pctrl_desc->name = dev_name(&pdev->dev);
> +	pctrl_desc->owner = THIS_MODULE;
> +	pctrl_desc->pins = pins;
> +	pctrl_desc->npins = gpio->desc->npins;
> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
> +	pctrl_desc->pmxops = &axp20x_pmx_ops;

The strict flag needs to be set too in order to avoid concurrent uses
of GPIO and other functions.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/ebf6bcf8/attachment.sig>

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  2017-09-26 12:17     ` Quentin Schulz
@ 2017-09-26 13:01       ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:01 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
> Instead of using a function to retrieve each pin's correct control
> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
> 
> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
> drv_data.

Why do you need to do that? This should be explained.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 13:01       ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
> Instead of using a function to retrieve each pin's correct control
> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
> 
> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
> drv_data.

Why do you need to do that? This should be explained.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/560bafdb/attachment.sig>

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
  2017-09-26 13:00         ` Maxime Ripard
  (?)
@ 2017-09-26 13:08           ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:08 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8


[-- Attachment #1.1: Type: text/plain, Size: 2008 bytes --]

Hi Maxime,

On 26/09/2017 15:00, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
>> +static const struct axp20x_desc_pin axp209_pins[] = {
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>> +		   AXP20X_FUNCTION(0x4, "adc")),
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>> +		   AXP20X_FUNCTION(0x4, "adc")),
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
>> +};
> 
> If all the functions are the same, and at the same offset, can't we
> just hardcode it, instead of having (and duplicate) all the logic
> below?
> 

AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
		AXP20X_GPIO_OUT,
		AXP20X_GPIO_IN,
		AXP20X_LDO,
		AXP20X_ADC))

That's what you mean?

>> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
>> +	if (!pctrl_desc)
>> +		return -ENOMEM;
>> +
>> +	pctrl_desc->name = dev_name(&pdev->dev);
>> +	pctrl_desc->owner = THIS_MODULE;
>> +	pctrl_desc->pins = pins;
>> +	pctrl_desc->npins = gpio->desc->npins;
>> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
>> +	pctrl_desc->pmxops = &axp20x_pmx_ops;
> 
> The strict flag needs to be set too in order to avoid concurrent uses
> of GPIO and other functions.
> 

Strict is a property of pinmux_ops struct (pmxops) and it is set.

Thanks,
Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:08           ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:08 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 1749 bytes --]

Hi Maxime,

On 26/09/2017 15:00, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
>> +static const struct axp20x_desc_pin axp209_pins[] = {
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>> +		   AXP20X_FUNCTION(0x4, "adc")),
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>> +		   AXP20X_FUNCTION(0x4, "adc")),
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
>> +};
> 
> If all the functions are the same, and at the same offset, can't we
> just hardcode it, instead of having (and duplicate) all the logic
> below?
> 

AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
		AXP20X_GPIO_OUT,
		AXP20X_GPIO_IN,
		AXP20X_LDO,
		AXP20X_ADC))

That's what you mean?

>> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
>> +	if (!pctrl_desc)
>> +		return -ENOMEM;
>> +
>> +	pctrl_desc->name = dev_name(&pdev->dev);
>> +	pctrl_desc->owner = THIS_MODULE;
>> +	pctrl_desc->pins = pins;
>> +	pctrl_desc->npins = gpio->desc->npins;
>> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
>> +	pctrl_desc->pmxops = &axp20x_pmx_ops;
> 
> The strict flag needs to be set too in order to avoid concurrent uses
> of GPIO and other functions.
> 

Strict is a property of pinmux_ops struct (pmxops) and it is set.

Thanks,
Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:08           ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Maxime,

On 26/09/2017 15:00, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
>> +static const struct axp20x_desc_pin axp209_pins[] = {
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>> +		   AXP20X_FUNCTION(0x4, "adc")),
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>> +		   AXP20X_FUNCTION(0x4, "adc")),
>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
>> +};
> 
> If all the functions are the same, and at the same offset, can't we
> just hardcode it, instead of having (and duplicate) all the logic
> below?
> 

AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
		AXP20X_GPIO_OUT,
		AXP20X_GPIO_IN,
		AXP20X_LDO,
		AXP20X_ADC))

That's what you mean?

>> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
>> +	if (!pctrl_desc)
>> +		return -ENOMEM;
>> +
>> +	pctrl_desc->name = dev_name(&pdev->dev);
>> +	pctrl_desc->owner = THIS_MODULE;
>> +	pctrl_desc->pins = pins;
>> +	pctrl_desc->npins = gpio->desc->npins;
>> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
>> +	pctrl_desc->pmxops = &axp20x_pmx_ops;
> 
> The strict flag needs to be set too in order to avoid concurrent uses
> of GPIO and other functions.
> 

Strict is a property of pinmux_ops struct (pmxops) and it is set.

Thanks,
Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/e49a811a/attachment-0001.sig>

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

* Re: [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
  2017-09-26 12:59           ` Quentin Schulz
@ 2017-09-26 13:08             ` Chen-Yu Tsai
  -1 siblings, 0 replies; 80+ messages in thread
From: Chen-Yu Tsai @ 2017-09-26 13:08 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Maxime Ripard, Linus Walleij, Rob Herring, Mark Rutland,
	Chen-Yu Tsai, Russell King, Lee Jones, linux-gpio, devicetree,
	linux-kernel, linux-arm-kernel, linux-sunxi, Thomas Petazzoni

On Tue, Sep 26, 2017 at 8:59 PM, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:
> Hi Maxime,
>
> On 26/09/2017 14:55, Maxime Ripard wrote:
>> On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
>>> To prepare the driver for the upcoming pinctrl features, move the GPIO
>>> driver AXP209 from GPIO to pinctrl subsystem.
>>>
>>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>
>> I'm not sure we actually need to do this. Can't we just keep the
>> driver here?
>>
>
> That's not what I understood from:
> https://lkml.org/lkml/2016/11/24/360 and the following answers from
> Linus on the first version.

Please remember to add -M to git format-patch, as Linus mentioned,
if you resend.

Chenyu

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-09-26 13:08             ` Chen-Yu Tsai
  0 siblings, 0 replies; 80+ messages in thread
From: Chen-Yu Tsai @ 2017-09-26 13:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 8:59 PM, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:
> Hi Maxime,
>
> On 26/09/2017 14:55, Maxime Ripard wrote:
>> On Tue, Sep 26, 2017 at 12:17:11PM +0000, Quentin Schulz wrote:
>>> To prepare the driver for the upcoming pinctrl features, move the GPIO
>>> driver AXP209 from GPIO to pinctrl subsystem.
>>>
>>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>
>> I'm not sure we actually need to do this. Can't we just keep the
>> driver here?
>>
>
> That's not what I understood from:
> https://lkml.org/lkml/2016/11/24/360 and the following answers from
> Linus on the first version.

Please remember to add -M to git format-patch, as Linus mentioned,
if you resend.

Chenyu

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

* Re: [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
  2017-09-26 12:17     ` Quentin Schulz
  (?)
@ 2017-09-26 13:12         ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:12 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 4232 bytes --]

On Tue, Sep 26, 2017 at 12:17:16PM +0000, Quentin Schulz wrote:
> The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
> LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
> regulator.
> 
> Moreover, the status bit of the GPIOs when in input mode is not offset
> by 4 unlike the AXP209.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
>  drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-
>  2 files changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> index a5bfe87..a1d5dec 100644
> --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> @@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
>  Documentation/devicetree/bindings/gpio/gpio.txt
>  
>  Required properties:
> -- compatible: Should be "x-powers,axp209-gpio"
> +- compatible: Should be one of:
> +	- "x-powers,axp209-gpio"
> +	- "x-powers,axp813-pctl"
>  - #gpio-cells: Should be two. The first cell is the pin number and the
>    second is the GPIO flags.
>  - gpio-controller: Marks the device node as a GPIO controller.
> @@ -49,8 +51,17 @@ Example:
>  GPIOs and their functions
>  -------------------------
>  
> +axp209
> +------
>  GPIO	|	Functions
>  ------------------------
>  GPIO0	|	gpio_in, gpio_out, ldo, adc
>  GPIO1	|	gpio_in, gpio_out, ldo, adc
>  GPIO2	|	gpio_in, gpio_out
> +
> +axp813
> +------
> +GPIO	|	Functions
> +------------------------
> +GPIO0	|	gpio_in, gpio_out, ldo, adc
> +GPIO1	|	gpio_in, gpio_out, ldo
> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
> index 11f871e..500862b 100644
> --- a/drivers/pinctrl/pinctrl-axp209.c
> +++ b/drivers/pinctrl/pinctrl-axp209.c
> @@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
>  		   AXP20X_FUNCTION(0x2, "gpio_in")),
>  };
>  
> +static const struct axp20x_desc_pin axp813_pins[] = {
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo")),
> +};
> +
>  static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
>  	.pins	= axp209_pins,
>  	.npins	= ARRAY_SIZE(axp209_pins),
>  };
>  
> +static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
> +	.pins	= axp813_pins,
> +	.npins	= ARRAY_SIZE(axp813_pins),
> +};
> +
>  static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
>  {
>  	return pinctrl_gpio_direction_input(chip->base + offset);
> @@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	struct axp20x_pctl *pctl;
>  	struct pinctrl_desc *pctrl_desc;
>  	struct pinctrl_pin_desc *pins;
> +	struct device_node *np = pdev->dev.of_node;
>  	int ret, i;
>  
>  	if (!of_device_is_available(pdev->dev.of_node))
> @@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	pctl->chip.set			= axp20x_gpio_set;
>  	pctl->chip.direction_input	= axp20x_gpio_input;
>  	pctl->chip.direction_output	= axp20x_gpio_output;
> -	pctl->chip.ngpio		= 3;
>  
>  	pctl->regmap = axp20x->regmap;
>  
> -	pctl->desc = &axp20x_pinctrl_data;
> -	pctl->gpio_status_offset = 4;
> +	if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
> +		pctl->desc = &axp20x_pinctrl_data;
> +		pctl->gpio_status_offset = 4;
> +	} else {
> +		pctl->desc = &axp813_pinctrl_data;
> +		pctl->gpio_status_offset = 0;
> +	}
>  	pctl->dev = &pdev->dev;
> +	pctl->chip.ngpio = pctl->desc->npins;

This should be part of a structure that would be attached to the
compatible.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
@ 2017-09-26 13:12         ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:12 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 4320 bytes --]

On Tue, Sep 26, 2017 at 12:17:16PM +0000, Quentin Schulz wrote:
> The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
> LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
> regulator.
> 
> Moreover, the status bit of the GPIOs when in input mode is not offset
> by 4 unlike the AXP209.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
>  drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-
>  2 files changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> index a5bfe87..a1d5dec 100644
> --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> @@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
>  Documentation/devicetree/bindings/gpio/gpio.txt
>  
>  Required properties:
> -- compatible: Should be "x-powers,axp209-gpio"
> +- compatible: Should be one of:
> +	- "x-powers,axp209-gpio"
> +	- "x-powers,axp813-pctl"
>  - #gpio-cells: Should be two. The first cell is the pin number and the
>    second is the GPIO flags.
>  - gpio-controller: Marks the device node as a GPIO controller.
> @@ -49,8 +51,17 @@ Example:
>  GPIOs and their functions
>  -------------------------
>  
> +axp209
> +------
>  GPIO	|	Functions
>  ------------------------
>  GPIO0	|	gpio_in, gpio_out, ldo, adc
>  GPIO1	|	gpio_in, gpio_out, ldo, adc
>  GPIO2	|	gpio_in, gpio_out
> +
> +axp813
> +------
> +GPIO	|	Functions
> +------------------------
> +GPIO0	|	gpio_in, gpio_out, ldo, adc
> +GPIO1	|	gpio_in, gpio_out, ldo
> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
> index 11f871e..500862b 100644
> --- a/drivers/pinctrl/pinctrl-axp209.c
> +++ b/drivers/pinctrl/pinctrl-axp209.c
> @@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
>  		   AXP20X_FUNCTION(0x2, "gpio_in")),
>  };
>  
> +static const struct axp20x_desc_pin axp813_pins[] = {
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo")),
> +};
> +
>  static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
>  	.pins	= axp209_pins,
>  	.npins	= ARRAY_SIZE(axp209_pins),
>  };
>  
> +static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
> +	.pins	= axp813_pins,
> +	.npins	= ARRAY_SIZE(axp813_pins),
> +};
> +
>  static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
>  {
>  	return pinctrl_gpio_direction_input(chip->base + offset);
> @@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	struct axp20x_pctl *pctl;
>  	struct pinctrl_desc *pctrl_desc;
>  	struct pinctrl_pin_desc *pins;
> +	struct device_node *np = pdev->dev.of_node;
>  	int ret, i;
>  
>  	if (!of_device_is_available(pdev->dev.of_node))
> @@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	pctl->chip.set			= axp20x_gpio_set;
>  	pctl->chip.direction_input	= axp20x_gpio_input;
>  	pctl->chip.direction_output	= axp20x_gpio_output;
> -	pctl->chip.ngpio		= 3;
>  
>  	pctl->regmap = axp20x->regmap;
>  
> -	pctl->desc = &axp20x_pinctrl_data;
> -	pctl->gpio_status_offset = 4;
> +	if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
> +		pctl->desc = &axp20x_pinctrl_data;
> +		pctl->gpio_status_offset = 4;
> +	} else {
> +		pctl->desc = &axp813_pinctrl_data;
> +		pctl->gpio_status_offset = 0;
> +	}
>  	pctl->dev = &pdev->dev;
> +	pctl->chip.ngpio = pctl->desc->npins;

This should be part of a structure that would be attached to the
compatible.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
@ 2017-09-26 13:12         ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 12:17:16PM +0000, Quentin Schulz wrote:
> The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
> LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
> regulator.
> 
> Moreover, the status bit of the GPIOs when in input mode is not offset
> by 4 unlike the AXP209.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
>  drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-
>  2 files changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> index a5bfe87..a1d5dec 100644
> --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> @@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
>  Documentation/devicetree/bindings/gpio/gpio.txt
>  
>  Required properties:
> -- compatible: Should be "x-powers,axp209-gpio"
> +- compatible: Should be one of:
> +	- "x-powers,axp209-gpio"
> +	- "x-powers,axp813-pctl"
>  - #gpio-cells: Should be two. The first cell is the pin number and the
>    second is the GPIO flags.
>  - gpio-controller: Marks the device node as a GPIO controller.
> @@ -49,8 +51,17 @@ Example:
>  GPIOs and their functions
>  -------------------------
>  
> +axp209
> +------
>  GPIO	|	Functions
>  ------------------------
>  GPIO0	|	gpio_in, gpio_out, ldo, adc
>  GPIO1	|	gpio_in, gpio_out, ldo, adc
>  GPIO2	|	gpio_in, gpio_out
> +
> +axp813
> +------
> +GPIO	|	Functions
> +------------------------
> +GPIO0	|	gpio_in, gpio_out, ldo, adc
> +GPIO1	|	gpio_in, gpio_out, ldo
> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
> index 11f871e..500862b 100644
> --- a/drivers/pinctrl/pinctrl-axp209.c
> +++ b/drivers/pinctrl/pinctrl-axp209.c
> @@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
>  		   AXP20X_FUNCTION(0x2, "gpio_in")),
>  };
>  
> +static const struct axp20x_desc_pin axp813_pins[] = {
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo"),
> +		   AXP20X_FUNCTION(0x4, "adc")),
> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> +		   AXP20X_FUNCTION(0x3, "ldo")),
> +};
> +
>  static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
>  	.pins	= axp209_pins,
>  	.npins	= ARRAY_SIZE(axp209_pins),
>  };
>  
> +static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
> +	.pins	= axp813_pins,
> +	.npins	= ARRAY_SIZE(axp813_pins),
> +};
> +
>  static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
>  {
>  	return pinctrl_gpio_direction_input(chip->base + offset);
> @@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	struct axp20x_pctl *pctl;
>  	struct pinctrl_desc *pctrl_desc;
>  	struct pinctrl_pin_desc *pins;
> +	struct device_node *np = pdev->dev.of_node;
>  	int ret, i;
>  
>  	if (!of_device_is_available(pdev->dev.of_node))
> @@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	pctl->chip.set			= axp20x_gpio_set;
>  	pctl->chip.direction_input	= axp20x_gpio_input;
>  	pctl->chip.direction_output	= axp20x_gpio_output;
> -	pctl->chip.ngpio		= 3;
>  
>  	pctl->regmap = axp20x->regmap;
>  
> -	pctl->desc = &axp20x_pinctrl_data;
> -	pctl->gpio_status_offset = 4;
> +	if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
> +		pctl->desc = &axp20x_pinctrl_data;
> +		pctl->gpio_status_offset = 4;
> +	} else {
> +		pctl->desc = &axp813_pinctrl_data;
> +		pctl->gpio_status_offset = 0;
> +	}
>  	pctl->dev = &pdev->dev;
> +	pctl->chip.ngpio = pctl->desc->npins;

This should be part of a structure that would be attached to the
compatible.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/0d2db9f0/attachment.sig>

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

* Re: [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
  2017-09-26 12:17   ` Quentin Schulz
  (?)
@ 2017-09-26 13:14       ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:14 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 1039 bytes --]

On Tue, Sep 26, 2017 at 12:17:17PM +0000, Quentin Schulz wrote:
> As pinctrl and GPIO driver now supports AXP813, add a cell for it.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  drivers/mfd/axp20x.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 336de66..a457528 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
>  		.name			= "axp221-pek",
>  		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
>  		.resources		= axp803_pek_resources,
> +	}, {
> +		.name			= "axp20x-gpio",
> +		.of_compatible		= "x-powers,axp813-pctl",

This was probably introduced in the previous driver, but why are you
using the pctl suffix? Can't we just use the GPIO one to remain
consistent with the previous users and the datasheet?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
@ 2017-09-26 13:14       ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:14 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

On Tue, Sep 26, 2017 at 12:17:17PM +0000, Quentin Schulz wrote:
> As pinctrl and GPIO driver now supports AXP813, add a cell for it.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  drivers/mfd/axp20x.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 336de66..a457528 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
>  		.name			= "axp221-pek",
>  		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
>  		.resources		= axp803_pek_resources,
> +	}, {
> +		.name			= "axp20x-gpio",
> +		.of_compatible		= "x-powers,axp813-pctl",

This was probably introduced in the previous driver, but why are you
using the pctl suffix? Can't we just use the GPIO one to remain
consistent with the previous users and the datasheet?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
@ 2017-09-26 13:14       ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 12:17:17PM +0000, Quentin Schulz wrote:
> As pinctrl and GPIO driver now supports AXP813, add a cell for it.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  drivers/mfd/axp20x.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 336de66..a457528 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
>  		.name			= "axp221-pek",
>  		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
>  		.resources		= axp803_pek_resources,
> +	}, {
> +		.name			= "axp20x-gpio",
> +		.of_compatible		= "x-powers,axp813-pctl",

This was probably introduced in the previous driver, but why are you
using the pctl suffix? Can't we just use the GPIO one to remain
consistent with the previous users and the datasheet?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/41ce5562/attachment.sig>

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

* Re: [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
  2017-09-26 12:17     ` Quentin Schulz
@ 2017-09-26 13:16       ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:16 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

On Tue, Sep 26, 2017 at 12:17:18PM +0000, Quentin Schulz wrote:
> From: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
> include in each board embedding it.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

There must be my Signed-off-by here.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
@ 2017-09-26 13:16       ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 12:17:18PM +0000, Quentin Schulz wrote:
> From: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
> include in each board embedding it.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

There must be my Signed-off-by here.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/61a4e401/attachment-0001.sig>

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  2017-09-26 13:01       ` Maxime Ripard
  (?)
@ 2017-09-26 13:17         ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:17 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8


[-- Attachment #1.1: Type: text/plain, Size: 1546 bytes --]

Hi Maxime,

On 26/09/2017 15:01, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
>> Instead of using a function to retrieve each pin's correct control
>> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
>>
>> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
>> drv_data.
> 
> Why do you need to do that? This should be explained.
> 

Agreed that it misses an explanation.

Today, to get a register addr of one of the GPIOs in the PMIC, we
basically get the GPIO number and returns the register via this info.

There are 3 GPIOs in AXP209, 2 in AXP813. I didn't want to have a switch
case for the GPIO number and then an if/else inside one of the case to
check if the device is AXP209 or AXP813 in which case we return -EINVAL
instead of the GPIO2 reg. With support for new PMIC, we would have a
bunch of if conditions and complexify the process for something really
simple.

IMHO, this also allows easier integration of future PMICs which might
have different regs for the GPIOs.

I don't *need* it but I find this solution nicer.

Thanks,
Quentin

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 13:17         ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:17 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 1268 bytes --]

Hi Maxime,

On 26/09/2017 15:01, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
>> Instead of using a function to retrieve each pin's correct control
>> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
>>
>> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
>> drv_data.
> 
> Why do you need to do that? This should be explained.
> 

Agreed that it misses an explanation.

Today, to get a register addr of one of the GPIOs in the PMIC, we
basically get the GPIO number and returns the register via this info.

There are 3 GPIOs in AXP209, 2 in AXP813. I didn't want to have a switch
case for the GPIO number and then an if/else inside one of the case to
check if the device is AXP209 or AXP813 in which case we return -EINVAL
instead of the GPIO2 reg. With support for new PMIC, we would have a
bunch of if conditions and complexify the process for something really
simple.

IMHO, this also allows easier integration of future PMICs which might
have different regs for the GPIOs.

I don't *need* it but I find this solution nicer.

Thanks,
Quentin

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 13:17         ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Maxime,

On 26/09/2017 15:01, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
>> Instead of using a function to retrieve each pin's correct control
>> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
>>
>> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
>> drv_data.
> 
> Why do you need to do that? This should be explained.
> 

Agreed that it misses an explanation.

Today, to get a register addr of one of the GPIOs in the PMIC, we
basically get the GPIO number and returns the register via this info.

There are 3 GPIOs in AXP209, 2 in AXP813. I didn't want to have a switch
case for the GPIO number and then an if/else inside one of the case to
check if the device is AXP209 or AXP813 in which case we return -EINVAL
instead of the GPIO2 reg. With support for new PMIC, we would have a
bunch of if conditions and complexify the process for something really
simple.

IMHO, this also allows easier integration of future PMICs which might
have different regs for the GPIOs.

I don't *need* it but I find this solution nicer.

Thanks,
Quentin

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/9d10b27f/attachment.sig>

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
  2017-09-26 13:08           ` Quentin Schulz
  (?)
@ 2017-09-26 13:27               ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:27 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 2112 bytes --]

On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
> Hi Maxime,
> 
> On 26/09/2017 15:00, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> >> +static const struct axp20x_desc_pin axp209_pins[] = {
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >> +		   AXP20X_FUNCTION(0x4, "adc")),
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >> +		   AXP20X_FUNCTION(0x4, "adc")),
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> >> +};
> > 
> > If all the functions are the same, and at the same offset, can't we
> > just hardcode it, instead of having (and duplicate) all the logic
> > below?
> > 
> 
> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> 		AXP20X_GPIO_OUT,
> 		AXP20X_GPIO_IN,
> 		AXP20X_LDO,
> 		AXP20X_ADC))
> 
> That's what you mean?

What I mean is:

static int axp20x_get_func(char *func)
{
	if (!strcmp(func, "gpio_out"))
		return 0;

	if (!strcmp(func, "gpio_in"))
		return 2;
 
	if (!strcmp(func, "ldo"))
 		return 3;
 
	if (!strcmp(func, "adc"))
 		return 4;

	return -EINVAL;
}

> >> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
> >> +	if (!pctrl_desc)
> >> +		return -ENOMEM;
> >> +
> >> +	pctrl_desc->name = dev_name(&pdev->dev);
> >> +	pctrl_desc->owner = THIS_MODULE;
> >> +	pctrl_desc->pins = pins;
> >> +	pctrl_desc->npins = gpio->desc->npins;
> >> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
> >> +	pctrl_desc->pmxops = &axp20x_pmx_ops;
> > 
> > The strict flag needs to be set too in order to avoid concurrent uses
> > of GPIO and other functions.
> > 
> 
> Strict is a property of pinmux_ops struct (pmxops) and it is set.

Ah, right, my bad.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:27               ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:27 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 2191 bytes --]

On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
> Hi Maxime,
> 
> On 26/09/2017 15:00, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> >> +static const struct axp20x_desc_pin axp209_pins[] = {
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >> +		   AXP20X_FUNCTION(0x4, "adc")),
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >> +		   AXP20X_FUNCTION(0x4, "adc")),
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> >> +};
> > 
> > If all the functions are the same, and at the same offset, can't we
> > just hardcode it, instead of having (and duplicate) all the logic
> > below?
> > 
> 
> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> 		AXP20X_GPIO_OUT,
> 		AXP20X_GPIO_IN,
> 		AXP20X_LDO,
> 		AXP20X_ADC))
> 
> That's what you mean?

What I mean is:

static int axp20x_get_func(char *func)
{
	if (!strcmp(func, "gpio_out"))
		return 0;

	if (!strcmp(func, "gpio_in"))
		return 2;
 
	if (!strcmp(func, "ldo"))
 		return 3;
 
	if (!strcmp(func, "adc"))
 		return 4;

	return -EINVAL;
}

> >> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
> >> +	if (!pctrl_desc)
> >> +		return -ENOMEM;
> >> +
> >> +	pctrl_desc->name = dev_name(&pdev->dev);
> >> +	pctrl_desc->owner = THIS_MODULE;
> >> +	pctrl_desc->pins = pins;
> >> +	pctrl_desc->npins = gpio->desc->npins;
> >> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
> >> +	pctrl_desc->pmxops = &axp20x_pmx_ops;
> > 
> > The strict flag needs to be set too in order to avoid concurrent uses
> > of GPIO and other functions.
> > 
> 
> Strict is a property of pinmux_ops struct (pmxops) and it is set.

Ah, right, my bad.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:27               ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
> Hi Maxime,
> 
> On 26/09/2017 15:00, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> >> +static const struct axp20x_desc_pin axp209_pins[] = {
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >> +		   AXP20X_FUNCTION(0x4, "adc")),
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >> +		   AXP20X_FUNCTION(0x4, "adc")),
> >> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> >> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> >> +};
> > 
> > If all the functions are the same, and at the same offset, can't we
> > just hardcode it, instead of having (and duplicate) all the logic
> > below?
> > 
> 
> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> 		AXP20X_GPIO_OUT,
> 		AXP20X_GPIO_IN,
> 		AXP20X_LDO,
> 		AXP20X_ADC))
> 
> That's what you mean?

What I mean is:

static int axp20x_get_func(char *func)
{
	if (!strcmp(func, "gpio_out"))
		return 0;

	if (!strcmp(func, "gpio_in"))
		return 2;
 
	if (!strcmp(func, "ldo"))
 		return 3;
 
	if (!strcmp(func, "adc"))
 		return 4;

	return -EINVAL;
}

> >> +	pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KERNEL);
> >> +	if (!pctrl_desc)
> >> +		return -ENOMEM;
> >> +
> >> +	pctrl_desc->name = dev_name(&pdev->dev);
> >> +	pctrl_desc->owner = THIS_MODULE;
> >> +	pctrl_desc->pins = pins;
> >> +	pctrl_desc->npins = gpio->desc->npins;
> >> +	pctrl_desc->pctlops = &axp20x_pctrl_ops;
> >> +	pctrl_desc->pmxops = &axp20x_pmx_ops;
> > 
> > The strict flag needs to be set too in order to avoid concurrent uses
> > of GPIO and other functions.
> > 
> 
> Strict is a property of pinmux_ops struct (pmxops) and it is set.

Ah, right, my bad.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/90d8aa86/attachment.sig>

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
  2017-09-26 13:27               ` Maxime Ripard
  (?)
@ 2017-09-26 13:37                 ` Quentin Schulz
  -1 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:37 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8


[-- Attachment #1.1: Type: text/plain, Size: 2195 bytes --]

On 26/09/2017 15:27, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
>> Hi Maxime,
>>
>> On 26/09/2017 15:00, Maxime Ripard wrote:
>>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
>>>> +static const struct axp20x_desc_pin axp209_pins[] = {
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>>>> +		   AXP20X_FUNCTION(0x4, "adc")),
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>>>> +		   AXP20X_FUNCTION(0x4, "adc")),
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
>>>> +};
>>>
>>> If all the functions are the same, and at the same offset, can't we
>>> just hardcode it, instead of having (and duplicate) all the logic
>>> below?
>>>
>>
>> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>> 		AXP20X_GPIO_OUT,
>> 		AXP20X_GPIO_IN,
>> 		AXP20X_LDO,
>> 		AXP20X_ADC))
>>
>> That's what you mean?
> 
> What I mean is:
> 
> static int axp20x_get_func(char *func)
> {
> 	if (!strcmp(func, "gpio_out"))
> 		return 0;
> 
> 	if (!strcmp(func, "gpio_in"))
> 		return 2;
>  
> 	if (!strcmp(func, "ldo"))
>  		return 3;
>  
> 	if (!strcmp(func, "adc"))
>  		return 4;
> 
> 	return -EINVAL;
> }
> 

GPIO2 on AXP209 does not support ldo nor adc.
GPIO1 on AXP813 does not support adc.

I find it more complex to handle those two cases in a function than by
hardcoding it in structures like above.

Moreover, nothing tells us that it would be the same offset for other PMICs.

Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:37                 ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:37 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 1948 bytes --]

On 26/09/2017 15:27, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
>> Hi Maxime,
>>
>> On 26/09/2017 15:00, Maxime Ripard wrote:
>>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
>>>> +static const struct axp20x_desc_pin axp209_pins[] = {
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>>>> +		   AXP20X_FUNCTION(0x4, "adc")),
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>>>> +		   AXP20X_FUNCTION(0x4, "adc")),
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
>>>> +};
>>>
>>> If all the functions are the same, and at the same offset, can't we
>>> just hardcode it, instead of having (and duplicate) all the logic
>>> below?
>>>
>>
>> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>> 		AXP20X_GPIO_OUT,
>> 		AXP20X_GPIO_IN,
>> 		AXP20X_LDO,
>> 		AXP20X_ADC))
>>
>> That's what you mean?
> 
> What I mean is:
> 
> static int axp20x_get_func(char *func)
> {
> 	if (!strcmp(func, "gpio_out"))
> 		return 0;
> 
> 	if (!strcmp(func, "gpio_in"))
> 		return 2;
>  
> 	if (!strcmp(func, "ldo"))
>  		return 3;
>  
> 	if (!strcmp(func, "adc"))
>  		return 4;
> 
> 	return -EINVAL;
> }
> 

GPIO2 on AXP209 does not support ldo nor adc.
GPIO1 on AXP813 does not support adc.

I find it more complex to handle those two cases in a function than by
hardcoding it in structures like above.

Moreover, nothing tells us that it would be the same offset for other PMICs.

Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-26 13:37                 ` Quentin Schulz
  0 siblings, 0 replies; 80+ messages in thread
From: Quentin Schulz @ 2017-09-26 13:37 UTC (permalink / raw)
  To: linux-arm-kernel

On 26/09/2017 15:27, Maxime Ripard wrote:
> On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
>> Hi Maxime,
>>
>> On 26/09/2017 15:00, Maxime Ripard wrote:
>>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
>>>> +static const struct axp20x_desc_pin axp209_pins[] = {
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>>>> +		   AXP20X_FUNCTION(0x4, "adc")),
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
>>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
>>>> +		   AXP20X_FUNCTION(0x4, "adc")),
>>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
>>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
>>>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
>>>> +};
>>>
>>> If all the functions are the same, and at the same offset, can't we
>>> just hardcode it, instead of having (and duplicate) all the logic
>>> below?
>>>
>>
>> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
>> 		AXP20X_GPIO_OUT,
>> 		AXP20X_GPIO_IN,
>> 		AXP20X_LDO,
>> 		AXP20X_ADC))
>>
>> That's what you mean?
> 
> What I mean is:
> 
> static int axp20x_get_func(char *func)
> {
> 	if (!strcmp(func, "gpio_out"))
> 		return 0;
> 
> 	if (!strcmp(func, "gpio_in"))
> 		return 2;
>  
> 	if (!strcmp(func, "ldo"))
>  		return 3;
>  
> 	if (!strcmp(func, "adc"))
>  		return 4;
> 
> 	return -EINVAL;
> }
> 

GPIO2 on AXP209 does not support ldo nor adc.
GPIO1 on AXP813 does not support adc.

I find it more complex to handle those two cases in a function than by
hardcoding it in structures like above.

Moreover, nothing tells us that it would be the same offset for other PMICs.

Quentin
-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/ff97d032/attachment.sig>

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  2017-09-26 13:17         ` Quentin Schulz
  (?)
@ 2017-09-26 13:45             ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:45 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 1965 bytes --]

On Tue, Sep 26, 2017 at 01:17:05PM +0000, Quentin Schulz wrote:
> Hi Maxime,
> 
> On 26/09/2017 15:01, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
> >> Instead of using a function to retrieve each pin's correct control
> >> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
> >>
> >> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
> >> drv_data.
> > 
> > Why do you need to do that? This should be explained.
> > 
> 
> Agreed that it misses an explanation.
> 
> Today, to get a register addr of one of the GPIOs in the PMIC, we
> basically get the GPIO number and returns the register via this info.
> 
> There are 3 GPIOs in AXP209, 2 in AXP813. I didn't want to have a switch
> case for the GPIO number and then an if/else inside one of the case to
> check if the device is AXP209 or AXP813 in which case we return -EINVAL
> instead of the GPIO2 reg. With support for new PMIC, we would have a
> bunch of if conditions and complexify the process for something really
> simple.

I'm not sure how that relates to your code actually. The only thing
that patch is doing is to move the register offset from a function to
the structure associated to the pin.

However, even in the AXP813 case, you're using exactly the same
values, so that's not really needed.

Now, you also mentionned the pin number. While this patch doesn't
really address it, it's also no really needed. The number of pins is
already known and registered in the GPIO framework. If the framework
doesn't already do it (which would be surprising), you can just check
that the pin number passed is not going to be higher than the one you
registered.

> IMHO, this also allows easier integration of future PMICs which might
> have different regs for the GPIOs.

Let's worry about future PMICs in the future.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 13:45             ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:45 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 2017 bytes --]

On Tue, Sep 26, 2017 at 01:17:05PM +0000, Quentin Schulz wrote:
> Hi Maxime,
> 
> On 26/09/2017 15:01, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
> >> Instead of using a function to retrieve each pin's correct control
> >> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
> >>
> >> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
> >> drv_data.
> > 
> > Why do you need to do that? This should be explained.
> > 
> 
> Agreed that it misses an explanation.
> 
> Today, to get a register addr of one of the GPIOs in the PMIC, we
> basically get the GPIO number and returns the register via this info.
> 
> There are 3 GPIOs in AXP209, 2 in AXP813. I didn't want to have a switch
> case for the GPIO number and then an if/else inside one of the case to
> check if the device is AXP209 or AXP813 in which case we return -EINVAL
> instead of the GPIO2 reg. With support for new PMIC, we would have a
> bunch of if conditions and complexify the process for something really
> simple.

I'm not sure how that relates to your code actually. The only thing
that patch is doing is to move the register offset from a function to
the structure associated to the pin.

However, even in the AXP813 case, you're using exactly the same
values, so that's not really needed.

Now, you also mentionned the pin number. While this patch doesn't
really address it, it's also no really needed. The number of pins is
already known and registered in the GPIO framework. If the framework
doesn't already do it (which would be surprising), you can just check
that the pin number passed is not going to be higher than the one you
registered.

> IMHO, this also allows easier integration of future PMICs which might
> have different regs for the GPIOs.

Let's worry about future PMICs in the future.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-26 13:45             ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-26 13:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 01:17:05PM +0000, Quentin Schulz wrote:
> Hi Maxime,
> 
> On 26/09/2017 15:01, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 12:17:13PM +0000, Quentin Schulz wrote:
> >> Instead of using a function to retrieve each pin's correct control
> >> register, use drv_data within pinctrl_pin_desc to store the ctrl reg.
> >>
> >> Remove axp20x_gpio_get_reg and replace every occurrence by a get from
> >> drv_data.
> > 
> > Why do you need to do that? This should be explained.
> > 
> 
> Agreed that it misses an explanation.
> 
> Today, to get a register addr of one of the GPIOs in the PMIC, we
> basically get the GPIO number and returns the register via this info.
> 
> There are 3 GPIOs in AXP209, 2 in AXP813. I didn't want to have a switch
> case for the GPIO number and then an if/else inside one of the case to
> check if the device is AXP209 or AXP813 in which case we return -EINVAL
> instead of the GPIO2 reg. With support for new PMIC, we would have a
> bunch of if conditions and complexify the process for something really
> simple.

I'm not sure how that relates to your code actually. The only thing
that patch is doing is to move the register offset from a function to
the structure associated to the pin.

However, even in the AXP813 case, you're using exactly the same
values, so that's not really needed.

Now, you also mentionned the pin number. While this patch doesn't
really address it, it's also no really needed. The number of pins is
already known and registered in the GPIO framework. If the framework
doesn't already do it (which would be surprising), you can just check
that the pin number passed is not going to be higher than the one you
registered.

> IMHO, this also allows easier integration of future PMICs which might
> have different regs for the GPIOs.

Let's worry about future PMICs in the future.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/5424c9fc/attachment.sig>

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

* Re: [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
  2017-09-26 12:17     ` Quentin Schulz
@ 2017-09-26 13:53       ` Chen-Yu Tsai
  -1 siblings, 0 replies; 80+ messages in thread
From: Chen-Yu Tsai @ 2017-09-26 13:53 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Linus Walleij, Rob Herring, Mark Rutland, Chen-Yu Tsai,
	Russell King, Maxime Ripard, Lee Jones, linux-gpio, devicetree,
	linux-kernel, linux-arm-kernel, linux-sunxi, Thomas Petazzoni

On Tue, Sep 26, 2017 at 8:17 PM, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:
> From: Maxime Ripard <maxime.ripard@free-electrons.com>
>
> The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
> include in each board embedding it.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  arch/arm/boot/dts/axp813.dtsi | 58 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 58 insertions(+)
>  create mode 100644 arch/arm/boot/dts/axp813.dtsi
>
> diff --git a/arch/arm/boot/dts/axp813.dtsi b/arch/arm/boot/dts/axp813.dtsi
> new file mode 100644
> index 0000000..e7f95e8
> --- /dev/null
> +++ b/arch/arm/boot/dts/axp813.dtsi
> @@ -0,0 +1,58 @@
> +/*
> + * Copyright 2017 Free Electrons
> + *
> + * Quentin Schulz <quentin.schulz@free-electrons.com>
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is free software; you can redistribute it and/or
> + *     modify it under the terms of the GNU General Public License as
> + *     published by the Free Software Foundation; either version 2 of the
> + *     License, or (at your option) any later version.
> + *
> + *     This file is distributed in the hope that it will be useful,
> + *     but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *     GNU General Public License for more details.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + *     obtaining a copy of this software and associated documentation
> + *     files (the "Software"), to deal in the Software without
> + *     restriction, including without limitation the rights to use,
> + *     copy, modify, merge, publish, distribute, sublicense, and/or
> + *     sell copies of the Software, and to permit persons to whom the
> + *     Software is furnished to do so, subject to the following
> + *     conditions:
> + *
> + *     The above copyright notice and this permission notice shall be
> + *     included in all copies or substantial portions of the Software.
> + *
> + *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> + *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + *     OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +/*
> + * AXP813 Integrated Power Management Chip
> + */
> +
> +&axp813 {

I'd like to name the label axp81x instead. And possibly the filename as well.

See https://github.com/wens/linux/commit/05b9ca82c795816f7f2569ce96dc35b62487f89c

ChenYu

> +       interrupt-controller;
> +       #interrupt-cells = <1>;
> +
> +       axp_pctl: axp_pctl {
> +               compatible = "x-powers,axp813-pctl";
> +               gpio-controller;
> +               #gpio-cells = <2>;
> +       };
> +};
> --
> git-series 0.9.1

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

* [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC
@ 2017-09-26 13:53       ` Chen-Yu Tsai
  0 siblings, 0 replies; 80+ messages in thread
From: Chen-Yu Tsai @ 2017-09-26 13:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 8:17 PM, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:
> From: Maxime Ripard <maxime.ripard@free-electrons.com>
>
> The AXP813 PMIC is used with some Allwinner SoCs. Create a dtsi to
> include in each board embedding it.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  arch/arm/boot/dts/axp813.dtsi | 58 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 58 insertions(+)
>  create mode 100644 arch/arm/boot/dts/axp813.dtsi
>
> diff --git a/arch/arm/boot/dts/axp813.dtsi b/arch/arm/boot/dts/axp813.dtsi
> new file mode 100644
> index 0000000..e7f95e8
> --- /dev/null
> +++ b/arch/arm/boot/dts/axp813.dtsi
> @@ -0,0 +1,58 @@
> +/*
> + * Copyright 2017 Free Electrons
> + *
> + * Quentin Schulz <quentin.schulz@free-electrons.com>
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is free software; you can redistribute it and/or
> + *     modify it under the terms of the GNU General Public License as
> + *     published by the Free Software Foundation; either version 2 of the
> + *     License, or (at your option) any later version.
> + *
> + *     This file is distributed in the hope that it will be useful,
> + *     but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *     GNU General Public License for more details.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + *     obtaining a copy of this software and associated documentation
> + *     files (the "Software"), to deal in the Software without
> + *     restriction, including without limitation the rights to use,
> + *     copy, modify, merge, publish, distribute, sublicense, and/or
> + *     sell copies of the Software, and to permit persons to whom the
> + *     Software is furnished to do so, subject to the following
> + *     conditions:
> + *
> + *     The above copyright notice and this permission notice shall be
> + *     included in all copies or substantial portions of the Software.
> + *
> + *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> + *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + *     OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +/*
> + * AXP813 Integrated Power Management Chip
> + */
> +
> +&axp813 {

I'd like to name the label axp81x instead. And possibly the filename as well.

See https://github.com/wens/linux/commit/05b9ca82c795816f7f2569ce96dc35b62487f89c

ChenYu

> +       interrupt-controller;
> +       #interrupt-cells = <1>;
> +
> +       axp_pctl: axp_pctl {
> +               compatible = "x-powers,axp813-pctl";
> +               gpio-controller;
> +               #gpio-cells = <2>;
> +       };
> +};
> --
> git-series 0.9.1

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
  2017-09-26 13:37                 ` Quentin Schulz
  (?)
@ 2017-09-27  9:28                     ` Maxime Ripard
  -1 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-27  9:28 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 2830 bytes --]

On Tue, Sep 26, 2017 at 01:37:37PM +0000, Quentin Schulz wrote:
> On 26/09/2017 15:27, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
> >> Hi Maxime,
> >>
> >> On 26/09/2017 15:00, Maxime Ripard wrote:
> >>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> >>>> +static const struct axp20x_desc_pin axp209_pins[] = {
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >>>> +		   AXP20X_FUNCTION(0x4, "adc")),
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >>>> +		   AXP20X_FUNCTION(0x4, "adc")),
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> >>>> +};
> >>>
> >>> If all the functions are the same, and at the same offset, can't we
> >>> just hardcode it, instead of having (and duplicate) all the logic
> >>> below?
> >>>
> >>
> >> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >> 		AXP20X_GPIO_OUT,
> >> 		AXP20X_GPIO_IN,
> >> 		AXP20X_LDO,
> >> 		AXP20X_ADC))
> >>
> >> That's what you mean?
> > 
> > What I mean is:
> > 
> > static int axp20x_get_func(char *func)
> > {
> > 	if (!strcmp(func, "gpio_out"))
> > 		return 0;
> > 
> > 	if (!strcmp(func, "gpio_in"))
> > 		return 2;
> >  
> > 	if (!strcmp(func, "ldo"))
> >  		return 3;
> >  
> > 	if (!strcmp(func, "adc"))
> >  		return 4;
> > 
> > 	return -EINVAL;
> > }
> > 
> 
> GPIO2 on AXP209 does not support ldo nor adc.
> GPIO1 on AXP813 does not support adc.

Right, and surely that can be caught as well. This was a global
approach. You could add a bitmap for example to encode whether ldo and
adc are available. It takes two bytes, and two or operations.

> I find it more complex to handle those two cases in a function than by
> hardcoding it in structures like above.

You find more complex to add a 10 lines function than 450 lines of
code that you ripped off from another driver, that generates 4
structures many structures (groups, functions, pins and pins'
functions) and will provide three different lookup methods? Really? :)

It's way overkill for that driver. Most of these lists can be
hardcoded as well.

> Moreover, nothing tells us that it would be the same offset for
> other PMICs.

Again, let's worry about those PMICs when we'll need to support
them. Unless you already have an example in mind of course. Otherwise,
it's just building things on theories that have never been proven (and
might never be).

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-27  9:28                     ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-27  9:28 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, robh+dt, mark.rutland, wens, linux, lee.jones,
	linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 2919 bytes --]

On Tue, Sep 26, 2017 at 01:37:37PM +0000, Quentin Schulz wrote:
> On 26/09/2017 15:27, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
> >> Hi Maxime,
> >>
> >> On 26/09/2017 15:00, Maxime Ripard wrote:
> >>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> >>>> +static const struct axp20x_desc_pin axp209_pins[] = {
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >>>> +		   AXP20X_FUNCTION(0x4, "adc")),
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >>>> +		   AXP20X_FUNCTION(0x4, "adc")),
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> >>>> +};
> >>>
> >>> If all the functions are the same, and at the same offset, can't we
> >>> just hardcode it, instead of having (and duplicate) all the logic
> >>> below?
> >>>
> >>
> >> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >> 		AXP20X_GPIO_OUT,
> >> 		AXP20X_GPIO_IN,
> >> 		AXP20X_LDO,
> >> 		AXP20X_ADC))
> >>
> >> That's what you mean?
> > 
> > What I mean is:
> > 
> > static int axp20x_get_func(char *func)
> > {
> > 	if (!strcmp(func, "gpio_out"))
> > 		return 0;
> > 
> > 	if (!strcmp(func, "gpio_in"))
> > 		return 2;
> >  
> > 	if (!strcmp(func, "ldo"))
> >  		return 3;
> >  
> > 	if (!strcmp(func, "adc"))
> >  		return 4;
> > 
> > 	return -EINVAL;
> > }
> > 
> 
> GPIO2 on AXP209 does not support ldo nor adc.
> GPIO1 on AXP813 does not support adc.

Right, and surely that can be caught as well. This was a global
approach. You could add a bitmap for example to encode whether ldo and
adc are available. It takes two bytes, and two or operations.

> I find it more complex to handle those two cases in a function than by
> hardcoding it in structures like above.

You find more complex to add a 10 lines function than 450 lines of
code that you ripped off from another driver, that generates 4
structures many structures (groups, functions, pins and pins'
functions) and will provide three different lookup methods? Really? :)

It's way overkill for that driver. Most of these lists can be
hardcoded as well.

> Moreover, nothing tells us that it would be the same offset for
> other PMICs.

Again, let's worry about those PMICs when we'll need to support
them. Unless you already have an example in mind of course. Otherwise,
it's just building things on theories that have never been proven (and
might never be).

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH v2 02/10] pinctrl: axp209: add pinctrl features
@ 2017-09-27  9:28                     ` Maxime Ripard
  0 siblings, 0 replies; 80+ messages in thread
From: Maxime Ripard @ 2017-09-27  9:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 01:37:37PM +0000, Quentin Schulz wrote:
> On 26/09/2017 15:27, Maxime Ripard wrote:
> > On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote:
> >> Hi Maxime,
> >>
> >> On 26/09/2017 15:00, Maxime Ripard wrote:
> >>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote:
> >>>> +static const struct axp20x_desc_pin axp209_pins[] = {
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >>>> +		   AXP20X_FUNCTION(0x4, "adc")),
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in"),
> >>>> +		   AXP20X_FUNCTION(0x3, "ldo"),
> >>>> +		   AXP20X_FUNCTION(0x4, "adc")),
> >>>> +	AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"),
> >>>> +		   AXP20X_FUNCTION(0x0, "gpio_out"),
> >>>> +		   AXP20X_FUNCTION(0x2, "gpio_in")),
> >>>> +};
> >>>
> >>> If all the functions are the same, and at the same offset, can't we
> >>> just hardcode it, instead of having (and duplicate) all the logic
> >>> below?
> >>>
> >>
> >> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"),
> >> 		AXP20X_GPIO_OUT,
> >> 		AXP20X_GPIO_IN,
> >> 		AXP20X_LDO,
> >> 		AXP20X_ADC))
> >>
> >> That's what you mean?
> > 
> > What I mean is:
> > 
> > static int axp20x_get_func(char *func)
> > {
> > 	if (!strcmp(func, "gpio_out"))
> > 		return 0;
> > 
> > 	if (!strcmp(func, "gpio_in"))
> > 		return 2;
> >  
> > 	if (!strcmp(func, "ldo"))
> >  		return 3;
> >  
> > 	if (!strcmp(func, "adc"))
> >  		return 4;
> > 
> > 	return -EINVAL;
> > }
> > 
> 
> GPIO2 on AXP209 does not support ldo nor adc.
> GPIO1 on AXP813 does not support adc.

Right, and surely that can be caught as well. This was a global
approach. You could add a bitmap for example to encode whether ldo and
adc are available. It takes two bytes, and two or operations.

> I find it more complex to handle those two cases in a function than by
> hardcoding it in structures like above.

You find more complex to add a 10 lines function than 450 lines of
code that you ripped off from another driver, that generates 4
structures many structures (groups, functions, pins and pins'
functions) and will provide three different lookup methods? Really? :)

It's way overkill for that driver. Most of these lists can be
hardcoded as well.

> Moreover, nothing tells us that it would be the same offset for
> other PMICs.

Again, let's worry about those PMICs when we'll need to support
them. Unless you already have an example in mind of course. Otherwise,
it's just building things on theories that have never been proven (and
might never be).

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170927/0af8035c/attachment.sig>

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

* Re: [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
  2017-09-26 13:14       ` Maxime Ripard
  (?)
@ 2017-09-28 19:06         ` Lee Jones
  -1 siblings, 0 replies; 80+ messages in thread
From: Lee Jones @ 2017-09-28 19:06 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Quentin Schulz, linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

On Tue, 26 Sep 2017, Maxime Ripard wrote:

> On Tue, Sep 26, 2017 at 12:17:17PM +0000, Quentin Schulz wrote:
> > As pinctrl and GPIO driver now supports AXP813, add a cell for it.
> > 
> > Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> > ---
> >  drivers/mfd/axp20x.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> > index 336de66..a457528 100644
> > --- a/drivers/mfd/axp20x.c
> > +++ b/drivers/mfd/axp20x.c
> > @@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
> >  		.name			= "axp221-pek",
> >  		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
> >  		.resources		= axp803_pek_resources,
> > +	}, {
> > +		.name			= "axp20x-gpio",
> > +		.of_compatible		= "x-powers,axp813-pctl",
> 
> This was probably introduced in the previous driver, but why are you
> using the pctl suffix? Can't we just use the GPIO one to remain
> consistent with the previous users and the datasheet?

Right.  Pinctrl is a Linuxisum.  GPIO sounds more appropriate.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
@ 2017-09-28 19:06         ` Lee Jones
  0 siblings, 0 replies; 80+ messages in thread
From: Lee Jones @ 2017-09-28 19:06 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Quentin Schulz, linus.walleij, robh+dt, mark.rutland, wens,
	linux, linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi, thomas.petazzoni

On Tue, 26 Sep 2017, Maxime Ripard wrote:

> On Tue, Sep 26, 2017 at 12:17:17PM +0000, Quentin Schulz wrote:
> > As pinctrl and GPIO driver now supports AXP813, add a cell for it.
> > 
> > Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> > ---
> >  drivers/mfd/axp20x.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> > index 336de66..a457528 100644
> > --- a/drivers/mfd/axp20x.c
> > +++ b/drivers/mfd/axp20x.c
> > @@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
> >  		.name			= "axp221-pek",
> >  		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
> >  		.resources		= axp803_pek_resources,
> > +	}, {
> > +		.name			= "axp20x-gpio",
> > +		.of_compatible		= "x-powers,axp813-pctl",
> 
> This was probably introduced in the previous driver, but why are you
> using the pctl suffix? Can't we just use the GPIO one to remain
> consistent with the previous users and the datasheet?

Right.  Pinctrl is a Linuxisum.  GPIO sounds more appropriate.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813
@ 2017-09-28 19:06         ` Lee Jones
  0 siblings, 0 replies; 80+ messages in thread
From: Lee Jones @ 2017-09-28 19:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 26 Sep 2017, Maxime Ripard wrote:

> On Tue, Sep 26, 2017 at 12:17:17PM +0000, Quentin Schulz wrote:
> > As pinctrl and GPIO driver now supports AXP813, add a cell for it.
> > 
> > Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> > ---
> >  drivers/mfd/axp20x.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> > index 336de66..a457528 100644
> > --- a/drivers/mfd/axp20x.c
> > +++ b/drivers/mfd/axp20x.c
> > @@ -876,6 +876,9 @@ static struct mfd_cell axp813_cells[] = {
> >  		.name			= "axp221-pek",
> >  		.num_resources		= ARRAY_SIZE(axp803_pek_resources),
> >  		.resources		= axp803_pek_resources,
> > +	}, {
> > +		.name			= "axp20x-gpio",
> > +		.of_compatible		= "x-powers,axp813-pctl",
> 
> This was probably introduced in the previous driver, but why are you
> using the pctl suffix? Can't we just use the GPIO one to remain
> consistent with the previous users and the datasheet?

Right.  Pinctrl is a Linuxisum.  GPIO sounds more appropriate.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
  2017-09-26 12:17     ` Quentin Schulz
  (?)
@ 2017-09-29 17:27       ` kbuild test robot
  -1 siblings, 0 replies; 80+ messages in thread
From: kbuild test robot @ 2017-09-29 17:27 UTC (permalink / raw)
  Cc: kbuild-all, linus.walleij, robh+dt, mark.rutland, wens, linux,
	maxime.ripard, lee.jones, linux-gpio, devicetree, linux-kernel,
	linux-arm-kernel, linux-sunxi, thomas.petazzoni, Quentin Schulz

[-- Attachment #1: Type: text/plain, Size: 2453 bytes --]

Hi Quentin,

[auto build test WARNING on ]

url:    https://github.com/0day-ci/linux/commits/Quentin-Schulz/add-pinmuxing-support-for-pins-in-AXP209-and-AXP813-PMICs/20170929-162846
base:    
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_get_direction':
>> drivers//pinctrl/pinctrl-axp209.c:136:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^
   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_set':
   drivers//pinctrl/pinctrl-axp209.c:171:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^
   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_pmx_set':
   drivers//pinctrl/pinctrl-axp209.c:183:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^

vim +136 drivers//pinctrl/pinctrl-axp209.c

   132	
   133	static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
   134	{
   135		struct axp20x_gpio *gpio = gpiochip_get_data(chip);
 > 136		int reg = (int)gpio->desc->pins[offset].pin.drv_data;
   137		unsigned int val;
   138		int ret;
   139	
   140		ret = regmap_read(gpio->regmap, reg, &val);
   141		if (ret)
   142			return ret;
   143	
   144		/*
   145		 * This shouldn't really happen if the pin is in use already,
   146		 * or if it's not in use yet, it doesn't matter since we're
   147		 * going to change the value soon anyway. Default to output.
   148		 */
   149		if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
   150			return 0;
   151	
   152		/*
   153		 * The GPIO directions are the three lowest values.
   154		 * 2 is input, 0 and 1 are output
   155		 */
   156		return val & 2;
   157	}
   158	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 57613 bytes --]

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

* Re: [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-29 17:27       ` kbuild test robot
  0 siblings, 0 replies; 80+ messages in thread
From: kbuild test robot @ 2017-09-29 17:27 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: kbuild-all, linus.walleij, robh+dt, mark.rutland, wens, linux,
	maxime.ripard, lee.jones, linux-gpio, devicetree, linux-kernel,
	linux-arm-kernel, linux-sunxi, thomas.petazzoni, Quentin Schulz

[-- Attachment #1: Type: text/plain, Size: 2453 bytes --]

Hi Quentin,

[auto build test WARNING on ]

url:    https://github.com/0day-ci/linux/commits/Quentin-Schulz/add-pinmuxing-support-for-pins-in-AXP209-and-AXP813-PMICs/20170929-162846
base:    
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_get_direction':
>> drivers//pinctrl/pinctrl-axp209.c:136:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^
   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_set':
   drivers//pinctrl/pinctrl-axp209.c:171:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^
   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_pmx_set':
   drivers//pinctrl/pinctrl-axp209.c:183:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^

vim +136 drivers//pinctrl/pinctrl-axp209.c

   132	
   133	static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
   134	{
   135		struct axp20x_gpio *gpio = gpiochip_get_data(chip);
 > 136		int reg = (int)gpio->desc->pins[offset].pin.drv_data;
   137		unsigned int val;
   138		int ret;
   139	
   140		ret = regmap_read(gpio->regmap, reg, &val);
   141		if (ret)
   142			return ret;
   143	
   144		/*
   145		 * This shouldn't really happen if the pin is in use already,
   146		 * or if it's not in use yet, it doesn't matter since we're
   147		 * going to change the value soon anyway. Default to output.
   148		 */
   149		if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
   150			return 0;
   151	
   152		/*
   153		 * The GPIO directions are the three lowest values.
   154		 * 2 is input, 0 and 1 are output
   155		 */
   156		return val & 2;
   157	}
   158	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 57613 bytes --]

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

* [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg
@ 2017-09-29 17:27       ` kbuild test robot
  0 siblings, 0 replies; 80+ messages in thread
From: kbuild test robot @ 2017-09-29 17:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Quentin,

[auto build test WARNING on ]

url:    https://github.com/0day-ci/linux/commits/Quentin-Schulz/add-pinmuxing-support-for-pins-in-AXP209-and-AXP813-PMICs/20170929-162846
base:    
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_get_direction':
>> drivers//pinctrl/pinctrl-axp209.c:136:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^
   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_set':
   drivers//pinctrl/pinctrl-axp209.c:171:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^
   drivers//pinctrl/pinctrl-axp209.c: In function 'axp20x_pmx_set':
   drivers//pinctrl/pinctrl-axp209.c:183:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int reg = (int)gpio->desc->pins[offset].pin.drv_data;
               ^

vim +136 drivers//pinctrl/pinctrl-axp209.c

   132	
   133	static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
   134	{
   135		struct axp20x_gpio *gpio = gpiochip_get_data(chip);
 > 136		int reg = (int)gpio->desc->pins[offset].pin.drv_data;
   137		unsigned int val;
   138		int ret;
   139	
   140		ret = regmap_read(gpio->regmap, reg, &val);
   141		if (ret)
   142			return ret;
   143	
   144		/*
   145		 * This shouldn't really happen if the pin is in use already,
   146		 * or if it's not in use yet, it doesn't matter since we're
   147		 * going to change the value soon anyway. Default to output.
   148		 */
   149		if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
   150			return 0;
   151	
   152		/*
   153		 * The GPIO directions are the three lowest values.
   154		 * 2 is input, 0 and 1 are output
   155		 */
   156		return val & 2;
   157	}
   158	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 57613 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170930/e25f335d/attachment-0001.gz>

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

* Re: [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
  2017-09-26 12:17     ` Quentin Schulz
  (?)
@ 2017-10-05 20:50         ` Rob Herring
  -1 siblings, 0 replies; 80+ messages in thread
From: Rob Herring @ 2017-10-05 20:50 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

On Tue, Sep 26, 2017 at 02:17:11PM +0200, Quentin Schulz wrote:
> To prepare the driver for the upcoming pinctrl features, move the GPIO
> driver AXP209 from GPIO to pinctrl subsystem.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  30 +-
>  drivers/gpio/Kconfig                                         |   6 +-
>  drivers/gpio/Makefile                                        |   1 +-
>  drivers/gpio/gpio-axp209.c                                   | 188 +-------
>  drivers/pinctrl/Kconfig                                      |   6 +-
>  drivers/pinctrl/Makefile                                     |   1 +-
>  drivers/pinctrl/pinctrl-axp209.c                             | 188 +++++++-
>  8 files changed, 225 insertions(+), 225 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
>  create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
>  delete mode 100644 drivers/gpio/gpio-axp209.c
>  create mode 100644 drivers/pinctrl/pinctrl-axp209.c
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
> deleted file mode 100644
> index a661130..0000000
> --- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -AXP209 GPIO controller
> -
> -This driver follows the usual GPIO bindings found in
> -Documentation/devicetree/bindings/gpio/gpio.txt
> -
> -Required properties:
> -- compatible: Should be "x-powers,axp209-gpio"
> -- #gpio-cells: Should be two. The first cell is the pin number and the
> -  second is the GPIO flags.
> -- gpio-controller: Marks the device node as a GPIO controller.
> -
> -This node must be a subnode of the axp20x PMIC, documented in
> -Documentation/devicetree/bindings/mfd/axp20x.txt
> -
> -Example:
> -
> -axp209: pmic@34 {
> -	compatible = "x-powers,axp209";
> -	reg = <0x34>;
> -	interrupt-parent = <&nmi_intc>;
> -	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
> -	interrupt-controller;
> -	#interrupt-cells = <1>;
> -
> -	axp_gpio: gpio {
> -		compatible = "x-powers,axp209-gpio";
> -		gpio-controller;
> -		#gpio-cells = <2>;
> -	};
> -};
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> new file mode 100644
> index 0000000..a661130
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> @@ -0,0 +1,30 @@
> +AXP209 GPIO controller
> +
> +This driver follows the usual GPIO bindings found in
> +Documentation/devicetree/bindings/gpio/gpio.txt
> +
> +Required properties:
> +- compatible: Should be "x-powers,axp209-gpio"
> +- #gpio-cells: Should be two. The first cell is the pin number and the
> +  second is the GPIO flags.
> +- gpio-controller: Marks the device node as a GPIO controller.

Maybe there's some reason to move the driver, but the binding describes 
a gpio-controller so it should remain in bindings/gpio/. Binding and 
driver directories aren't one to one necessarily.

Rob

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

* Re: [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-10-05 20:50         ` Rob Herring
  0 siblings, 0 replies; 80+ messages in thread
From: Rob Herring @ 2017-10-05 20:50 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, mark.rutland, wens, linux, maxime.ripard,
	lee.jones, linux-gpio, devicetree, linux-kernel,
	linux-arm-kernel, linux-sunxi, thomas.petazzoni

On Tue, Sep 26, 2017 at 02:17:11PM +0200, Quentin Schulz wrote:
> To prepare the driver for the upcoming pinctrl features, move the GPIO
> driver AXP209 from GPIO to pinctrl subsystem.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  30 +-
>  drivers/gpio/Kconfig                                         |   6 +-
>  drivers/gpio/Makefile                                        |   1 +-
>  drivers/gpio/gpio-axp209.c                                   | 188 +-------
>  drivers/pinctrl/Kconfig                                      |   6 +-
>  drivers/pinctrl/Makefile                                     |   1 +-
>  drivers/pinctrl/pinctrl-axp209.c                             | 188 +++++++-
>  8 files changed, 225 insertions(+), 225 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
>  create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
>  delete mode 100644 drivers/gpio/gpio-axp209.c
>  create mode 100644 drivers/pinctrl/pinctrl-axp209.c
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
> deleted file mode 100644
> index a661130..0000000
> --- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -AXP209 GPIO controller
> -
> -This driver follows the usual GPIO bindings found in
> -Documentation/devicetree/bindings/gpio/gpio.txt
> -
> -Required properties:
> -- compatible: Should be "x-powers,axp209-gpio"
> -- #gpio-cells: Should be two. The first cell is the pin number and the
> -  second is the GPIO flags.
> -- gpio-controller: Marks the device node as a GPIO controller.
> -
> -This node must be a subnode of the axp20x PMIC, documented in
> -Documentation/devicetree/bindings/mfd/axp20x.txt
> -
> -Example:
> -
> -axp209: pmic@34 {
> -	compatible = "x-powers,axp209";
> -	reg = <0x34>;
> -	interrupt-parent = <&nmi_intc>;
> -	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
> -	interrupt-controller;
> -	#interrupt-cells = <1>;
> -
> -	axp_gpio: gpio {
> -		compatible = "x-powers,axp209-gpio";
> -		gpio-controller;
> -		#gpio-cells = <2>;
> -	};
> -};
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> new file mode 100644
> index 0000000..a661130
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> @@ -0,0 +1,30 @@
> +AXP209 GPIO controller
> +
> +This driver follows the usual GPIO bindings found in
> +Documentation/devicetree/bindings/gpio/gpio.txt
> +
> +Required properties:
> +- compatible: Should be "x-powers,axp209-gpio"
> +- #gpio-cells: Should be two. The first cell is the pin number and the
> +  second is the GPIO flags.
> +- gpio-controller: Marks the device node as a GPIO controller.

Maybe there's some reason to move the driver, but the binding describes 
a gpio-controller so it should remain in bindings/gpio/. Binding and 
driver directories aren't one to one necessarily.

Rob

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

* [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl
@ 2017-10-05 20:50         ` Rob Herring
  0 siblings, 0 replies; 80+ messages in thread
From: Rob Herring @ 2017-10-05 20:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 26, 2017 at 02:17:11PM +0200, Quentin Schulz wrote:
> To prepare the driver for the upcoming pinctrl features, move the GPIO
> driver AXP209 from GPIO to pinctrl subsystem.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/gpio/gpio-axp209.txt       |  30 +-
>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt |  30 +-
>  drivers/gpio/Kconfig                                         |   6 +-
>  drivers/gpio/Makefile                                        |   1 +-
>  drivers/gpio/gpio-axp209.c                                   | 188 +-------
>  drivers/pinctrl/Kconfig                                      |   6 +-
>  drivers/pinctrl/Makefile                                     |   1 +-
>  drivers/pinctrl/pinctrl-axp209.c                             | 188 +++++++-
>  8 files changed, 225 insertions(+), 225 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
>  create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
>  delete mode 100644 drivers/gpio/gpio-axp209.c
>  create mode 100644 drivers/pinctrl/pinctrl-axp209.c
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
> deleted file mode 100644
> index a661130..0000000
> --- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -AXP209 GPIO controller
> -
> -This driver follows the usual GPIO bindings found in
> -Documentation/devicetree/bindings/gpio/gpio.txt
> -
> -Required properties:
> -- compatible: Should be "x-powers,axp209-gpio"
> -- #gpio-cells: Should be two. The first cell is the pin number and the
> -  second is the GPIO flags.
> -- gpio-controller: Marks the device node as a GPIO controller.
> -
> -This node must be a subnode of the axp20x PMIC, documented in
> -Documentation/devicetree/bindings/mfd/axp20x.txt
> -
> -Example:
> -
> -axp209: pmic at 34 {
> -	compatible = "x-powers,axp209";
> -	reg = <0x34>;
> -	interrupt-parent = <&nmi_intc>;
> -	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
> -	interrupt-controller;
> -	#interrupt-cells = <1>;
> -
> -	axp_gpio: gpio {
> -		compatible = "x-powers,axp209-gpio";
> -		gpio-controller;
> -		#gpio-cells = <2>;
> -	};
> -};
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> new file mode 100644
> index 0000000..a661130
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> @@ -0,0 +1,30 @@
> +AXP209 GPIO controller
> +
> +This driver follows the usual GPIO bindings found in
> +Documentation/devicetree/bindings/gpio/gpio.txt
> +
> +Required properties:
> +- compatible: Should be "x-powers,axp209-gpio"
> +- #gpio-cells: Should be two. The first cell is the pin number and the
> +  second is the GPIO flags.
> +- gpio-controller: Marks the device node as a GPIO controller.

Maybe there's some reason to move the driver, but the binding describes 
a gpio-controller so it should remain in bindings/gpio/. Binding and 
driver directories aren't one to one necessarily.

Rob

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

end of thread, other threads:[~2017-10-05 20:50 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26 12:17 [PATCH v2 00/10] add pinmuxing support for pins in AXP209 and AXP813 PMICs Quentin Schulz
2017-09-26 12:17 ` Quentin Schulz
     [not found] ` <cover.1c314f4154a6d27354625f03d0a5269eee55a9c5.1506428208.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 12:17   ` [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
     [not found]     ` <e193f8efe9092171ebeffb77ab77422179fd3cab.1506428208.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 12:55       ` Maxime Ripard
2017-09-26 12:55         ` Maxime Ripard
2017-09-26 12:55         ` Maxime Ripard
2017-09-26 12:59         ` Quentin Schulz
2017-09-26 12:59           ` Quentin Schulz
2017-09-26 13:08           ` Chen-Yu Tsai
2017-09-26 13:08             ` Chen-Yu Tsai
2017-10-05 20:50       ` Rob Herring
2017-10-05 20:50         ` Rob Herring
2017-10-05 20:50         ` Rob Herring
2017-09-26 12:17   ` [PATCH v2 02/10] pinctrl: axp209: add pinctrl features Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
     [not found]     ` <6b89df1bf07dac2ab295fca5fdf0e55179c47ed6.1506428208.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 13:00       ` Maxime Ripard
2017-09-26 13:00         ` Maxime Ripard
2017-09-26 13:00         ` Maxime Ripard
2017-09-26 13:08         ` Quentin Schulz
2017-09-26 13:08           ` Quentin Schulz
2017-09-26 13:08           ` Quentin Schulz
     [not found]           ` <5596280a-51bb-7491-31f4-5800219888ad-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 13:27             ` Maxime Ripard
2017-09-26 13:27               ` Maxime Ripard
2017-09-26 13:27               ` Maxime Ripard
2017-09-26 13:37               ` Quentin Schulz
2017-09-26 13:37                 ` Quentin Schulz
2017-09-26 13:37                 ` Quentin Schulz
     [not found]                 ` <0bc7efe6-8d0e-ddae-617b-36e4357f76ce-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-27  9:28                   ` Maxime Ripard
2017-09-27  9:28                     ` Maxime Ripard
2017-09-27  9:28                     ` Maxime Ripard
2017-09-26 12:17   ` [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 13:01     ` Maxime Ripard
2017-09-26 13:01       ` Maxime Ripard
2017-09-26 13:17       ` Quentin Schulz
2017-09-26 13:17         ` Quentin Schulz
2017-09-26 13:17         ` Quentin Schulz
     [not found]         ` <0ae64e95-ee49-fb4c-e79b-e8c25c86580c-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 13:45           ` Maxime Ripard
2017-09-26 13:45             ` Maxime Ripard
2017-09-26 13:45             ` Maxime Ripard
2017-09-29 17:27     ` kbuild test robot
2017-09-29 17:27       ` kbuild test robot
2017-09-29 17:27       ` kbuild test robot
2017-09-26 12:17   ` [PATCH v2 04/10] pinctrl: axp209: rename everything from gpio to pctl Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17   ` [PATCH v2 05/10] pinctrl: axp209: add programmable gpio_status_offset Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17   ` [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
     [not found]     ` <b950efcbb2f4d399812591cdf5dce11d0d35b42b.1506428208.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 13:12       ` Maxime Ripard
2017-09-26 13:12         ` Maxime Ripard
2017-09-26 13:12         ` Maxime Ripard
2017-09-26 12:17   ` [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 13:16     ` Maxime Ripard
2017-09-26 13:16       ` Maxime Ripard
2017-09-26 13:53     ` Chen-Yu Tsai
2017-09-26 13:53       ` Chen-Yu Tsai
2017-09-26 12:17   ` [PATCH v2 09/10] ARM: dts: sun8i: a711: include axp813 dtsi Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17   ` [PATCH v2 10/10] ARM: dts: sun8i: bananapi-m3: " Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17     ` Quentin Schulz
2017-09-26 12:17 ` [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813 Quentin Schulz
2017-09-26 12:17   ` Quentin Schulz
     [not found]   ` <5345a2e94013f4e4f7b545cd4d84b098bd2fa349.1506428208.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-09-26 13:14     ` Maxime Ripard
2017-09-26 13:14       ` Maxime Ripard
2017-09-26 13:14       ` Maxime Ripard
2017-09-28 19:06       ` Lee Jones
2017-09-28 19:06         ` Lee Jones
2017-09-28 19:06         ` Lee Jones

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.