Skip to contentSkip to conversation

Microchip mpfs/pic64gx pinctrl part 2

RFC Superseded Conor Dooley 3 participants 12 messages Nov 27, 2025 – Jan 15

Subsystems (6)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Conor Dooley

author maintainer
#0 lore raw

v2 cover Microchip mpfs/pic64gx pinctrl part 2

From: Conor Dooley <[email protected]>

Hey Linus,

v2 here, with what I need out of a generic function. I think I've done what you wanted location wise, but my naming failed me again with the Kconfig knob for it.

Still RFC, so ignore the lack of a meaningful commit message on it.

I didn't touch the mutual exclusion stuff yet, that's next and why I left RFC on it in addition to ibufmd still being unexplained.

There's one @Linus in the driver worth checking out, cos it's the impact of using a generic function to do function + group creation. Don't think it's a big deal, but worth confirming that it's fine.

Mainly looking for feedback on the new generic function here.

Cheers,
Conor.

main changes in v2:
- bank voltage is now controllable from dt
- bank lockdown no longer controllable from dt
- dt_node_to_map callback is now a new (attempt at) a generic function
- some schmitt properties now no longer supported

Conor Dooley (5):
dt-bindings: pinctrl: document polarfire soc mssio pin controller
pinctrl: add generic functions + pins mapper
pinctrl: add polarfire soc mssio pinctrl driver
MAINTAINERS: add Microchip mpfs mssio driver/bindings to entry
riscv: dts: microchip: add pinctrl nodes for mpfs/icicle kit

 .../pinctrl/microchip,mpfs-pinctrl-mssio.yaml | 119 +++
 .../microchip,mpfs-mss-top-sysreg.yaml        |   4 +
 MAINTAINERS                                   |   2 +
 .../dts/microchip/mpfs-icicle-kit-common.dtsi |   1 -
 .../dts/microchip/mpfs-icicle-kit-fabric.dtsi |  63 ++
 .../boot/dts/microchip/mpfs-pinctrl.dtsi      | 167 ++++
 arch/riscv/boot/dts/microchip/mpfs.dtsi       |  16 +
 drivers/pinctrl/Kconfig                       |  13 +-
 drivers/pinctrl/Makefile                      |   2 +
 drivers/pinctrl/pinconf.h                     |   7 +
 drivers/pinctrl/pinctrl-generic.c             | 186 +++++
 drivers/pinctrl/pinctrl-mpfs-mssio.c          | 750 ++++++++++++++++++
 12 files changed, 1327 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml
 create mode 100644 arch/riscv/boot/dts/microchip/mpfs-pinctrl.dtsi
 create mode 100644 drivers/pinctrl/pinctrl-generic.c
 create mode 100644 drivers/pinctrl/pinctrl-mpfs-mssio.c
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

RFC v2 1/5 dt-bindings: pinctrl: document polarfire soc mssio pin controller

From: Conor Dooley <[email protected]>

On Polarfire SoC, the Bank 2 and Bank 4 IOs connected to the Multiprocessor Subsystem (MSS) are controlled by IOMUX_CRs 1 through 6, which determine what function in routed to them, and MSSIO_BANK#_IO_CFG_CRs, which determine the configuration of each pin.

Document it, including several custom configuration options that stem from MSS Configurator options (the MSS Configurator is part of the FPGA tooling for this device). "ibufmd" unfortunately is not a 1:1 mapping with an MSS Configurator option, unlike clamp-diode or lockdown, and I do not know the effect of any bits in the field. I have no been able to find an explanation for these bits in documentation.

---
 .../pinctrl/microchip,mpfs-pinctrl-mssio.yaml | 119 ++++++++++++++++++
 .../microchip,mpfs-mss-top-sysreg.yaml        |   4 +
 2 files changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +119 -0
