public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] fix gpiochip_lock_as_irq() failure when pinmux is unknown
@ 2026-03-19 17:19 michal.piekos
  2026-03-19 17:19 ` [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines michal.piekos
  2026-03-19 17:19 ` [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown Michal Piekos
  0 siblings, 2 replies; 7+ messages in thread
From: michal.piekos @ 2026-03-19 17:19 UTC (permalink / raw)
  To: Linus Walleij, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel,
	Andre Przywara, Michal Piekos

Changes in v5:
- Simplified logic checking pinmux layout
- Remove unneded curly braces
- Replace subtraction with one variable
- Fix typo in commit message
- Link to v4: https://lore.kernel.org/r/20260319-rc2-boot-hang-v4-0-4372f47cb6b8@mmpsystems.pl

Changes in v4:
- Fixed check for pinmux disabled value based on pinctrl layout
- Cherry picked
  https://lore.kernel.org/linux-arm-kernel/20250821004232.8134-3-andre.przywara@arm.com/
  to have flags for pinctrl layout recognition
- Link to v3: https://lore.kernel.org/r/20260314-rc2-boot-hang-v3-1-0b48221181a9@mmpsystems.pl

Changes in v3:
- Drop v2 solution which was returning input instead of error when pin
  is not initialized.
- Add checking pinmux configuration in
  sunxi_pinctrl_irq_request_resources() and set pin to input if
  uninitialized
- Link to v2: https://lore.kernel.org/r/20260308-rc2-boot-hang-v2-1-516fdb820953@mmpsystems.pl

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@mmpsystems.pl

---
Andre Przywara (1):
      pinctrl: sunxi: pass down flags to pinctrl routines

Michal Piekos (1):
      pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown

 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 44 ++++++++++++++++++++++++++---------
 drivers/pinctrl/sunxi/pinctrl-sunxi.h |  4 +++-
 2 files changed, 36 insertions(+), 12 deletions(-)
---
base-commit: 8a30aeb0d1b4e4aaf7f7bae72f20f2ae75385ccb
change-id: 20260308-rc2-boot-hang-269e8546635b

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



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

* [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines
  2026-03-19 17:19 [PATCH v5 0/2] fix gpiochip_lock_as_irq() failure when pinmux is unknown michal.piekos
@ 2026-03-19 17:19 ` michal.piekos
  2026-03-19 17:42   ` Chen-Yu Tsai
  2026-03-19 17:19 ` [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown Michal Piekos
  1 sibling, 1 reply; 7+ messages in thread
From: michal.piekos @ 2026-03-19 17:19 UTC (permalink / raw)
  To: Linus Walleij, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel,
	Andre Przywara, Michal Piekos

From: Andre Przywara <andre.przywara@arm.com>

Recent changes in the Allwinner pinctrl/GPIO IP made us add some quirks,
which the new SoCs (A523 family) need to use. We now have a comfortable
"flags" field on the per-SoC setup side, to tag those quirks we need, but
were translating those flag bits into specific fields for runtime use, in
the init routine.
Now the newest Allwinner GPIO IP adds even more quirks and exceptions,
some of a boolean nature.
To avoid inventing various new boolean flags for the runtime struct
sunxi_pinctrl, let's just directly pass on the flags variable used by the
setup code, so runtime can check for those various quirk bits directly.

Rename the "variant" member to "flags", and directly copy the value from
the setup code into there. Move the variant masking from the init
routine to the functions which actually use the "variant" value.

This mostly paves the way for the new A733 IP generation, which needs
more quirks to be checked at runtime.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 23 ++++++++++++++---------
 drivers/pinctrl/sunxi/pinctrl-sunxi.h |  2 +-
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index c990b6118172..685b79fc0bf8 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -157,6 +157,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
 					 const char *pin_name,
 					 const char *func_name)
 {
+	unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
 	int i;
 
 	for (i = 0; i < pctl->desc->npins; i++) {
@@ -168,7 +169,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
 			while (func->name) {
 				if (!strcmp(func->name, func_name) &&
 					(!func->variant ||
-					func->variant & pctl->variant))
+					func->variant & variant))
 					return func;
 
 				func++;
@@ -209,6 +210,8 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl,
 						const u16 pin_num,
 						const u8 muxval)
 {
+	unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
+
 	for (unsigned int i = 0; i < pctl->desc->npins; i++) {
 		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
 		struct sunxi_desc_function *func = pin->functions;
@@ -216,7 +219,7 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl,
 		if (pin->pin.number != pin_num)
 			continue;
 
-		if (pin->variant && !(pctl->variant & pin->variant))
+		if (pin->variant && !(variant & pin->variant))
 			continue;
 
 		while (func->name) {
@@ -1338,6 +1341,7 @@ static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
 static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 {
 	struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
+	unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
 	void *ptr;
 	int i;
 
@@ -1362,7 +1366,7 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
 		struct sunxi_pinctrl_group *group = pctl->groups + pctl->ngroups;
 
-		if (pin->variant && !(pctl->variant & pin->variant))
+		if (pin->variant && !(variant & pin->variant))
 			continue;
 
 		group->name = pin->pin.name;
@@ -1387,11 +1391,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
 		struct sunxi_desc_function *func;
 
-		if (pin->variant && !(pctl->variant & pin->variant))
+		if (pin->variant && !(variant & pin->variant))
 			continue;
 
 		for (func = pin->functions; func->name; func++) {
-			if (func->variant && !(pctl->variant & func->variant))
+			if (func->variant && !(variant & func->variant))
 				continue;
 
 			/* Create interrupt mapping while we're at it */
@@ -1419,14 +1423,14 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
 		struct sunxi_desc_function *func;
 
-		if (pin->variant && !(pctl->variant & pin->variant))
+		if (pin->variant && !(variant & pin->variant))
 			continue;
 
 		for (func = pin->functions; func->name; func++) {
 			struct sunxi_pinctrl_function *func_item;
 			const char **func_grp;
 
-			if (func->variant && !(pctl->variant & func->variant))
+			if (func->variant && !(variant & func->variant))
 				continue;
 
 			func_item = sunxi_pinctrl_find_function_by_name(pctl,
@@ -1568,7 +1572,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
 
 	pctl->dev = &pdev->dev;
 	pctl->desc = desc;
-	pctl->variant = flags & SUNXI_PINCTRL_VARIANT_MASK;
+	pctl->flags = flags;
 	if (flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) {
 		pctl->bank_mem_size = D1_BANK_MEM_SIZE;
 		pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;
@@ -1604,8 +1608,9 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
 
 	for (i = 0, pin_idx = 0; i < pctl->desc->npins; i++) {
 		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
+		unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
 
-		if (pin->variant && !(pctl->variant & pin->variant))
+		if (pin->variant && !(variant & pin->variant))
 			continue;
 
 		pins[pin_idx++] = pin->pin;
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
index ad26e4de16a8..22bffac1c3f0 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
@@ -174,7 +174,7 @@ struct sunxi_pinctrl {
 	unsigned			*irq_array;
 	raw_spinlock_t			lock;
 	struct pinctrl_dev		*pctl_dev;
-	unsigned long			variant;
+	unsigned long			flags;
 	u32				bank_mem_size;
 	u32				pull_regs_offset;
 	u32				dlevel_field_width;

-- 
2.43.0



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

* [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown
  2026-03-19 17:19 [PATCH v5 0/2] fix gpiochip_lock_as_irq() failure when pinmux is unknown michal.piekos
  2026-03-19 17:19 ` [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines michal.piekos
@ 2026-03-19 17:19 ` Michal Piekos
  2026-03-19 17:43   ` Chen-Yu Tsai
  2026-03-20 13:48   ` Andre Przywara
  1 sibling, 2 replies; 7+ messages in thread
From: Michal Piekos @ 2026-03-19 17:19 UTC (permalink / raw)
  To: Linus Walleij, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel,
	Michal Piekos

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

The issue is caused by gpiochip_lock_as_irq() which is failing when gpio
is in uninitialized state.

Solution is to set pinmux to GPIO INPUT in
sunxi_pinctrl_irq_request_resources() if it wasn't initialized
earlier.

Tested on Orange Pi Zero 3.

Fixes: 01e10d0272b9 ("pinctrl: sunxi: Implement gpiochip::get_direction()")
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 21 +++++++++++++++++++--
 drivers/pinctrl/sunxi/pinctrl-sunxi.h |  2 ++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 685b79fc0bf8..e3aa2b70aa7d 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -1092,15 +1092,32 @@ static int sunxi_pinctrl_irq_request_resources(struct irq_data *d)
 {
 	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
 	struct sunxi_desc_function *func;
+	unsigned int offset;
+	u32 reg, shift, mask;
+	u8 muxval;
 	int ret;
+	u8 disabled_mux;
 
 	func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
 					pctl->irq_array[d->hwirq], "irq");
 	if (!func)
 		return -EINVAL;
 
-	ret = gpiochip_lock_as_irq(pctl->chip,
-			pctl->irq_array[d->hwirq] - pctl->desc->pin_base);
+	offset = pctl->irq_array[d->hwirq] - pctl->desc->pin_base;
+	sunxi_mux_reg(pctl, offset, &reg, &shift, &mask);
+	muxval = (readl(pctl->membase + reg) & mask) >> shift;
+
+	/* Change muxing to GPIO INPUT mode if at reset value */
+	if (pctl->flags & SUNXI_PINCTRL_NEW_REG_LAYOUT)
+		disabled_mux = SUN4I_FUNC_DISABLED_NEW;
+	else                                           
+		disabled_mux = SUN4I_FUNC_DISABLED_OLD;
+	
+	if (muxval == disabled_mux)                    
+		sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq],
+			      SUN4I_FUNC_INPUT);
+
+	ret = gpiochip_lock_as_irq(pctl->chip, offset);
 	if (ret) {
 		dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n",
 			irqd_to_hwirq(d));
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
index 22bffac1c3f0..0daf7600e2fb 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
@@ -86,6 +86,8 @@
 
 #define SUN4I_FUNC_INPUT	0
 #define SUN4I_FUNC_IRQ		6
+#define SUN4I_FUNC_DISABLED_OLD 7
+#define SUN4I_FUNC_DISABLED_NEW 15
 
 #define SUNXI_PINCTRL_VARIANT_MASK	GENMASK(7, 0)
 #define SUNXI_PINCTRL_NEW_REG_LAYOUT	BIT(8)

-- 
2.43.0



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

* Re: [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines
  2026-03-19 17:19 ` [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines michal.piekos
@ 2026-03-19 17:42   ` Chen-Yu Tsai
  2026-03-19 18:13     ` Michal Piekos
  0 siblings, 1 reply; 7+ messages in thread
From: Chen-Yu Tsai @ 2026-03-19 17:42 UTC (permalink / raw)
  To: michal.piekos
  Cc: Linus Walleij, Jernej Skrabec, Samuel Holland, linux-gpio,
	linux-arm-kernel, linux-sunxi, linux-kernel, Andre Przywara

On Fri, Mar 20, 2026 at 1:19 AM <michal.piekos@mmpsystems.pl> wrote:
>
> From: Andre Przywara <andre.przywara@arm.com>
>
> Recent changes in the Allwinner pinctrl/GPIO IP made us add some quirks,
> which the new SoCs (A523 family) need to use. We now have a comfortable
> "flags" field on the per-SoC setup side, to tag those quirks we need, but
> were translating those flag bits into specific fields for runtime use, in
> the init routine.
> Now the newest Allwinner GPIO IP adds even more quirks and exceptions,
> some of a boolean nature.
> To avoid inventing various new boolean flags for the runtime struct
> sunxi_pinctrl, let's just directly pass on the flags variable used by the
> setup code, so runtime can check for those various quirk bits directly.
>
> Rename the "variant" member to "flags", and directly copy the value from
> the setup code into there. Move the variant masking from the init
> routine to the functions which actually use the "variant" value.
>
> This mostly paves the way for the new A733 IP generation, which needs
> more quirks to be checked at runtime.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>

Please carry tags forward if the patch is unchanged.


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

* Re: [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown
  2026-03-19 17:19 ` [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown Michal Piekos
@ 2026-03-19 17:43   ` Chen-Yu Tsai
  2026-03-20 13:48   ` Andre Przywara
  1 sibling, 0 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2026-03-19 17:43 UTC (permalink / raw)
  To: Michal Piekos
  Cc: Linus Walleij, Jernej Skrabec, Samuel Holland, linux-gpio,
	linux-arm-kernel, linux-sunxi, linux-kernel

On Fri, Mar 20, 2026 at 1:19 AM Michal Piekos
<michal.piekos@mmpsystems.pl> wrote:
>
> Fixes kernel hang during boot due to inability to set up IRQ on AXP313a.
>
> The issue is caused by gpiochip_lock_as_irq() which is failing when gpio
> is in uninitialized state.
>
> Solution is to set pinmux to GPIO INPUT in
> sunxi_pinctrl_irq_request_resources() if it wasn't initialized
> earlier.
>
> Tested on Orange Pi Zero 3.
>
> Fixes: 01e10d0272b9 ("pinctrl: sunxi: Implement gpiochip::get_direction()")
> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>


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

* Re: [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines
  2026-03-19 17:42   ` Chen-Yu Tsai
@ 2026-03-19 18:13     ` Michal Piekos
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Piekos @ 2026-03-19 18:13 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Linus Walleij, Jernej Skrabec, Samuel Holland, linux-gpio,
	linux-arm-kernel, linux-sunxi, linux-kernel, Andre Przywara

On Fri, Mar 20, 2026 at 01:42:18AM +0800, Chen-Yu Tsai wrote:
> On Fri, Mar 20, 2026 at 1:19 AM <michal.piekos@mmpsystems.pl> wrote:
> >
> > From: Andre Przywara <andre.przywara@arm.com>
> >
> > Recent changes in the Allwinner pinctrl/GPIO IP made us add some quirks,
> > which the new SoCs (A523 family) need to use. We now have a comfortable
> > "flags" field on the per-SoC setup side, to tag those quirks we need, but
> > were translating those flag bits into specific fields for runtime use, in
> > the init routine.
> > Now the newest Allwinner GPIO IP adds even more quirks and exceptions,
> > some of a boolean nature.
> > To avoid inventing various new boolean flags for the runtime struct
> > sunxi_pinctrl, let's just directly pass on the flags variable used by the
> > setup code, so runtime can check for those various quirk bits directly.
> >
> > Rename the "variant" member to "flags", and directly copy the value from
> > the setup code into there. Move the variant masking from the init
> > routine to the functions which actually use the "variant" value.
> >
> > This mostly paves the way for the new A733 IP generation, which needs
> > more quirks to be checked at runtime.
> >
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
> 
> Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
> 
> Please carry tags forward if the patch is unchanged.

Will do. Sorry for ommision and thank you for quick review rounds.

Michal


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

* Re: [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown
  2026-03-19 17:19 ` [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown Michal Piekos
  2026-03-19 17:43   ` Chen-Yu Tsai
@ 2026-03-20 13:48   ` Andre Przywara
  1 sibling, 0 replies; 7+ messages in thread
From: Andre Przywara @ 2026-03-20 13:48 UTC (permalink / raw)
  To: Michal Piekos, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel

Hi Michal,

On 3/19/26 18:19, Michal Piekos wrote:
> Fixes kernel hang during boot due to inability to set up IRQ on AXP313a.
> 
> The issue is caused by gpiochip_lock_as_irq() which is failing when gpio
> is in uninitialized state.
> 
> Solution is to set pinmux to GPIO INPUT in
> sunxi_pinctrl_irq_request_resources() if it wasn't initialized
> earlier.
> 
> Tested on Orange Pi Zero 3.
> 
> Fixes: 01e10d0272b9 ("pinctrl: sunxi: Implement gpiochip::get_direction()")
> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
> ---
>   drivers/pinctrl/sunxi/pinctrl-sunxi.c | 21 +++++++++++++++++++--
>   drivers/pinctrl/sunxi/pinctrl-sunxi.h |  2 ++
>   2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index 685b79fc0bf8..e3aa2b70aa7d 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -1092,15 +1092,32 @@ static int sunxi_pinctrl_irq_request_resources(struct irq_data *d)
>   {
>   	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
>   	struct sunxi_desc_function *func;
> +	unsigned int offset;
> +	u32 reg, shift, mask;
> +	u8 muxval;
>   	int ret;
> +	u8 disabled_mux;

Iff you are going to respin, maybe use the inverted Christmas tree 
style, and group the u8 variables.

>   
>   	func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
>   					pctl->irq_array[d->hwirq], "irq");
>   	if (!func)
>   		return -EINVAL;
>   
> -	ret = gpiochip_lock_as_irq(pctl->chip,
> -			pctl->irq_array[d->hwirq] - pctl->desc->pin_base);
> +	offset = pctl->irq_array[d->hwirq] - pctl->desc->pin_base;
> +	sunxi_mux_reg(pctl, offset, &reg, &shift, &mask);
> +	muxval = (readl(pctl->membase + reg) & mask) >> shift;
> +
> +	/* Change muxing to GPIO INPUT mode if at reset value */
> +	if (pctl->flags & SUNXI_PINCTRL_NEW_REG_LAYOUT)
> +		disabled_mux = SUN4I_FUNC_DISABLED_NEW;
> +	else
> +		disabled_mux = SUN4I_FUNC_DISABLED_OLD;
> +	
> +	if (muxval == disabled_mux)

There is whitespace damage in three of the four lines above.
Maybe this can be fixed up while applying?

The patch still feels a bit arbitrary, and looking at the definition of 
SUN4I_FUNC_IRQ below we probably need another rework, but if that fixes 
the issues observed, we should take it now:

(with the w/s damage fixed:)
Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> +		sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq],
> +			      SUN4I_FUNC_INPUT);
> +
> +	ret = gpiochip_lock_as_irq(pctl->chip, offset);
>   	if (ret) {
>   		dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n",
>   			irqd_to_hwirq(d));
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
> index 22bffac1c3f0..0daf7600e2fb 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
> @@ -86,6 +86,8 @@
>   
>   #define SUN4I_FUNC_INPUT	0
>   #define SUN4I_FUNC_IRQ		6
> +#define SUN4I_FUNC_DISABLED_OLD 7
> +#define SUN4I_FUNC_DISABLED_NEW 15
>   
>   #define SUNXI_PINCTRL_VARIANT_MASK	GENMASK(7, 0)
>   #define SUNXI_PINCTRL_NEW_REG_LAYOUT	BIT(8)
> 



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

end of thread, other threads:[~2026-03-20 13:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 17:19 [PATCH v5 0/2] fix gpiochip_lock_as_irq() failure when pinmux is unknown michal.piekos
2026-03-19 17:19 ` [PATCH v5 1/2] pinctrl: sunxi: pass down flags to pinctrl routines michal.piekos
2026-03-19 17:42   ` Chen-Yu Tsai
2026-03-19 18:13     ` Michal Piekos
2026-03-19 17:19 ` [PATCH v5 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown Michal Piekos
2026-03-19 17:43   ` Chen-Yu Tsai
2026-03-20 13:48   ` Andre Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox