linux/drivers/pinctrl/renesas
Cosmin Tanislav e86bc719b0 pinctrl: renesas: rzt2h: Allow .get_direction() for IRQ function GPIOs
[ Upstream commit 49b039a61a ]

Setting up an IRQ would normally be done in the .activate() and
.deactivate() ops of the IRQ domain, but for hierarchical IRQ domains
the .activate() and .deactivate() ops are overridden in the
gpiochip_hierarchy_setup_domain_ops() function.

As such, activating and deactivating need to be done in the .translate()
and .free() ops of the IRQ domain.

For RZ/T2H and RZ/N2H, interrupts go through the pin controller, into
the ICU, which level-translates them and forwards them to the GIC.

To use a GPIO as an interrupt it needs to be put into peripheral
function mode 0, which will connect it to the IRQ lines of the ICU.

The IRQ chip .child_to_parent_hwirq() callback is called as part of the
IRQ fwspec parsing logic (as part of irq_create_of_mapping()) which
happens before the IRQ is requested (as part of gpiochip_lock_as_irq()).

gpiochip_lock_as_irq() calls gpiod_get_direction() if the
.get_direction() callback is provided to ensure that the GPIO line is
set up as input.

In our case, IRQ function is separate from GPIO, and both cannot be true
at the same time.

Return GPIO_LINE_DIRECTION_IN even if pin is in IRQ function to allow
this setup to work.

Hold the spinlock to ensure atomicity between reading the PMC register
(which determines whether the pin is in GPIO mode or not) and reading
the function of the pin when it is not in GPIO mode.

Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20251205150234.2958140-3-cosmin-gabriel.tanislav.xa@renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-04 07:20:34 -05:00
..
core.c pinctrl: renesas: Allow the compiler to optimize away sh_pfc_pm 2024-02-21 16:34:33 +01:00
core.h pinctrl: renesas: Move R-Car bias helpers to sh_pfc.h 2021-03-24 10:38:29 +01:00
gpio.c treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
Kconfig pinctrl: renesas: rzt2h: Add support for RZ/N2H 2025-08-20 08:56:15 +02:00
Makefile pinctrl: renesas: Add support for RZ/T2H 2025-08-20 08:56:14 +02:00
pfc-emev2.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a73a4.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a779a0.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a779f0.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a779g0.c pinctrl: renesas: r8a779g0: Fix trivial typo in SoC type comment 2025-09-08 12:03:08 +02:00
pfc-r8a779h0.c pinctrl: renesas: r8a779h0: Remove unneeded separators 2024-07-01 11:27:39 +02:00
pfc-r8a7740.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a7778.c pinctrl: renesas: r8a7778: Add LBSC pins, groups, and functions 2023-10-13 09:38:04 +02:00
pfc-r8a7779.c pinctrl: renesas: r8a7779: s/LSBC/LBSC/ 2023-09-11 13:24:39 +02:00
pfc-r8a7790.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a7791.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a7792.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a7794.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a7796.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a77470.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a77951.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a77965.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a77970.c pinctrl: renesas: Fix spaces followed by tabs 2023-05-09 11:51:33 +02:00
pfc-r8a77980.c pinctrl: renesas: Fix spaces followed by tabs 2023-05-09 11:51:33 +02:00
pfc-r8a77990.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-r8a77995.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh73a0.c pinctrl: renesas: sh73a0: Use rdev_get_drvdata() 2024-07-01 11:27:38 +02:00
pfc-sh7203.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7264.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7269.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7720.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7722.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7723.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7724.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7734.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7757.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7785.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-sh7786.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pfc-shx3.c pinctrl: renesas: Annotate sentinels in tables 2023-03-30 15:39:05 +02:00
pinctrl-rza1.c pinctrl: generic: rename PIN_CONFIG_OUTPUT to LEVEL 2025-09-08 14:24:20 +02:00
pinctrl-rza2.c pinctrl: constify pinmux_generic_get_function() 2025-09-08 14:22:33 +02:00
pinctrl-rzg2l.c pinctrl: renesas: rzg2l: Fix ISEL restore on resume 2026-01-02 12:57:18 +01:00
pinctrl-rzn1.c pinctrl: renesas: Move fixed assignments to 'pinctrl_desc' definition 2025-06-18 13:26:37 +02:00
pinctrl-rzt2h.c pinctrl: renesas: rzt2h: Allow .get_direction() for IRQ function GPIOs 2026-03-04 07:20:34 -05:00
pinctrl-rzv2m.c pinctrl: constify pinmux_generic_get_function() 2025-09-08 14:22:33 +02:00
pinctrl.c pinctrl: renesas: Use int type to store negative error codes 2025-09-08 12:03:08 +02:00
sh_pfc.h pinctrl: renesas: Initial R8A779H0 (R-Car V4M) PFC support 2024-02-20 11:43:48 +01:00