diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2012-05-02 15:06:13 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-05-11 05:14:15 -0400 |
commit | 6f4350a6da99652423039765b9d1c57784150d39 (patch) | |
tree | 090ae4f1a1d4fe778c8add6f49bff7b7e0d41a72 /drivers/pinctrl/pinctrl-nomadik.c | |
parent | e98ea774c8d210364379329f042e7596f83ecc58 (diff) |
pinctrl/nomadik: break out single GPIO debug function
Break out the code displaying the status of a single pin so we
can use the same code in the pinctrl debug function.
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-nomadik.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-nomadik.c | 105 |
1 files changed, 57 insertions, 48 deletions
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 7d5484fee5f3..8ed7917d513d 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c | |||
@@ -943,14 +943,16 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) | |||
943 | 943 | ||
944 | #include <linux/seq_file.h> | 944 | #include <linux/seq_file.h> |
945 | 945 | ||
946 | static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | 946 | static void nmk_gpio_dbg_show_one(struct seq_file *s, struct gpio_chip *chip, |
947 | unsigned offset, unsigned gpio) | ||
947 | { | 948 | { |
948 | int mode; | 949 | const char *label = gpiochip_is_requested(chip, offset); |
949 | unsigned i; | ||
950 | unsigned gpio = chip->base; | ||
951 | int is_out; | ||
952 | struct nmk_gpio_chip *nmk_chip = | 950 | struct nmk_gpio_chip *nmk_chip = |
953 | container_of(chip, struct nmk_gpio_chip, chip); | 951 | container_of(chip, struct nmk_gpio_chip, chip); |
952 | int mode; | ||
953 | bool is_out; | ||
954 | bool pull; | ||
955 | u32 bit = 1 << offset; | ||
954 | const char *modes[] = { | 956 | const char *modes[] = { |
955 | [NMK_GPIO_ALT_GPIO] = "gpio", | 957 | [NMK_GPIO_ALT_GPIO] = "gpio", |
956 | [NMK_GPIO_ALT_A] = "altA", | 958 | [NMK_GPIO_ALT_A] = "altA", |
@@ -959,56 +961,63 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | |||
959 | }; | 961 | }; |
960 | 962 | ||
961 | clk_enable(nmk_chip->clk); | 963 | clk_enable(nmk_chip->clk); |
962 | 964 | is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit); | |
963 | for (i = 0; i < chip->ngpio; i++, gpio++) { | 965 | pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); |
964 | const char *label = gpiochip_is_requested(chip, i); | 966 | mode = nmk_gpio_get_mode(gpio); |
965 | bool pull; | 967 | |
966 | u32 bit = 1 << i; | 968 | seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s", |
967 | 969 | gpio, label ?: "(none)", | |
968 | is_out = readl(nmk_chip->addr + NMK_GPIO_DIR) & bit; | 970 | is_out ? "out" : "in ", |
969 | pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); | 971 | chip->get |
970 | mode = nmk_gpio_get_mode(gpio); | 972 | ? (chip->get(chip, offset) ? "hi" : "lo") |
971 | seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s", | 973 | : "? ", |
972 | gpio, label ?: "(none)", | 974 | (mode < 0) ? "unknown" : modes[mode], |
973 | is_out ? "out" : "in ", | 975 | pull ? "pull" : "none"); |
974 | chip->get | 976 | |
975 | ? (chip->get(chip, i) ? "hi" : "lo") | 977 | if (label && !is_out) { |
976 | : "? ", | 978 | int irq = gpio_to_irq(gpio); |
977 | (mode < 0) ? "unknown" : modes[mode], | 979 | struct irq_desc *desc = irq_to_desc(irq); |
978 | pull ? "pull" : "none"); | 980 | |
979 | 981 | /* This races with request_irq(), set_irq_type(), | |
980 | if (label && !is_out) { | 982 | * and set_irq_wake() ... but those are "rare". |
981 | int irq = gpio_to_irq(gpio); | 983 | */ |
982 | struct irq_desc *desc = irq_to_desc(irq); | 984 | if (irq >= 0 && desc->action) { |
983 | 985 | char *trigger; | |
984 | /* This races with request_irq(), set_irq_type(), | 986 | u32 bitmask = nmk_gpio_get_bitmask(gpio); |
985 | * and set_irq_wake() ... but those are "rare". | 987 | |
986 | */ | 988 | if (nmk_chip->edge_rising & bitmask) |
987 | if (irq >= 0 && desc->action) { | 989 | trigger = "edge-rising"; |
988 | char *trigger; | 990 | else if (nmk_chip->edge_falling & bitmask) |
989 | u32 bitmask = nmk_gpio_get_bitmask(gpio); | 991 | trigger = "edge-falling"; |
990 | 992 | else | |
991 | if (nmk_chip->edge_rising & bitmask) | 993 | trigger = "edge-undefined"; |
992 | trigger = "edge-rising"; | 994 | |
993 | else if (nmk_chip->edge_falling & bitmask) | 995 | seq_printf(s, " irq-%d %s%s", |
994 | trigger = "edge-falling"; | 996 | irq, trigger, |
995 | else | 997 | irqd_is_wakeup_set(&desc->irq_data) |
996 | trigger = "edge-undefined"; | 998 | ? " wakeup" : ""); |
997 | |||
998 | seq_printf(s, " irq-%d %s%s", | ||
999 | irq, trigger, | ||
1000 | irqd_is_wakeup_set(&desc->irq_data) | ||
1001 | ? " wakeup" : ""); | ||
1002 | } | ||
1003 | } | 999 | } |
1000 | } | ||
1001 | clk_disable(nmk_chip->clk); | ||
1002 | } | ||
1003 | |||
1004 | static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | ||
1005 | { | ||
1006 | unsigned i; | ||
1007 | unsigned gpio = chip->base; | ||
1004 | 1008 | ||
1009 | for (i = 0; i < chip->ngpio; i++, gpio++) { | ||
1010 | nmk_gpio_dbg_show_one(s, chip, i, gpio); | ||
1005 | seq_printf(s, "\n"); | 1011 | seq_printf(s, "\n"); |
1006 | } | 1012 | } |
1007 | |||
1008 | clk_disable(nmk_chip->clk); | ||
1009 | } | 1013 | } |
1010 | 1014 | ||
1011 | #else | 1015 | #else |
1016 | static inline void nmk_gpio_dbg_show_one(struct seq_file *s, | ||
1017 | struct gpio_chip *chip, | ||
1018 | unsigned offset, unsigned gpio) | ||
1019 | { | ||
1020 | } | ||
1012 | #define nmk_gpio_dbg_show NULL | 1021 | #define nmk_gpio_dbg_show NULL |
1013 | #endif | 1022 | #endif |
1014 | 1023 | ||