diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2010-03-04 07:09:05 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2011-03-14 09:05:15 -0400 |
commit | d0b543c772af20f576e204cae442ccfd221631a7 (patch) | |
tree | af998ba41832776ed506bd071c8708969d42515a /arch/arm/plat-nomadik/gpio.c | |
parent | e493e06fedd86b484d172f961234f105f295d4d4 (diff) |
plat-nomadik: add custom dbg_show for GPIO
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'arch/arm/plat-nomadik/gpio.c')
-rw-r--r-- | arch/arm/plat-nomadik/gpio.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/arch/arm/plat-nomadik/gpio.c b/arch/arm/plat-nomadik/gpio.c index 30bb92a746e1..5b5fd1ee3c04 100644 --- a/arch/arm/plat-nomadik/gpio.c +++ b/arch/arm/plat-nomadik/gpio.c | |||
@@ -604,6 +604,97 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) | |||
604 | return NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base) + offset; | 604 | return NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base) + offset; |
605 | } | 605 | } |
606 | 606 | ||
607 | #ifdef CONFIG_DEBUG_FS | ||
608 | |||
609 | #include <linux/seq_file.h> | ||
610 | |||
611 | static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | ||
612 | { | ||
613 | int mode; | ||
614 | unsigned i; | ||
615 | unsigned gpio = chip->base; | ||
616 | int is_out; | ||
617 | struct nmk_gpio_chip *nmk_chip = | ||
618 | container_of(chip, struct nmk_gpio_chip, chip); | ||
619 | const char *modes[] = { | ||
620 | [NMK_GPIO_ALT_GPIO] = "gpio", | ||
621 | [NMK_GPIO_ALT_A] = "altA", | ||
622 | [NMK_GPIO_ALT_B] = "altB", | ||
623 | [NMK_GPIO_ALT_C] = "altC", | ||
624 | }; | ||
625 | |||
626 | for (i = 0; i < chip->ngpio; i++, gpio++) { | ||
627 | const char *label = gpiochip_is_requested(chip, i); | ||
628 | bool pull; | ||
629 | u32 bit = 1 << i; | ||
630 | |||
631 | if (!label) | ||
632 | continue; | ||
633 | |||
634 | is_out = readl(nmk_chip->addr + NMK_GPIO_DIR) & bit; | ||
635 | pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); | ||
636 | mode = nmk_gpio_get_mode(gpio); | ||
637 | seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s", | ||
638 | gpio, label, | ||
639 | is_out ? "out" : "in ", | ||
640 | chip->get | ||
641 | ? (chip->get(chip, i) ? "hi" : "lo") | ||
642 | : "? ", | ||
643 | (mode < 0) ? "unknown" : modes[mode], | ||
644 | pull ? "pull" : "none"); | ||
645 | |||
646 | if (!is_out) { | ||
647 | int irq = gpio_to_irq(gpio); | ||
648 | struct irq_desc *desc = irq_to_desc(irq); | ||
649 | |||
650 | /* This races with request_irq(), set_irq_type(), | ||
651 | * and set_irq_wake() ... but those are "rare". | ||
652 | * | ||
653 | * More significantly, trigger type flags aren't | ||
654 | * currently maintained by genirq. | ||
655 | */ | ||
656 | if (irq >= 0 && desc->action) { | ||
657 | char *trigger; | ||
658 | |||
659 | switch (desc->status & IRQ_TYPE_SENSE_MASK) { | ||
660 | case IRQ_TYPE_NONE: | ||
661 | trigger = "(default)"; | ||
662 | break; | ||
663 | case IRQ_TYPE_EDGE_FALLING: | ||
664 | trigger = "edge-falling"; | ||
665 | break; | ||
666 | case IRQ_TYPE_EDGE_RISING: | ||
667 | trigger = "edge-rising"; | ||
668 | break; | ||
669 | case IRQ_TYPE_EDGE_BOTH: | ||
670 | trigger = "edge-both"; | ||
671 | break; | ||
672 | case IRQ_TYPE_LEVEL_HIGH: | ||
673 | trigger = "level-high"; | ||
674 | break; | ||
675 | case IRQ_TYPE_LEVEL_LOW: | ||
676 | trigger = "level-low"; | ||
677 | break; | ||
678 | default: | ||
679 | trigger = "?trigger?"; | ||
680 | break; | ||
681 | } | ||
682 | |||
683 | seq_printf(s, " irq-%d %s%s", | ||
684 | irq, trigger, | ||
685 | (desc->status & IRQ_WAKEUP) | ||
686 | ? " wakeup" : ""); | ||
687 | } | ||
688 | } | ||
689 | |||
690 | seq_printf(s, "\n"); | ||
691 | } | ||
692 | } | ||
693 | |||
694 | #else | ||
695 | #define nmk_gpio_dbg_show NULL | ||
696 | #endif | ||
697 | |||
607 | /* This structure is replicated for each GPIO block allocated at probe time */ | 698 | /* This structure is replicated for each GPIO block allocated at probe time */ |
608 | static struct gpio_chip nmk_gpio_template = { | 699 | static struct gpio_chip nmk_gpio_template = { |
609 | .direction_input = nmk_gpio_make_input, | 700 | .direction_input = nmk_gpio_make_input, |
@@ -611,6 +702,7 @@ static struct gpio_chip nmk_gpio_template = { | |||
611 | .direction_output = nmk_gpio_make_output, | 702 | .direction_output = nmk_gpio_make_output, |
612 | .set = nmk_gpio_set_output, | 703 | .set = nmk_gpio_set_output, |
613 | .to_irq = nmk_gpio_to_irq, | 704 | .to_irq = nmk_gpio_to_irq, |
705 | .dbg_show = nmk_gpio_dbg_show, | ||
614 | .can_sleep = 0, | 706 | .can_sleep = 0, |
615 | }; | 707 | }; |
616 | 708 | ||