Re: [PATCH v7 2/3] pinctrl: pinmux: Add pinmux-select debugfs file

From: Drew Fustini
Date: Sat Feb 20 2021 - 13:30:37 EST


On Fri, Feb 19, 2021 at 10:06:51AM +0100, Geert Uytterhoeven wrote:
> Hi Drew,
>
> On Wed, Feb 17, 2021 at 11:15 PM Drew Fustini <drew@xxxxxxxxxxxxxxx> wrote:
> > Add "pinmux-select" to debugfs which will activate a function and group:
> >
> > echo "<function-name group-name>" > pinmux-select
> >
> > The write operation pinmux_select() handles this by checking that the
> > names map to valid selectors and then calling ops->set_mux().
> >
> > The existing "pinmux-functions" debugfs file lists the pin functions
> > registered for the pin controller. For example:
> >
> > function: pinmux-uart0, groups = [ pinmux-uart0-pins ]
> > function: pinmux-mmc0, groups = [ pinmux-mmc0-pins ]
> > function: pinmux-mmc1, groups = [ pinmux-mmc1-pins ]
> > function: pinmux-i2c0, groups = [ pinmux-i2c0-pins ]
> > function: pinmux-i2c1, groups = [ pinmux-i2c1-pins ]
> > function: pinmux-spi1, groups = [ pinmux-spi1-pins ]
> >
> > To activate function pinmux-i2c1 and group pinmux-i2c1-pins:
> >
> > echo "pinmux-i2c1 pinmux-i2c1-pins" > pinmux-select
> >
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
> > Reviewed-by: Tony Lindgren <tony@xxxxxxxxxxx>
> > Signed-off-by: Drew Fustini <drew@xxxxxxxxxxxxxxx>
>
> Thanks for your patch!
>
> On R-Car M2-W, which does not use pinctrl-single, I have:
>
> # cat pinmux-functions
> ...
> function 14: i2c2, groups = [ i2c2 i2c2_b i2c2_c i2c2_d ]
> ...
> function 51: ssi, groups = [ ssi0_data ssi0_data_b ssi0129_ctrl
> ssi0129_ctrl_b ssi1_data ssi1_data_b ssi1_ctrl ssi1_ctrl_b ssi2_data
> ssi2_ctrl ssi3_data ssi34_ctrl ssi4_data ssi4_ctrl ssi5_data ssi5_ctrl
> ssi6_data ssi6_ctrl ssi7_data ssi7_data_b ssi78_ctrl ssi78_ctrl_b
> ssi8_data ssi8_data_b ssi9_data ssi9_data_b ssi9_ctrl ssi9_ctrl_b ]
> ...
>
> On the Koelsch board:
>
> # cd /sys/kernel/debug/pinctrl/e6060000.pinctrl-sh-pfc/
> # echo ssi ssi2_ctrl > pinmux-select # Configure i2c2 pins for ssi
> # i2cdetect -y -a 2 # Fails
> # echo i2c2 i2c2 > pinmux-select # Restore i2c2
> # i2cdetect -y -a 2 # Works again
>
> The order of the 2 parameters looks a bit odd to me, as the operation
> configures the pins from "group" to be used for "function".
> See also arch/arm/boot/dts/r8a7791-koelsch.dts
> For the i2c2 example it's not that obvious, but for ssi it is.
> Might feel different for pinctrl-single, and perhaps I just need to get
> used to it ;-)

Thank you for comments and testing.

Regarding the order of "<function-name> <group-name>", I can change it
to "<group-name function-name>" if that seems more natural.

pinctrl-single does not actually use the group selector in pcs_set_mux()
so it essentially does not matter for pinctrl-single.

-Drew

>
> Anyway:
> Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> Tested-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
>
> Gr{oetje,eeting}s,
>
> Geert
>
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds