X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=arch%2Farm%2Fmach-pxa%2Firq.c;h=f6e0300e4f64c386fab8916dbf93e73b34b436cb;hp=fa69c3a6a38e2f558ca2176fc271f5c031ad413f;hb=5123bc35d2bd2e5c344a53e634edec2cd0861a0e;hpb=36ac1d2f323f8bf8bc10c25b88f617657720e241 diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c index fa69c3a6a38e..f6e0300e4f64 100644 --- a/arch/arm/mach-pxa/irq.c +++ b/arch/arm/mach-pxa/irq.c @@ -20,7 +20,8 @@ #include #include #include -#include +#include +#include #include "generic.h" @@ -51,6 +52,72 @@ static struct irq_chip pxa_internal_irq_chip = { .unmask = pxa_unmask_irq, }; +/* + * GPIO IRQs for GPIO 0 and 1 + */ +static int pxa_set_low_gpio_type(unsigned int irq, unsigned int type) +{ + int gpio = irq - IRQ_GPIO0; + + if (__gpio_is_occupied(gpio)) { + pr_err("%s failed: GPIO is configured\n", __func__); + return -EINVAL; + } + + if (type & IRQ_TYPE_EDGE_RISING) + GRER0 |= GPIO_bit(gpio); + else + GRER0 &= ~GPIO_bit(gpio); + + if (type & IRQ_TYPE_EDGE_FALLING) + GFER0 |= GPIO_bit(gpio); + else + GFER0 &= ~GPIO_bit(gpio); + + return 0; +} + +static void pxa_ack_low_gpio(unsigned int irq) +{ + GEDR0 = (1 << (irq - IRQ_GPIO0)); +} + +static void pxa_mask_low_gpio(unsigned int irq) +{ + ICMR &= ~(1 << (irq - PXA_IRQ(0))); +} + +static void pxa_unmask_low_gpio(unsigned int irq) +{ + ICMR |= 1 << (irq - PXA_IRQ(0)); +} + +static struct irq_chip pxa_low_gpio_chip = { + .name = "GPIO-l", + .ack = pxa_ack_low_gpio, + .mask = pxa_mask_low_gpio, + .unmask = pxa_unmask_low_gpio, + .set_type = pxa_set_low_gpio_type, +}; + +static void __init pxa_init_low_gpio_irq(set_wake_t fn) +{ + int irq; + + /* clear edge detection on GPIO 0 and 1 */ + GFER0 &= ~0x3; + GRER0 &= ~0x3; + GEDR0 = 0x3; + + for (irq = IRQ_GPIO0; irq <= IRQ_GPIO1; irq++) { + set_irq_chip(irq, &pxa_low_gpio_chip); + set_irq_handler(irq, handle_edge_irq); + set_irq_flags(irq, IRQF_VALID); + } + + pxa_low_gpio_chip.set_wake = fn; +} + void __init pxa_init_irq(int irq_nr, set_wake_t fn) { int irq; @@ -72,6 +139,7 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn) } pxa_internal_irq_chip.set_wake = fn; + pxa_init_low_gpio_irq(fn); } #ifdef CONFIG_PM