On Sun, Jun 16, 2019 at 4:31 PM David Bauer <m...@david-bauer.net> wrote:
> 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. It shows what the problem is for sure. delays are forbidden in irqchip callback functions since they are all called from IRQ context with IRQs disabled though. > @@ -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); After this and before the raw_spin_unlock() try to read the status register until it eads zero for the requested IRQ: while (ath79_gpio_read(ctrl, AR71XX_GPIO_REG_INT_PENDING) & mask) {} This way we wait for the status to go low before we allow any IRQs to fire after enableing. Maybe not so good since we may want to turn on IRQs that are asserted at some point, but worth a try. Yours, Linus Walleij _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel