linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support
@ 2024-02-28 11:27 Théo Lebrun
  2024-02-28 11:28 ` [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe() Théo Lebrun
  2024-02-29  9:44 ` [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Théo Lebrun @ 2024-02-28 11:27 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
	Thomas Bogendoerfer
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-mips, Gregory CLEMENT, Vladimir Kondratiev,
	Thomas Petazzoni, Tawfik Bayouk, Théo Lebrun,
	Krzysztof Kozlowski, Stephen Warren, Jonathan Corbet, linux-doc

Hi,

This patch series reworks the Nomadik GPIO driver to bring it up to date
to current kernel standards. We then add Mobileye EyeQ5 support that
uses the same IP block but with limited functionality. We also add
features required by our newly supported platform:

 - Dynamic GPIO ID allocation;
 - Make clock optional;
 - Shared IRQ (usecase: EyeQ5 has two banks using the same IRQ);
 - Handle variadic GPIO counts (usecase: EyeQ5 has <32 GPIOs per bank);
 - Grab optional reset at probe (usecase: EyeQ5 has a shared GPIO reset).

This GPIO platform driver was previously declared & registered inside
drivers/pinctrl/nomadik/pinctrl-nomadik.c, side-by-side with the
pinctrl driver. Both are tightly integrated, mostly for muxing reasons.
Now that gpio-nomadik is used for another platform, we loosen the
relationship. The behavior should not change on already supported
hardware but I do not have Nomadik hardware to test for that.

We have some dependencies. Those are:
- The base platform support series from Grégory [0], present in
  mips-next. It in turns depends on [1], also in mips-next. This
  relates to the last four patches (27 thru 30), ie defconfig and
  devicetree.
- The OLB syscon support series [2]. It provides reset and pinctrl nodes
  inside the devicetree. This relates to the last two patches (29 and
  30), ie resets and gpio-ranges DT props. GPIO works fine if patches
  29 and 30 are dropped and bootloader deasserts the reset (it does).

This has been tested on the EyeQ5 hardware, with the two parent series
applied. It also works fine without the OLB syscon series when our last
two patches are removed. It has been built on both Arm defconfigs that
rely on pinctrl-nomadik: nhk8815_defconfig and u8500_defconfig. I don't
have any Nomadik hardware to test though.

Have a nice day,
Théo

[0]: https://lore.kernel.org/lkml/20240216174227.409400-1-gregory.clement@bootlin.com/
[1]: https://lore.kernel.org/linux-mips/20240209-regname-v1-0-2125efa016ef@flygoat.com/
[2]: https://lore.kernel.org/lkml/20240227-mbly-clk-v8-0-c57fbda7664a@bootlin.com/

To: Linus Walleij <linus.walleij@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
To: Rob Herring <robh+dt@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-gpio@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mips@vger.kernel.org
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Tawfik Bayouk <tawfik.bayouk@mobileye.com>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Changes in v2:
- dt-bindings: add description to gpio-bank.
- dt-bindings: fix disabling of st,supports-sleepmode prop with
  st,supports-sleepmode compatible.
- gpio: move "fix offset bug in nmk_pmx_set()" to the start of the
  series and add a Fixes trailer. The patch changed because of that.
- pinctrl: allow building PINCTRL_NOMADIK and co with COMPILE_TEST.
- gpio: in "support shared GPIO IRQs" remove fake raw lock and use
  generic_handle_domain_irq_safe() helper.
- gpio: remove OF API calls.
    of_property_read_*()     => device_property_read_*()
    of_find_device_by_node() => bus_find_device_by_of_node()
- gpio: use device_is_compatible() rather than match data to detect for
  Mobileye SoC. If GPIO device is populated by pinctrl match data is
  unavailable.
- gpio: rename quirk_mbly field to is_mobileye_soc.
- gpio: add comment about unbalanced reset_control_deassert() and
  disable bind sysfs attributes.
- gpio: use devm_platform_ioremap_resource() helper.
- gpio: use devres version of clk_get*() in case of probe failure.
- gpio: add missing <linux/slab.h> include.
- Documentation: gpio: replace outdated comment of using a fake spin
  lock and mention the generic_handle_irq_safe() helper.
- gpio: in "follow whitespace kernel coding conventions", add missing
  newline before headers.
- Take 6 Reviewed-By Linus, 1 Reviewed-by and 1 Acked-by Krzysztof.
- Link to v1: https://lore.kernel.org/r/20240214-mbly-gpio-v1-0-f88c0ccf372b@bootlin.com

---
Théo Lebrun (30):
      dt-bindings: gpio: nomadik: convert into yaml format
      dt-bindings: gpio: nomadik: add optional ngpios property
      dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible
      dt-bindings: gpio: nomadik: add optional reset property
      gpio: nomadik: fix offset bug in nmk_pmx_set()
      gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/
      pinctrl: nomadik: Kconfig: allow building with COMPILE_TEST
      pinctrl: nomadik: fix build warning (-Wformat)
      pinctrl: nomadik: fix build warning (-Wpointer-to-int-cast)
      pinctrl: nomadik: minimise indentation in probe
      pinctrl: nomadik: follow type-system kernel coding conventions
      pinctrl: nomadik: follow whitespace kernel coding conventions
      pinctrl: nomadik: follow conditional kernel coding conventions
      gpio: nomadik: add #include <linux/slab.h>
      gpio: nomadik: replace of_find_*() by bus_find_device_by_of_node()
      gpio: nomadik: replace of_property_read_*() by device_property_read_*()
      gpio: nomadik: use devm_platform_ioremap_resource() helper
      gpio: nomadik: use devres version of clk_get*()
      gpio: nomadik: request dynamic ID allocation
      gpio: nomadik: make clock optional
      gpio: nomadik: change driver name from gpio to gpio-nomadik
      gpio: nomadik: support shared GPIO IRQs
      gpio: nomadik: handle variadic GPIO count
      gpio: nomadik: support mobileye,eyeq5-gpio
      gpio: nomadik: grab optional reset control and deassert it at probe
      Documentation: gpio: mention generic_handle_irq_safe()
      MIPS: eyeq5_defconfig: enable GPIO by default
      MIPS: mobileye: eyeq5: add two GPIO bank nodes
      MIPS: mobileye: eyeq5: add resets to GPIO banks
      MIPS: mobileye: eyeq5: map GPIOs to pins using gpio-ranges

 .../devicetree/bindings/gpio/gpio-nmk.txt          |  31 -
 .../devicetree/bindings/gpio/st,nomadik-gpio.yaml  |  95 +++
 Documentation/driver-api/gpio/driver.rst           |  11 +-
 MAINTAINERS                                        |   2 +
 arch/mips/boot/dts/mobileye/eyeq5.dtsi             |  30 +
 arch/mips/configs/eyeq5_defconfig                  |   2 +
 drivers/gpio/Kconfig                               |  13 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-nomadik.c                        | 722 ++++++++++++++++
 drivers/pinctrl/nomadik/Kconfig                    |   7 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c   |   3 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik-stn8815.c  |   3 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik.c          | 939 +++------------------
 .../linux/gpio/gpio-nomadik.h                      | 123 ++-
 14 files changed, 1117 insertions(+), 865 deletions(-)
---
base-commit: 3ebad8a9638d4c667e8925968806a82e1b9025ea
change-id: 20231023-mbly-gpio-a30571ec3283

Best regards,
-- 
Théo Lebrun <theo.lebrun@bootlin.com>


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

* [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe()
  2024-02-28 11:27 [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Théo Lebrun
@ 2024-02-28 11:28 ` Théo Lebrun
  2024-02-29  9:40   ` Linus Walleij
  2024-02-29  9:44 ` [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: Théo Lebrun @ 2024-02-28 11:28 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
	Thomas Bogendoerfer
  Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
	linux-mips, Gregory CLEMENT, Vladimir Kondratiev,
	Thomas Petazzoni, Tawfik Bayouk, Théo Lebrun, Stephen Warren,
	Jonathan Corbet, linux-doc

generic_handle_irq() must be called from a no-IRQ context. Documentation
advices on using a fake raw lock to call generic_handle_irq() from any
context.

Since 509853f9e1e7 ("genirq: Provide generic_handle_irq_safe()"), a
better alternative is available.

To: Stephen Warren <swarren@wwwdotorg.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
 Documentation/driver-api/gpio/driver.rst | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/Documentation/driver-api/gpio/driver.rst b/Documentation/driver-api/gpio/driver.rst
index bf6319cc531b..550d167a82ed 100644
--- a/Documentation/driver-api/gpio/driver.rst
+++ b/Documentation/driver-api/gpio/driver.rst
@@ -339,15 +339,8 @@ Cascaded GPIO irqchips usually fall in one of three categories:
 
   The generic_handle_irq() is expected to be called with IRQ disabled,
   so the IRQ core will complain if it is called from an IRQ handler which is
-  forced to a thread. The "fake?" raw lock can be used to work around this
-  problem::
-
-    raw_spinlock_t wa_lock;
-    static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank)
-        unsigned long wa_lock_flags;
-        raw_spin_lock_irqsave(&bank->wa_lock, wa_lock_flags);
-        generic_handle_irq(irq_find_mapping(bank->chip.irq.domain, bit));
-        raw_spin_unlock_irqrestore(&bank->wa_lock, wa_lock_flags);
+  forced to a thread. generic_handle_irq_safe() can be used to work around
+  this problem; it can safely be called from any context.
 
 - GENERIC CHAINED GPIO IRQCHIPS: these are the same as "CHAINED GPIO irqchips",
   but chained IRQ handlers are not used. Instead GPIO IRQs dispatching is

-- 
2.44.0


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

* Re: [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe()
  2024-02-28 11:28 ` [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe() Théo Lebrun
@ 2024-02-29  9:40   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2024-02-29  9:40 UTC (permalink / raw)
  To: Théo Lebrun
  Cc: Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Philipp Zabel, Thomas Bogendoerfer, linux-gpio,
	devicetree, linux-kernel, linux-arm-kernel, linux-mips,
	Gregory CLEMENT, Vladimir Kondratiev, Thomas Petazzoni,
	Tawfik Bayouk, Stephen Warren, Jonathan Corbet, linux-doc

On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> generic_handle_irq() must be called from a no-IRQ context. Documentation
> advices on using a fake raw lock to call generic_handle_irq() from any
> context.
>
> Since 509853f9e1e7 ("genirq: Provide generic_handle_irq_safe()"), a
> better alternative is available.
>
> To: Stephen Warren <swarren@wwwdotorg.org>
> To: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-doc@vger.kernel.org
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
I leave this one off from my branch, Bartosz can apply it separately.

Yours,
Linus Walleij

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

* Re: [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support
  2024-02-28 11:27 [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Théo Lebrun
  2024-02-28 11:28 ` [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe() Théo Lebrun
@ 2024-02-29  9:44 ` Linus Walleij
  2024-02-29  9:56   ` Théo Lebrun
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2024-02-29  9:44 UTC (permalink / raw)
  To: Théo Lebrun
  Cc: Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Philipp Zabel, Thomas Bogendoerfer, linux-gpio,
	devicetree, linux-kernel, linux-arm-kernel, linux-mips,
	Gregory CLEMENT, Vladimir Kondratiev, Thomas Petazzoni,
	Tawfik Bayouk, Krzysztof Kozlowski, Stephen Warren,
	Jonathan Corbet, linux-doc

On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> This patch series reworks the Nomadik GPIO driver to bring it up to date
> to current kernel standards. We then add Mobileye EyeQ5 support that
> uses the same IP block but with limited functionality. We also add
> features required by our newly supported platform:
>
>  - Dynamic GPIO ID allocation;
>  - Make clock optional;
>  - Shared IRQ (usecase: EyeQ5 has two banks using the same IRQ);
>  - Handle variadic GPIO counts (usecase: EyeQ5 has <32 GPIOs per bank);
>  - Grab optional reset at probe (usecase: EyeQ5 has a shared GPIO reset).
>
> This GPIO platform driver was previously declared & registered inside
> drivers/pinctrl/nomadik/pinctrl-nomadik.c, side-by-side with the
> pinctrl driver. Both are tightly integrated, mostly for muxing reasons.
> Now that gpio-nomadik is used for another platform, we loosen the
> relationship. The behavior should not change on already supported
> hardware but I do not have Nomadik hardware to test for that.

I have queued the relevant patches to an immutable branch in the
pinctrl tree for testing and I can also pick up some ACKs if they arrive.

When I'm confident in the branch, I will send an optional pull request
to Bartosz for it!

Yours,
Linus Walleij

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

* Re: [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support
  2024-02-29  9:44 ` [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Linus Walleij
@ 2024-02-29  9:56   ` Théo Lebrun
  0 siblings, 0 replies; 5+ messages in thread
From: Théo Lebrun @ 2024-02-29  9:56 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Philipp Zabel, Thomas Bogendoerfer, linux-gpio,
	devicetree, linux-kernel, linux-arm-kernel, linux-mips,
	Gregory CLEMENT, Vladimir Kondratiev, Thomas Petazzoni,
	Tawfik Bayouk, Krzysztof Kozlowski, Stephen Warren,
	Jonathan Corbet, linux-doc

Hello,

On Thu Feb 29, 2024 at 10:44 AM CET, Linus Walleij wrote:
> On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:
>
> > This patch series reworks the Nomadik GPIO driver to bring it up to date
> > to current kernel standards. We then add Mobileye EyeQ5 support that
> > uses the same IP block but with limited functionality. We also add
> > features required by our newly supported platform:
> >
> >  - Dynamic GPIO ID allocation;
> >  - Make clock optional;
> >  - Shared IRQ (usecase: EyeQ5 has two banks using the same IRQ);
> >  - Handle variadic GPIO counts (usecase: EyeQ5 has <32 GPIOs per bank);
> >  - Grab optional reset at probe (usecase: EyeQ5 has a shared GPIO reset).
> >
> > This GPIO platform driver was previously declared & registered inside
> > drivers/pinctrl/nomadik/pinctrl-nomadik.c, side-by-side with the
> > pinctrl driver. Both are tightly integrated, mostly for muxing reasons.
> > Now that gpio-nomadik is used for another platform, we loosen the
> > relationship. The behavior should not change on already supported
> > hardware but I do not have Nomadik hardware to test for that.
>
> I have queued the relevant patches to an immutable branch in the
> pinctrl tree for testing and I can also pick up some ACKs if they arrive.
>
> When I'm confident in the branch, I will send an optional pull request
> to Bartosz for it!

That is all great news, thanks Linus! I'm staying available if you
encounter anything that needs action.

Have a nice day,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


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

end of thread, other threads:[~2024-02-29  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 11:27 [PATCH v2 00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support Théo Lebrun
2024-02-28 11:28 ` [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe() Théo Lebrun
2024-02-29  9:40   ` 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:56   ` Théo Lebrun

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