new file mode 100644
index 000000000000..c8e509ba2f51
@@ -0,0 +1,119 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/microchip,mpfs-pinctrl-mssio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip Polarfire SoC MSSIO pinctrl
+
+maintainers:
+  - Conor Dooley <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: microchip,mpfs-pinctrl-mssio
+      - items:
+          - const: microchip,pic64gx-pinctrl-mssio
+          - const: microchip,mpfs-pinctrl-mssio
+
+  reg:
+    maxItems: 1
+
+  pinctrl-use-default: true
+
+patternProperties:
+  '-cfg$':
+    type: object
+    additionalProperties: false
+
+    patternProperties:
+      '-pins$':
+        type: object
+        additionalProperties: false
+
+        allOf:
+          - $ref: pincfg-node.yaml#
+          - $ref: pinmux-node.yaml#
+
+        properties:
+          pins:
+            description:
+              The list of IOs that properties in the pincfg node apply to.
+
+          function:
+            description:
+              A string containing the name of the function to mux for these
+              pins. The "reserved" function tristates a pin.
+            enum: [ sd, emmc, qspi, spi, usb, uart, i2c, can, mdio, misc
+                    reserved, gpio, fabric-test, tied-low, tied-high, tristate ]
+
+          bias-bus-hold: true
+          bias-disable: true
+          bias-pull-down: true
+          bias-pull-up: true
+          input-schmitt-enable: true
+          low-power-enable: true
+
+          drive-strength:
+            enum: [ 2, 4, 6, 8, 10, 12, 16, 20 ]
+
+          microchip,bank-voltage-microvolt:
+            description:
+              Which bank voltage to use. This cannot differ for pins in a
+              given bank, the whole bank uses the same voltage.
+            enum: [ 1200000, 1500000, 1800000, 2500000, 3300000 ]
+
+          microchip,clamp-diode:
+            $ref: /schemas/types.yaml#/definitions/flag
+            description:
+              Reflects the "Clamp Diode" setting in the MSS Configurator for
+              this pin. This setting controls whether or not input voltage
+              clamping should be enabled.
+
+          microchip,ibufmd:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            default: 0
+            description:
+              Reflects the "IBUFMD" bits in the MSS Configurator output files
+              for this pin.
+
+        required:
+          - pins
+          - function
+          - microchip,bank-voltage-microvolt
+
+        if:
+          properties:
+            microchip,bank-voltage-microvolt:
+              contains:
+                enum: [ 1200000, 1500000, 1800000 ]
+        then:
+          required:
+            - input-schmitt-enable
+
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    pinctrl@204 {
+      compatible = "microchip,mpfs-pinctrl-mssio";
+      reg = <0x204 0x7c>;
+
+      ikrd-spi1-cfg {
+        spi1-pins {
+          pins = <30>, <31>, <32>, <33>;
+          function = "spi";
+          bias-pull-up;
+          drive-strength = <8>;
+          microchip,bank-voltage-microvolt = <3300000>;
+          microchip,ibufmd = <0x1>;
+        };
+      };
+    };
+...
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml +4 -0
index 39987f722411..44e4a50c3155 100644
@@ -42,6 +42,10 @@ properties:
     type: object
     $ref: /schemas/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
 
+  pinctrl@204:
+    type: object
+    $ref: /schemas/pinctrl/microchip,mpfs-pinctrl-mssio.yaml
+
 required:
   - compatible
   - reg
Signature · 1 line
2.51.0
author maintainer
#4 lore raw

RFC v2 2/5 pinctrl: add generic functions + pins mapper

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

---
 drivers/pinctrl/Kconfig           |   6 +
 drivers/pinctrl/Makefile          |   1 +
 drivers/pinctrl/pinconf.h         |   7 ++
 drivers/pinctrl/pinctrl-generic.c | 186 ++++++++++++++++++++++++++++++
 4 files changed, 200 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-generic.c
drivers/pinctrl/Kconfig +6 -0
index 4ec2bb7f67cf..b43d4d7d25a8 100644
@@ -25,6 +25,12 @@ config GENERIC_PINCONF
 	bool
 	select PINCONF
 
+config GENERIC_PINCTRL_BELLS_AND_WHISTLES
+	bool
+	depends on GENERIC_PINCONF
+	depends on GENERIC_PINCTRL_GROUPS
+	depends on GENERIC_PINMUX_FUNCTIONS
+
 config DEBUG_PINCTRL
 	bool "Debug PINCTRL calls"
 	depends on DEBUG_KERNEL
drivers/pinctrl/Makefile +1 -0
index ea4e890766e1..ea679ca84d85 100644
@@ -7,6 +7,7 @@ obj-y				+= core.o pinctrl-utils.o
 obj-$(CONFIG_PINMUX)		+= pinmux.o
 obj-$(CONFIG_PINCONF)		+= pinconf.o
 obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
