Hello Linus,

On 15.06.19 10:26, Linus Walleij wrote:
> Without any detailed knowledge I'd say the most common cause
> is the underlying GPIO chip implementation. 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.
> 
> I tried to half-guess what gpio chip this is using and since it
> is WiFi pro 1200e I guess ths gpio driver is
> drivers/gpio-ath79.c which does indeed initialize an
> irqchip without clearing the interrupts first.
> 
> Can you try this patch, if this solves the problem I will commit
> it upstream as well:

Thanks for your patch. I've tested it on my device but sadly, i still
see the ghost presses.

It seems the input is indeed not stable after setting the GPIO
direction. With the following patch applied, i get zero ghost presses
and the buttons work as expected. However I'm not sure if this approach
is the right one to fix the underlying issue.


>From 2b0c12c9c9aa1955a1fa42234597601148bcf548 Mon Sep 17 00:00:00 2001
From: David Bauer <m...@david-bauer.net>
Date: Sun, 16 Jun 2019 16:20:49 +0200
Subject: [PATCH] gpio: ath79: circumvent ghost interrupts

The ath79 gpio driver may emit "ghost interrupts" in case the interrupts
are registered directly after setting the GPIO direction.

This patch adds a short delay before activating interrupts on any line
to make sure no ghost interrupts will be registered.

Signed-off-by: David Bauer <m...@david-bauer.net>
---
 drivers/gpio/gpio-ath79.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index 0a553d676042..238f5bdbe7a8 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -12,6 +12,7 @@
  */
 
 #include <linux/gpio/driver.h>
+#include <linux/delay.h>
 #include <linux/platform_data/gpio-ath79.h>
 #include <linux/of_device.h>
 #include <linux/interrupt.h>
@@ -96,6 +97,12 @@ static void ath79_gpio_irq_enable(struct irq_data *data)
        u32 mask = BIT(irqd_to_hwirq(data));
        unsigned long flags;
 
+       /*
+        * The input can be unstable after configuring GPIO direction.
+        * Wait a bit to assert the input is stable.
+        */
+       msleep(25);
+
        raw_spin_lock_irqsave(&ctrl->lock, flags);
        ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask);
        ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask);
-- 
2.22.0


Best wishes
David





_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to