aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91/gpio.c')
-rw-r--r--arch/arm/mach-at91/gpio.c71
1 files changed, 29 insertions, 42 deletions
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index ae4772e744ac..4615528205c8 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -274,10 +274,10 @@ EXPORT_SYMBOL(at91_get_gpio_value);
274static u32 wakeups[MAX_GPIO_BANKS]; 274static u32 wakeups[MAX_GPIO_BANKS];
275static u32 backups[MAX_GPIO_BANKS]; 275static u32 backups[MAX_GPIO_BANKS];
276 276
277static int gpio_irq_set_wake(unsigned pin, unsigned state) 277static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
278{ 278{
279 unsigned mask = pin_to_mask(pin); 279 unsigned mask = pin_to_mask(d->irq);
280 unsigned bank = (pin - PIN_BASE) / 32; 280 unsigned bank = (d->irq - PIN_BASE) / 32;
281 281
282 if (unlikely(bank >= MAX_GPIO_BANKS)) 282 if (unlikely(bank >= MAX_GPIO_BANKS))
283 return -EINVAL; 283 return -EINVAL;
@@ -287,7 +287,7 @@ static int gpio_irq_set_wake(unsigned pin, unsigned state)
287 else 287 else
288 wakeups[bank] &= ~mask; 288 wakeups[bank] &= ~mask;
289 289
290 set_irq_wake(gpio_chip[bank].bank->id, state); 290 irq_set_irq_wake(gpio_chip[bank].bank->id, state);
291 291
292 return 0; 292 return 0;
293} 293}
@@ -344,25 +344,25 @@ void at91_gpio_resume(void)
344 * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering. 344 * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering.
345 */ 345 */
346 346
347static void gpio_irq_mask(unsigned pin) 347static void gpio_irq_mask(struct irq_data *d)
348{ 348{
349 void __iomem *pio = pin_to_controller(pin); 349 void __iomem *pio = pin_to_controller(d->irq);
350 unsigned mask = pin_to_mask(pin); 350 unsigned mask = pin_to_mask(d->irq);
351 351
352 if (pio) 352 if (pio)
353 __raw_writel(mask, pio + PIO_IDR); 353 __raw_writel(mask, pio + PIO_IDR);
354} 354}
355 355
356static void gpio_irq_unmask(unsigned pin) 356static void gpio_irq_unmask(struct irq_data *d)
357{ 357{
358 void __iomem *pio = pin_to_controller(pin); 358 void __iomem *pio = pin_to_controller(d->irq);
359 unsigned mask = pin_to_mask(pin); 359 unsigned mask = pin_to_mask(d->irq);
360 360
361 if (pio) 361 if (pio)
362 __raw_writel(mask, pio + PIO_IER); 362 __raw_writel(mask, pio + PIO_IER);
363} 363}
364 364
365static int gpio_irq_type(unsigned pin, unsigned type) 365static int gpio_irq_type(struct irq_data *d, unsigned type)
366{ 366{
367 switch (type) { 367 switch (type) {
368 case IRQ_TYPE_NONE: 368 case IRQ_TYPE_NONE:
@@ -375,25 +375,24 @@ static int gpio_irq_type(unsigned pin, unsigned type)
375 375
376static struct irq_chip gpio_irqchip = { 376static struct irq_chip gpio_irqchip = {
377 .name = "GPIO", 377 .name = "GPIO",
378 .mask = gpio_irq_mask, 378 .irq_disable = gpio_irq_mask,
379 .unmask = gpio_irq_unmask, 379 .irq_mask = gpio_irq_mask,
380 .set_type = gpio_irq_type, 380 .irq_unmask = gpio_irq_unmask,
381 .set_wake = gpio_irq_set_wake, 381 .irq_set_type = gpio_irq_type,
382 .irq_set_wake = gpio_irq_set_wake,
382}; 383};
383 384
384static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) 385static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
385{ 386{
386 unsigned pin; 387 unsigned pin;
387 struct irq_desc *gpio; 388 struct irq_data *idata = irq_desc_get_irq_data(desc);
388 struct at91_gpio_chip *at91_gpio; 389 struct irq_chip *chip = irq_data_get_irq_chip(idata);
389 void __iomem *pio; 390 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata);
391 void __iomem *pio = at91_gpio->regbase;
390 u32 isr; 392 u32 isr;
391 393
392 at91_gpio = get_irq_chip_data(irq);
393 pio = at91_gpio->regbase;
394
395 /* temporarily mask (level sensitive) parent IRQ */ 394 /* temporarily mask (level sensitive) parent IRQ */
396 desc->chip->ack(irq); 395 chip->irq_ack(idata);
397 for (;;) { 396 for (;;) {
398 /* Reading ISR acks pending (edge triggered) GPIO interrupts. 397 /* Reading ISR acks pending (edge triggered) GPIO interrupts.
399 * When there none are pending, we're finished unless we need 398 * When there none are pending, we're finished unless we need
@@ -409,27 +408,15 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
409 } 408 }
410 409
411 pin = at91_gpio->chip.base; 410 pin = at91_gpio->chip.base;
412 gpio = &irq_desc[pin];
413 411
414 while (isr) { 412 while (isr) {
415 if (isr & 1) { 413 if (isr & 1)
416 if (unlikely(gpio->depth)) { 414 generic_handle_irq(pin);
417 /*
418 * The core ARM interrupt handler lazily disables IRQs so
419 * another IRQ must be generated before it actually gets
420 * here to be disabled on the GPIO controller.
421 */
422 gpio_irq_mask(pin);
423 }
424 else
425 generic_handle_irq(pin);
426 }
427 pin++; 415 pin++;
428 gpio++;
429 isr >>= 1; 416 isr >>= 1;
430 } 417 }
431 } 418 }
432 desc->chip->unmask(irq); 419 chip->irq_unmask(idata);
433 /* now it may re-trigger */ 420 /* now it may re-trigger */
434} 421}
435 422
@@ -518,14 +505,14 @@ void __init at91_gpio_irq_setup(void)
518 __raw_writel(~0, this->regbase + PIO_IDR); 505 __raw_writel(~0, this->regbase + PIO_IDR);
519 506
520 for (i = 0, pin = this->chip.base; i < 32; i++, pin++) { 507 for (i = 0, pin = this->chip.base; i < 32; i++, pin++) {
521 lockdep_set_class(&irq_desc[pin].lock, &gpio_lock_class); 508 irq_set_lockdep_class(pin, &gpio_lock_class);
522 509
523 /* 510 /*
524 * Can use the "simple" and not "edge" handler since it's 511 * Can use the "simple" and not "edge" handler since it's
525 * shorter, and the AIC handles interrupts sanely. 512 * shorter, and the AIC handles interrupts sanely.
526 */ 513 */
527 set_irq_chip(pin, &gpio_irqchip); 514 irq_set_chip_and_handler(pin, &gpio_irqchip,
528 set_irq_handler(pin, handle_simple_irq); 515 handle_simple_irq);
529 set_irq_flags(pin, IRQF_VALID); 516 set_irq_flags(pin, IRQF_VALID);
530 } 517 }
531 518
@@ -536,8 +523,8 @@ void __init at91_gpio_irq_setup(void)
536 if (prev && prev->next == this) 523 if (prev && prev->next == this)
537 continue; 524 continue;
538 525
539 set_irq_chip_data(id, this); 526 irq_set_chip_data(id, this);
540 set_irq_chained_handler(id, gpio_irq_handler); 527 irq_set_chained_handler(id, gpio_irq_handler);
541 } 528 }
542 pr_info("AT91: %d gpio irqs in %d banks\n", pin - PIN_BASE, gpio_banks); 529 pr_info("AT91: %d gpio irqs in %d banks\n", pin - PIN_BASE, gpio_banks);
543} 530}