+obj-$(CONFIG_GENERIC_PINCTRL_BELLS_AND_WHISTLES) += pinctrl-generic.o
 obj-$(CONFIG_OF)		+= devicetree.o
 
 obj-$(CONFIG_PINCTRL_AMD)	+= pinctrl-amd.o
drivers/pinctrl/pinconf.h +7 -0
index e1ae71610526..127da9a1e30e 100644
@@ -160,3 +160,10 @@ pinconf_generic_parse_dt_pinmux(struct device_node *np, struct device *dev,
 	return -ENOTSUPP;
 }
 #endif
+
+#if defined(CONFIG_GENERIC_PINCTRL_BELLS_AND_WHISTLES) && defined (CONFIG_OF)
+int pinctrl_generic_pins_function_dt_node_to_map(struct pinctrl_dev *pctldev,
+						 struct device_node *np,
+						 struct pinctrl_map **maps,
+						 unsigned int *num_maps);
+#endif
drivers/pinctrl/pinctrl-generic.c new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#7 lore raw

RFC v2 3/5 pinctrl: add polarfire soc mssio pinctrl driver

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

On Polarfire SoC, the Bank 2 and Bank 4 IOs connected to the Multiprocessor Subsystem (MSS) are controlled by IOMUX_CRs 1 through 6, which determine what function in routed to them, and MSSIO_BANK#_IO_CFG_CRs, which determine the configuration of each pin.

Add a driver for this pin controller, including several custom properties that reflect aspects of the MSS's configuration.

Reuse the Kconfig option for iomux0, since controlling MSSIOs without iomux0 routing a function to the MSSIOs in question is pointless, and routing a function to the MSSIOs is equally unhelpful if none of them are configured to make use of that function.

---
 drivers/pinctrl/Kconfig              |   7 +-
 drivers/pinctrl/Makefile             |   1 +
 drivers/pinctrl/pinctrl-mpfs-mssio.c | 750 +++++++++++++++++++++++++++
 3 files changed, 756 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pinctrl/pinctrl-mpfs-mssio.c
drivers/pinctrl/Kconfig +5 -2
index b43d4d7d25a8..0e32f91b69ec 100644
@@ -512,12 +512,15 @@ config PINCTRL_PISTACHIO
 	  This support pinctrl and GPIO driver for IMG Pistachio SoC.
 
 config PINCTRL_POLARFIRE_SOC
-	bool "Polarfire SoC pinctrl driver"
+	bool "Polarfire SoC pinctrl drivers"
 	depends on ARCH_MICROCHIP || COMPILE_TEST
 	select GENERIC_PINCONF
+	select GENERIC_PINCTRL_GROUPS
+	select GENERIC_PINMUX_FUNCTIONS
+	select GENERIC_PINCTRL_BELLS_AND_WHISTLES
 	default y
 	help
-	  This selects the pinctrl driver for Microchip Polarfire SoC.
+	  This selects the pinctrl drivers for Microchip Polarfire SoC.
 
 config PINCTRL_RK805
 	tristate "Pinctrl and GPIO driver for RK805 PMIC"
drivers/pinctrl/Makefile +1 -0
index ea679ca84d85..7d7dc1f4873c 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_PINCTRL_PEF2256)	+= pinctrl-pef2256.o
 obj-$(CONFIG_PINCTRL_PIC32)	+= pinctrl-pic32.o
 obj-$(CONFIG_PINCTRL_PIC64GX)	+= pinctrl-pic64gx-gpio2.o
 obj-$(CONFIG_PINCTRL_PISTACHIO)	+= pinctrl-pistachio.o
+obj-$(CONFIG_PINCTRL_POLARFIRE_SOC)	+= pinctrl-mpfs-mssio.o
 obj-$(CONFIG_PINCTRL_POLARFIRE_SOC)	+= pinctrl-mpfs-iomux0.o
 obj-$(CONFIG_PINCTRL_RK805)	+= pinctrl-rk805.o
 obj-$(CONFIG_PINCTRL_ROCKCHIP)	+= pinctrl-rockchip.o
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +750 -0

750 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#10 lore raw

RFC v2 4/5 MAINTAINERS: add Microchip mpfs mssio driver/bindings to entry

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

