Skip to contentSkip to conversation

pinctrl: ralink: pinctrl driver for the rt2880 family

PATCH In review Sergio Paracuellos 4 participants 8 messages Dec 8, 2020 – Dec 11, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: ralink: pinctrl driver for the rt2880 family

This series adds a pinctrl driver for ralink rt2880 SoC.

After last cleanup in staging I was told [0] this driver is ready to be promoted from staging.

This series are rebased on the top of staging-testing.

Thanks in advance for your time.

Changes in v2:
- Squash PATCH 2/3 and PATCH 3/3 in only one.
- Put driver inside 'ralink' subdir of pinctrl.
- Add Linus'Acked-by for driver after squashing two patches.
- Make changes suggested by Linus in bindings doc: [1].
NOTE that I simplified but not removes if-clause because without that I am not be able to validate using 'dt_binding_check' with errors in all pinctrl nodes because are not of type 'object'.

Best regards,
Sergio Paracuellos

[0]: http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-December/149178.html
[1]: http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-December/149204.html

*** BLURB HERE ***

Sergio Paracuellos (2):
dt-bindings: pinctrl: rt2880: add binding document
pinctrl: ralink: add a pinctrl driver for the rt2880 family

 .../pinctrl/ralink,rt2880-pinmux.yaml         | 70 +++++++++++++++++++
 drivers/pinctrl/Kconfig                       |  1 +
 drivers/pinctrl/Makefile                      |  1 +
 drivers/pinctrl/ralink/Kconfig                | 14 ++++
 .../ralink}/Makefile                          |  2 -
 .../ralink}/pinctrl-rt2880.c                  |  4 +-
 drivers/staging/Kconfig                       |  2 -
 drivers/staging/Makefile                      |  1 -
 drivers/staging/mt7621-pinctrl/Kconfig        |  6 --
 drivers/staging/mt7621-pinctrl/TODO           |  6 --
 10 files changed, 88 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml
 create mode 100644 drivers/pinctrl/ralink/Kconfig
 rename drivers/{staging/mt7621-pinctrl => pinctrl/ralink}/Makefile (66%)
 rename drivers/{staging/mt7621-pinctrl => pinctrl/ralink}/pinctrl-rt2880.c (99%)
 delete mode 100644 drivers/staging/mt7621-pinctrl/Kconfig
 delete mode 100644 drivers/staging/mt7621-pinctrl/TODO
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 dt-bindings: pinctrl: rt2880: add binding document

The commit adds rt2880 compatible node in binding document.

---
 .../pinctrl/ralink,rt2880-pinmux.yaml         | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +70 -0
new file mode 100644
index 000000000000..7dea3e26d99e
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/ralink,rt2880-pinmux.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Ralink rt2880 pinmux controller
+
+maintainers:
+  - Sergio Paracuellos <[email protected]>
+
+description:
+  The rt2880 pinmux can only set the muxing of pin groups. muxing indiviual pins
+  is not supported. There is no pinconf support.
+
+properties:
+  compatible:
+    enum:
+      - ralink,rt2880-pinmux
+
+  pinctrl-0:
+    description:
+      A phandle to the node containing the subnodes containing default
+      configurations. This is for pinctrl hogs.
+
+  pinctrl-names:
+    description:
+      A pinctrl state named "default" can be defined.
+    const: default
+
+required:
+  - compatible
+
+patternProperties:
+  '[a-z0-9_-]+':
+    if:
+      type: object
+      description: node for pinctrl.
+      $ref: "pinmux-node.yaml"
+    then:
+      properties:
+        groups:
+          description: Name of the pin group to use for the functions.
+          enum: [i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2, mdio,
+                 pcie, sdhci]
+        function:
+          description: The mux function to select
+          enum: [gpio, i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2,
+                 mdio, nand1, nand2, sdhci]
+
+additionalProperties: false
+
+examples:
+  # Pinmux controller node
+  - |
+    pinctrl {
+      compatible = "ralink,rt2880-pinmux";
+      pinctrl-names = "default";
+      pinctrl-0 = <&state_default>;
+
+      state_default: pinctrl0 {
+      };
+
+      i2c_pins: i2c0 {
+        i2c0 {
+          groups = "i2c";
+          function = "i2c";
+        };
+      };
+    };
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: pinctrl: rt2880: add binding document

Quoted 23 lines · Sergio Paracuellos

The commit adds rt2880 compatible node in binding document.

---
 .../pinctrl/ralink,rt2880-pinmux.yaml         | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +9 -0
