pinctrl: at91: implement at91_pinconf_dbg_show
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Sat, 7 Dec 2013 13:08:54 +0000 (14:08 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 13 Dec 2013 09:34:07 +0000 (10:34 +0100)
This allows to get the pin configuration by using debugfs. On my system:
 # cat /sys/kernel/debug/pinctrl/pinctrl.3/pinconf-pins

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-at91.c

index b0b78f3468aee33f28b5071b98da58baa490a2ec..bcfc8a2eebca7c99da31a8dda527c6f88a035a33 100644 (file)
@@ -784,10 +784,35 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev,
        return 0;
 }
 
+#define DBG_SHOW_FLAG(flag) do {               \
+       if (config & flag) {                    \
+               if (num_conf)                   \
+                       seq_puts(s, "|");       \
+               seq_puts(s, #flag);             \
+               num_conf++;                     \
+       }                                       \
+} while (0)
+
 static void at91_pinconf_dbg_show(struct pinctrl_dev *pctldev,
                                   struct seq_file *s, unsigned pin_id)
 {
+       unsigned long config;
+       int ret, val, num_conf = 0;
+
+       ret = at91_pinconf_get(pctldev, pin_id, &config);
+
+       DBG_SHOW_FLAG(MULTI_DRIVE);
+       DBG_SHOW_FLAG(PULL_UP);
+       DBG_SHOW_FLAG(PULL_DOWN);
+       DBG_SHOW_FLAG(DIS_SCHMIT);
+       DBG_SHOW_FLAG(DEGLITCH);
+       DBG_SHOW_FLAG(DEBOUNCE);
+       if (config & DEBOUNCE) {
+               val = config >> DEBOUNCE_VAL_SHIFT;
+               seq_printf(s, "(%d)", val);
+       }
 
+       return;
 }
 
 static void at91_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,