Add the new mssio driver and bindings to the existing entry for Microchip RISC-V devices.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 5d4825073fcd..380970935407 100644
@@ -22090,6 +22090,7 @@ F:	Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml
 F:	Documentation/devicetree/bindings/mailbox/microchip,mpfs-mailbox.yaml
 F:	Documentation/devicetree/bindings/net/can/microchip,mpfs-can.yaml
 F:	Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
+F:	Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml
 F:	Documentation/devicetree/bindings/pinctrl/microchip,pic64gx-pinctrl-gpio2.yaml
 F:	Documentation/devicetree/bindings/pwm/microchip,corepwm.yaml
 F:	Documentation/devicetree/bindings/riscv/microchip.yaml
@@ -22105,6 +22106,7 @@ F:	drivers/i2c/busses/i2c-microchip-corei2c.c
 F:	drivers/mailbox/mailbox-mpfs.c
 F:	drivers/pci/controller/plda/pcie-microchip-host.c
 F:	drivers/pinctrl/pinctrl-mpfs-iomux0.c
+F:	drivers/pinctrl/pinctrl-mpfs-mssio.c
 F:	drivers/pinctrl/pinctrl-pic64gx-gpio2.c
 F:	drivers/pwm/pwm-microchip-core.c
 F:	drivers/reset/reset-mpfs.c
Signature · 1 line
2.51.0
author maintainer
#11 lore raw

RFC v2 5/5 riscv: dts: microchip: add pinctrl nodes for mpfs/icicle kit

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

Add pinctrl nodes to PolarFire to demonstrate their use, matching the default configuration set by the HSS firmware for the Icicle kit's reference design, as a demonstration of use.

---
 .../dts/microchip/mpfs-icicle-kit-common.dtsi |   1 -
 .../dts/microchip/mpfs-icicle-kit-fabric.dtsi |  63 +++++++
 .../boot/dts/microchip/mpfs-pinctrl.dtsi      | 167 ++++++++++++++++++
 arch/riscv/boot/dts/microchip/mpfs.dtsi       |  16 ++
 4 files changed, 246 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/boot/dts/microchip/mpfs-pinctrl.dtsi
arch/riscv/boot/dts/microchip/mpfs-icicle-kit-common.dtsi +0 -1
index b3f61c58e57c..5667805b4b14 100644
@@ -3,7 +3,6 @@
 
 /dts-v1/;
 
-#include "mpfs.dtsi"
 #include "mpfs-icicle-kit-fabric.dtsi"
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/leds/common.h>
arch/riscv/boot/dts/microchip/mpfs-icicle-kit-fabric.dtsi +63 -0

78 lines not on this page · raw message

arch/riscv/boot/dts/microchip/mpfs-pinctrl.dtsi new file +167 -0

167 lines not on this page · raw message

