From 53f2447ed7e86e829bd49eb3f5e9b01ef34f6d47 Mon Sep 17 00:00:00 2001 From: eric miao Date: Tue, 4 Mar 2008 17:18:38 +0800 Subject: [PATCH] --- yaml --- r: 91223 b: refs/heads/master c: 689c04a3904d68343a9258e2de12412e3bb89d09 h: refs/heads/master i: 91221: 277fbe6836d2b54c6f7c9a7a91c97bba024d75d7 91219: 70646ea6917ccd445b1a1ea5e58e83bd07487f17 91215: c5745b0e18a0f0868fa475443732183dbce9d19d v: v3 --- [refs] | 2 +- trunk/arch/arm/mach-pxa/gpio.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 351679139731..ffc0fd946bfd 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 663707c1a99b23a79f9e21117b7c1bdbfe80a899 +refs/heads/master: 689c04a3904d68343a9258e2de12412e3bb89d09 diff --git a/trunk/arch/arm/mach-pxa/gpio.c b/trunk/arch/arm/mach-pxa/gpio.c index a98b2da4c962..f96cae04f6f5 100644 --- a/trunk/arch/arm/mach-pxa/gpio.c +++ b/trunk/arch/arm/mach-pxa/gpio.c @@ -164,6 +164,20 @@ static long GPIO_IRQ_rising_edge[4]; static long GPIO_IRQ_falling_edge[4]; static long GPIO_IRQ_mask[4]; +/* + * On PXA25x and PXA27x, GAFRx and GPDRx together decide the alternate + * function of a GPIO, and GPDRx cannot be altered once configured. It + * is attributed as "occupied" here (I know this terminology isn't + * accurate, you are welcome to propose a better one :-) + */ +static int __gpio_is_occupied(unsigned gpio) +{ + if (cpu_is_pxa25x() || cpu_is_pxa27x()) + return GAFR(gpio) & (0x3 << (((gpio) & 0xf) * 2)); + else + return 0; +} + static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) { int gpio, idx; @@ -179,12 +193,14 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) GPIO_IRQ_falling_edge[idx] | GPDR(gpio)) & GPIO_bit(gpio)) return 0; - if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2))) + + if (__gpio_is_occupied(gpio)) return 0; + type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; } - pxa_gpio_mode(gpio | GPIO_IN); + GPDR(gpio) &= ~GPIO_bit(gpio); if (type & IRQ_TYPE_EDGE_RISING) __set_bit(gpio, GPIO_IRQ_rising_edge);