new file mode 100644
index 000000000000..7dea3e26d99e
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/ralink,rt2880-pinmux.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Ralink rt2880 pinmux controller
+
+maintainers:

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 19

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +10 -0
+  - Sergio Paracuellos <[email protected]>
+
+description:
+  The rt2880 pinmux can only set the muxing of pin groups. muxing indiviual pins
+  is not supported. There is no pinconf support.
+
+properties:
+  compatible:
+    enum:
+      - ralink,rt2880-pinmux

What's the control interface as you have no 'reg' property.

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 29

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +10 -0
+
+  pinctrl-0:
+    description:
+      A phandle to the node containing the subnodes containing default
+      configurations. This is for pinctrl hogs.
+
+  pinctrl-names:
+    description:
+      A pinctrl state named "default" can be defined.
+    const: default

These 2 properties go in consumer nodes.

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 40

Quoted 11 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +11 -0
+
+required:
+  - compatible
+
+patternProperties:
+  '[a-z0-9_-]+':
+    if:
+      type: object
+      description: node for pinctrl.
+      $ref: "pinmux-node.yaml"
+    then:

For new bindings, don't do this hack. Just name the nodes '-pins$'

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 49

Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +9 -0
+      properties:
+        groups:
+          description: Name of the pin group to use for the functions.
+          enum: [i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2, mdio,
+                 pcie, sdhci]
+        function:
+          description: The mux function to select
+          enum: [gpio, i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2,
+                 mdio, nand1, nand2, sdhci]

additionalProperties: false

Quoted 24 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +21 -0
+
+additionalProperties: false
+
+examples:
+  # Pinmux controller node
+  - |
+    pinctrl {
+      compatible = "ralink,rt2880-pinmux";
+      pinctrl-names = "default";
+      pinctrl-0 = <&state_default>;
+
+      state_default: pinctrl0 {
+      };
+
+      i2c_pins: i2c0 {
+        i2c0 {
+          groups = "i2c";
+          function = "i2c";
+        };
+      };
+    };
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v2 1/2] dt-bindings: pinctrl: rt2880: add binding document

Hi Rob,

Quoted 29 lines · Rob Herring
Quoted 27 lines · Sergio Paracuellos

The commit adds rt2880 compatible node in binding document.

---
 .../pinctrl/ralink,rt2880-pinmux.yaml         | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +13 -0
new file mode 100644
index 000000000000..7dea3e26d99e
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/ralink,rt2880-pinmux.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Ralink rt2880 pinmux controller
+
+maintainers:
+  - Sergio Paracuellos <[email protected]>
+
+description:
+  The rt2880 pinmux can only set the muxing of pin groups. muxing indiviual pins
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 19

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +6 -0
+  is not supported. There is no pinconf support.
+
+properties:
+  compatible:
+    enum:
+      - ralink,rt2880-pinmux

What's the control interface as you have no 'reg' property.

There is not used in pinctrl. Every pin has a gpio function and pinctrl and gpio are separate drivers. Here only pin functions and groups are defined. The glue
code for this driver is done in arch/mips/ralink/mt7621.c using specific pinmux.h header defined for ralink and then all that settings are used in drivers through
the pinctrl driver.

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 29

Quoted 11 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +10 -0
+
+  pinctrl-0:
+    description:
+      A phandle to the node containing the subnodes containing default
+      configurations. This is for pinctrl hogs.
+
+  pinctrl-names:
+    description:
+      A pinctrl state named "default" can be defined.
+    const: default

These 2 properties go in consumer nodes.

Ok, So I have to remove them from here. I see.

Quoted 14 lines

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 40

Quoted 12 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +11 -0
+
+required:
+  - compatible
+
+patternProperties:
+  '[a-z0-9_-]+':
+    if:
+      type: object
+      description: node for pinctrl.
+      $ref: "pinmux-node.yaml"
+    then:

For new bindings, don't do this hack. Just name the nodes '-pins$'

I see. I will update bindings for pinctrl in staging and avoid this if-then clause.

Quoted 11 lines

Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +9 -0
+      properties:
+        groups:
+          description: Name of the pin group to use for the functions.
+          enum: [i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2, mdio,
+                 pcie, sdhci]
+        function:
+          description: The mux function to select
+          enum: [gpio, i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2,
+                 mdio, nand1, nand2, sdhci]
Quoted 1 line

additionalProperties: false

