[PATCH v2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown

From: Michal Piekos

Date: Sun Mar 08 2026 - 09:44:01 EST


Fixes kernel hang during boot due to inability to set up IRQ on AXP313a.

The issue is caused by gpiochip::get_direction() which was returning
-ENODEV when gpio is in unitialized state.

Instead of failing when the current muxval is at default value, report
the line as input.

Tested on Orange Pi Zero 3.

Signed-off-by: Michal Piekos <michal.piekos@xxxxxxxxxxxxx>
Suggested-by: Andrey Skvortsov <andrej.skvortzov@xxxxxxxxx>
---
This fixes a kernel hang during boot on the Orange Pi Zero 3 caused by
inability to set up interrupt for the AXP313A PMIC.

The issue is caused by gpiochip::get_direction() which was returning
-ENODEV when gpio is in unitialized state and its muxval is at default
value.

Instead of failing, report the line as input.

To: Rob Herring <robh@xxxxxxxxxx>
To: Krzysztof Kozlowski <krzk+dt@xxxxxxxxxx>
To: Conor Dooley <conor+dt@xxxxxxxxxx>
To: Chen-Yu Tsai <wens@xxxxxxxxxx>
To: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>
To: Samuel Holland <samuel@xxxxxxxxxxxx>
To: Andre Przywara <andre.przywara@xxxxxxx>
To: Linus Walleij <linusw@xxxxxxxxxx>
Cc: devicetree@xxxxxxxxxxxxxxx
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-sunxi@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-gpio@xxxxxxxxxxxxxxx

Changes in v2:
- Dropped the previous faulty solution which was forcing the axp313 to
use r_pio as interrupt controller as pointed out by Jernej Škrabec.
- Implemented suggestion from Andrey Skvortsov to return default
direction as input
- Link to v1: https://lore.kernel.org/r/20260308-rc2-boot-hang-v1-0-d792d1a78dfd@xxxxxxxxxxxxx
---
drivers/pinctrl/sunxi/pinctrl-sunxi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index c990b6118172..e438cf35ff28 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -971,7 +971,7 @@ static int sunxi_pinctrl_gpio_get_direction(struct gpio_chip *chip,

func = sunxi_pinctrl_desc_find_function_by_pin_and_mux(pctl, pin, muxval);
if (!func)
- return -ENODEV;
+ return GPIO_LINE_DIRECTION_IN;

if (!strcmp(func->name, "gpio_out"))
return GPIO_LINE_DIRECTION_OUT;

---
base-commit: 4ae12d8bd9a830799db335ee661d6cbc6597f838
change-id: 20260308-rc2-boot-hang-269e8546635b

Best regards,
--
Michal Piekos <michal.piekos@xxxxxxxxxxxxx>