All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	 Bartosz Golaszewski <brgl@bgdev.pl>,
	Rob Herring <robh+dt@kernel.org>,
	 Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	 Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
	"Théo Lebrun" <theo.lebrun@bootlin.com>
Subject: [PATCH v2 25/30] gpio: nomadik: grab optional reset control and deassert it at probe
Date: Wed, 28 Feb 2024 12:28:23 +0100	[thread overview]
Message-ID: <20240228-mbly-gpio-v2-25-3ba757474006@bootlin.com> (raw)
In-Reply-To: <20240228-mbly-gpio-v2-0-3ba757474006@bootlin.com>

Fetch a reference to the optional shared reset control and deassert it
if it exists.

Optional because not all platforms that use this driver have a reset
attached to the reset block. Shared because some platforms that use the
reset (at least Mobileye EyeQ5) share the reset across banks.

Do not keep a reference to the reset control as it is not needed
afterwards; the driver does not handle suspend, does not use runtime
PM, does not register a remove callback and does not support unbinding
from sysfs (made explicit with suppress_bind_attrs).

The operation is done in nmk_gpio_populate_chip(). This function is
called by either gpio-nomadik or pinctrl-nomadik, whoever comes first.
This is here for historic reasons and could probably be removed now; it
seems gpio-ranges enforces the ordering to be pinctrl-first. It is not
the topic of the present patch however.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
 drivers/gpio/gpio-nomadik.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
index 6adb3c4417d3..c9fd6631e0aa 100644
--- a/drivers/gpio/gpio-nomadik.c
+++ b/drivers/gpio/gpio-nomadik.c
@@ -509,11 +509,13 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 {
 	struct nmk_gpio_chip *nmk_chip;
 	struct platform_device *gpio_pdev;
+	struct reset_control *reset;
 	struct device *gpio_dev;
 	struct gpio_chip *chip;
 	struct clk *clk;
 	void __iomem *base;
 	u32 id, ngpio;
+	int ret;
 
 	gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
 	if (!gpio_dev) {
@@ -572,6 +574,24 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	clk_prepare(clk);
 	nmk_chip->clk = clk;
 
+	reset = devm_reset_control_get_optional_shared(gpio_dev, NULL);
+	if (IS_ERR(reset)) {
+		dev_err(&pdev->dev, "failed getting reset control: %ld\n",
+			PTR_ERR(reset));
+		return ERR_CAST(reset);
+	}
+
+	/*
+	 * Reset might be shared and asserts/deasserts calls are unbalanced. We
+	 * only support sharing this reset with other gpio-nomadik devices that
+	 * use this reset to ensure deassertion at probe.
+	 */
+	ret = reset_control_deassert(reset);
+	if (ret) {
+		dev_err(&pdev->dev, "failed reset deassert: %d\n", ret);
+		return ERR_PTR(ret);
+	}
+
 #ifdef CONFIG_PINCTRL_NOMADIK
 	BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips));
 	nmk_gpio_chips[id] = nmk_chip;
@@ -690,6 +710,7 @@ static struct platform_driver nmk_gpio_driver = {
 	.driver = {
 		.name = "nomadik-gpio",
 		.of_match_table = nmk_gpio_match,
+		.suppress_bind_attrs = true,
 	},
 	.probe = nmk_gpio_probe,
 };

-- 
2.44.0


WARNING: multiple messages have this Message-ID (diff)
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	 Bartosz Golaszewski <brgl@bgdev.pl>,
	Rob Herring <robh+dt@kernel.org>,
	 Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	 Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
	"Théo Lebrun" <theo.lebrun@bootlin.com>
Subject: [PATCH v2 25/30] gpio: nomadik: grab optional reset control and deassert it at probe
Date: Wed, 28 Feb 2024 12:28:23 +0100	[thread overview]
Message-ID: <20240228-mbly-gpio-v2-25-3ba757474006@bootlin.com> (raw)
In-Reply-To: <20240228-mbly-gpio-v2-0-3ba757474006@bootlin.com>

