configure gpio for interrupt function

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Uwe
Date: Tuesday, May 27, 2008 - 6:02 am

Hello David,

I want to use a driver that in turn uses the gpio API (i.e.
drivers/input/keyboard/gpio_keys.c).  My problem with that is, that my
machine[1]'s external irqs don't fit into the GPIO API model.  The main
problem is that gpio_direction_input isn't enough to get an irq.
I need to explicitly set the gpio to an EXT_IRQ function.
(I can workaround that because the EXT_IRQ function allows to read the
state of the gpio.  So I can use the EXT_IRQ function if input is
requested.)

Another problem is that I cannot implement irq_to_gpio correctly,
because several gpio's share the same irq.
(Note this makes the workaround above less reliable.  Consider two
gpios sharing the same irq.  I cannot assert that only one of them can
trigger the interrupt.)

So I suggest to extend the gpio API with two functions like:

	int gpio_direction_inputirq(unsigned gpio, unsigned flags);
	void gpio_ackirq(unsigned gpio);

with flags being similar to the IRQF_TRIGGER_* defines in
include/linux/interrupt.h.  I need gpio_ackirq because ns9xxx requires
that an edge triggered irq is acknowledged separatly in the "External
Interrupt X Control register"[2].  (If you have better names ...)

Moreover this makes the API more flexible because the irq type can be
configured.

OTOH I'd like to deprecate irq_to_gpio.  $(git grep -l irq_to_gpio
drivers) suggests that this function is only used in two places.  One of
them[3] is AT91 specific, the other[4] seems specific for the
RouterBoard 532.
(There are some other users below arch/, but I expect no breakage here.
I expect that every arch that uses the function have it implemented
anyhow.)

What do you think?

Best regards
Uwe

[1] http://www.digi.com/products/embeddedsolutions/ns9215.jsp
    Interesting sections are "Pinout -> General purpose I/O (GPIO)" and
    "I/O Control Module".  E.g. GPIO4's func1 is "Ext Int Ch 2"
[2] System Control Module -> External Interrupt 0­3 Control register
[3] drivers/mmc/host/at91_mci.c
[4] drivers/ata/pata_rb532_cf.c

-- 
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
configure gpio for interrupt function, Uwe , (Tue May 27, 6:02 am)
Re: configure gpio for interrupt function, David Brownell, (Tue May 27, 1:49 pm)
Re: configure gpio for interrupt function, Uwe , (Wed May 28, 12:17 am)