pinctrl: single: print gpio number in pins debugfs file
Subsystems (3)
PATCH 1/1 pinctrl: single: print gpio number in pins debugfs file
If there is a gpio range mapping for the pin, then print out the gpio number for the pin in the debugfs 'pins' file.
Here is an example on the BeagleBone Black:
$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |head -20 registered pins: 142 pin 0 (PIN0) 44e10800 00000027 pinctrl-single GPIO-32 pin 1 (PIN1) 44e10804 00000027 pinctrl-single GPIO-33 pin 2 (PIN2) 44e10808 00000027 pinctrl-single GPIO-34 pin 3 (PIN3) 44e1080c 00000027 pinctrl-single GPIO-35 pin 4 (PIN4) 44e10810 00000027 pinctrl-single GPIO-36 pin 5 (PIN5) 44e10814 00000027 pinctrl-single GPIO-37 pin 6 (PIN6) 44e10818 00000027 pinctrl-single GPIO-38 pin 7 (PIN7) 44e1081c 00000027 pinctrl-single GPIO-39 pin 8 (PIN8) 44e10820 00000027 pinctrl-single GPIO-22 pin 9 (PIN9) 44e10824 00000030 pinctrl-single GPIO-23 pin 10 (PIN10) 44e10828 00000030 pinctrl-single GPIO-26 pin 11 (PIN11) 44e1082c 00000030 pinctrl-single GPIO-27 pin 12 (PIN12) 44e10830 00000030 pinctrl-single GPIO-44 pin 13 (PIN13) 44e10834 00000030 pinctrl-single GPIO-45 pin 14 (PIN14) 44e10838 00000030 pinctrl-single GPIO-46 pin 15 (PIN15) 44e1083c 00000030 pinctrl-single GPIO-47 pin 16 (PIN16) 44e10840 00000027 pinctrl-single GPIO-48 pin 17 (PIN17) 44e10844 00000027 pinctrl-single GPIO-49 pin 18 (PIN18) 44e10848 00000000 pinctrl-single GPIO-50
--- drivers/pinctrl/pinctrl-single.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-single.c +12 -1
@@ -275,6 +275,14 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,unsigned val, mux_bytes;unsigned long offset;size_t pa; +struct pinctrl_gpio_range *range; +unsigned gpio_num =0 ; + +list_for_each_entry (range, &pctldev->gpio_ranges, node) { +if ((pin >= range->pin_base) && + (pin < (range->pin_base + range->npins))) + gpio_num = range->base + (pin - range->pin_base); + } pcs =pinctrl_dev_get_drvdata (pctldev);
@@ -283,7 +291,10 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev, val = pcs->read (pcs->base + offset); pa = pcs->res->start + offset; -seq_printf (s,"%zx %08x %s " , pa, val,DRIVER_NAME ); +if (gpio_num >0 ) +seq_printf (s,"%zx %08x %s GPIO-%u" , pa, val,DRIVER_NAME , gpio_num); +else +seq_printf (s,"%zx %08x %s" , pa, val,DRIVER_NAME ); } static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
Signature · 1 line
2.25.1
Quoted 6 lines · Drew Fustini
If there is a gpio range mapping for the pin, then print out the gpio number for the pin in the debugfs 'pins' file.
Here is an example on the BeagleBone Black:
Quoted 10 lines
pin 0 (PIN0)
44e1080000000027 pinctrl-single GPIO-32 pin 1 (PIN1)44e1080400000027 pinctrl-single GPIO-33 pin 2 (PIN2)44e1080800000027 pinctrl-single GPIO-34 pin 3 (PIN3)44e1080c00000027 pinctrl-single GPIO-35 pin 4 (PIN4)44e1081000000027 pinctrl-single GPIO-36 pin 5 (PIN5)44e1081400000027 pinctrl-single GPIO-37 pin 6 (PIN6)44e1081800000027 pinctrl-single GPIO-38 pin 7 (PIN7)44e1081c00000027 pinctrl-single GPIO-39 pin 8 (PIN8)44e1082000000027 pinctrl-single GPIO-22 pin 9 (PIN9)44e1082400000030 pinctrl-single GPIO-23
Wouldn't it be better to have this for all types of pin controllers? But I'm not sure about the format of output.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 18 lines · Andy Shevchenko
Quoted 6 lines · Drew Fustini
If there is a gpio range mapping for the pin, then print out the gpio number for the pin in the debugfs 'pins' file.
Here is an example on the BeagleBone Black:
Quoted 10 lines
pin 0 (PIN0)
44e1080000000027 pinctrl-single GPIO-32 pin 1 (PIN1)44e1080400000027 pinctrl-single GPIO-33 pin 2 (PIN2)44e1080800000027 pinctrl-single GPIO-34 pin 3 (PIN3)44e1080c00000027 pinctrl-single GPIO-35 pin 4 (PIN4)44e1081000000027 pinctrl-single GPIO-36 pin 5 (PIN5)44e1081400000027 pinctrl-single GPIO-37 pin 6 (PIN6)44e1081800000027 pinctrl-single GPIO-38 pin 7 (PIN7)44e1081c00000027 pinctrl-single GPIO-39 pin 8 (PIN8)44e1082000000027 pinctrl-single GPIO-22 pin 9 (PIN9)44e1082400000030 pinctrl-single GPIO-23
Quoted 6 lines
Wouldn't it be better to have this for all types of pin controllers? But I'm not sure about the format of output.
Signature · 2 lines
With Best Regards, Andy Shevchenko
I added the gpio column based on Tony's feedback [0].
I'm not sure how I could do it genericly.
The pin_dbg_show callback is implemented in pcs_pin_dbg_show() which prints the contents of each line in the 'pins' file.
Any advice on how I could implement a gpio column for 'pins' file without chaning the pin_dbg_show in all the drivers?A
thanks,
drew
Quoted 2 lines · Drew Fustini
Quoted 1 line · Andy Shevchenko
On Fri, Jul 17, 2020 at 4:36 AM Drew Fustini <[email protected]> wrote:
...
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
pin 0 (PIN0)
44e1080000000027 pinctrl-single GPIO-32 pin 1 (PIN1)44e1080400000027 pinctrl-single GPIO-33 pin 2 (PIN2)44e1080800000027 pinctrl-single GPIO-34 pin 3 (PIN3)44e1080c00000027 pinctrl-single GPIO-35 pin 4 (PIN4)44e1081000000027 pinctrl-single GPIO-36 pin 5 (PIN5)44e1081400000027 pinctrl-single GPIO-37 pin 6 (PIN6)44e1081800000027 pinctrl-single GPIO-38 pin 7 (PIN7)44e1081c00000027 pinctrl-single GPIO-39 pin 8 (PIN8)44e1082000000027 pinctrl-single GPIO-22 pin 9 (PIN9)44e1082400000030 pinctrl-single GPIO-23Wouldn't it be better to have this for all types of pin controllers? But I'm not sure about the format of output.
...
Quoted 9 lines
I added the gpio column based on Tony's feedback [0].
I'm not sure how I could do it genericly.
The
pin_dbg_showcallback is implemented inpcs_pin_dbg_show()which prints the contents of each line in the 'pins' file.Any advice on how I could implement a gpio column for 'pins' file without chaning the
pin_dbg_showin all the drivers?A
My question was exactly about changing core, i.e. pinctrl_pins_show(), rather than each driver.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 26 lines · Andy Shevchenko
Quoted 2 lines · Drew Fustini
Quoted 1 line · Andy Shevchenko
On Fri, Jul 17, 2020 at 4:36 AM Drew Fustini <[email protected]> wrote:
...
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
pin 0 (PIN0)
44e1080000000027 pinctrl-single GPIO-32 pin 1 (PIN1)44e1080400000027 pinctrl-single GPIO-33 pin 2 (PIN2)44e1080800000027 pinctrl-single GPIO-34 pin 3 (PIN3)44e1080c00000027 pinctrl-single GPIO-35 pin 4 (PIN4)44e1081000000027 pinctrl-single GPIO-36 pin 5 (PIN5)44e1081400000027 pinctrl-single GPIO-37 pin 6 (PIN6)44e1081800000027 pinctrl-single GPIO-38 pin 7 (PIN7)44e1081c00000027 pinctrl-single GPIO-39 pin 8 (PIN8)44e1082000000027 pinctrl-single GPIO-22 pin 9 (PIN9)44e1082400000030 pinctrl-single GPIO-23Wouldn't it be better to have this for all types of pin controllers? But I'm not sure about the format of output.
...
Quoted 4 lines
I added the gpio column based on Tony's feedback [0].
I'm not sure how I could do it genericly.
Quoted 12 lines
Quoted 5 lines
The
pin_dbg_showcallback is implemented inpcs_pin_dbg_show()which prints the contents of each line in the 'pins' file.Any advice on how I could implement a gpio column for 'pins' file without chaning the
pin_dbg_showin all the drivers?AMy question was exactly about changing core, i.e.
pinctrl_pins_show(), rather than each driver.Signature · 2 lines
With Best Regards, Andy Shevchenko
Ah ok, so I see in pinctrl_pins_show() that it prints:
seq_printf(s, "pin %d (%s) ", pin, desc->name);
and then calls ops->pin_dbg_show() to have the driver finish printing the line.
I will try to add the gpio number to the seq_printf() after desc->name.
thanks,
drew