Browse Source

apm821xx: fix bogus key-presses on boot

"There are often transient line events when
the system is powered up and initialized and it
is often necessary for the gpio_chip driver to
clear any interrupt flags in hardware before
setting up the gpio chip, especially the
irqchip portions of it."
<http://lists.infradead.org/pipermail/openwrt-devel/2019-June/017630.html>

This patch adds a fix for the APM821XX's interrupt
controller to clear any bogus pending toggled
interrupts that happens on various APM821XX boards
on boot.

The patch also changes the debouce-interval from the
default 5ms debounce interval to 60ms all around.
The default setting caused on occasions that the button
state became stuck in a pressed state, even though the
button was released.

Signed-off-by: Christian Lamparter <[email protected]>
Christian Lamparter 6 years ago
parent
commit
971f31bedc

+ 1 - 0
target/linux/apm821xx/dts/meraki-mr24.dts

@@ -175,6 +175,7 @@
 			interrupt-parent = <&UIC1>;
 			interrupts = <0x15 IRQ_TYPE_EDGE_FALLING>;
 			gpios = <&GPIO0 16 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
 		};
 	};
 };

+ 1 - 0
target/linux/apm821xx/dts/meraki-mx60.dts

@@ -167,6 +167,7 @@
 			gpios = <&GPIO0 16 GPIO_ACTIVE_LOW>;
 			interrupt-parent = <&UIC1>;
 			interrupts = <0x15 IRQ_TYPE_EDGE_FALLING>;
+			debounce-interval = <60>;
 		};
 	};
 };

+ 1 - 0
target/linux/apm821xx/dts/netgear-wndap6x0.dtsi

@@ -131,6 +131,7 @@
 			linux,code = <KEY_RESTART>;
 			interrupt-parent = <&UIC1>;
 			interrupts = <0x15 IRQ_TYPE_EDGE_FALLING>;
+			debounce-interval = <60>;
 		};
 	};
 

+ 4 - 0
target/linux/apm821xx/dts/netgear-wndr4700.dts

@@ -317,6 +317,7 @@
 			linux,code = <KEY_RESTART>;
 			interrupt-parent = <&UIC1>;
 			interrupts = <0x14 IRQ_TYPE_EDGE_FALLING>;
+			debounce-interval = <60>;
 		};
 
 		backup_hd {
@@ -325,6 +326,7 @@
 			linux,code = <BTN_0>;
 			interrupt-parent = <&UIC1>;
 			interrupts = <0x1e IRQ_TYPE_EDGE_FALLING>;
+			debounce-interval = <60>;
 		};
 
 		rfkill {
@@ -333,6 +335,7 @@
 			linux,code = <KEY_RFKILL>;
 			interrupt-parent = <&UIC1>;
 			interrupts = <0x1f IRQ_TYPE_EDGE_FALLING>;
+			debounce-interval = <60>;
 		};
 
 		wps {
@@ -341,6 +344,7 @@
 			linux,code = <KEY_WPS_BUTTON>;
 			interrupt-parent = <&UIC2>;
 			interrupts = <0x19 IRQ_TYPE_EDGE_FALLING>;
+			debounce-interval = <60>;
 		};
 	};
 

+ 30 - 0
target/linux/apm821xx/patches-4.14/100-powerpc-4xx-uic-clear-pending-interrupt-after-irq-ty.patch

@@ -0,0 +1,30 @@
+From 9b84ad676e248a3e3c81db7f5d39e1739b3780aa Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <[email protected]>
+Date: Sat, 15 Jun 2019 16:35:26 +0200
+Subject: [PATCH] powerpc/4xx/uic: clear pending interrupt after irq type/pol
+ change
+
+When testing out gpio-keys with a button, a spurious
+interrupt (and therefore a key press or release event)
+gets triggered as soon as the driver enables the irq
+line for the first time.
+
+This patch clears any potential bogus generated interrupt
+that was caused by the switching of the associated irq's
+type and polarity.
+
+Signed-off-by: Christian Lamparter <[email protected]>
+---
+ arch/powerpc/platforms/4xx/uic.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/powerpc/platforms/4xx/uic.c
++++ b/arch/powerpc/platforms/4xx/uic.c
+@@ -158,6 +158,7 @@ static int uic_set_irq_type(struct irq_d
+ 
+ 	mtdcr(uic->dcrbase + UIC_PR, pr);
+ 	mtdcr(uic->dcrbase + UIC_TR, tr);
++	mtdcr(uic->dcrbase + UIC_SR, ~mask);
+ 
+ 	raw_spin_unlock_irqrestore(&uic->lock, flags);
+ 

+ 30 - 0
target/linux/apm821xx/patches-4.19/100-powerpc-4xx-uic-clear-pending-interrupt-after-irq-ty.patch

@@ -0,0 +1,30 @@
+From 9b84ad676e248a3e3c81db7f5d39e1739b3780aa Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <[email protected]>
+Date: Sat, 15 Jun 2019 16:35:26 +0200
+Subject: [PATCH] powerpc/4xx/uic: clear pending interrupt after irq type/pol
+ change
+
+When testing out gpio-keys with a button, a spurious
+interrupt (and therefore a key press or release event)
+gets triggered as soon as the driver enables the irq
+line for the first time.
+
+This patch clears any potential bogus generated interrupt
+that was caused by the switching of the associated irq's
+type and polarity.
+
+Signed-off-by: Christian Lamparter <[email protected]>
+---
+ arch/powerpc/platforms/4xx/uic.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/powerpc/platforms/4xx/uic.c
++++ b/arch/powerpc/platforms/4xx/uic.c
+@@ -158,6 +158,7 @@ static int uic_set_irq_type(struct irq_d
+ 
+ 	mtdcr(uic->dcrbase + UIC_PR, pr);
+ 	mtdcr(uic->dcrbase + UIC_TR, tr);
++	mtdcr(uic->dcrbase + UIC_SR, ~mask);
+ 
+ 	raw_spin_unlock_irqrestore(&uic->lock, flags);
+