linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device
@ 2015-07-14  8:29 Tomeu Vizoso
  2015-07-14  8:29 ` [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found Tomeu Vizoso
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Tomeu Vizoso @ 2015-07-14  8:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, devicetree, linux-tegra, Tomeu Vizoso,
	Thierry Reding, Russell King, Linus Walleij, Kumar Gala,
	Stephen Warren, Grant Likely, Ian Campbell, Rob Herring,
	Pawel Moll, Mark Rutland, Alexandre Courbot, linux-arm-kernel

Hello,

these three patches make sure that there's an explicit dependency from
the GPIO chip in Tegra SoCs to the corresponding pinctrl device, without
having duplicated gpio ranges.

By having an explicit dependency, we can do things such as probing the
pinctrl device before the GPIO chip device to avoid deferred probes.

Thanks,

Tomeu

Changes in v2:
- Don't defer probe if the pinctrl node is disabled
- Remove outdated comment from the commit changelog

Tomeu Vizoso (3):
  gpio: defer probe if pinctrl cannot be found
  pinctrl: tegra: Only set the gpio range if needed
  ARM: tegra: Add gpio-ranges property

 arch/arm/boot/dts/tegra114.dtsi |  1 +
 arch/arm/boot/dts/tegra124.dtsi |  1 +
 arch/arm/boot/dts/tegra20.dtsi  |  1 +
 arch/arm/boot/dts/tegra30.dtsi  |  1 +
 drivers/gpio/gpiolib-of.c       | 27 ++++++++++++++++++---------
 drivers/gpio/gpiolib.c          |  5 ++++-
 drivers/pinctrl/pinctrl-tegra.c | 19 ++++++++++++++++++-
 include/linux/of_gpio.h         |  4 ++--
 8 files changed, 46 insertions(+), 13 deletions(-)

-- 
2.4.3


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

* [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found
  2015-07-14  8:29 [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Tomeu Vizoso
@ 2015-07-14  8:29 ` Tomeu Vizoso
  2015-07-24  9:15   ` Tomeu Vizoso
  2015-07-28 10:23   ` Linus Walleij
  2015-07-14  8:29 ` [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed Tomeu Vizoso
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Tomeu Vizoso @ 2015-07-14  8:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, devicetree, linux-tegra, Tomeu Vizoso, Linus Walleij,
	Grant Likely, Rob Herring, Alexandre Courbot

When an OF node has a pin range for its GPIOs, return -EPROBE_DEFER if
the pin controller isn't available.

Otherwise, the GPIO range wouldn't be set at all unless the pin
controller probed always before the GPIO chip.

With this change, the probe of the GPIO chip will be deferred and will
be retried at a later point, hopefully once the pin controller has been
registered and probed already.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---

Changes in v2:
- Don't defer probe if the pinctrl node is disabled

 drivers/gpio/gpiolib-of.c | 27 ++++++++++++++++++---------
 drivers/gpio/gpiolib.c    |  5 ++++-
 include/linux/of_gpio.h   |  4 ++--
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 9a0ec48a4737..4e1f73b9136a 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -338,7 +338,7 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
 EXPORT_SYMBOL(of_mm_gpiochip_remove);
 
 #ifdef CONFIG_PINCTRL
-static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
+static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
 {
 	struct device_node *np = chip->of_node;
 	struct of_phandle_args pinspec;
@@ -349,7 +349,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
 	struct property *group_names;
 
 	if (!np)
-		return;
+		return 0;
 
 	group_names = of_find_property(np, group_names_propname, NULL);
 
@@ -361,7 +361,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
 
 		pctldev = of_pinctrl_get(pinspec.np);
 		if (!pctldev)
-			break;
+			return -EPROBE_DEFER;
 
 		if (pinspec.args[2]) {
 			if (group_names) {
@@ -381,7 +381,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
 					pinspec.args[1],
 					pinspec.args[2]);
 			if (ret)
-				break;
+				return ret;
 		} else {
 			/* npins == 0: special range */
 			if (pinspec.args[1]) {
@@ -411,32 +411,41 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
 			ret = gpiochip_add_pingroup_range(chip, pctldev,
 						pinspec.args[0], name);
 			if (ret)
-				break;
+				return ret;
 		}
 	}
+
+	return 0;
 }
 
 #else
-static void of_gpiochip_add_pin_range(struct gpio_chip *chip) {}
+static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { return 0; }
 #endif
 
-void of_gpiochip_add(struct gpio_chip *chip)
+int of_gpiochip_add(struct gpio_chip *chip)
 {
+	int status;
+
 	if ((!chip->of_node) && (chip->dev))
 		chip->of_node = chip->dev->of_node;
 
 	if (!chip->of_node)
-		return;
+		return 0;
 
 	if (!chip->of_xlate) {
 		chip->of_gpio_n_cells = 2;
 		chip->of_xlate = of_gpio_simple_xlate;
 	}
 
-	of_gpiochip_add_pin_range(chip);
+	status = of_gpiochip_add_pin_range(chip);
+	if (status)
+		return status;
+
 	of_node_get(chip->of_node);
 
 	of_gpiochip_scan_hogs(chip);
+
+	return 0;
 }
 
 void of_gpiochip_remove(struct gpio_chip *chip)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bf4bd1d120c3..a8cab335c0cc 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -287,7 +287,10 @@ int gpiochip_add(struct gpio_chip *chip)
 	INIT_LIST_HEAD(&chip->pin_ranges);
 #endif
 
-	of_gpiochip_add(chip);
+	status = of_gpiochip_add(chip);
+	if (status)
+		goto err_remove_chip;
+
 	acpi_gpiochip_add(chip);
 
 	status = gpiochip_sysfs_register(chip);
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 69dbe312b11b..f3191828f037 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -54,7 +54,7 @@ extern int of_mm_gpiochip_add(struct device_node *np,
 			      struct of_mm_gpio_chip *mm_gc);
 extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
 
-extern void of_gpiochip_add(struct gpio_chip *gc);
+extern int of_gpiochip_add(struct gpio_chip *gc);
 extern void of_gpiochip_remove(struct gpio_chip *gc);
 extern int of_gpio_simple_xlate(struct gpio_chip *gc,
 				const struct of_phandle_args *gpiospec,
@@ -76,7 +76,7 @@ static inline int of_gpio_simple_xlate(struct gpio_chip *gc,
 	return -ENOSYS;
 }
 
-static inline void of_gpiochip_add(struct gpio_chip *gc) { }
+static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; }
 static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
 
 #endif /* CONFIG_OF_GPIO */
-- 
2.4.3


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

* [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed
  2015-07-14  8:29 [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Tomeu Vizoso
  2015-07-14  8:29 ` [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found Tomeu Vizoso
@ 2015-07-14  8:29 ` Tomeu Vizoso
  2015-08-06 13:40   ` Tomeu Vizoso
  2015-07-14  8:29 ` [PATCH v2 3/3] ARM: tegra: Add gpio-ranges property Tomeu Vizoso
  2015-08-13 14:33 ` [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Thierry Reding
  3 siblings, 1 reply; 9+ messages in thread
From: Tomeu Vizoso @ 2015-07-14  8:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, devicetree, linux-tegra, Tomeu Vizoso,
	Thierry Reding, Linus Walleij, Stephen Warren, Alexandre Courbot

If the gpio DT node has the gpio-ranges property, the range will be
added by the gpio core and doesn't need to be added by the pinctrl
driver.

By having the gpio-ranges property, we have an explicit dependency from
the gpio node to the pinctrl node and we can stop using the deprecated
pinctrl_add_gpio_range() function.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
---

Changes in v2: None

 drivers/pinctrl/pinctrl-tegra.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
index 0f982b829be1..0fd7fd2b0f72 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -624,6 +624,22 @@ static struct pinctrl_desc tegra_pinctrl_desc = {
 	.owner = THIS_MODULE,
 };
 
+static bool gpio_node_has_range(void)
+{
+	struct device_node *np;
+	bool has_prop = false;
+
+	np = of_find_compatible_node(NULL, NULL, "nvidia,tegra30-gpio");
+	if (!np)
+		return has_prop;
+
+	has_prop = of_find_property(np, "gpio-ranges", NULL);
+
+	of_node_put(np);
+
+	return has_prop;
+}
+
 int tegra_pinctrl_probe(struct platform_device *pdev,
 			const struct tegra_pinctrl_soc_data *soc_data)
 {
@@ -708,7 +724,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
 		return PTR_ERR(pmx->pctl);
 	}
 
-	pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range);
+	if (!gpio_node_has_range())
+		pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range);
 
 	platform_set_drvdata(pdev, pmx);
 
