]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
OMAP gpios implement new to_irq()
authorDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 3 Oct 2008 16:04:12 +0000 (09:04 -0700)
committerTony Lindgren <tony@atomide.com>
Mon, 6 Oct 2008 06:33:33 +0000 (09:33 +0300)
Make OMAP use the new __gpio_to_irq() hook, to make it easier to
support IRQs coming in from off-chip gpio controllers like the
TWL4030/TPS65930 chip used on OMAP3 boads like Beagleboard.org and
the Gumstix Overo.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/plat-omap/gpio.c
arch/arm/plat-omap/include/mach/gpio.h

index 2d630230fcffe290d17ee623edba275880859159..c1346eee678b046ba7869988aceaef7e0065cb6e 100644 (file)
@@ -1287,6 +1287,14 @@ static void gpio_set(struct gpio_chip *chip, unsigned offset, int value)
        spin_unlock_irqrestore(&bank->lock, flags);
 }
 
+static int gpio_2irq(struct gpio_chip *chip, unsigned offset)
+{
+       struct gpio_bank *bank;
+
+       bank = container_of(chip, struct gpio_bank, chip);
+       return bank->virtual_irq_start + offset;
+}
+
 /*---------------------------------------------------------------------*/
 
 static int initialized;
@@ -1482,6 +1490,7 @@ static int __init _omap_gpio_init(void)
                bank->chip.get = gpio_get;
                bank->chip.direction_output = gpio_output;
                bank->chip.set = gpio_set;
+               bank->chip.to_irq = gpio_2irq;
                if (bank_is_mpuio(bank)) {
                        bank->chip.label = "mpuio";
 #ifdef CONFIG_ARCH_OMAP16XX
index 98e9008b7e9d172ad06eb50a000cca0ef5443bb0..5f996f350c84e5df1ffc533b02038a57f2a0162b 100644 (file)
@@ -109,16 +109,24 @@ static inline int gpio_cansleep(unsigned gpio)
 
 static inline int gpio_to_irq(unsigned gpio)
 {
-       if (gpio < (OMAP_MAX_GPIO_LINES + 16))
-               return OMAP_GPIO_IRQ(gpio);
-       return -EINVAL;
+       return __gpio_to_irq(gpio);
 }
 
 static inline int irq_to_gpio(unsigned irq)
 {
+       int tmp;
+
+       /* omap1 SOC mpuio */
        if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16)))
                return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES;
-       return irq - IH_GPIO_BASE;
+
+       /* SOC gpio */
+       tmp = irq - IH_GPIO_BASE;
+       if (tmp < OMAP_MAX_GPIO_LINES)
+               return tmp;
+
+       /* we don't supply reverse mappings for non-SOC gpios */
+       return -EIO;
 }
 
 #endif