diff options
Diffstat (limited to 'arch/arm/mach-ep93xx')
-rw-r--r-- | arch/arm/mach-ep93xx/core.c | 90 |
1 files changed, 62 insertions, 28 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index 5d2739abd960..94bba0b87e36 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c | |||
@@ -152,22 +152,29 @@ struct sys_timer ep93xx_timer = { | |||
152 | /************************************************************************* | 152 | /************************************************************************* |
153 | * GPIO handling for EP93xx | 153 | * GPIO handling for EP93xx |
154 | *************************************************************************/ | 154 | *************************************************************************/ |
155 | static unsigned char gpio_int_enable[2]; | 155 | static unsigned char gpio_int_enable[3]; |
156 | static unsigned char gpio_int_type1[2]; | 156 | static unsigned char gpio_int_type1[3]; |
157 | static unsigned char gpio_int_type2[2]; | 157 | static unsigned char gpio_int_type2[3]; |
158 | 158 | ||
159 | static void update_gpio_ab_int_params(int port) | 159 | static void update_gpio_int_params(int abf) |
160 | { | 160 | { |
161 | if (port == 0) { | 161 | if (abf == 0) { |
162 | __raw_writeb(0, EP93XX_GPIO_A_INT_ENABLE); | 162 | __raw_writeb(0, EP93XX_GPIO_A_INT_ENABLE); |
163 | __raw_writeb(gpio_int_type2[0], EP93XX_GPIO_A_INT_TYPE2); | 163 | __raw_writeb(gpio_int_type2[0], EP93XX_GPIO_A_INT_TYPE2); |
164 | __raw_writeb(gpio_int_type1[0], EP93XX_GPIO_A_INT_TYPE1); | 164 | __raw_writeb(gpio_int_type1[0], EP93XX_GPIO_A_INT_TYPE1); |
165 | __raw_writeb(gpio_int_enable[0], EP93XX_GPIO_A_INT_ENABLE); | 165 | __raw_writeb(gpio_int_enable[0], EP93XX_GPIO_A_INT_ENABLE); |
166 | } else if (port == 1) { | 166 | } else if (abf == 1) { |
167 | __raw_writeb(0, EP93XX_GPIO_B_INT_ENABLE); | 167 | __raw_writeb(0, EP93XX_GPIO_B_INT_ENABLE); |
168 | __raw_writeb(gpio_int_type2[1], EP93XX_GPIO_B_INT_TYPE2); | 168 | __raw_writeb(gpio_int_type2[1], EP93XX_GPIO_B_INT_TYPE2); |
169 | __raw_writeb(gpio_int_type1[1], EP93XX_GPIO_B_INT_TYPE1); | 169 | __raw_writeb(gpio_int_type1[1], EP93XX_GPIO_B_INT_TYPE1); |
170 | __raw_writeb(gpio_int_enable[1], EP93XX_GPIO_B_INT_ENABLE); | 170 | __raw_writeb(gpio_int_enable[1], EP93XX_GPIO_B_INT_ENABLE); |
171 | } else if (abf == 2) { | ||
172 | __raw_writeb(0, EP93XX_GPIO_F_INT_ENABLE); | ||
173 | __raw_writeb(gpio_int_type2[2], EP93XX_GPIO_F_INT_TYPE2); | ||
174 | __raw_writeb(gpio_int_type1[2], EP93XX_GPIO_F_INT_TYPE1); | ||
175 | __raw_writeb(gpio_int_enable[2], EP93XX_GPIO_F_INT_ENABLE); | ||
176 | } else { | ||
177 | BUG(); | ||
171 | } | 178 | } |
172 | } | 179 | } |
173 | 180 | ||
@@ -192,8 +199,13 @@ void gpio_line_config(int line, int direction) | |||
192 | local_irq_save(flags); | 199 | local_irq_save(flags); |
193 | if (direction == GPIO_OUT) { | 200 | if (direction == GPIO_OUT) { |
194 | if (line >= 0 && line < 16) { | 201 | if (line >= 0 && line < 16) { |
202 | /* Port A/B. */ | ||
195 | gpio_int_enable[line >> 3] &= ~(1 << (line & 7)); | 203 | gpio_int_enable[line >> 3] &= ~(1 << (line & 7)); |
196 | update_gpio_ab_int_params(line >> 3); | 204 | update_gpio_int_params(line >> 3); |
205 | } else if (line >= 40 && line < 48) { | ||
206 | /* Port F. */ | ||
207 | gpio_int_enable[2] &= ~(1 << (line & 7)); | ||
208 | update_gpio_int_params(2); | ||
197 | } | 209 | } |
198 | 210 | ||
199 | v = __raw_readb(data_direction_register); | 211 | v = __raw_readb(data_direction_register); |
@@ -244,8 +256,7 @@ EXPORT_SYMBOL(gpio_line_set); | |||
244 | /************************************************************************* | 256 | /************************************************************************* |
245 | * EP93xx IRQ handling | 257 | * EP93xx IRQ handling |
246 | *************************************************************************/ | 258 | *************************************************************************/ |
247 | static void ep93xx_gpio_ab_irq_handler(unsigned int irq, | 259 | static void ep93xx_gpio_ab_irq_handler(unsigned int irq, struct irq_desc *desc) |
248 | struct irq_desc *desc) | ||
249 | { | 260 | { |
250 | unsigned char status; | 261 | unsigned char status; |
251 | int i; | 262 | int i; |
@@ -267,37 +278,46 @@ static void ep93xx_gpio_ab_irq_handler(unsigned int irq, | |||
267 | } | 278 | } |
268 | } | 279 | } |
269 | 280 | ||
270 | static void ep93xx_gpio_ab_irq_mask_ack(unsigned int irq) | 281 | static void ep93xx_gpio_f_irq_handler(unsigned int irq, struct irq_desc *desc) |
282 | { | ||
283 | int gpio_irq = IRQ_EP93XX_GPIO(16) + (((irq + 1) & 7) ^ 4); | ||
284 | |||
285 | desc_handle_irq(gpio_irq, irq_desc + gpio_irq); | ||
286 | } | ||
287 | |||
288 | static void ep93xx_gpio_irq_mask_ack(unsigned int irq) | ||
271 | { | 289 | { |
272 | int line = irq - IRQ_EP93XX_GPIO(0); | 290 | int line = irq - IRQ_EP93XX_GPIO(0); |
273 | int port = line >> 3; | 291 | int port = line >> 3; |
274 | 292 | ||
275 | gpio_int_enable[port] &= ~(1 << (line & 7)); | 293 | gpio_int_enable[port] &= ~(1 << (line & 7)); |
276 | update_gpio_ab_int_params(port); | 294 | update_gpio_int_params(port); |
277 | 295 | ||
278 | if (line >> 3) { | 296 | if (port == 0) { |
279 | __raw_writel(1 << (line & 7), EP93XX_GPIO_B_INT_ACK); | ||
280 | } else { | ||
281 | __raw_writel(1 << (line & 7), EP93XX_GPIO_A_INT_ACK); | 297 | __raw_writel(1 << (line & 7), EP93XX_GPIO_A_INT_ACK); |
298 | } else if (port == 1) { | ||
299 | __raw_writel(1 << (line & 7), EP93XX_GPIO_B_INT_ACK); | ||
300 | } else if (port == 2) { | ||
301 | __raw_writel(1 << (line & 7), EP93XX_GPIO_F_INT_ACK); | ||
282 | } | 302 | } |
283 | } | 303 | } |
284 | 304 | ||
285 | static void ep93xx_gpio_ab_irq_mask(unsigned int irq) | 305 | static void ep93xx_gpio_irq_mask(unsigned int irq) |
286 | { | 306 | { |
287 | int line = irq - IRQ_EP93XX_GPIO(0); | 307 | int line = irq - IRQ_EP93XX_GPIO(0); |
288 | int port = line >> 3; | 308 | int port = line >> 3; |
289 | 309 | ||
290 | gpio_int_enable[port] &= ~(1 << (line & 7)); | 310 | gpio_int_enable[port] &= ~(1 << (line & 7)); |
291 | update_gpio_ab_int_params(port); | 311 | update_gpio_int_params(port); |
292 | } | 312 | } |
293 | 313 | ||
294 | static void ep93xx_gpio_ab_irq_unmask(unsigned int irq) | 314 | static void ep93xx_gpio_irq_unmask(unsigned int irq) |
295 | { | 315 | { |
296 | int line = irq - IRQ_EP93XX_GPIO(0); | 316 | int line = irq - IRQ_EP93XX_GPIO(0); |
297 | int port = line >> 3; | 317 | int port = line >> 3; |
298 | 318 | ||
299 | gpio_int_enable[port] |= 1 << (line & 7); | 319 | gpio_int_enable[port] |= 1 << (line & 7); |
300 | update_gpio_ab_int_params(port); | 320 | update_gpio_int_params(port); |
301 | } | 321 | } |
302 | 322 | ||
303 | 323 | ||
@@ -306,13 +326,17 @@ static void ep93xx_gpio_ab_irq_unmask(unsigned int irq) | |||
306 | * edge (1) triggered, while gpio_int_type2 controls whether it | 326 | * edge (1) triggered, while gpio_int_type2 controls whether it |
307 | * triggers on low/falling (0) or high/rising (1). | 327 | * triggers on low/falling (0) or high/rising (1). |
308 | */ | 328 | */ |
309 | static int ep93xx_gpio_ab_irq_type(unsigned int irq, unsigned int type) | 329 | static int ep93xx_gpio_irq_type(unsigned int irq, unsigned int type) |
310 | { | 330 | { |
311 | int port; | 331 | int port; |
312 | int line; | 332 | int line; |
313 | 333 | ||
314 | line = irq - IRQ_EP93XX_GPIO(0); | 334 | line = irq - IRQ_EP93XX_GPIO(0); |
315 | gpio_line_config(line, GPIO_IN); | 335 | if (line >= 0 && line < 16) { |
336 | gpio_line_config(line, GPIO_IN); | ||
337 | } else { | ||
338 | gpio_line_config(EP93XX_GPIO_LINE_F(line), GPIO_IN); | ||
339 | } | ||
316 | 340 | ||
317 | port = line >> 3; | 341 | port = line >> 3; |
318 | line &= 7; | 342 | line &= 7; |
@@ -330,16 +354,17 @@ static int ep93xx_gpio_ab_irq_type(unsigned int irq, unsigned int type) | |||
330 | gpio_int_type1[port] &= ~(1 << line); | 354 | gpio_int_type1[port] &= ~(1 << line); |
331 | gpio_int_type2[port] &= ~(1 << line); | 355 | gpio_int_type2[port] &= ~(1 << line); |
332 | } | 356 | } |
333 | update_gpio_ab_int_params(port); | 357 | update_gpio_int_params(port); |
334 | 358 | ||
335 | return 0; | 359 | return 0; |
336 | } | 360 | } |
337 | 361 | ||
338 | static struct irq_chip ep93xx_gpio_ab_irq_chip = { | 362 | static struct irq_chip ep93xx_gpio_irq_chip = { |
339 | .ack = ep93xx_gpio_ab_irq_mask_ack, | 363 | .name = "GPIO", |
340 | .mask = ep93xx_gpio_ab_irq_mask, | 364 | .ack = ep93xx_gpio_irq_mask_ack, |
341 | .unmask = ep93xx_gpio_ab_irq_unmask, | 365 | .mask = ep93xx_gpio_irq_mask, |
342 | .set_type = ep93xx_gpio_ab_irq_type, | 366 | .unmask = ep93xx_gpio_irq_unmask, |
367 | .set_type = ep93xx_gpio_irq_type, | ||
343 | }; | 368 | }; |
344 | 369 | ||
345 | 370 | ||
@@ -350,12 +375,21 @@ void __init ep93xx_init_irq(void) | |||
350 | vic_init((void *)EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK); | 375 | vic_init((void *)EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK); |
351 | vic_init((void *)EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK); | 376 | vic_init((void *)EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK); |
352 | 377 | ||
353 | for (irq = IRQ_EP93XX_GPIO(0) ; irq <= IRQ_EP93XX_GPIO(15); irq++) { | 378 | for (irq = IRQ_EP93XX_GPIO(0); irq <= IRQ_EP93XX_GPIO(23); irq++) { |
354 | set_irq_chip(irq, &ep93xx_gpio_ab_irq_chip); | 379 | set_irq_chip(irq, &ep93xx_gpio_irq_chip); |
355 | set_irq_handler(irq, handle_level_irq); | 380 | set_irq_handler(irq, handle_level_irq); |
356 | set_irq_flags(irq, IRQF_VALID); | 381 | set_irq_flags(irq, IRQF_VALID); |
357 | } | 382 | } |
383 | |||
358 | set_irq_chained_handler(IRQ_EP93XX_GPIO_AB, ep93xx_gpio_ab_irq_handler); | 384 | set_irq_chained_handler(IRQ_EP93XX_GPIO_AB, ep93xx_gpio_ab_irq_handler); |
385 | set_irq_chained_handler(IRQ_EP93XX_GPIO0MUX, ep93xx_gpio_f_irq_handler); | ||
386 | set_irq_chained_handler(IRQ_EP93XX_GPIO1MUX, ep93xx_gpio_f_irq_handler); | ||
387 | set_irq_chained_handler(IRQ_EP93XX_GPIO2MUX, ep93xx_gpio_f_irq_handler); | ||
388 | set_irq_chained_handler(IRQ_EP93XX_GPIO3MUX, ep93xx_gpio_f_irq_handler); | ||
389 | set_irq_chained_handler(IRQ_EP93XX_GPIO4MUX, ep93xx_gpio_f_irq_handler); | ||
390 | set_irq_chained_handler(IRQ_EP93XX_GPIO5MUX, ep93xx_gpio_f_irq_handler); | ||
391 | set_irq_chained_handler(IRQ_EP93XX_GPIO6MUX, ep93xx_gpio_f_irq_handler); | ||
392 | set_irq_chained_handler(IRQ_EP93XX_GPIO7MUX, ep93xx_gpio_f_irq_handler); | ||
359 | } | 393 | } |
360 | 394 | ||
361 | 395 | ||