diff options
author | eric miao <eric.miao@marvell.com> | 2008-03-04 04:18:38 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-04-19 06:29:04 -0400 |
commit | 689c04a3904d68343a9258e2de12412e3bb89d09 (patch) | |
tree | 777b047f0a21f87296dd9e29bea06108b6e03e91 /arch/arm/mach-pxa | |
parent | 663707c1a99b23a79f9e21117b7c1bdbfe80a899 (diff) |
[ARM] pxa: make pxa_gpio_irq_type() processor generic
The main issue here is that pxa3xx does not have GAFRx registers,
access directly to these registers should be avoided for pxa3xx:
1. introduce __gpio_is_occupied() to indicate the GAFRx and GPDRx
registers are already configured on pxa{25x,27x} while returns
0 always on pxa3xx
2. pxa_gpio_mode(gpio | GPIO_IN) is replaced directly with assign-
ment of GPDRx, the side effect of this change is that the pin
_must_ be configured before use, pxa_gpio_irq_type() will not
change the pin to GPIO, as this restriction is sane, esp. with
the new MFP framework
Signed-off-by: eric miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa')
-rw-r--r-- | arch/arm/mach-pxa/gpio.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/arch/arm/mach-pxa/gpio.c b/arch/arm/mach-pxa/gpio.c index a98b2da4c962..f96cae04f6f5 100644 --- a/arch/arm/mach-pxa/gpio.c +++ b/arch/arm/mach-pxa/gpio.c | |||
@@ -164,6 +164,20 @@ static long GPIO_IRQ_rising_edge[4]; | |||
164 | static long GPIO_IRQ_falling_edge[4]; | 164 | static long GPIO_IRQ_falling_edge[4]; |
165 | static long GPIO_IRQ_mask[4]; | 165 | static long GPIO_IRQ_mask[4]; |
166 | 166 | ||
167 | /* | ||
168 | * On PXA25x and PXA27x, GAFRx and GPDRx together decide the alternate | ||
169 | * function of a GPIO, and GPDRx cannot be altered once configured. It | ||
170 | * is attributed as "occupied" here (I know this terminology isn't | ||
171 | * accurate, you are welcome to propose a better one :-) | ||
172 | */ | ||
173 | static int __gpio_is_occupied(unsigned gpio) | ||
174 | { | ||
175 | if (cpu_is_pxa25x() || cpu_is_pxa27x()) | ||
176 | return GAFR(gpio) & (0x3 << (((gpio) & 0xf) * 2)); | ||
177 | else | ||
178 | return 0; | ||
179 | } | ||
180 | |||
167 | static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) | 181 | static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) |
168 | { | 182 | { |
169 | int gpio, idx; | 183 | int gpio, idx; |
@@ -179,12 +193,14 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) | |||
179 | GPIO_IRQ_falling_edge[idx] | | 193 | GPIO_IRQ_falling_edge[idx] | |
180 | GPDR(gpio)) & GPIO_bit(gpio)) | 194 | GPDR(gpio)) & GPIO_bit(gpio)) |
181 | return 0; | 195 | return 0; |
182 | if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2))) | 196 | |
197 | if (__gpio_is_occupied(gpio)) | ||
183 | return 0; | 198 | return 0; |
199 | |||
184 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; | 200 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; |
185 | } | 201 | } |
186 | 202 | ||
187 | pxa_gpio_mode(gpio | GPIO_IN); | 203 | GPDR(gpio) &= ~GPIO_bit(gpio); |
188 | 204 | ||
189 | if (type & IRQ_TYPE_EDGE_RISING) | 205 | if (type & IRQ_TYPE_EDGE_RISING) |
190 | __set_bit(gpio, GPIO_IRQ_rising_edge); | 206 | __set_bit(gpio, GPIO_IRQ_rising_edge); |