-- 
2.4.3


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

* [PATCH v2 3/3] ARM: tegra: Add gpio-ranges property
  2015-07-14  8:29 [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Tomeu Vizoso
  2015-07-14  8:29 ` [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found Tomeu Vizoso
  2015-07-14  8:29 ` [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed Tomeu Vizoso
@ 2015-07-14  8:29 ` Tomeu Vizoso
  2015-08-13 14:33 ` [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Thierry Reding
  3 siblings, 0 replies; 9+ messages in thread
From: Tomeu Vizoso @ 2015-07-14  8:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, devicetree, linux-tegra, Tomeu Vizoso, Russell King,
	Thierry Reding, Kumar Gala, Stephen Warren, Ian Campbell,
	Rob Herring, Pawel Moll, Mark Rutland, Alexandre Courbot,
	linux-arm-kernel

Specify how the GPIOs map to the pins in Tegra SoCs, so the dependency is
explicit.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
---

Changes in v2:
- Remove outdated comment from the commit changelog

 arch/arm/boot/dts/tegra114.dtsi | 1 +
 arch/arm/boot/dts/tegra124.dtsi | 1 +
 arch/arm/boot/dts/tegra20.dtsi  | 1 +
 arch/arm/boot/dts/tegra30.dtsi  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/tegra114.dtsi b/arch/arm/boot/dts/tegra114.dtsi
index f58a3d9d5f13..7e1e1717e46a 100644
--- a/arch/arm/boot/dts/tegra114.dtsi
+++ b/arch/arm/boot/dts/tegra114.dtsi
@@ -234,6 +234,7 @@
 		gpio-controller;
 		#interrupt-cells = <2>;
 		interrupt-controller;
+		gpio-ranges = <&pinmux 0 0 246>;
 	};
 
 	apbmisc@70000800 {
diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi
index 87318a72f615..4779df336cb6 100644
--- a/arch/arm/boot/dts/tegra124.dtsi
+++ b/arch/arm/boot/dts/tegra124.dtsi
@@ -255,6 +255,7 @@
 		gpio-controller;
 		#interrupt-cells = <2>;
 		interrupt-controller;
+		gpio-ranges = <&pinmux 0 0 251>;
 	};
 
 	apbdma: dma@0,60020000 {
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index f444b67f55c6..b44277c63e8e 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -244,6 +244,7 @@
 		gpio-controller;
 		#interrupt-cells = <2>;
 		interrupt-controller;
+		gpio-ranges = <&pinmux 0 0 224>;
 	};
 
 	apbmisc@70000800 {
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index 782b11b2af6a..28c547f27ecd 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -349,6 +349,7 @@
 		gpio-controller;
 		#interrupt-cells = <2>;
 		interrupt-controller;
+		gpio-ranges = <&pinmux 0 0 248>;
 	};
 
 	apbmisc@70000800 {
-- 
2.4.3


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

* Re: [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found
  2015-07-14  8:29 ` [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found Tomeu Vizoso
@ 2015-07-24  9:15   ` Tomeu Vizoso
  2015-07-28 10:23   ` Linus Walleij
  1 sibling, 0 replies; 9+ messages in thread
From: Tomeu Vizoso @ 2015-07-24  9:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, devicetree, linux-tegra, Tomeu Vizoso, Linus Walleij,
	Grant Likely, Rob Herring, Alexandre Courbot

On 14 July 2015 at 10:29, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> When an OF node has a pin range for its GPIOs, return -EPROBE_DEFER if
> the pin controller isn't available.
>
> Otherwise, the GPIO range wouldn't be set at all unless the pin
> controller probed always before the GPIO chip.
>
> With this change, the probe of the GPIO chip will be deferred and will
> be retried at a later point, hopefully once the pin controller has been
> registered and probed already.

Ping :)

Thanks,

Tomeu

> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> ---
>
> Changes in v2:
> - Don't defer probe if the pinctrl node is disabled
>
>  drivers/gpio/gpiolib-of.c | 27 ++++++++++++++++++---------
>  drivers/gpio/gpiolib.c    |  5 ++++-
>  include/linux/of_gpio.h   |  4 ++--
>  3 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 9a0ec48a4737..4e1f73b9136a 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -338,7 +338,7 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
>  EXPORT_SYMBOL(of_mm_gpiochip_remove);
>
>  #ifdef CONFIG_PINCTRL
> -static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
> +static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
>  {
>         struct device_node *np = chip->of_node;
>         struct of_phandle_args pinspec;
> @@ -349,7 +349,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
>         struct property *group_names;
>
>         if (!np)
> -               return;
> +               return 0;
>
>         group_names = of_find_property(np, group_names_propname, NULL);
>
> @@ -361,7 +361,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
>
>                 pctldev = of_pinctrl_get(pinspec.np);
>                 if (!pctldev)
> -                       break;
> +                       return -EPROBE_DEFER;
>
>                 if (pinspec.args[2]) {
>                         if (group_names) {
> @@ -381,7 +381,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
>                                         pinspec.args[1],
>                                         pinspec.args[2]);
>                         if (ret)
> -                               break;
> +                               return ret;
>                 } else {
>                         /* npins == 0: special range */
>                         if (pinspec.args[1]) {
> @@ -411,32 +411,41 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
>                         ret = gpiochip_add_pingroup_range(chip, pctldev,
>                                                 pinspec.args[0], name);
>                         if (ret)
> -                               break;
> +                               return ret;
>                 }
>         }
> +
> +       return 0;
>  }
>
>  #else
> -static void of_gpiochip_add_pin_range(struct gpio_chip *chip) {}
> +static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { return 0; }
>  #endif
>
> -void of_gpiochip_add(struct gpio_chip *chip)
> +int of_gpiochip_add(struct gpio_chip *chip)
>  {
> +       int status;
> +
>         if ((!chip->of_node) && (chip->dev))
>                 chip->of_node = chip->dev->of_node;
>
>         if (!chip->of_node)
> -               return;
> +               return 0;
>
>         if (!chip->of_xlate) {
>                 chip->of_gpio_n_cells = 2;
>                 chip->of_xlate = of_gpio_simple_xlate;
>         }
>
> -       of_gpiochip_add_pin_range(chip);
> +       status = of_gpiochip_add_pin_range(chip);
> +       if (status)
> +               return status;
> +
>         of_node_get(chip->of_node);
>
>         of_gpiochip_scan_hogs(chip);
> +
> +       return 0;
>  }
>
>  void of_gpiochip_remove(struct gpio_chip *chip)
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index bf4bd1d120c3..a8cab335c0cc 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -287,7 +287,10 @@ int gpiochip_add(struct gpio_chip *chip)
>         INIT_LIST_HEAD(&chip->pin_ranges);
>  #endif
>
> -       of_gpiochip_add(chip);
> +       status = of_gpiochip_add(chip);
> +       if (status)
> +               goto err_remove_chip;
> +
>         acpi_gpiochip_add(chip);
>
>         status = gpiochip_sysfs_register(chip);
> diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
> index 69dbe312b11b..f3191828f037 100644
> --- a/include/linux/of_gpio.h
> +++ b/include/linux/of_gpio.h
> @@ -54,7 +54,7 @@ extern int of_mm_gpiochip_add(struct device_node *np,
>                               struct of_mm_gpio_chip *mm_gc);
>  extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
>
> -extern void of_gpiochip_add(struct gpio_chip *gc);
> +extern int of_gpiochip_add(struct gpio_chip *gc);
>  extern void of_gpiochip_remove(struct gpio_chip *gc);
>  extern int of_gpio_simple_xlate(struct gpio_chip *gc,
>                                 const struct of_phandle_args *gpiospec,
> @@ -76,7 +76,7 @@ static inline int of_gpio_simple_xlate(struct gpio_chip *gc,
>         return -ENOSYS;
>  }
>
> -static inline void of_gpiochip_add(struct gpio_chip *gc) { }
> +static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; }
>  static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
>
>  #endif /* CONFIG_OF_GPIO */
> --
> 2.4.3
>

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

* Re: [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found
  2015-07-14  8:29 ` [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found Tomeu Vizoso
  2015-07-24  9:15   ` Tomeu Vizoso
@ 2015-07-28 10:23   ` Linus Walleij
  1 sibling, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-07-28 10:23 UTC (permalink / raw)
  To: Tomeu Vizoso
  Cc: linux-kernel, linux-gpio, devicetree, linux-tegra, Grant Likely,
	Rob Herring, Alexandre Courbot

On Tue, Jul 14, 2015 at 10:29 AM, Tomeu Vizoso
<tomeu.vizoso@collabora.com> wrote:

> When an OF node has a pin range for its GPIOs, return -EPROBE_DEFER if
> the pin controller isn't available.
>
> Otherwise, the GPIO range wouldn't be set at all unless the pin
> controller probed always before the GPIO chip.
>
> With this change, the probe of the GPIO chip will be deferred and will
> be retried at a later point, hopefully once the pin controller has been
> registered and probed already.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> ---
>
> Changes in v2:
> - Don't defer probe if the pinctrl node is disabled

Sorry for the delay.

This looks like the right thing to do, I was just worried that it would have
undesired semantic or probe order effects on some platforms, but I think
this is one of these cases where I just have to apply this and see what
happens when people test it in linux-next.

So, patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed
  2015-07-14  8:29 ` [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed Tomeu Vizoso
@ 2015-08-06 13:40   ` Tomeu Vizoso
  2015-08-13 12:55     ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: Tomeu Vizoso @ 2015-08-06 13:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, devicetree, linux-tegra, Tomeu Vizoso,
	Thierry Reding, Linus Walleij, Stephen Warren, Alexandre Courbot

On 14 July 2015 at 10:29, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> If the gpio DT node has the gpio-ranges property, the range will be
> added by the gpio core and doesn't need to be added by the pinctrl
> driver.
>
> By having the gpio-ranges property, we have an explicit dependency from
> the gpio node to the pinctrl node and we can stop using the deprecated
> pinctrl_add_gpio_range() function.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Acked-by: Stephen Warren <swarren@nvidia.com>

Hi Linus,

do you mind if this goes through the Tegra tree? It would be best if
it went together with 3/3 ("ARM: tegra: Add gpio-ranges property"), to
avoid duplicated GPIO ranges.

Thanks,

Tomeu

> ---
>
> Changes in v2: None
>
>  drivers/pinctrl/pinctrl-tegra.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
> index 0f982b829be1..0fd7fd2b0f72 100644
> --- a/drivers/pinctrl/pinctrl-tegra.c
> +++ b/drivers/pinctrl/pinctrl-tegra.c
> @@ -624,6 +624,22 @@ static struct pinctrl_desc tegra_pinctrl_desc = {
>         .owner = THIS_MODULE,
>  };
>
> +static bool gpio_node_has_range(void)
> +{
> +       struct device_node *np;
> +       bool has_prop = false;
> +
> +       np = of_find_compatible_node(NULL, NULL, "nvidia,tegra30-gpio");
> +       if (!np)
> +               return has_prop;
> +
> +       has_prop = of_find_property(np, "gpio-ranges", NULL);
> +
> +       of_node_put(np);
> +
> +       return has_prop;
> +}
> +
>  int tegra_pinctrl_probe(struct platform_device *pdev,
>                         const struct tegra_pinctrl_soc_data *soc_data)
>  {
> @@ -708,7 +724,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
>                 return PTR_ERR(pmx->pctl);
>         }
>
> -       pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range);
> +       if (!gpio_node_has_range())
> +               pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range);
>
>         platform_set_drvdata(pdev, pmx);
>
> --
> 2.4.3
>

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

* Re: [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed
  2015-08-06 13:40   ` Tomeu Vizoso
@ 2015-08-13 12:55     ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-08-13 12:55 UTC (permalink / raw)
  To: Tomeu Vizoso
  Cc: linux-kernel, linux-gpio, devicetree, linux-tegra,
	Thierry Reding, Stephen Warren, Alexandre Courbot

On Thu, Aug 6, 2015 at 3:40 PM, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> On 14 July 2015 at 10:29, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
>> If the gpio DT node has the gpio-ranges property, the range will be
>> added by the gpio core and doesn't need to be added by the pinctrl
>> driver.
>>
>> By having the gpio-ranges property, we have an explicit dependency from
>> the gpio node to the pinctrl node and we can stop using the deprecated
>> pinctrl_add_gpio_range() function.
>>
>> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
>> Acked-by: Stephen Warren <swarren@nvidia.com>
>
> Hi Linus,
>
> do you mind if this goes through the Tegra tree? It would be best if
> it went together with 3/3 ("ARM: tegra: Add gpio-ranges property"), to
> avoid duplicated GPIO ranges.

It's cool, go ahead:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device
  2015-07-14  8:29 [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Tomeu Vizoso
                   ` (2 preceding siblings ...)
  2015-07-14  8:29 ` [PATCH v2 3/3] ARM: tegra: Add gpio-ranges property Tomeu Vizoso
@ 2015-08-13 14:33 ` Thierry Reding
  3 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2015-08-13 14:33 UTC (permalink / raw)
  To: Tomeu Vizoso
  Cc: linux-kernel, linux-gpio, devicetree, linux-tegra, Russell King,
	Linus Walleij, Kumar Gala, Stephen Warren, Grant Likely,
	Ian Campbell, Rob Herring, Pawel Moll, Mark Rutland,
	Alexandre Courbot, linux-arm-kernel

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

On Tue, Jul 14, 2015 at 10:29:53AM +0200, Tomeu Vizoso wrote:
> Hello,
> 
> these three patches make sure that there's an explicit dependency from
> the GPIO chip in Tegra SoCs to the corresponding pinctrl device, without
> having duplicated gpio ranges.
> 
> By having an explicit dependency, we can do things such as probing the
> pinctrl device before the GPIO chip device to avoid deferred probes.
> 
> Thanks,
> 
> Tomeu
> 
> Changes in v2:
> - Don't defer probe if the pinctrl node is disabled
> - Remove outdated comment from the commit changelog
> 
> Tomeu Vizoso (3):
>   gpio: defer probe if pinctrl cannot be found
>   pinctrl: tegra: Only set the gpio range if needed
>   ARM: tegra: Add gpio-ranges property

Patches 2 and 3 applied to the Tegra tree. Linus, I've applied the
pinctrl patch to a separate branch, so we could use that to resolve
conflicts, should there be any.

Thierry

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

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

end of thread, other threads:[~2015-08-13 14:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14  8:29 [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Tomeu Vizoso
2015-07-14  8:29 ` [PATCH v2 1/3] gpio: defer probe if pinctrl cannot be found Tomeu Vizoso
2015-07-24  9:15   ` Tomeu Vizoso
2015-07-28 10:23   ` Linus Walleij
2015-07-14  8:29 ` [PATCH v2 2/3] pinctrl: tegra: Only set the gpio range if needed Tomeu Vizoso
2015-08-06 13:40   ` Tomeu Vizoso
2015-08-13 12:55     ` Linus Walleij
2015-07-14  8:29 ` [PATCH v2 3/3] ARM: tegra: Add gpio-ranges property Tomeu Vizoso
2015-08-13 14:33 ` [PATCH v2 0/3] Have Tegra's GPIO chip depend explicitly on the pinctrl device Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).