Fetch a reference to the optional shared reset control and deassert it
if it exists.

Optional because not all platforms that use this driver have a reset
attached to the reset block. Shared because some platforms that use the
reset (at least Mobileye EyeQ5) share the reset across banks.

Do not keep a reference to the reset control as it is not needed
afterwards; the driver does not handle suspend, does not use runtime
PM, does not register a remove callback and does not support unbinding
from sysfs (made explicit with suppress_bind_attrs).

The operation is done in nmk_gpio_populate_chip(). This function is
called by either gpio-nomadik or pinctrl-nomadik, whoever comes first.
This is here for historic reasons and could probably be removed now; it
seems gpio-ranges enforces the ordering to be pinctrl-first. It is not
the topic of the present patch however.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
 drivers/gpio/gpio-nomadik.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
index 6adb3c4417d3..c9fd6631e0aa 100644
--- a/drivers/gpio/gpio-nomadik.c
+++ b/drivers/gpio/gpio-nomadik.c
@@ -509,11 +509,13 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 {
 	struct nmk_gpio_chip *nmk_chip;
 	struct platform_device *gpio_pdev;
+	struct reset_control *reset;
 	struct device *gpio_dev;
 	struct gpio_chip *chip;
 	struct clk *clk;
 	void __iomem *base;
 	u32 id, ngpio;
+	int ret;
 
 	gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
 	if (!gpio_dev) {
@@ -572,6 +574,24 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	clk_prepare(clk);
 	nmk_chip->clk = clk;
 
+	reset = devm_reset_control_get_optional_shared(gpio_dev, NULL);
+	if (IS_ERR(reset)) {
+		dev_err(&pdev->dev, "failed getting reset control: %ld\n",
+			PTR_ERR(reset));
+		return ERR_CAST(reset);
+	}
+
+	/*
+	 * Reset might be shared and asserts/deasserts calls are unbalanced. We
+	 * only support sharing this reset with other gpio-nomadik devices that
+	 * use this reset to ensure deassertion at probe.
+	 */
+	ret = reset_control_deassert(reset);
+	if (ret) {
+		dev_err(&pdev->dev, "failed reset deassert: %d\n", ret);
+		return ERR_PTR(ret);
+	}
+
 #ifdef CONFIG_PINCTRL_NOMADIK
 	BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips));
 	nmk_gpio_chips[id] = nmk_chip;
@@ -690,6 +710,7 @@ static struct platform_driver nmk_gpio_driver = {
 	.driver = {
 		.name = "nomadik-gpio",
 		.of_match_table = nmk_gpio_match,
+		.suppress_bind_attrs = true,
 	},
 	.probe = nmk_gpio_probe,
 };