Ok, I will add this.

Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +16 -0
+
+additionalProperties: false
+
+examples:
+  # Pinmux controller node
+  - |
+    pinctrl {
+      compatible = "ralink,rt2880-pinmux";
+      pinctrl-names = "default";
+      pinctrl-0 = <&state_default>;
+
+      state_default: pinctrl0 {
+      };
+
+      i2c_pins: i2c0 {
+        i2c0 {
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file +5 -1
+          groups = "i2c";
+          function = "i2c";
+        };
+      };
+    };
--

2.25.1

Thanks for the review.

Best regards,
Sergio Paracuellos

#4 lore raw

PATCH v2 2/2 pinctrl: ralink: add a pinctrl driver for the rt2880 family

In reply to Sergio Paracuellos

These Socs have 1-3 banks of 8-32 gpios. Rather then setting the muxing of each pin individually, these socs have mux groups that when set will effect 1-N pins. Pin groups have a 2, 4 or 8 different muxes.

---
 drivers/pinctrl/Kconfig                            |  1 +
 drivers/pinctrl/Makefile                           |  1 +
 drivers/pinctrl/ralink/Kconfig                     | 14 ++++++++++++++
 .../mt7621-pinctrl => pinctrl/ralink}/Makefile     |  2 --
 .../ralink}/pinctrl-rt2880.c                       |  4 ++--
 drivers/staging/Kconfig                            |  2 --
 drivers/staging/Makefile                           |  1 -
 drivers/staging/mt7621-pinctrl/Kconfig             |  6 ------
 drivers/staging/mt7621-pinctrl/TODO                |  6 ------
 9 files changed, 18 insertions(+), 19 deletions(-)
 create mode 100644 drivers/pinctrl/ralink/Kconfig
 rename drivers/{staging/mt7621-pinctrl => pinctrl/ralink}/Makefile (66%)
 rename drivers/{staging/mt7621-pinctrl => pinctrl/ralink}/pinctrl-rt2880.c (99%)
 delete mode 100644 drivers/staging/mt7621-pinctrl/Kconfig
 delete mode 100644 drivers/staging/mt7621-pinctrl/TODO
drivers/pinctrl/Kconfig +1 -0
index 815095326e2d..453acce3d0c3 100644
@@ -385,6 +385,7 @@ source "drivers/pinctrl/nomadik/Kconfig"
 source "drivers/pinctrl/nuvoton/Kconfig"
 source "drivers/pinctrl/pxa/Kconfig"
 source "drivers/pinctrl/qcom/Kconfig"
+source "drivers/pinctrl/ralink/Kconfig"
 source "drivers/pinctrl/renesas/Kconfig"
 source "drivers/pinctrl/samsung/Kconfig"
 source "drivers/pinctrl/spear/Kconfig"
drivers/pinctrl/Makefile +1 -0
index f53933b2ff02..3cdb6529db95 100644
@@ -59,6 +59,7 @@ obj-y				+= nomadik/
 obj-$(CONFIG_ARCH_NPCM7XX)	+= nuvoton/
 obj-$(CONFIG_PINCTRL_PXA)	+= pxa/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_PINCTRL_RALINK)	+= ralink/
 obj-$(CONFIG_PINCTRL_RENESAS)	+= renesas/
 obj-$(CONFIG_PINCTRL_SAMSUNG)	+= samsung/
 obj-$(CONFIG_PINCTRL_SPEAR)	+= spear/
drivers/pinctrl/ralink/Kconfig new file +14 -0
new file mode 100644
index 000000000000..8c5f6341477f
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-only
+menu "Ralink pinctrl drivers"
+        depends on RALINK
+
+config PINCTRL_RALINK
+        bool "Ralink pin control support"
+        default y if RALINK
+
+config PINCTRL_RT2880
+        bool "RT2880 pinctrl driver for RALINK/Mediatek SOCs"
+        select PINMUX
+        select GENERIC_PINCONF
+
+endmenu
drivers/pinctrl/ralink/Makefile renamed from drivers/staging/mt7621-pinctrl/Makefile +0 -2
similarity index 66%
rename from drivers/staging/mt7621-pinctrl/Makefile
rename to drivers/pinctrl/ralink/Makefile
index 49445f40c3cd..242554298d07 100644
@@ -1,4 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_PINCTRL_RT2880)   += pinctrl-rt2880.o
-
-ccflags-y += -I$(srctree)/drivers/pinctrl
drivers/pinctrl/ralink/pinctrl-rt2880.c renamed from drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +2 -2
similarity index 99%
rename from drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
rename to drivers/pinctrl/ralink/pinctrl-rt2880.c
index e61dbe186bc9..42b1c6cecb57 100644
@@ -20,8 +20,8 @@
 #include <asm/mach-ralink/pinmux.h>
 #include <asm/mach-ralink/mt7620.h>
 