arch/riscv/boot/dts/microchip/mpfs.dtsi +16 -0
index 5c2963e269b8..0fb94581b6cb 100644
@@ -254,7 +254,23 @@ pdma: dma-controller@3000000 {
 		mss_top_sysreg: syscon@20002000 {
 			compatible = "microchip,mpfs-mss-top-sysreg", "syscon", "simple-mfd";
 			reg = <0x0 0x20002000 0x0 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
 			#reset-cells = <1>;
+
+			iomux0: pinctrl@200 {
+				compatible = "microchip,mpfs-pinctrl-iomux0";
+				reg = <0x200 0x4>;
+				pinctrl-use-default;
+
+			};
+
+			mssio: pinctrl@204 {
+				compatible = "microchip,mpfs-pinctrl-mssio";
+				reg = <0x204 0x7c>;
+				/* on icicle ref design at least */
+				pinctrl-use-default;
+			};
 		};
 
 		sysreg_scb: syscon@20003000 {
Signature · 1 line
2.51.0
maintainer
#2 lore raw

Re: [RFC v2 1/5] dt-bindings: pinctrl: document polarfire soc mssio pin controller

In reply to Conor Dooley
Quoted 59 lines · Conor Dooley

From: Conor Dooley <[email protected]>

On Polarfire SoC, the Bank 2 and Bank 4 IOs connected to the Multiprocessor Subsystem (MSS) are controlled by IOMUX_CRs 1 through 6, which determine what function in routed to them, and MSSIO_BANK#_IO_CFG_CRs, which determine the configuration of each pin.

Document it, including several custom configuration options that stem from MSS Configurator options (the MSS Configurator is part of the FPGA tooling for this device). "ibufmd" unfortunately is not a 1:1 mapping with an MSS Configurator option, unlike clamp-diode or lockdown, and I do not know the effect of any bits in the field. I have no been able to find an explanation for these bits in documentation.

---
 .../pinctrl/microchip,mpfs-pinctrl-mssio.yaml | 119 ++++++++++++++++++
 .../microchip,mpfs-mss-top-sysreg.yaml        |   4 +
 2 files changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +32 -0
new file mode 100644
index 000000000000..c8e509ba2f51
@@ -0,0 +1,119 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/microchip,mpfs-pinctrl-mssio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip Polarfire SoC MSSIO pinctrl
+
+maintainers:
+  - Conor Dooley <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: microchip,mpfs-pinctrl-mssio
+      - items:
+          - const: microchip,pic64gx-pinctrl-mssio
+          - const: microchip,mpfs-pinctrl-mssio
+
+  reg:
+    maxItems: 1
+
+  pinctrl-use-default: true
+
+patternProperties:
+  '-cfg$':
+    type: object
+    additionalProperties: false
+
+    patternProperties:
+      '-pins$':
+        type: object

Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml line 42

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +10 -0
+        additionalProperties: false
+
+        allOf:
+          - $ref: pincfg-node.yaml#
+          - $ref: pinmux-node.yaml#
+
+        properties:
+          pins:
+            description:
+              The list of IOs that properties in the pincfg node apply to.

pins can be int or string. You need to define which one here.

Quoted 13 lines
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +13 -0
+
+          function:
+            description:
+              A string containing the name of the function to mux for these
+              pins. The "reserved" function tristates a pin.
+            enum: [ sd, emmc, qspi, spi, usb, uart, i2c, can, mdio, misc
+                    reserved, gpio, fabric-test, tied-low, tied-high, tristate ]
+
+          bias-bus-hold: true
+          bias-disable: true
+          bias-pull-down: true
+          bias-pull-up: true
+          input-schmitt-enable: true

Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml line 65

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +10 -0
+          low-power-enable: true
+
+          drive-strength:
+            enum: [ 2, 4, 6, 8, 10, 12, 16, 20 ]
+
+          microchip,bank-voltage-microvolt:
+            description:
+              Which bank voltage to use. This cannot differ for pins in a
+              given bank, the whole bank uses the same voltage.
+            enum: [ 1200000, 1500000, 1800000, 2500000, 3300000 ]

"power-source" serves this purpose. It's not well defined as sometimes it's a register value and sometimes a voltage (in various units).

Quoted 72 lines
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +54 -0
+
+          microchip,clamp-diode:
+            $ref: /schemas/types.yaml#/definitions/flag
+            description:
+              Reflects the "Clamp Diode" setting in the MSS Configurator for
+              this pin. This setting controls whether or not input voltage
+              clamping should be enabled.
+
+          microchip,ibufmd:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            default: 0
+            description:
+              Reflects the "IBUFMD" bits in the MSS Configurator output files
+              for this pin.
+
+        required:
+          - pins
+          - function
+          - microchip,bank-voltage-microvolt
+
+        if:
+          properties:
+            microchip,bank-voltage-microvolt:
+              contains:
+                enum: [ 1200000, 1500000, 1800000 ]
+        then:
+          required:
+            - input-schmitt-enable
+
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    pinctrl@204 {
+      compatible = "microchip,mpfs-pinctrl-mssio";
+      reg = <0x204 0x7c>;
+
+      ikrd-spi1-cfg {
+        spi1-pins {
+          pins = <30>, <31>, <32>, <33>;
+          function = "spi";
+          bias-pull-up;
+          drive-strength = <8>;
+          microchip,bank-voltage-microvolt = <3300000>;
+          microchip,ibufmd = <0x1>;
+        };
+      };
+    };
+...
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml +4 -0
index 39987f722411..44e4a50c3155 100644
@@ -42,6 +42,10 @@ properties:
     type: object
     $ref: /schemas/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
 
+  pinctrl@204:
+    type: object
+    $ref: /schemas/pinctrl/microchip,mpfs-pinctrl-mssio.yaml
+
 required:
   - compatible
   - reg
Signature · 1 line
2.51.0
author maintainer
#3 lore raw

Re: [RFC v2 1/5] dt-bindings: pinctrl: document polarfire soc mssio pin controller

Quoted 10 lines · Rob Herring

Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml line 65

Quoted 6 lines · Conor Dooley
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +6 -0
+
+          microchip,bank-voltage-microvolt:
+            description:
+              Which bank voltage to use. This cannot differ for pins in a
+              given bank, the whole bank uses the same voltage.
+            enum: [ 1200000, 1500000, 1800000, 2500000, 3300000 ]

"power-source" serves this purpose. It's not well defined as sometimes it's a register value and sometimes a voltage (in various units).

I don't recall exactly why I chose not to use that property, because I did know it existed. I *think* it was because the selection was not per pin and I wanted to make it clear - but I should probably just use that property and add the description from above.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-mssio.yaml new file +7 -0
+
+          microchip,clamp-diode:
+            $ref: /schemas/types.yaml#/definitions/flag
+            description:
+              Reflects the "Clamp Diode" setting in the MSS Configurator for
+              this pin. This setting controls whether or not input voltage
+              clamping should be enabled.
maintainer
#5 lore raw

Re: [RFC v2 2/5] pinctrl: add generic functions + pins mapper

In reply to Conor Dooley

Hi Conor,

sorry for being slow in reviews!

Quoted 1 line · Conor Dooley

+config GENERIC_PINCTRL_BELLS_AND_WHISTLES

Interesting name :D

A bit like GENERIC_PINCTRL_LOCK_STOCK_AND_BARREL.

Have you considered simply GENERIC_PINCTRL?

Quoted 1 line

+obj-$(CONFIG_GENERIC_PINCTRL_BELLS_AND_WHISTLES) += pinctrl-generic.o

especially since the file is named like so...

drivers/pinctrl/pinctrl-generic.c line 114

Quoted 11 lines
drivers/pinctrl/pinctrl-generic.c new file +11 -0
+/*
+ * For platforms that do not define groups or functions in the driver, but
+ * instead use the devicetree to describe them. This function will, unlike
+ * pinconf_generic_dt_node_to_map() etc which rely on driver defined groups
+ * and functions, create them in addition to parsing pinconf properties and
+ * adding mappings.
+ */
+int pinctrl_generic_pins_function_dt_node_to_map(struct pinctrl_dev *pctldev,
+                                                struct device_node *np,
+                                                struct pinctrl_map **maps,
+                                                unsigned int *num_maps)

All code looks fine.

There is just the philosophical question whether groups and functions should really be in the device tree, as they can obviously be statically defined and associated with the compatible.

I got so much pressure to do it this way because so many driver authors really wanted to keep this in the device tree (usually because it saves memory in the kernel) that I eventually caved in, and I have also been criticized for being to lenient on this because the compatible should suffice.

For me this is all fine, and with you submitting this I suppose even the DT maintainers think this is fine to keep groups and functions in the device tree, so there it is.

I can merge this when it's out of RFC.

Yours,
Linus Walleij

maintainer
#8 lore raw

Re: [RFC v2 3/5] pinctrl: add polarfire soc mssio pinctrl driver

In reply to Conor Dooley
Quoted 3 lines · Conor Dooley
 drivers/pinctrl/Kconfig              |   7 +-
 drivers/pinctrl/Makefile             |   1 +
 drivers/pinctrl/pinctrl-mpfs-mssio.c | 750 +++++++++++++++++++++++++++

Time to move the drivers to drivers/pinctrl/microchip before it becomes an overpopulation problem?

(The previous drivers can be moved in a separate patch.)

drivers/pinctrl/Kconfig config PINCTRL_PISTACHIO · line 520

Quoted 3 lines
drivers/pinctrl/Kconfig +3 -0
+       select GENERIC_PINCTRL_GROUPS
+       select GENERIC_PINMUX_FUNCTIONS
+       select GENERIC_PINCTRL_BELLS_AND_WHISTLES

Just the bottom select will bring it all in, right?

drivers/pinctrl/pinctrl-mpfs-mssio.c line 266

Quoted 9 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +9 -0
+static int mpfs_pinctrl_pin_to_iocfg_reg(unsigned int pin)
+{
+       u32 reg = MPFS_PINCTRL_IOCFG01_REG;
+
+       if (pin >= MPFS_PINCTRL_BANK2_START)
+               reg += MPFS_PINCTRL_INTER_BANK_GAP;
+
+       // 2 pins per 32-bit register
+       reg += (pin / 2) * 0x4;

It's helpful with these nice comments that ease the reading of the code quite a bit.

Quoted 19 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +19 -0
+static int mpfs_pinctrl_set_mux(struct pinctrl_dev *pctrl_dev, unsigned int fsel,
+                               unsigned int gsel)
+{
+       struct mpfs_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
+       const struct group_desc *group;
+       const char **functions;
+
+       group = pinctrl_generic_get_group(pctrl_dev, gsel);
+       if (!group)
+               return -EINVAL;
+
+       functions = group->data;
+
+       for (int i = 0; i < group->grp.npins; i++) {
+               u32 function;
+
+               //TODO @Linus my new function being actually generic means that
+               // the mapping of function string to something the hardware
+               // understands only happens at this point.

drivers/pinctrl/pinctrl-mpfs-mssio.c line 356

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +10 -0
+               // I think this is fine, because dt validation would whinge
+               // about something invalid, but it's the "catch" with my approach.
+               // The other option I considered was to provide a mapping
+               // function pointer that the driver can populate, but I think
+               // that's overkill.
+               function = mpfs_pinctrl_function_map(functions[i]);
+               if (function < 0) {
+                       dev_err(pctrl->dev, "invalid function %s\n", functions[i]);
+                       return function;
+               }

This is fine with me.

Ideally I would like code that does a lot of string stacking and comparing to be using Rust, but we cannot yet use that in core code so that is for another day.

Yours,
Linus Walleij

author maintainer
#6 lore raw

Re: [RFC v2 2/5] pinctrl: add generic functions + pins mapper

In reply to Linus Walleij
Quoted 6 lines · Linus Walleij

Hi Conor,

sorry for being slow in reviews!

On Thu, Nov 27, 2025 at 11:58 AM Conor Dooley <[email protected]> wrote:

Quoted 7 lines
Quoted 1 line

+config GENERIC_PINCTRL_BELLS_AND_WHISTLES

Interesting name :D

A bit like GENERIC_PINCTRL_LOCK_STOCK_AND_BARREL.

Have you considered simply GENERIC_PINCTRL?

Sure, I really didn't know if that was too "core" sounding for something with almost nothing in it.

Quoted 22 lines
Quoted 1 line

+obj-$(CONFIG_GENERIC_PINCTRL_BELLS_AND_WHISTLES) += pinctrl-generic.o

especially since the file is named like so...

drivers/pinctrl/pinctrl-generic.c line 114

Quoted 11 lines
drivers/pinctrl/pinctrl-generic.c new file +11 -0
+/*
+ * For platforms that do not define groups or functions in the driver, but
+ * instead use the devicetree to describe them. This function will, unlike
+ * pinconf_generic_dt_node_to_map() etc which rely on driver defined groups
+ * and functions, create them in addition to parsing pinconf properties and
+ * adding mappings.
+ */
+int pinctrl_generic_pins_function_dt_node_to_map(struct pinctrl_dev *pctldev,
+                                                struct device_node *np,
+                                                struct pinctrl_map **maps,
+                                                unsigned int *num_maps)

All code looks fine.

There is just the philosophical question whether groups and functions should really be in the device tree, as they can obviously be statically defined and associated with the compatible.

Quoted 8 lines

I got so much pressure to do it this way because so many driver authors really wanted to keep this in the device tree (usually because it saves memory in the kernel) that I eventually caved in, and I have also been criticized for being to lenient on this because the compatible should suffice.

For me this is all fine, and with you submitting this I suppose even the DT maintainers think this is fine to keep groups and functions in the device tree, so there it is.

I think that you're mostly right though. There's a lot of situations where the pinmux-node properties are used because they're easier than putting functions and groups structs into a devicetree. They're boring and annoying to write, when a pinmux property can do the job for you, particularly on bigger devices where there may be lots of them. My personal take would be that it comes down to complexity, and the number of possible groups/functions that a pin can belong to. If that number is very high then it makes sense I think to put it in dt, but if there's only a small number than spelling them out in the driver I think makes the most sense.

The pinmux property on the other hand, were I asked to review it as a new property, I would reject. I'd probably push for not using pinmux, as you did with my drivers, more. I think finding good examples to copy from of it being done that way was why I didn't try. The docs that explain about statically defined functions and groups, IIRC, kinda come across as being a mach-foo thing, rather than intended for use with dt, until you pointed out an example and I was able to link the two. Based on what I've done for this series, I know that what that property seeks to do can be done using pins and functions, rather than mixing both up together into a single property - even worse, it's even a single cell! I only used it myself in the earlier versions cos everyone else does it and the infra existed to use it already. I've not looked at every user, but every user I looked at used it to hold the function, not some additional mux setting.

Quoted 1 line

I can merge this when it's out of RFC.

Sweet. I'll hopefully get it out in the next day or so.

author maintainer
#9 lore raw

Re: [RFC v2 3/5] pinctrl: add polarfire soc mssio pinctrl driver

In reply to Linus Walleij
Quoted 8 lines · Linus Walleij
Quoted 3 lines · Conor Dooley
 drivers/pinctrl/Kconfig              |   7 +-
 drivers/pinctrl/Makefile             |   1 +
 drivers/pinctrl/pinctrl-mpfs-mssio.c | 750 +++++++++++++++++++++++++++

Time to move the drivers to drivers/pinctrl/microchip before it becomes an overpopulation problem?

Sure, no problem.

Quoted 9 lines

(The previous drivers can be moved in a separate patch.)

drivers/pinctrl/Kconfig config PINCTRL_PISTACHIO · line 520

Quoted 3 lines
drivers/pinctrl/Kconfig +3 -0
+       select GENERIC_PINCTRL_GROUPS
+       select GENERIC_PINMUX_FUNCTIONS
+       select GENERIC_PINCTRL_BELLS_AND_WHISTLES

Just the bottom select will bring it all in, right?

I'll make it do that if it's not already. Just didn't know if you were a "select everything you use" kinda guy or didn't mind selects selecting.

Quoted 4 lines
Quoted 4 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +4 -0
+static int mpfs_pinctrl_pin_to_iocfg_reg(unsigned int pin)
+{
+       u32 reg = MPFS_PINCTRL_IOCFG01_REG;
+
Quoted 8 lines

drivers/pinctrl/pinctrl-mpfs-mssio.c line 266

Quoted 5 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +5 -0
+       if (pin >= MPFS_PINCTRL_BANK2_START)
+               reg += MPFS_PINCTRL_INTER_BANK_GAP;
+
+       // 2 pins per 32-bit register
+       reg += (pin / 2) * 0x4;

It's helpful with these nice comments that ease the reading of the code quite a bit.

Eh, I feel like sometimes a comment like this is just better than trying to insert silly defines to unmagic the numbers.

Quoted 33 lines
Quoted 20 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +19 -0
+static int mpfs_pinctrl_set_mux(struct pinctrl_dev *pctrl_dev, unsigned int fsel,
+                               unsigned int gsel)
+{
+       struct mpfs_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
+       const struct group_desc *group;
+       const char **functions;
+
+       group = pinctrl_generic_get_group(pctrl_dev, gsel);
+       if (!group)
+               return -EINVAL;
+
+       functions = group->data;
+
+       for (int i = 0; i < group->grp.npins; i++) {
+               u32 function;
+
+               //TODO @Linus my new function being actually generic means that
+               // the mapping of function string to something the hardware
+               // understands only happens at this point.

drivers/pinctrl/pinctrl-mpfs-mssio.c line 356

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-mssio.c new file +10 -0
+               // I think this is fine, because dt validation would whinge
+               // about something invalid, but it's the "catch" with my approach.
+               // The other option I considered was to provide a mapping
+               // function pointer that the driver can populate, but I think
+               // that's overkill.
+               function = mpfs_pinctrl_function_map(functions[i]);
+               if (function < 0) {
+                       dev_err(pctrl->dev, "invalid function %s\n", functions[i]);
+                       return function;
+               }

This is fine with me.

Quoted 3 lines

Ideally I would like code that does a lot of string stacking and comparing to be using Rust, but we cannot yet use that in core code so that is for another day.

Yeah, would be nice. My problem with it was more about the point in time where this happens rather than doing it in the first place though.