Linux-OMAP Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] pinctrl: single: print gpio number in pins debugfs file
@ 2020-07-17  1:33 Drew Fustini
  2020-07-17 15:14 ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Fustini @ 2020-07-17  1:33 UTC (permalink / raw)
  To: Tony Lindgren, Haojian Zhuang, Linus Walleij, linux-omap,
	linux-gpio, Jason Kridner, Robert Nelson
  Cc: 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:

  $ 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

Signed-off-by: Drew Fustini <drew@beagleboard.org>
---
 drivers/pinctrl/pinctrl-single.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index f3a8a465d27e..473fe0f61792 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -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,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: single: print gpio number in pins debugfs file
  2020-07-17  1:33 [PATCH] pinctrl: single: print gpio number in pins debugfs file Drew Fustini
@ 2020-07-17 15:14 ` Andy Shevchenko
  2020-07-17 19:50   ` Drew Fustini
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-17 15:14 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Tony Lindgren, Haojian Zhuang, Linus Walleij,
	Linux OMAP Mailing List, open list:GPIO SUBSYSTEM, Jason Kridner,
	Robert Nelson

On Fri, Jul 17, 2020 at 4:36 AM Drew Fustini <drew@beagleboard.org> wrote:
>
> 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:

>   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

Wouldn't it be better to have this for all types of pin controllers?
But I'm not sure about the format of output.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: single: print gpio number in pins debugfs file
  2020-07-17 15:14 ` Andy Shevchenko
@ 2020-07-17 19:50   ` Drew Fustini
  2020-07-17 20:09     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Fustini @ 2020-07-17 19:50 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tony Lindgren, Haojian Zhuang, Linus Walleij,
	Linux OMAP Mailing List, open list:GPIO SUBSYSTEM, Jason Kridner,
	Robert Nelson

On Fri, Jul 17, 2020 at 06:14:06PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 17, 2020 at 4:36 AM Drew Fustini <drew@beagleboard.org> wrote:
> >
> > 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:
> 
> >   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
> 
> Wouldn't it be better to have this for all types of pin controllers?
> But I'm not sure about the format of output.
> 
> -- 
> 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

[0] https://lore.kernel.org/linux-gpio/20200713180519.GN5849@atomide.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: single: print gpio number in pins debugfs file
  2020-07-17 19:50   ` Drew Fustini
@ 2020-07-17 20:09     ` Andy Shevchenko
  2020-07-17 22:56       ` Drew Fustini
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-17 20:09 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Tony Lindgren, Haojian Zhuang, Linus Walleij,
	Linux OMAP Mailing List, open list:GPIO SUBSYSTEM, Jason Kridner,
	Robert Nelson

On Fri, Jul 17, 2020 at 10:50 PM Drew Fustini <drew@beagleboard.org> wrote:
> On Fri, Jul 17, 2020 at 06:14:06PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 17, 2020 at 4:36 AM Drew Fustini <drew@beagleboard.org> wrote:

...

> > >   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
> >
> > Wouldn't it be better to have this for all types of pin controllers?
> > But I'm not sure about the format of output.

...

> 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

My question was exactly about changing core, i.e. pinctrl_pins_show(),
rather than each driver.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: single: print gpio number in pins debugfs file
  2020-07-17 20:09     ` Andy Shevchenko
@ 2020-07-17 22:56       ` Drew Fustini
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Fustini @ 2020-07-17 22:56 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tony Lindgren, Haojian Zhuang, Linus Walleij,
	Linux OMAP Mailing List, open list:GPIO SUBSYSTEM, Jason Kridner,
	Robert Nelson

On Fri, Jul 17, 2020 at 11:09:11PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 17, 2020 at 10:50 PM Drew Fustini <drew@beagleboard.org> wrote:
> > On Fri, Jul 17, 2020 at 06:14:06PM +0300, Andy Shevchenko wrote:
> > > On Fri, Jul 17, 2020 at 4:36 AM Drew Fustini <drew@beagleboard.org> wrote:
> 
> ...
> 
> > > >   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
> > >
> > > Wouldn't it be better to have this for all types of pin controllers?
> > > But I'm not sure about the format of output.
> 
> ...
> 
> > 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
> 
> My question was exactly about changing core, i.e. pinctrl_pins_show(),
> rather than each driver.
> 
> -- 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17  1:33 [PATCH] pinctrl: single: print gpio number in pins debugfs file Drew Fustini
2020-07-17 15:14 ` Andy Shevchenko
2020-07-17 19:50   ` Drew Fustini
2020-07-17 20:09     ` Andy Shevchenko
2020-07-17 22:56       ` Drew Fustini

Linux-OMAP Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-omap/0 linux-omap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-omap linux-omap/ https://lore.kernel.org/linux-omap \
		linux-omap@vger.kernel.org
	public-inbox-index linux-omap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-omap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git