linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: xway: fix gpio-hog related boot issues
@ 2018-12-14  7:48 Martin Schiller
  2018-12-17 14:32 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Schiller @ 2018-12-14  7:48 UTC (permalink / raw)
  To: linus.walleij; +Cc: linux-gpio, linux-kernel, Martin Schiller

This patch is based on commit a86caa9ba5d7 ("pinctrl: msm: fix gpio-hog
related boot issues").

It fixes the issue that the gpio ranges needs to be defined before
gpiochip_add().

Therefore, we also have to swap the order of registering the pinctrl
driver and registering the gpio chip.

You also have to add the "gpio-ranges" property to the pinctrl device
node to get it finally working.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 drivers/pinctrl/pinctrl-xway.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
index 93f8bd04e7fe..ae74b260b014 100644
--- a/drivers/pinctrl/pinctrl-xway.c
+++ b/drivers/pinctrl/pinctrl-xway.c
@@ -1746,14 +1746,6 @@ static int pinmux_xway_probe(struct platform_device *pdev)
 	}
 	xway_pctrl_desc.pins = xway_info.pads;
 
-	/* register the gpio chip */
-	xway_chip.parent = &pdev->dev;
-	ret = devm_gpiochip_add_data(&pdev->dev, &xway_chip, NULL);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register gpio chip\n");
-		return ret;
-	}
-
 	/* setup the data needed by pinctrl */
 	xway_pctrl_desc.name	= dev_name(&pdev->dev);
 	xway_pctrl_desc.npins	= xway_chip.ngpio;
@@ -1775,10 +1767,33 @@ static int pinmux_xway_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	/* finish with registering the gpio range in pinctrl */
-	xway_gpio_range.npins = xway_chip.ngpio;
-	xway_gpio_range.base = xway_chip.base;
-	pinctrl_add_gpio_range(xway_info.pctrl, &xway_gpio_range);
+	/* register the gpio chip */
+	xway_chip.parent = &pdev->dev;
+	xway_chip.owner = THIS_MODULE;
+	xway_chip.of_node = pdev->dev.of_node;
+	ret = devm_gpiochip_add_data(&pdev->dev, &xway_chip, NULL);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to register gpio chip\n");
+		return ret;
+	}
+
+	/*
+	 * For DeviceTree-supported systems, the gpio core checks the
+	 * pinctrl's device node for the "gpio-ranges" property.
+	 * If it is present, it takes care of adding the pin ranges
+	 * for the driver. In this case the driver can skip ahead.
+	 *
+	 * In order to remain compatible with older, existing DeviceTree
+	 * files which don't set the "gpio-ranges" property or systems that
+	 * utilize ACPI the driver has to call gpiochip_add_pin_range().
+	 */
+	if (!of_property_read_bool(pdev->dev.of_node, "gpio-ranges")) {
+		/* finish with registering the gpio range in pinctrl */
+		xway_gpio_range.npins = xway_chip.ngpio;
+		xway_gpio_range.base = xway_chip.base;
+		pinctrl_add_gpio_range(xway_info.pctrl, &xway_gpio_range);
+	}
+
 	dev_info(&pdev->dev, "Init done\n");
 	return 0;
 }
-- 
2.11.0

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

* Re: [PATCH] pinctrl: xway: fix gpio-hog related boot issues
  2018-12-14  7:48 [PATCH] pinctrl: xway: fix gpio-hog related boot issues Martin Schiller
@ 2018-12-17 14:32 ` Linus Walleij
  2018-12-17 16:45   ` John Crispin
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2018-12-17 14:32 UTC (permalink / raw)
  To: Martin Schiller, John Crispin
  Cc: open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org

On Fri, Dec 14, 2018 at 8:48 AM Martin Schiller <ms@dev.tdt.de> wrote:

> This patch is based on commit a86caa9ba5d7 ("pinctrl: msm: fix gpio-hog
> related boot issues").
>
> It fixes the issue that the gpio ranges needs to be defined before
> gpiochip_add().
>
> Therefore, we also have to swap the order of registering the pinctrl
> driver and registering the gpio chip.
>
> You also have to add the "gpio-ranges" property to the pinctrl device
> node to get it finally working.
>
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>

Patch applied unless John Crispin has objections, it looks
good to me!

Yours,
Linus Walleij

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

* Re: [PATCH] pinctrl: xway: fix gpio-hog related boot issues
  2018-12-17 14:32 ` Linus Walleij
@ 2018-12-17 16:45   ` John Crispin
  2018-12-18  6:43     ` Martin Schiller
  0 siblings, 1 reply; 4+ messages in thread
From: John Crispin @ 2018-12-17 16:45 UTC (permalink / raw)
  To: Linus Walleij, Martin Schiller
  Cc: open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org


On 17/12/2018 15:32, Linus Walleij wrote:
> On Fri, Dec 14, 2018 at 8:48 AM Martin Schiller <ms@dev.tdt.de> wrote:
>
>> This patch is based on commit a86caa9ba5d7 ("pinctrl: msm: fix gpio-hog
>> related boot issues").
>>
>> It fixes the issue that the gpio ranges needs to be defined before
>> gpiochip_add().
>>
>> Therefore, we also have to swap the order of registering the pinctrl
>> driver and registering the gpio chip.
>>
>> You also have to add the "gpio-ranges" property to the pinctrl device
>> node to get it finally working.
>>
>> Signed-off-by: Martin Schiller <ms@dev.tdt.de>
> Patch applied unless John Crispin has objections, it looks
> good to me!
>
> Yours,
> Linus Walleij


sorry did not see the patch in my inbox

Acked-by: John Crispin <john@phrozen.org>

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

* Re: [PATCH] pinctrl: xway: fix gpio-hog related boot issues
  2018-12-17 16:45   ` John Crispin
@ 2018-12-18  6:43     ` Martin Schiller
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Schiller @ 2018-12-18  6:43 UTC (permalink / raw)
  To: John Crispin, Linus Walleij; +Cc: open list:GPIO SUBSYSTEM, linux-kernel

On 2018-12-17 17:45, John Crispin wrote:
> On 17/12/2018 15:32, Linus Walleij wrote:
>> On Fri, Dec 14, 2018 at 8:48 AM Martin Schiller <ms@dev.tdt.de> wrote:
>> 
>>> This patch is based on commit a86caa9ba5d7 ("pinctrl: msm: fix 
>>> gpio-hog
>>> related boot issues").
>>> 
>>> It fixes the issue that the gpio ranges needs to be defined before
>>> gpiochip_add().
>>> 
>>> Therefore, we also have to swap the order of registering the pinctrl
>>> driver and registering the gpio chip.
>>> 
>>> You also have to add the "gpio-ranges" property to the pinctrl device
>>> node to get it finally working.
>>> 
>>> Signed-off-by: Martin Schiller <ms@dev.tdt.de>
>> Patch applied unless John Crispin has objections, it looks
>> good to me!
>> 
>> Yours,
>> Linus Walleij
> 
> 
> sorry did not see the patch in my inbox
> 

Sorry, that was my fault.
I've added everyone from getmaintainers.pl output, but forgot to also 
add you.

Regards,
Martin

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

end of thread, other threads:[~2018-12-18  6:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-14  7:48 [PATCH] pinctrl: xway: fix gpio-hog related boot issues Martin Schiller
2018-12-17 14:32 ` Linus Walleij
2018-12-17 16:45   ` John Crispin
2018-12-18  6:43     ` Martin Schiller

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).