diff options
Diffstat (limited to 'arch/arm/mach-at91/gpio.c')
-rw-r--r-- | arch/arm/mach-at91/gpio.c | 69 |
1 files changed, 65 insertions, 4 deletions
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index 028e4f7a88be..f2236f0e101f 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c | |||
@@ -437,7 +437,68 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
437 | 437 | ||
438 | /*--------------------------------------------------------------------------*/ | 438 | /*--------------------------------------------------------------------------*/ |
439 | 439 | ||
440 | /* This lock class tells lockdep that GPIO irqs are in a different | 440 | #ifdef CONFIG_DEBUG_FS |
441 | |||
442 | static int at91_gpio_show(struct seq_file *s, void *unused) | ||
443 | { | ||
444 | int bank, j; | ||
445 | |||
446 | /* print heading */ | ||
447 | seq_printf(s, "Pin\t"); | ||
448 | for (bank = 0; bank < gpio_banks; bank++) { | ||
449 | seq_printf(s, "PIO%c\t", 'A' + bank); | ||
450 | }; | ||
451 | seq_printf(s, "\n\n"); | ||
452 | |||
453 | /* print pin status */ | ||
454 | for (j = 0; j < 32; j++) { | ||
455 | seq_printf(s, "%i:\t", j); | ||
456 | |||
457 | for (bank = 0; bank < gpio_banks; bank++) { | ||
458 | unsigned pin = PIN_BASE + (32 * bank) + j; | ||
459 | void __iomem *pio = pin_to_controller(pin); | ||
460 | unsigned mask = pin_to_mask(pin); | ||
461 | |||
462 | if (__raw_readl(pio + PIO_PSR) & mask) | ||
463 | seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0"); | ||
464 | else | ||
465 | seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A"); | ||
466 | |||
467 | seq_printf(s, "\t"); | ||
468 | } | ||
469 | |||
470 | seq_printf(s, "\n"); | ||
471 | } | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static int at91_gpio_open(struct inode *inode, struct file *file) | ||
477 | { | ||
478 | return single_open(file, at91_gpio_show, NULL); | ||
479 | } | ||
480 | |||
481 | static const struct file_operations at91_gpio_operations = { | ||
482 | .open = at91_gpio_open, | ||
483 | .read = seq_read, | ||
484 | .llseek = seq_lseek, | ||
485 | .release = single_release, | ||
486 | }; | ||
487 | |||
488 | static int __init at91_gpio_debugfs_init(void) | ||
489 | { | ||
490 | /* /sys/kernel/debug/at91_gpio */ | ||
491 | (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, &at91_gpio_operations); | ||
492 | return 0; | ||
493 | } | ||
494 | postcore_initcall(at91_gpio_debugfs_init); | ||
495 | |||
496 | #endif | ||
497 | |||
498 | /*--------------------------------------------------------------------------*/ | ||
499 | |||
500 | /* | ||
501 | * This lock class tells lockdep that GPIO irqs are in a different | ||
441 | * category than their parents, so it won't report false recursion. | 502 | * category than their parents, so it won't report false recursion. |
442 | */ | 503 | */ |
443 | static struct lock_class_key gpio_lock_class; | 504 | static struct lock_class_key gpio_lock_class; |
@@ -456,9 +517,6 @@ void __init at91_gpio_irq_setup(void) | |||
456 | unsigned id = this->bank->id; | 517 | unsigned id = this->bank->id; |
457 | unsigned i; | 518 | unsigned i; |
458 | 519 | ||
459 | /* enable PIO controller's clock */ | ||
460 | clk_enable(this->bank->clock); | ||
461 | |||
462 | __raw_writel(~0, this->regbase + PIO_IDR); | 520 | __raw_writel(~0, this->regbase + PIO_IDR); |
463 | 521 | ||
464 | for (i = 0, pin = this->chip.base; i < 32; i++, pin++) { | 522 | for (i = 0, pin = this->chip.base; i < 32; i++, pin++) { |
@@ -589,6 +647,9 @@ void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks) | |||
589 | at91_gpio->regbase = at91_gpio->bank->offset + | 647 | at91_gpio->regbase = at91_gpio->bank->offset + |
590 | (void __iomem *)AT91_VA_BASE_SYS; | 648 | (void __iomem *)AT91_VA_BASE_SYS; |
591 | 649 | ||
650 | /* enable PIO controller's clock */ | ||
651 | clk_enable(at91_gpio->bank->clock); | ||
652 | |||
592 | /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ | 653 | /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ |
593 | if (last && last->bank->id == at91_gpio->bank->id) | 654 | if (last && last->bank->id == at91_gpio->bank->id) |
594 | last->next = at91_gpio; | 655 | last->next = at91_gpio; |