Message ID | 20210406055346.1624891-1-ilya.lipnitskiy@gmail.com |
---|---|
State | Accepted, archived |
Delegated to: | Chuanhong Guo |
Headers | show |
Series | ramips: gpio-ralink: use ngpios, not ralink,num-gpios | expand |
Hi Ilya, On Mon, 2021-04-05 at 22:53 -0700, Ilya Lipnitskiy wrote: > DTS properties that match *-gpios are treated specially. > > Use ngpios instead, as most GPIO drivers upstream do. > > Fixes 5.10 DTS errors such as: > OF: /palmbus@300000/gpio@600: could not find phandle > > Fixes DTC warnings such as: > Warning (gpios_property): /palmbus@300000/gpio@600:ralink,num- > gpios: > Could not get phandle node for (cell 0) > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> > Cc: Daniel Golle <daniel@makrotopia.org> > --- > [...] > diff --git a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink- > add-gpio-driver-for-ralink-SoC.patch b/target/linux/ramips/patches- > 5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch > index 141d29f9401c..c173336924d2 100644 > --- a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio- > driver-for-ralink-SoC.patch > +++ b/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio- > driver-for-ralink-SoC.patch > @@ -357,7 +357,7 @@ Cc: linux-gpio@vger.kernel.org > + return -EINVAL; > + } > + > -+ ngpio = of_get_property(np, "ralink,num-gpios", NULL); > ++ ngpio = of_get_property(np, "ngpios", NULL); I guess you just went for the smallest patch that fixes the errors and warnings? Otherwise, if you use of_property_read_u32() here, you don't have to deal with be32_to_cpu() later on. Based on my recent experience with linux-gpio, I think more things would need to change too, for the driver to be upstream-compatible. But I don't know what your plans are with this driver, so maybe this quick fix is sufficient for OpenWrt. Best, Sander
On Wed, Apr 7, 2021 at 2:46 AM Sander Vanheule <sander@svanheule.net> wrote: > > Hi Ilya, > > On Mon, 2021-04-05 at 22:53 -0700, Ilya Lipnitskiy wrote: > > DTS properties that match *-gpios are treated specially. > > > > Use ngpios instead, as most GPIO drivers upstream do. > > > > Fixes 5.10 DTS errors such as: > > OF: /palmbus@300000/gpio@600: could not find phandle > > > > Fixes DTC warnings such as: > > Warning (gpios_property): /palmbus@300000/gpio@600:ralink,num- > > gpios: > > Could not get phandle node for (cell 0) > > > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> > > Cc: Daniel Golle <daniel@makrotopia.org> > > --- > > > > [...] > > > diff --git a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink- > > add-gpio-driver-for-ralink-SoC.patch b/target/linux/ramips/patches- > > 5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch > > index 141d29f9401c..c173336924d2 100644 > > --- a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio- > > driver-for-ralink-SoC.patch > > +++ b/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio- > > driver-for-ralink-SoC.patch > > @@ -357,7 +357,7 @@ Cc: linux-gpio@vger.kernel.org > > + return -EINVAL; > > + } > > + > > -+ ngpio = of_get_property(np, "ralink,num-gpios", NULL); > > ++ ngpio = of_get_property(np, "ngpios", NULL); > > I guess you just went for the smallest patch that fixes the errors and > warnings? Correct, the goal of this patch was just to rename "ralink,num-gpios" to "ngpios". > > Based on my recent experience with linux-gpio, I think more things > would need to change too, for the driver to be upstream-compatible. But > I don't know what your plans are with this driver, so maybe this quick > fix is sufficient for OpenWrt. I wasn't planning on fixing all issues and upstreaming the driver, but may attempt that in the future. Just trying to make a step in the right direction here and save people time so they don't see these errors/warnings. Ilya
Hi! On Thu, Apr 8, 2021 at 6:41 AM Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> wrote: > > On Wed, Apr 7, 2021 at 2:46 AM Sander Vanheule <sander@svanheule.net> wrote: > > > > Hi Ilya, > > > > On Mon, 2021-04-05 at 22:53 -0700, Ilya Lipnitskiy wrote: > > > DTS properties that match *-gpios are treated specially. > > > > > > Use ngpios instead, as most GPIO drivers upstream do. > > > > > > Fixes 5.10 DTS errors such as: > > > OF: /palmbus@300000/gpio@600: could not find phandle > > > > > > Fixes DTC warnings such as: > > > Warning (gpios_property): /palmbus@300000/gpio@600:ralink,num- > > > gpios: > > > Could not get phandle node for (cell 0) > > > > > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> > > > Cc: Daniel Golle <daniel@makrotopia.org> > > > --- > > > > > > > [...] > > > > > diff --git a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink- > > > add-gpio-driver-for-ralink-SoC.patch b/target/linux/ramips/patches- > > > 5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch > > > index 141d29f9401c..c173336924d2 100644 > > > --- a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio- > > > driver-for-ralink-SoC.patch > > > +++ b/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio- > > > driver-for-ralink-SoC.patch > > > @@ -357,7 +357,7 @@ Cc: linux-gpio@vger.kernel.org > > > + return -EINVAL; > > > + } > > > + > > > -+ ngpio = of_get_property(np, "ralink,num-gpios", NULL); > > > ++ ngpio = of_get_property(np, "ngpios", NULL); > > > > I guess you just went for the smallest patch that fixes the errors and > > warnings? > Correct, the goal of this patch was just to rename "ralink,num-gpios" > to "ngpios". > > > > > Based on my recent experience with linux-gpio, I think more things > > would need to change too, for the driver to be upstream-compatible. But > > I don't know what your plans are with this driver, so maybe this quick > > fix is sufficient for OpenWrt. > I wasn't planning on fixing all issues and upstreaming the driver, but > may attempt that in the future. Just trying to make a step in the > right direction here and save people time so they don't see these > errors/warnings. This whole driver probably needs a complete rewrite if you want to upstream it. Multiple gpio nodes should be merged into one, bgpio_init should be used to replace our current manual register operations, and this num-gpios is a SoC-specific property, which should be hard-coded in the driver and distinguished using compatible strings. I think current upstream gpio driver for mt7621 is a good start point. It's on my to-do list but I probably won't find any time for it before June.
diff --git a/target/linux/ramips/dts/mt7620a.dtsi b/target/linux/ramips/dts/mt7620a.dtsi index afd638a38622..c33dd135fef1 100644 --- a/target/linux/ramips/dts/mt7620a.dtsi +++ b/target/linux/ramips/dts/mt7620a.dtsi @@ -117,8 +117,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <0>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -134,8 +134,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <16>; ralink,gpio-base = <24>; - ralink,num-gpios = <16>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -153,8 +153,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <32>; ralink,gpio-base = <40>; - ralink,num-gpios = <32>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -172,8 +172,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <1>; ralink,gpio-base = <72>; - ralink,num-gpios = <1>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/dts/mt7620n.dtsi b/target/linux/ramips/dts/mt7620n.dtsi index 309608adb139..2fac091898d9 100644 --- a/target/linux/ramips/dts/mt7620n.dtsi +++ b/target/linux/ramips/dts/mt7620n.dtsi @@ -102,8 +102,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <0>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -119,8 +119,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <16>; ralink,gpio-base = <24>; - ralink,num-gpios = <16>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -138,8 +138,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <32>; ralink,gpio-base = <40>; - ralink,num-gpios = <32>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -157,8 +157,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <1>; ralink,gpio-base = <72>; - ralink,num-gpios = <1>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/dts/rt2880.dtsi b/target/linux/ramips/dts/rt2880.dtsi index b02ef4f465f0..9dd8f3c6e38b 100644 --- a/target/linux/ramips/dts/rt2880.dtsi +++ b/target/linux/ramips/dts/rt2880.dtsi @@ -81,8 +81,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <0>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -95,8 +95,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <16>; ralink,gpio-base = <24>; - ralink,num-gpios = <16>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -111,8 +111,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <32>; ralink,gpio-base = <40>; - ralink,num-gpios = <32>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/dts/rt3050.dtsi b/target/linux/ramips/dts/rt3050.dtsi index 9ba8a4df3609..0cecd5d8cf02 100644 --- a/target/linux/ramips/dts/rt3050.dtsi +++ b/target/linux/ramips/dts/rt3050.dtsi @@ -110,8 +110,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <0>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -130,8 +130,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <16>; ralink,gpio-base = <24>; - ralink,num-gpios = <16>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -146,8 +146,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <12>; ralink,gpio-base = <40>; - ralink,num-gpios = <12>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/dts/rt3352.dtsi b/target/linux/ramips/dts/rt3352.dtsi index 054d2e845050..84d6ed590587 100644 --- a/target/linux/ramips/dts/rt3352.dtsi +++ b/target/linux/ramips/dts/rt3352.dtsi @@ -108,8 +108,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <0>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -127,8 +127,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <16>; ralink,gpio-base = <24>; - ralink,num-gpios = <16>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -143,8 +143,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <6>; ralink,gpio-base = <40>; - ralink,num-gpios = <6>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/dts/rt3883.dtsi b/target/linux/ramips/dts/rt3883.dtsi index 081b52bfd873..158640bf925c 100644 --- a/target/linux/ramips/dts/rt3883.dtsi +++ b/target/linux/ramips/dts/rt3883.dtsi @@ -117,8 +117,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <0>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -131,8 +131,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <16>; ralink,gpio-base = <24>; - ralink,num-gpios = <16>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -147,8 +147,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <32>; ralink,gpio-base = <40>; - ralink,num-gpios = <32>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; @@ -163,8 +163,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <24>; ralink,gpio-base = <72>; - ralink,num-gpios = <24>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/dts/rt5350.dtsi b/target/linux/ramips/dts/rt5350.dtsi index 579d41456bf2..ac4c6d9db259 100644 --- a/target/linux/ramips/dts/rt5350.dtsi +++ b/target/linux/ramips/dts/rt5350.dtsi @@ -117,8 +117,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <22>; ralink,gpio-base = <0>; - ralink,num-gpios = <22>; ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; @@ -134,8 +134,8 @@ gpio-controller; #gpio-cells = <2>; + ngpios = <6>; ralink,gpio-base = <22>; - ralink,num-gpios = <6>; ralink,register-map = [ 00 04 08 0c 10 14 18 1c 20 24 ]; diff --git a/target/linux/ramips/patches-5.10/801-DT-Add-documentation-for-gpio-ralink.patch b/target/linux/ramips/patches-5.10/801-DT-Add-documentation-for-gpio-ralink.patch index 7d5f98f64722..93dabf877626 100644 --- a/target/linux/ramips/patches-5.10/801-DT-Add-documentation-for-gpio-ralink.patch +++ b/target/linux/ramips/patches-5.10/801-DT-Add-documentation-for-gpio-ralink.patch @@ -29,7 +29,7 @@ Cc: linux-gpio@vger.kernel.org +- reg : Physical base address and length of the controller's registers +- interrupt-parent: phandle to the INTC device node +- interrupts : Specify the INTC interrupt number -+- ralink,num-gpios : Specify the number of GPIOs ++- ngpios : Specify the number of GPIOs +- ralink,register-map : The register layout depends on the GPIO bank and actual + SoC type. Register offsets need to be in this order. + [ INT, EDGE, RENA, FENA, DATA, DIR, POL, SET, RESET, TOGGLE ] @@ -50,8 +50,8 @@ Cc: linux-gpio@vger.kernel.org + interrupt-parent = <&intc>; + interrupts = <6>; + ++ ngpios = <24>; + ralink,gpio-base = <0>; -+ ralink,num-gpios = <24>; + ralink,register-map = [ 00 04 08 0c + 20 24 28 2c + 30 34 ]; diff --git a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch b/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch index 141d29f9401c..c173336924d2 100644 --- a/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch +++ b/target/linux/ramips/patches-5.10/802-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch @@ -357,7 +357,7 @@ Cc: linux-gpio@vger.kernel.org + return -EINVAL; + } + -+ ngpio = of_get_property(np, "ralink,num-gpios", NULL); ++ ngpio = of_get_property(np, "ngpios", NULL); + if (!ngpio) { + dev_err(&pdev->dev, "failed to read number of pins\n"); + return -EINVAL; diff --git a/target/linux/ramips/patches-5.10/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch b/target/linux/ramips/patches-5.10/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch new file mode 100644 index 000000000000..0d62bd8b0356 --- /dev/null +++ b/target/linux/ramips/patches-5.10/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch @@ -0,0 +1,11 @@ +--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c ++++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +@@ -354,7 +354,7 @@ static int rt2880_pinmux_probe(struct pl + if (!of_device_is_available(np)) + continue; + +- ngpio = of_get_property(np, "ralink,num-gpios", NULL); ++ ngpio = of_get_property(np, "ngpios", NULL); + gpiobase = of_get_property(np, "ralink,gpio-base", NULL); + if (!ngpio || !gpiobase) { + dev_err(&pdev->dev, "failed to load chip info\n"); diff --git a/target/linux/ramips/patches-5.4/0026-DT-Add-documentation-for-gpio-ralink.patch b/target/linux/ramips/patches-5.4/0026-DT-Add-documentation-for-gpio-ralink.patch index 7d5f98f64722..93dabf877626 100644 --- a/target/linux/ramips/patches-5.4/0026-DT-Add-documentation-for-gpio-ralink.patch +++ b/target/linux/ramips/patches-5.4/0026-DT-Add-documentation-for-gpio-ralink.patch @@ -29,7 +29,7 @@ Cc: linux-gpio@vger.kernel.org +- reg : Physical base address and length of the controller's registers +- interrupt-parent: phandle to the INTC device node +- interrupts : Specify the INTC interrupt number -+- ralink,num-gpios : Specify the number of GPIOs ++- ngpios : Specify the number of GPIOs +- ralink,register-map : The register layout depends on the GPIO bank and actual + SoC type. Register offsets need to be in this order. + [ INT, EDGE, RENA, FENA, DATA, DIR, POL, SET, RESET, TOGGLE ] @@ -50,8 +50,8 @@ Cc: linux-gpio@vger.kernel.org + interrupt-parent = <&intc>; + interrupts = <6>; + ++ ngpios = <24>; + ralink,gpio-base = <0>; -+ ralink,num-gpios = <24>; + ralink,register-map = [ 00 04 08 0c + 20 24 28 2c + 30 34 ]; diff --git a/target/linux/ramips/patches-5.4/0027-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch b/target/linux/ramips/patches-5.4/0027-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch index eae507bcd7b6..525c1976f915 100644 --- a/target/linux/ramips/patches-5.4/0027-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch +++ b/target/linux/ramips/patches-5.4/0027-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch @@ -357,7 +357,7 @@ Cc: linux-gpio@vger.kernel.org + return -EINVAL; + } + -+ ngpio = of_get_property(np, "ralink,num-gpios", NULL); ++ ngpio = of_get_property(np, "ngpios", NULL); + if (!ngpio) { + dev_err(&pdev->dev, "failed to read number of pins\n"); + return -EINVAL; diff --git a/target/linux/ramips/patches-5.4/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch b/target/linux/ramips/patches-5.4/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch new file mode 100644 index 000000000000..0d62bd8b0356 --- /dev/null +++ b/target/linux/ramips/patches-5.4/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch @@ -0,0 +1,11 @@ +--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c ++++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +@@ -354,7 +354,7 @@ static int rt2880_pinmux_probe(struct pl + if (!of_device_is_available(np)) + continue; + +- ngpio = of_get_property(np, "ralink,num-gpios", NULL); ++ ngpio = of_get_property(np, "ngpios", NULL); + gpiobase = of_get_property(np, "ralink,gpio-base", NULL); + if (!ngpio || !gpiobase) { + dev_err(&pdev->dev, "failed to load chip info\n");
DTS properties that match *-gpios are treated specially. Use ngpios instead, as most GPIO drivers upstream do. Fixes 5.10 DTS errors such as: OF: /palmbus@300000/gpio@600: could not find phandle Fixes DTC warnings such as: Warning (gpios_property): /palmbus@300000/gpio@600:ralink,num-gpios: Could not get phandle node for (cell 0) Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> Cc: Daniel Golle <daniel@makrotopia.org> --- target/linux/ramips/dts/mt7620a.dtsi | 8 ++++---- target/linux/ramips/dts/mt7620n.dtsi | 8 ++++---- target/linux/ramips/dts/rt2880.dtsi | 6 +++--- target/linux/ramips/dts/rt3050.dtsi | 6 +++--- target/linux/ramips/dts/rt3352.dtsi | 6 +++--- target/linux/ramips/dts/rt3883.dtsi | 8 ++++---- target/linux/ramips/dts/rt5350.dtsi | 4 ++-- .../801-DT-Add-documentation-for-gpio-ralink.patch | 4 ++-- ...O-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch | 2 +- ...ging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch | 11 +++++++++++ .../0026-DT-Add-documentation-for-gpio-ralink.patch | 4 ++-- ...O-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch | 2 +- ...ging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch | 11 +++++++++++ 13 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 target/linux/ramips/patches-5.10/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch create mode 100644 target/linux/ramips/patches-5.4/804-staging-mt7621-pinctrl-use-ngpios-not-num-gpios.patch