-- 
2.44.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2024-02-28 11:28 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 11:27 [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Théo Lebrun
2024-02-28 11:27 ` Théo Lebrun
2024-02-28 11:27 ` [PATCH v2 01/30] dt-bindings: gpio: nomadik: convert into yaml format Théo Lebrun
2024-02-28 11:27   ` Théo Lebrun
2024-02-28 12:49   ` Conor Dooley
2024-02-28 12:49     ` Conor Dooley
2024-02-29  9:16   ` Linus Walleij
2024-02-29  9:16     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 02/30] dt-bindings: gpio: nomadik: add optional ngpios property Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:17   ` Linus Walleij
2024-02-29  9:17     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 03/30] dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-28 12:46   ` Conor Dooley
2024-02-28 12:46     ` Conor Dooley
2024-02-29  9:19   ` Linus Walleij
2024-02-29  9:19     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 04/30] dt-bindings: gpio: nomadik: add optional reset property Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:20   ` Linus Walleij
2024-02-29  9:20     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 05/30] gpio: nomadik: fix offset bug in nmk_pmx_set() Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:22   ` Linus Walleij
2024-02-29  9:22     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 06/30] gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/ Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:24   ` Linus Walleij
2024-02-29  9:24     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 07/30] pinctrl: nomadik: Kconfig: allow building with COMPILE_TEST Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:24   ` Linus Walleij
2024-02-29  9:24     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 08/30] pinctrl: nomadik: fix build warning (-Wformat) Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:25   ` Linus Walleij
2024-02-29  9:25     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 09/30] pinctrl: nomadik: fix build warning (-Wpointer-to-int-cast) Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:25   ` Linus Walleij
2024-02-29  9:25     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 10/30] pinctrl: nomadik: minimise indentation in probe Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:26   ` Linus Walleij
2024-02-29  9:26     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 11/30] pinctrl: nomadik: follow type-system kernel coding conventions Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:27   ` Linus Walleij
2024-02-29  9:27     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 12/30] pinctrl: nomadik: follow whitespace " Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:28   ` Linus Walleij
2024-02-29  9:28     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 13/30] pinctrl: nomadik: follow conditional " Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:28   ` Linus Walleij
2024-02-29  9:28     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 14/30] gpio: nomadik: add #include <linux/slab.h> Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:29   ` Linus Walleij
2024-02-29  9:29     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 15/30] gpio: nomadik: replace of_find_*() by bus_find_device_by_of_node() Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:30   ` Linus Walleij
2024-02-29  9:30     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 16/30] gpio: nomadik: replace of_property_read_*() by device_property_read_*() Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:30   ` Linus Walleij
2024-02-29  9:30     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 17/30] gpio: nomadik: use devm_platform_ioremap_resource() helper Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:31   ` Linus Walleij
2024-02-29  9:31     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 18/30] gpio: nomadik: use devres version of clk_get*() Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:31   ` Linus Walleij
2024-02-29  9:31     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 19/30] gpio: nomadik: request dynamic ID allocation Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:33   ` Linus Walleij
2024-02-29  9:33     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 20/30] gpio: nomadik: make clock optional Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:33   ` Linus Walleij
2024-02-29  9:33     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 21/30] gpio: nomadik: change driver name from gpio to gpio-nomadik Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:35   ` Linus Walleij
2024-02-29  9:35     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 22/30] gpio: nomadik: support shared GPIO IRQs Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:36   ` Linus Walleij
2024-02-29  9:36     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 23/30] gpio: nomadik: handle variadic GPIO count Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:36   ` Linus Walleij
2024-02-29  9:36     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 24/30] gpio: nomadik: support mobileye,eyeq5-gpio Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:38   ` Linus Walleij
2024-02-29  9:38     ` Linus Walleij
2024-02-28 11:28 ` Théo Lebrun [this message]
2024-02-28 11:28   ` [PATCH v2 25/30] gpio: nomadik: grab optional reset control and deassert it at probe Théo Lebrun
2024-02-29  9:38   ` Linus Walleij
2024-02-29  9:38     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe() Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:40   ` Linus Walleij
2024-02-29  9:40     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 27/30] MIPS: eyeq5_defconfig: enable GPIO by default Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:40   ` Linus Walleij
2024-02-29  9:40     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 28/30] MIPS: mobileye: eyeq5: add two GPIO bank nodes Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:41   ` Linus Walleij
2024-02-29  9:41     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 29/30] MIPS: mobileye: eyeq5: add resets to GPIO banks Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:42   ` Linus Walleij
2024-02-29  9:42     ` Linus Walleij
2024-02-28 11:28 ` [PATCH v2 30/30] MIPS: mobileye: eyeq5: map GPIOs to pins using gpio-ranges Théo Lebrun
2024-02-28 11:28   ` Théo Lebrun
2024-02-29  9:42   ` Linus Walleij
2024-02-29  9:42     ` Linus Walleij
2024-02-29  9:44 ` [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Linus Walleij
2024-02-29  9:44   ` Linus Walleij
2024-02-29  9:56   ` Théo Lebrun
2024-02-29  9:56     ` Théo Lebrun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240228-mbly-gpio-v2-25-3ba757474006@bootlin.com \
    --to=theo.lebrun@bootlin.com \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=tawfik.bayouk@mobileye.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=vladimir.kondratiev@mobileye.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.