Skip to content

Commit f1b206c

Browse files
pdp7linusw
authored andcommitted
pinctrl: core: print gpio in pins debugfs file
If there is a gpio range mapping for the pin, then print out the gpio chip and line index for the pin in the debugfs 'pins' file with the format: "[line-index]:[gpio-label]" Here is example output on the BeagleBoard.org PocketBeagle (AM3358): /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins pin 25 (PIN25) 25:gpio-32-63 44e10864 00000037 pinctrl-single pin 26 (PIN26) 26:gpio-32-63 44e10868 00000037 pinctrl-single pin 27 (PIN27) 27:gpio-32-63 44e1086c 00000037 pinctrl-single pin 28 (PIN28) 0:? 44e10870 00000036 pinctrl-single pin 29 (PIN29) 0:? 44e10874 00000006 pinctrl-single pin 30 (PIN30) 28:gpio-32-63 44e10878 00000027 pinctrl-single pin 31 (PIN31) 29:gpio-32-63 44e1087c 00000037 pinctrl-single pin 32 (PIN32) 30:gpio-32-63 44e10880 00000037 pinctrl-single pin 33 (PIN33) 31:gpio-32-63 44e10884 00000037 pinctrl-single pin 34 (PIN34) 0:gpio-64-95 44e10888 00000037 pinctrl-single pin 35 (PIN35) 1:gpio-64-95 44e1088c 00000037 pinctrl-single Suggested-by: Andy Shevchenko <[email protected]> Suggested-by: Tony Lindgren <[email protected]> Signed-off-by: Drew Fustini <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent c1282ae commit f1b206c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/pinctrl/core.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/pinctrl/machine.h>
2828

2929
#ifdef CONFIG_GPIOLIB
30+
#include "../gpio/gpiolib.h"
3031
#include <asm-generic/gpio.h>
3132
#endif
3233

@@ -1601,6 +1602,9 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
16011602
struct pinctrl_dev *pctldev = s->private;
16021603
const struct pinctrl_ops *ops = pctldev->desc->pctlops;
16031604
unsigned i, pin;
1605+
struct pinctrl_gpio_range *range;
1606+
unsigned int gpio_num;
1607+
struct gpio_chip *chip;
16041608

16051609
seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
16061610

@@ -1618,6 +1622,23 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
16181622

16191623
seq_printf(s, "pin %d (%s) ", pin, desc->name);
16201624

1625+
#ifdef CONFIG_GPIOLIB
1626+
gpio_num = 0;
1627+
list_for_each_entry(range, &pctldev->gpio_ranges, node) {
1628+
if ((pin >= range->pin_base) &&
1629+
(pin < (range->pin_base + range->npins))) {
1630+
gpio_num = range->base + (pin - range->pin_base);
1631+
break;
1632+
}
1633+
}
1634+
chip = gpio_to_chip(gpio_num);
1635+
if (chip && chip->gpiodev && chip->gpiodev->base)
1636+
seq_printf(s, "%u:%s ", gpio_num -
1637+
chip->gpiodev->base, chip->label);
1638+
else
1639+
seq_puts(s, "0:? ");
1640+
#endif
1641+
16211642
/* Driver-specific info per pin */
16221643
if (ops->pin_dbg_show)
16231644
ops->pin_dbg_show(pctldev, s, pin);

0 commit comments

Comments
 (0)