diff mbox series

[v4,2/2] ARM: dts: am33xx-l4: change #pinctrl-cells from 1 to 2

Message ID 20200701013320.130441-3-drew@beagleboard.org (mailing list archive)
State New, archived
Headers show
Series pinctrl: single: support #pinctrl-cells = 2 | expand

Commit Message

Drew Fustini July 1, 2020, 1:33 a.m. UTC
Increase #pinctrl-cells to 2 so that mux and conf be kept separate. This
requires the AM33XX_PADCONF macro in omap.h to also be modified to keep pin
conf and pin mux values separate.

Signed-off-by: Drew Fustini <drew@beagleboard.org>
---
 arch/arm/boot/dts/am33xx-l4.dtsi   | 2 +-
 include/dt-bindings/pinctrl/omap.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Trent Piepho Sept. 9, 2020, 12:34 a.m. UTC | #1
On Tuesday, June 30, 2020 6:33:20 PM PDT Drew Fustini wrote:
> Increase #pinctrl-cells to 2 so that mux and conf be kept separate. This
> requires the AM33XX_PADCONF macro in omap.h to also be modified to keep pin
> conf and pin mux values separate.

> --- a/arch/arm/boot/dts/am33xx-l4.dtsi
> +++ b/arch/arm/boot/dts/am33xx-l4.dtsi
> @@ -278,7 +278,7 @@ scm: scm@0 {
>  				am33xx_pinmux: pinmux@800 {
>  					compatible = "pinctrl-single";
>  					reg = <0x800 0x238>;
> -					#pinctrl-cells = <1>;
> +					#pinctrl-cells = <2>;

>  #define AM33XX_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> -#define AM33XX_PADCONF(pa, dir, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) ((dir) | (mux))
> +#define AM33XX_PADCONF(pa, conf, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) (conf) (mux)

If a dts file uses am33xx_pinmux from am33xx-l4.dtsi, but does not use the
AM33XX_PADCONF() macro for all pin settings, like say it uses AM33XX_IOPAD(),
then the dtb will be totally broken as pin addresses and values will all be
off.

Similarly, using AM33XX_PADCONF() with a different pinctrl defined elsewhere
would also break.

In the latest linux-next kernel, I found one case of the former problem, in
am335x-guardian.dts.

The barebox bootloader had all the am33xx boards broken when the dts change
was imported without adding the OR-two-values special case to the pinctrl
driver.  Which I then tracked to here.
Emmanuel Vadot Jan. 15, 2021, 6:02 p.m. UTC | #2
Hello Drew,

On Wed,  1 Jul 2020 03:33:20 +0200
Drew Fustini <drew@beagleboard.org> wrote:

> Increase #pinctrl-cells to 2 so that mux and conf be kept separate. This
> requires the AM33XX_PADCONF macro in omap.h to also be modified to keep pin
> conf and pin mux values separate.
> 
> Signed-off-by: Drew Fustini <drew@beagleboard.org>
> ---
>  arch/arm/boot/dts/am33xx-l4.dtsi   | 2 +-
>  include/dt-bindings/pinctrl/omap.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
> index a9cbefc80c0c..3141590e5889 100644
> --- a/arch/arm/boot/dts/am33xx-l4.dtsi
> +++ b/arch/arm/boot/dts/am33xx-l4.dtsi
> @@ -278,7 +278,7 @@ scm: scm@0 {
>  				am33xx_pinmux: pinmux@800 {
>  					compatible = "pinctrl-single";
>  					reg = <0x800 0x238>;
> -					#pinctrl-cells = <1>;
> +					#pinctrl-cells = <2>;
>  					pinctrl-single,register-width = <32>;
>  					pinctrl-single,function-mask = <0x7f>;
>  				};
> diff --git a/include/dt-bindings/pinctrl/omap.h b/include/dt-bindings/pinctrl/omap.h
> index 625718042413..2d2a8c737822 100644
> --- a/include/dt-bindings/pinctrl/omap.h
> +++ b/include/dt-bindings/pinctrl/omap.h
> @@ -65,7 +65,7 @@
>  #define DM814X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
>  #define DM816X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
>  #define AM33XX_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> -#define AM33XX_PADCONF(pa, dir, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) ((dir) | (mux))
> +#define AM33XX_PADCONF(pa, conf, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) (conf) (mux)
>  
>  /*
>   * Macros to allow using the offset from the padconf physical address
> -- 
> 2.25.1

 Based on the bindings doc a value of 2 is only acceptable if one uses
pinctrl-single,bits but all the am33xx pins still uses
pinctrl-single,pins.
 I noticed this because this breaks FreeBSD when I tried with 5.9 dts.
Drew Fustini Jan. 15, 2021, 9:40 p.m. UTC | #3
On Fri, Jan 15, 2021 at 07:02:01PM +0100, Emmanuel Vadot wrote:
> 
>  Hello Drew,
> 
> On Wed,  1 Jul 2020 03:33:20 +0200
> Drew Fustini <drew@beagleboard.org> wrote:
> 
> > Increase #pinctrl-cells to 2 so that mux and conf be kept separate. This
> > requires the AM33XX_PADCONF macro in omap.h to also be modified to keep pin
> > conf and pin mux values separate.
> > 
> > Signed-off-by: Drew Fustini <drew@beagleboard.org>
> > ---
> >  arch/arm/boot/dts/am33xx-l4.dtsi   | 2 +-
> >  include/dt-bindings/pinctrl/omap.h | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
> > index a9cbefc80c0c..3141590e5889 100644
> > --- a/arch/arm/boot/dts/am33xx-l4.dtsi
> > +++ b/arch/arm/boot/dts/am33xx-l4.dtsi
> > @@ -278,7 +278,7 @@ scm: scm@0 {
> >  				am33xx_pinmux: pinmux@800 {
> >  					compatible = "pinctrl-single";
> >  					reg = <0x800 0x238>;
> > -					#pinctrl-cells = <1>;
> > +					#pinctrl-cells = <2>;
> >  					pinctrl-single,register-width = <32>;
> >  					pinctrl-single,function-mask = <0x7f>;
> >  				};
> > diff --git a/include/dt-bindings/pinctrl/omap.h b/include/dt-bindings/pinctrl/omap.h
> > index 625718042413..2d2a8c737822 100644
> > --- a/include/dt-bindings/pinctrl/omap.h
> > +++ b/include/dt-bindings/pinctrl/omap.h
> > @@ -65,7 +65,7 @@
> >  #define DM814X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> >  #define DM816X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> >  #define AM33XX_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> > -#define AM33XX_PADCONF(pa, dir, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) ((dir) | (mux))
> > +#define AM33XX_PADCONF(pa, conf, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) (conf) (mux)
> >  
> >  /*
> >   * Macros to allow using the offset from the padconf physical address
> > -- 
> > 2.25.1
> 
>  Based on the bindings doc a value of 2 is only acceptable if one uses
> pinctrl-single,bits but all the am33xx pins still uses
> pinctrl-single,pins.
>  I noticed this because this breaks FreeBSD when I tried with 5.9 dts.
> 
> -- 
> Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>

Hello Emmanuel,

Sorry to hear about that. This change was made based on discussion with
Tony Lindgren this past July. Trent Piepho later pointed out issues wtih
the change including the binding documentation. I had tried to fix
the documentation in September [1]. However, I notice that it seems I
missed changing the lines near the top of pinctrl-single.txt [2]:

- #pinctrl-cells : number of cells in addition to the index, set to 1
  for pinctrl-single,pins and 2 for pinctrl-single,bits

I am thinking that should be re-written as:

- #pinctrl-cells : number of cells in addition to the index, this value
  can be 1 or 2 for pinctrl-single,pins and must be 2 for pinctrl-single,bits

Tony - what do you think?


Thanks,
Drew

[1] https://lore.kernel.org/linux-gpio/20200919200836.3218536-1-drew@beagleboard.org/
[2] https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-single.txt
Tony Lindgren Jan. 18, 2021, 7:41 a.m. UTC | #4
* Drew Fustini <drew@beagleboard.org> [210115 21:40]:
> On Fri, Jan 15, 2021 at 07:02:01PM +0100, Emmanuel Vadot wrote:
> > 
> >  Hello Drew,
> > 
> > On Wed,  1 Jul 2020 03:33:20 +0200
> > Drew Fustini <drew@beagleboard.org> wrote:
> > 
> > > Increase #pinctrl-cells to 2 so that mux and conf be kept separate. This
> > > requires the AM33XX_PADCONF macro in omap.h to also be modified to keep pin
> > > conf and pin mux values separate.
> > > 
> > > Signed-off-by: Drew Fustini <drew@beagleboard.org>
> > > ---
> > >  arch/arm/boot/dts/am33xx-l4.dtsi   | 2 +-
> > >  include/dt-bindings/pinctrl/omap.h | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
> > > index a9cbefc80c0c..3141590e5889 100644
> > > --- a/arch/arm/boot/dts/am33xx-l4.dtsi
> > > +++ b/arch/arm/boot/dts/am33xx-l4.dtsi
> > > @@ -278,7 +278,7 @@ scm: scm@0 {
> > >  				am33xx_pinmux: pinmux@800 {
> > >  					compatible = "pinctrl-single";
> > >  					reg = <0x800 0x238>;
> > > -					#pinctrl-cells = <1>;
> > > +					#pinctrl-cells = <2>;
> > >  					pinctrl-single,register-width = <32>;
> > >  					pinctrl-single,function-mask = <0x7f>;
> > >  				};
> > > diff --git a/include/dt-bindings/pinctrl/omap.h b/include/dt-bindings/pinctrl/omap.h
> > > index 625718042413..2d2a8c737822 100644
> > > --- a/include/dt-bindings/pinctrl/omap.h
> > > +++ b/include/dt-bindings/pinctrl/omap.h
> > > @@ -65,7 +65,7 @@
> > >  #define DM814X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> > >  #define DM816X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> > >  #define AM33XX_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
> > > -#define AM33XX_PADCONF(pa, dir, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) ((dir) | (mux))
> > > +#define AM33XX_PADCONF(pa, conf, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) (conf) (mux)
> > >  
> > >  /*
> > >   * Macros to allow using the offset from the padconf physical address
> > > -- 
> > > 2.25.1
> > 
> >  Based on the bindings doc a value of 2 is only acceptable if one uses
> > pinctrl-single,bits but all the am33xx pins still uses
> > pinctrl-single,pins.
> >  I noticed this because this breaks FreeBSD when I tried with 5.9 dts.
> > 
> > -- 
> > Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>
> 
> Hello Emmanuel,
> 
> Sorry to hear about that. This change was made based on discussion with
> Tony Lindgren this past July. Trent Piepho later pointed out issues wtih
> the change including the binding documentation. I had tried to fix
> the documentation in September [1]. However, I notice that it seems I
> missed changing the lines near the top of pinctrl-single.txt [2]:
> 
> - #pinctrl-cells : number of cells in addition to the index, set to 1
>   for pinctrl-single,pins and 2 for pinctrl-single,bits
> 
> I am thinking that should be re-written as:
> 
> - #pinctrl-cells : number of cells in addition to the index, this value
>   can be 1 or 2 for pinctrl-single,pins and must be 2 for pinctrl-single,bits
> 
> Tony - what do you think?

Sounds good to me.

Regards,

Tony

> [1] https://lore.kernel.org/linux-gpio/20200919200836.3218536-1-drew@beagleboard.org/
> [2] https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-single.txt
diff mbox series

Patch

diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
index a9cbefc80c0c..3141590e5889 100644
--- a/arch/arm/boot/dts/am33xx-l4.dtsi
+++ b/arch/arm/boot/dts/am33xx-l4.dtsi
@@ -278,7 +278,7 @@  scm: scm@0 {
 				am33xx_pinmux: pinmux@800 {
 					compatible = "pinctrl-single";
 					reg = <0x800 0x238>;
-					#pinctrl-cells = <1>;
+					#pinctrl-cells = <2>;
 					pinctrl-single,register-width = <32>;
 					pinctrl-single,function-mask = <0x7f>;
 				};
diff --git a/include/dt-bindings/pinctrl/omap.h b/include/dt-bindings/pinctrl/omap.h
index 625718042413..2d2a8c737822 100644
--- a/include/dt-bindings/pinctrl/omap.h
+++ b/include/dt-bindings/pinctrl/omap.h
@@ -65,7 +65,7 @@ 
 #define DM814X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
 #define DM816X_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
 #define AM33XX_IOPAD(pa, val)		OMAP_IOPAD_OFFSET((pa), 0x0800) (val)
-#define AM33XX_PADCONF(pa, dir, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) ((dir) | (mux))
+#define AM33XX_PADCONF(pa, conf, mux)	OMAP_IOPAD_OFFSET((pa), 0x0800) (conf) (mux)
 
 /*
  * Macros to allow using the offset from the padconf physical address