-#include "core.h"
-#include "pinctrl-utils.h"
+#include "../core.h"
+#include "../pinctrl-utils.h"
 
 #define SYSC_REG_GPIO_MODE	0x60
 #define SYSC_REG_GPIO_MODE2	0x64
drivers/staging/Kconfig +0 -2
index 9b7cb7c5766a..c42708e60afc 100644
@@ -94,8 +94,6 @@ source "drivers/staging/mt7621-pci/Kconfig"
 
 source "drivers/staging/mt7621-pci-phy/Kconfig"
 
-source "drivers/staging/mt7621-pinctrl/Kconfig"
-
 source "drivers/staging/mt7621-dma/Kconfig"
 
 source "drivers/staging/ralink-gdma/Kconfig"
drivers/staging/Makefile +0 -1
index 38226737c9f3..ebcc646d7b51 100644
@@ -37,7 +37,6 @@ obj-$(CONFIG_BCM2835_VCHIQ)	+= vc04_services/
 obj-$(CONFIG_PI433)		+= pi433/
 obj-$(CONFIG_PCI_MT7621)	+= mt7621-pci/
 obj-$(CONFIG_PCI_MT7621_PHY)	+= mt7621-pci-phy/
-obj-$(CONFIG_PINCTRL_RT2880)	+= mt7621-pinctrl/
 obj-$(CONFIG_SOC_MT7621)	+= mt7621-dma/
 obj-$(CONFIG_DMA_RALINK)	+= ralink-gdma/
 obj-$(CONFIG_SOC_MT7621)	+= mt7621-dts/
drivers/staging/mt7621-pinctrl/Kconfig deleted +0 -6
deleted file mode 100644
index f42974026480..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config PINCTRL_RT2880
-	bool "RT2800 pinctrl driver for RALINK/Mediatek SOCs"
-	depends on RALINK
-	select PINMUX
-	select GENERIC_PINCONF
drivers/staging/mt7621-pinctrl/TODO deleted +0 -6
deleted file mode 100644
index b2c235a16d5c..000000000000
@@ -1,6 +0,0 @@
-
-- general code review and cleanup
-- should probably be always selected by 'config RALINK'
-- ensure device-tree requirements are documented
-
-Cc: NeilBrown <[email protected]>
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH v2 2/2] pinctrl: ralink: add a pinctrl driver for the rt2880 family

Quoted 6 lines · Sergio Paracuellos

These Socs have 1-3 banks of 8-32 gpios. Rather then setting the muxing of each pin individually, these socs have mux groups that when set will effect 1-N pins. Pin groups have a 2, 4 or 8 different muxes.

Greg I'm happy if you just apply this right now for v5.11, as Sergio is obviously on top of things and the DT bindings will get there eventually so I don't see any need to hold back the de-staging just waiting for patch 1 (which I will eventually apply directly anyway).

Yours,
Linus Walleij

maintainer
#6 lore raw

Re: [PATCH v2 2/2] pinctrl: ralink: add a pinctrl driver for the rt2880 family

Quoted 7 lines · Linus Walleij
Quoted 4 lines · Sergio Paracuellos

These Socs have 1-3 banks of 8-32 gpios. Rather then setting the muxing of each pin individually, these socs have mux groups that when set will effect 1-N pins. Pin groups have a 2, 4 or 8 different muxes.

Quoted 7 lines
Quoted 2 lines

Greg I'm happy if you just apply this right now for v5.11, as Sergio is obviously on top of things and the DT bindings will get there eventually so I don't see any need to hold back the de-staging just waiting for patch 1 (which I will eventually apply directly anyway).

Now merged into my tree, thanks!

greg k-h

#7 lore raw

Re: [PATCH v2 2/2] pinctrl: ralink: add a pinctrl driver for the rt2880 family

Quoted 12 lines · Greg KH
Quoted 10 lines · Linus Walleij
Quoted 6 lines · Sergio Paracuellos

These Socs have 1-3 banks of 8-32 gpios. Rather then setting the muxing of each pin individually, these socs have mux groups that when set will effect 1-N pins. Pin groups have a 2, 4 or 8 different muxes.

Quoted 8 lines
Quoted 4 lines

Greg I'm happy if you just apply this right now for v5.11, as Sergio is obviously on top of things and the DT bindings will get there eventually so I don't see any need to hold back the de-staging just waiting for patch 1 (which I will eventually apply directly anyway).

Now merged into my tree, thanks!

greg k-h

Thanks!

Best regards,
Sergio Paracuellos