Re: [RFC PATCH] pinctrl: add helper to expose pinctrl state in debugfs

From: Drew Fustini
Date: Sat Dec 19 2020 - 15:22:23 EST


On Fri, Dec 18, 2020 at 06:00:49PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 16, 2020 at 12:42 AM Drew Fustini <drew@xxxxxxxxxxxxxxx> wrote:
> > On Tue, Dec 15, 2020 at 09:39:18PM +0200, Andy Shevchenko wrote:
> > > On Tue, Dec 15, 2020 at 9:36 PM Andy Shevchenko
> > > <andy.shevchenko@xxxxxxxxx> wrote:
> > > > On Mon, Dec 14, 2020 at 11:44 PM Drew Fustini <drew@xxxxxxxxxxxxxxx> wrote:
> > > > > On Mon, Dec 14, 2020 at 07:55:12PM +0200, Andy Shevchenko wrote:
> > >
> > > ...
> > >
> > > > > With regards to parent directory, I did discover there is
> > > > > debugfs_lookup(), so I can get the dentry for "pinctrl" and create new
> > > > > subdirectory inside of it. This is the structure now:
> > > > >
> > > > > /sys/kernel/debug/pinctrl/pinctrl_state/ocp:P2_35_pinmux/state
> > > > > /sys/kernel/debug/pinctrl/pinctrl_state/ocp:P2_34_pinmux/state
> > > > > /sys/kernel/debug/pinctrl/pinctrl_state/ocp:P2_33_pinmux/state
> > > > > /sys/kernel/debug/pinctrl/pinctrl_state/ocp:P2_32_pinmux/state
> > > > > etc..
> > >
> > > Missed part to comment.
> > >
> > > I was talking about
> > >
> > > /sys/kernel/debug/pinctrl/<$PINCTRL>/mux/<$PIN> (maybe folder, maybe node)
> >
> > Thanks for the example.
> >
> > What would the value be "<$PINCTRL>"? The name of the driver?
>
> The name of the device instance. This is already done in the pin control code.

Ah, so for the BeagleBone, that would be 44e10800.pinmux-pinctrl-single:

/sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/

>
> > The "ocp:Px_yy_pinmux" directory name comes from dev_name(dev). Is that
> > the name you were referencing in "<$PIN>"?
>
> No, the <$PIN> is an actual pin on this controller. However, I think
> we probably don't need this, just supply it as tuple of the parameters
> to be set: like
> echo $PIN $STATE > .../<$PINCTRL>/mux or alike.

Do you mean not having a debugfs file for each pin, but instead just using the
existing combined file?

/sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pinmux-pins

There is one line in there for each pin in the pinctrl-single instance.

For example:

pin 105 (PIN105): ocp:P2_34_pinmux (GPIO UNCLAIMED) function pinmux_P2_34_default_pin group pinmux_P2_34_default_pin

So maybe one solution to changing pinctrl state could to:

echo "105 gpio_pu" > /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pinmux-pins

I'll make an attempt at implementing that.

>
> --
> With Best Regards,
> Andy Shevchenko