triggering an gpio-irq on both edges

Linus Walleij linus.walleij at linaro.org
Sun Sep 16 18:09:10 EDT 2012


On Thu, Sep 13, 2012 at 10:19 AM, Uwe Kleine-König
<u.kleine-koenig at pengutronix.de> wrote:

> I guess there are more machines than mxc and mxs that have the same
> problem.

The COH901 GPIO driver has the same issue, see
drivers/pinctrl/pinctrl-coh901.c, functions named
u300_toggle_trigger() etc.

It will toggle the trigger from rising to falling on every
arriving IRQ by calling u300_toggle_trigger() from
fastpath in the IRQ handler.

Theoretically it is racy, but since it's used for GPIO
and these signals tend to not be super-fast we're safe.
It's used for card detection on SD cards and such.

> In my opinion this calls for a wrapper, something like:
>
>         int gpio_irq_emulate_both_edges_set_irq_type(struct irq_data *d,
>                 unsigned int type, int (*set_irq_type)(...),
>                 int (*get_value)(...), struct something *privdata)
>         {
>                 ...
>         }
>
>         int gpio_irq_emulate_both_edges_handler(...)
>         {
>
>         }
>
> Does this sound good and possible? I didn't find something like that
> already implemented, but maybe I missed it?

I've thought about this too but never thought there was something
generic enough to do about it...

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list