[PATCH v4 2/7] pinctrl: ingenic: Fix hardware dual-edge interrupts on X1600
From: H. Nikolaus Schaller
Date: Wed Nov 18 2026 - 12:26:01 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.
Fixes: 4da56f9c6f14 ("pinctrl: ingenic: add x1600 support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: H. Nikolaus Schaller <hns@xxxxxxxxxxxxx>
---
Notes:
Changes V4:
- Fix Fixes: and stable Cc trailers.
(suggested by Paul Cercueil and Sashiko-Bot)
- Merge the common shadow-register paths and simplify EDG handling.
(suggested by Paul Cercueil)
- Retested hardware dual-edge interrupts on X1600/X2000 after the
shadow-register refactoring. Verified both button transitions
with evtest and confirmed via devmem2 that PAT1, PAT0 and EDG
remain unchanged across GPIO input transitions.
drivers/pinctrl/pinctrl-ingenic.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 88c5edeaaddcc..7f65f3abf05f5 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -3601,7 +3601,8 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
switch (type) {
case IRQ_TYPE_EDGE_BOTH:
- val1 = val2 = false;
+ val1 = false;
+ val2 = is_soc_or_above(jzgc->jzpc, ID_X1600);
val3 = true;
break;
case IRQ_TYPE_EDGE_RISING:
@@ -3635,15 +3636,13 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
return;
}
- if (is_soc_or_above(jzgc->jzpc, ID_X2000)) {
- 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);
- ingenic_gpio_set_bit(jzgc, X2000_GPIO_EDG, offset, val3);
- } else if (is_soc_or_above(jzgc->jzpc, ID_X1000)) {
+ if (is_soc_or_above(jzgc->jzpc, ID_X1000)) {
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 +3717,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 +3757,7 @@ 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