[PATCH v2 2/7] pinctrl: ingenic: Fix hardware dual-edge interrupts on X1600

From: H. Nikolaus Schaller

Date: Tue Nov 17 2026 - 13:30:24 EST


Use the hardware dual-edge detector on X1600 and X2000.

Set PAT1 when configuring both edges and program EDG on X1600.
Keep software edge switching for older SoCs without EDG.

Tested on X1600 and X2000 using GPIO buttons and register readback.

Signed-off-by: H. Nikolaus Schaller <hns@xxxxxxxxxxxxx>
---
drivers/pinctrl/pinctrl-ingenic.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 88c5edeaaddcc..51a4b1839f42b 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -3622,6 +3622,10 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
break;
}

+ if (type == IRQ_TYPE_EDGE_BOTH &&
+ is_soc_or_above(jzgc->jzpc, ID_X1600))
+ val2 = true;
+
if (is_soc_or_above(jzgc->jzpc, ID_JZ4770)) {
reg1 = JZ4770_GPIO_PAT1;
reg2 = JZ4770_GPIO_PAT0;
@@ -3644,6 +3648,9 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
ingenic_gpio_shadow_set_bit_load(jzgc);
+
+ if (is_soc_or_above(jzgc->jzpc, ID_X1600))
+ ingenic_gpio_set_bit(jzgc, X2000_GPIO_EDG, offset, val3);
} else {
ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
@@ -3718,7 +3725,7 @@ static void ingenic_gpio_irq_ack(struct irq_data *irqd)
bool high;

if ((irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) &&
- !is_soc_or_above(jzgc->jzpc, ID_X2000)) {
+ !is_soc_or_above(jzgc->jzpc, ID_X1600)) {
/*
* Switch to an interrupt for the opposite edge to the one that
* triggered the interrupt being ACKed.
@@ -3758,7 +3765,8 @@ static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
irq_set_handler_locked(irqd, handle_bad_irq);
}

- if ((type == IRQ_TYPE_EDGE_BOTH) && !is_soc_or_above(jzgc->jzpc, ID_X2000)) {
+ if (type == IRQ_TYPE_EDGE_BOTH &&
+ !is_soc_or_above(jzgc->jzpc, ID_X1600)) {
/*
* The hardware does not support interrupts on both edges. The
* best we can do is to set up a single-edge interrupt and then
--
2.56.0