public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* configure gpio for interrupt function
@ 2008-05-27 13:02 Uwe Kleine-König
  2008-05-27 20:49 ` David Brownell
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2008-05-27 13:02 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-05-28  7:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-27 13:02 configure gpio for interrupt function Uwe Kleine-König
2008-05-27 20:49 ` David Brownell
2008-05-28  7:17   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox