Commit 6f4350a6 authored by Linus Walleij's avatar Linus Walleij

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: default avatarStephen Warren <swarren@wwwdotorg.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent e98ea774
...@@ -943,14 +943,16 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) ...@@ -943,14 +943,16 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
#include <linux/seq_file.h> #include <linux/seq_file.h>
static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) static void nmk_gpio_dbg_show_one(struct seq_file *s, struct gpio_chip *chip,
unsigned offset, unsigned gpio)
{ {
int mode; const char *label = gpiochip_is_requested(chip, offset);
unsigned i;
unsigned gpio = chip->base;
int is_out;
struct nmk_gpio_chip *nmk_chip = struct nmk_gpio_chip *nmk_chip =
container_of(chip, struct nmk_gpio_chip, chip); container_of(chip, struct nmk_gpio_chip, chip);
int mode;
bool is_out;
bool pull;
u32 bit = 1 << offset;
const char *modes[] = { const char *modes[] = {
[NMK_GPIO_ALT_GPIO] = "gpio", [NMK_GPIO_ALT_GPIO] = "gpio",
[NMK_GPIO_ALT_A] = "altA", [NMK_GPIO_ALT_A] = "altA",
...@@ -959,20 +961,15 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) ...@@ -959,20 +961,15 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
}; };
clk_enable(nmk_chip->clk); clk_enable(nmk_chip->clk);
is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit);
for (i = 0; i < chip->ngpio; i++, gpio++) {
const char *label = gpiochip_is_requested(chip, i);
bool pull;
u32 bit = 1 << i;
is_out = readl(nmk_chip->addr + NMK_GPIO_DIR) & bit;
pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit);
mode = nmk_gpio_get_mode(gpio); mode = nmk_gpio_get_mode(gpio);
seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s", seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s",
gpio, label ?: "(none)", gpio, label ?: "(none)",
is_out ? "out" : "in ", is_out ? "out" : "in ",
chip->get chip->get
? (chip->get(chip, i) ? "hi" : "lo") ? (chip->get(chip, offset) ? "hi" : "lo")
: "? ", : "? ",
(mode < 0) ? "unknown" : modes[mode], (mode < 0) ? "unknown" : modes[mode],
pull ? "pull" : "none"); pull ? "pull" : "none");
...@@ -1001,14 +998,26 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) ...@@ -1001,14 +998,26 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
? " wakeup" : ""); ? " wakeup" : "");
} }
} }
clk_disable(nmk_chip->clk);
}
static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{
unsigned i;
unsigned gpio = chip->base;
for (i = 0; i < chip->ngpio; i++, gpio++) {
nmk_gpio_dbg_show_one(s, chip, i, gpio);
seq_printf(s, "\n"); seq_printf(s, "\n");
} }
clk_disable(nmk_chip->clk);
} }
#else #else
static inline void nmk_gpio_dbg_show_one(struct seq_file *s,
struct gpio_chip *chip,
unsigned offset, unsigned gpio)
{
}
#define nmk_gpio_dbg_show NULL #define nmk_gpio_dbg_show NULL
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment