Skip to contentSkip to conversation

Microchip mpfs/pic64gx pinctrl

PATCH Superseded Conor Dooley 3 participants 11 messages Oct 14, 2025 – Oct 21, 2025

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Conor Dooley

author maintainer
#0 lore raw

v2 cover Microchip mpfs/pic64gx pinctrl

From: Conor Dooley <[email protected]>

Hey folks,

Following from my RFC recently [0] I've got a v2 here that's implemented the change from using the pinmux property to using functions and groups that you asked for Linus.

There's some use of macros to cut down on redefining groups etc multiple times that I figured would help me avoid ADHD mistakes, but I can just get rid of that if you hate it.

I'll follow this with a reply to the gpio2 driver with some comments about the noun use that we discussed on Monday Linus.

I'm not expecting this version to get applied, and it doesn't apply right now due to a missing dep that is the first patch in [1]. I maintain that binding directory though, so it's not as if we wouldn't be able to trivially figure out how to deal with that anyway.

Cheers,
Conor.

0 - https://lore.kernel.org/all/20250926-manpower-glacial-e9756c82b427@spud/
1 - https://lore.kernel.org/all/20251013-posting-alright-8f945a4bebfd@spud/

Conor Dooley (5):
dt-bindings: pinctrl: document pic64gx "gpio2" pinmux
pinctrl: add pic64gx "gpio2" pinmux driver
dt-bindings: pinctrl: document polarfire soc iomux0 pinmux
pinctrl: add polarfire soc iomux0 pinmux driver
MAINTAINERS: add Microchip RISC-V pinctrl drivers/bindings to entry

 .../microchip,mpfs-pinctrl-iomux0.yaml        |  88 +++++
 .../microchip,pic64gx-pinctrl-gpio2.yaml      |  73 ++++
 .../microchip,mpfs-mss-top-sysreg.yaml        |  13 +-
 MAINTAINERS                                   |   4 +
 drivers/pinctrl/Kconfig                       |  14 +
 drivers/pinctrl/Makefile                      |   2 +
 drivers/pinctrl/pinctrl-mpfs-iomux0.c         | 278 ++++++++++++++
 drivers/pinctrl/pinctrl-pic64gx-gpio2.c       | 357 ++++++++++++++++++
 8 files changed, 828 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic64gx-pinctrl-gpio2.yaml
 create mode 100644 drivers/pinctrl/pinctrl-mpfs-iomux0.c
 create mode 100644 drivers/pinctrl/pinctrl-pic64gx-gpio2.c
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH v2 1/5 dt-bindings: pinctrl: document pic64gx "gpio2" pinmux

From: Conor Dooley <[email protected]>

The pic64gx has a second pinmux "downstream" of the iomux0 pinmux. The documentation for the SoC provides no name for this device, but it is used to swap pins between either GPIO controller #2 or select other functions, hence the "gpio2" name. Currently there is no documentation about what each bit actually does that is publicly available, nor (I believe) what pins are affected. That info is as follows:

pin role (1/0)
--- ----------
E14 MAC_0_MDC/GPIO_2_0
E15 MAC_0_MDIO/GPIO_2_1
F16 MAC_1_MDC/GPIO_2_2
F17 MAC_1_MDIO/GPIO_2_3
D19 SPI_0_CLK/GPIO_2_4
B18 SPI_0_SS0/GPIO_2_5
B10 CAN_0_RXBUS/GPIO_2_6
C14 PCIE_PERST_2#/GPIO_2_7
E18 PCIE_WAKE#/GPIO_2_8
D18 PCIE_PERST_1#/GPIO_2_9
E19 SPI_0_DO/GPIO_2_10
C7 SPI_0_DI/GPIO_2_11
D6 QSPI_SS0/GPIO_2_12
D7 QSPI_CLK (B)/GPIO_2_13
C9 QSPI_DATA0/GPIO_2_14
C10 QSPI_DATA1/GPIO_2_15
A5 QSPI_DATA2/GPIO_2_16
A6 QSPI_DATA3/GPIO_2_17
D8 MMUART_3_RXD/GPIO_2_18
D9 MMUART_3_TXD/GPIO_2_19
B8 MMUART_4_RXD/GPIO_2_20
A8 MMUART_4_TXD/GPIO_2_21
C12 CAN_1_TXBUS/GPIO_2_22
B12 CAN_1_RXBUS/GPIO_2_23
A11 CAN_0_TX_EBL_N/GPIO_2_24
A10 CAN_1_TX_EBL_N/GPIO_2_25
D11 MMUART_2_RXD/GPIO_2_26
C11 MMUART_2_TXD/GPIO_2_27
B9 CAN_0_TXBUS/GPIO_2_28

---
 .../microchip,pic64gx-pinctrl-gpio2.yaml      | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic64gx-pinctrl-gpio2.yaml
Documentation/devicetree/bindings/pinctrl/microchip,pic64gx-pinctrl-gpio2.yaml new file +73 -0
new file mode 100644
index 000000000000..07d6befb299c
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/microchip,pic64gx-pinctrl-gpio2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip PIC64GX GPIO2 Mux
+
+maintainers:
+  - Conor Dooley <[email protected]>
+
+description:
+  The "GPIO2 Mux" determines whether GPIO2 or select other functions are
+  available on package pins on PIC64GX. Some of these functions must be
+  mapped to this mux via iomux0 for settings here to have any impact.
+
+properties:
+  compatible:
+    const: microchip,pic64gx-pinctrl-gpio2
+
+  reg:
+    maxItems: 1
+
+  pinctrl-use-default: true
+
+patternProperties:
+  '^mux-':
+    type: object
+    additionalProperties: false
+
+    properties:
+      function:
+        description:
+          A string containing the name of the function to mux to the group.
+        enum: [ mdio0, mdio1, spi0, can0, pcie, qspi, uart3, uart4, can1, uart2, gpio ]
+
+      groups:
+        description:
+          An array of strings. Each string contains the name of a group.
+        items:
+          enum: [ mdio0, mdio1, spi0, can0, pcie, qspi, uart3, uart4, can1, uart2,
+                  gpio_mdio0, gpio_mdio1, gpio_spi0, gpio_can0, gpio_pcie,
+                  gpio_qspi, gpio_uart3, gpio_uart4, gpio_can1, gpio_uart2 ]
+
+    required:
+      - function
+      - groups
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    pinctrl@41000000 {
+      compatible = "microchip,pic64gx-pinctrl-gpio2";
+      reg = <0x41000000 0x4>;
+      pinctrl-use-default;
+      pinctrl-names = "default";
+      pinctrl-0 = <&mdio0_gpio2>, <&mdio1_gpio2>, <&spi0_gpio2>, <&qspi_gpio2>,
+                  <&uart3_gpio2>, <&uart4_gpio2>, <&can1_gpio2>, <&can0_gpio2>,
+                  <&uart2_gpio2>;
+
+      mux-gpio2 {
+        function = "gpio";
+        groups = "gpio_mdio1", "gpio_spi0", "gpio_can0", "gpio_pcie",
+                 "gpio_qspi", "gpio_uart3", "gpio_uart4", "gpio_can1";
+      };
+    };
+
+...
Signature · 1 line
2.51.0
author maintainer
#3 lore raw

PATCH v2 2/5 pinctrl: add pic64gx "gpio2" pinmux driver

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

The pic64gx has a second pinmux "downstream" of the iomux0 pinmux. The documentation for the SoC provides no name for this device, but it is used to swap pins between either GPIO controller #2 or select other functions, hence the "gpio2" name. Add a driver for it.

---
 drivers/pinctrl/Kconfig                 |   7 +
 drivers/pinctrl/Makefile                |   1 +
 drivers/pinctrl/pinctrl-pic64gx-gpio2.c | 357 ++++++++++++++++++++++++
 3 files changed, 365 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-pic64gx-gpio2.c
drivers/pinctrl/Kconfig +7 -0
index 4f8507ebbdac..8b58f50d1184 100644
@@ -486,6 +486,13 @@ config PINCTRL_PIC32MZDA
 	def_bool y if PIC32MZDA
 	select PINCTRL_PIC32
 
+config PINCTRL_PIC64GX
+	bool "pic64gx gpio2 pinctrl driver"
+	depends on ARCH_MICROCHIP
+	default y
+	help
+	  This selects the pinctrl driver for gpio2 on pic64gx.
+
 config PINCTRL_PISTACHIO
 	bool "IMG Pistachio SoC pinctrl driver"
 	depends on OF && (MIPS || COMPILE_TEST)
drivers/pinctrl/Makefile +1 -0
index e0cfb9b7c99b..f33976a6c91b 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_PINCTRL_OCELOT)	+= pinctrl-ocelot.o
 obj-$(CONFIG_PINCTRL_PALMAS)	+= pinctrl-palmas.o
 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_RK805)	+= pinctrl-rk805.o
 obj-$(CONFIG_PINCTRL_ROCKCHIP)	+= pinctrl-rockchip.o
drivers/pinctrl/pinctrl-pic64gx-gpio2.c new file +357 -0

357 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#4 lore raw

PATCH v2 3/5 dt-bindings: pinctrl: document polarfire soc iomux0 pinmux

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

On Polarfire SoC, iomux0 is responsible for routing functions to either Multiprocessor Subsystem (MSS) IOs or to the FPGA fabric, where they can either interface with custom RTL or be routed to the FPGA fabric's IOs. Document it.

---
 .../microchip,mpfs-pinctrl-iomux0.yaml        | 88 +++++++++++++++++++
 .../microchip,mpfs-mss-top-sysreg.yaml        | 13 ++-
 2 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml new file +88 -0
new file mode 100644
index 000000000000..2b718de83a83
@@ -0,0 +1,88 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip PolarFire SoC iomux0
+
+maintainers:
+  - Conor Dooley <[email protected]>
+
+description:
+  iomux0 is responsible for routing some functions to either the FPGA fabric,
+  or to MSSIOs. It only performs muxing, and has no IO configuration role, as
+  fabric IOs are configured separately and just routing a function to MSSIOs is
+  not sufficient for it to actually get mapped to an MSSIO, just makes it
+  possible.
+
+properties:
+  compatible:
+    oneOf:
+      - const: microchip,mpfs-pinctrl-iomux0
+      - items:
+          - const: microchip,pic64gx-pinctrl-iomux0
+          - const: microchip,mpfs-pinctrl-iomux0
+
+  reg:
+    maxItems: 1
+
+  pinctrl-use-default: true
+
+patternProperties:
+  '^mux-':
+    type: object
+    additionalProperties: false
+
+    properties:
+      function:
+        description:
+          A string containing the name of the function to mux to the group.
+        enum: [ spi0, spi1, i2c0, i2c1, can0, can1, qspi, uart0, uart1, uart2,
+                uart3, uart4, mdio0, mdio1 ]
+
+      groups:
+        description:
+          An array of strings. Each string contains the name of a group.
+        items:
+          enum: [ spi0_fabric, spi0_mssio, spi1_fabric, spi1_mssio, i2c0_fabric,
+                  i2c0_mssio, i2c1_fabric, i2c1_mssio, can0_fabric, can0_mssio,
+                  can1_fabric, can1_mssio, qspi_fabric, qspi_mssio,
+                  uart0_fabric, uart0_mssio, uart1_fabric, uart1_mssio,
+                  uart2_fabric, uart2_mssio, uart3_fabric, uart3_mssio,
+                  uart4_fabric, uart4_mssio, mdio0_fabric, mdio0_mssio,
+                  mdio1_fabric, mdio1_mssio ]
+
+    required:
+      - function
+      - groups
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    soc {
+      #size-cells = <1>;
+      #address-cells = <1>;
+
+      pinctrl@200 {
+        compatible = "microchip,mpfs-pinctrl-iomux0";
+        reg = <0x200 0x4>;
+
+        mux-spi0-fabric {
+          function = "spi0";
+          groups = "spi0_fabric";
+        };
+
+        mux-spi1-mssio {
+          function = "spi1";
+          groups = "spi1_mssio";
+        };
+      };
+    };
+
+...
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml +12 -1
index 1ab691db8795..39987f722411 100644
@@ -18,10 +18,17 @@ properties:
     items:
       - const: microchip,mpfs-mss-top-sysreg
       - const: syscon
+      - const: simple-mfd
 
   reg:
     maxItems: 1
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
   '#reset-cells':
     description:
       The AHB/AXI peripherals on the PolarFire SoC have reset support, so
@@ -31,6 +38,10 @@ properties:
       of PolarFire clock/reset IDs.
     const: 1
 
+  pinctrl@200:
+    type: object
+    $ref: /schemas/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
+
 required:
   - compatible
   - reg
@@ -40,7 +51,7 @@ additionalProperties: false
 examples:
   - |
     syscon@20002000 {
-      compatible = "microchip,mpfs-mss-top-sysreg", "syscon";
+      compatible = "microchip,mpfs-mss-top-sysreg", "syscon", "simple-mfd";
       reg = <0x20002000 0x1000>;
       #reset-cells = <1>;
     };
Signature · 1 line
2.51.0
author maintainer
#6 lore raw

PATCH v2 4/5 pinctrl: add polarfire soc iomux0 pinmux driver

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

On Polarfire SoC, iomux0 is responsible for routing functions to either Multiprocessor Subsystem (MSS) IOs or to the FPGA fabric, where they can either interface with custom RTL or be routed to the FPGA fabric's IOs. Add a driver for it.

---
 drivers/pinctrl/Kconfig               |   7 +
 drivers/pinctrl/Makefile              |   1 +
 drivers/pinctrl/pinctrl-mpfs-iomux0.c | 278 ++++++++++++++++++++++++++
 3 files changed, 286 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-mpfs-iomux0.c
drivers/pinctrl/Kconfig +7 -0
index 8b58f50d1184..1772f63fca1b 100644
@@ -504,6 +504,13 @@ config PINCTRL_PISTACHIO
 	help
 	  This support pinctrl and GPIO driver for IMG Pistachio SoC.
 
+config PINCTRL_POLARFIRE_SOC
+	bool "Polarfire SoC pinctrl driver"
+	depends on ARCH_MICROCHIP
+	default y
+	help
+	  This selects the pinctrl driver for Microchip Polarfire SoC.
+
 config PINCTRL_RK805
 	tristate "Pinctrl and GPIO driver for RK805 PMIC"
 	depends on MFD_RK8XX
drivers/pinctrl/Makefile +1 -0
index f33976a6c91b..ea4e890766e1 100644
@@ -50,6 +50,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-iomux0.o
 obj-$(CONFIG_PINCTRL_RK805)	+= pinctrl-rk805.o
 obj-$(CONFIG_PINCTRL_ROCKCHIP)	+= pinctrl-rockchip.o
 obj-$(CONFIG_PINCTRL_RP1)       += pinctrl-rp1.o
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +278 -0

278 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#8 lore raw

PATCH v2 5/5 MAINTAINERS: add Microchip RISC-V pinctrl drivers/bindings to entry

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

Add the new gpio2 and iomux0 drivers and bindings to the existing entry for Microchip RISC-V devices.

---
 MAINTAINERS | 4 ++++
 1 file changed, 4 insertions(+)
MAINTAINERS +4 -0
index 46126ce2f968..5d4825073fcd 100644
@@ -22089,6 +22089,8 @@ F:	Documentation/devicetree/bindings/gpio/microchip,mpfs-gpio.yaml
 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,pic64gx-pinctrl-gpio2.yaml
 F:	Documentation/devicetree/bindings/pwm/microchip,corepwm.yaml
 F:	Documentation/devicetree/bindings/riscv/microchip.yaml
 F:	Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-sys-controller.yaml
@@ -22102,6 +22104,8 @@ F:	drivers/gpio/gpio-mpfs.c
 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-pic64gx-gpio2.c
 F:	drivers/pwm/pwm-microchip-core.c
 F:	drivers/reset/reset-mpfs.c
 F:	drivers/rtc/rtc-mpfs.c
Signature · 1 line
2.51.0
author maintainer
#7 lore raw

Re: [PATCH v2 4/5] pinctrl: add polarfire soc iomux0 pinmux driver

In reply to Conor Dooley

So, w.r.t. the correct wording, and whether "pin" etc are appropriate to use...

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 37

Quoted 13 lines · Conor Dooley
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +13 -0
+struct mpfs_iomux0_pinctrl {
+	struct pinctrl_dev *pctrl;
+	struct device *dev;
+	struct regmap *regmap;
+	struct pinctrl_desc desc;
+};
+
+struct mpfs_iomux0_pin_group {
+	const char *name;
+	const unsigned int *pins;
+	u32 mask;
+	u32 setting;
+};

"pin group" here could be "peripheral routing", similarly "pin" could be replaced by "peripheral", that's the wording that's most commonly used our docs and I just don't have many ideas about good alternative to function!

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 41

Quoted 4 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +4 -0
+
+struct mpfs_iomux0_function {
+	const char *name;
+	const char * const *groups;

groups would then be routing

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 44

Quoted 3 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +3 -0
+};
+
+static const struct pinctrl_pin_desc mpfs_iomux0_pins[] = {

static const struct pinctrl_pin_desc mpfs_iomux_peripherals

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 45

Quoted 1 line
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +1 -0
+	PINCTRL_PIN(0, "spi0"),

then this would be MPFS_PERIPHERAL or something, but the same actual macro contents in order to ideally retain use of pinctrl_pin_desc.

Quoted 6 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +6 -0
+	PINCTRL_PIN(1, "spi1"),
+	PINCTRL_PIN(2, "i2c0"),
+	PINCTRL_PIN(3, "i2c1"),
+	PINCTRL_PIN(4, "can0"),
+	PINCTRL_PIN(5, "can1"),
+	PINCTRL_PIN(6, "qspi"),

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 61

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+	PINCTRL_PIN(7, "uart0"),
+	PINCTRL_PIN(8, "uart1"),
+	PINCTRL_PIN(9, "uart2"),
+	PINCTRL_PIN(10, "uart3"),
+	PINCTRL_PIN(11, "uart4"),
+	PINCTRL_PIN(12, "mdio0"),
+	PINCTRL_PIN(13, "mdio1"),
+};
+
+static const unsigned int mpfs_iomux0_spi0_pins[] = { 0 };

s/_pins// maybe.

Quoted 5 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +5 -0
+static const unsigned int mpfs_iomux0_spi1_pins[] = { 1 };
+static const unsigned int mpfs_iomux0_i2c0_pins[] = { 2 };
+static const unsigned int mpfs_iomux0_i2c1_pins[] = { 3 };
+static const unsigned int mpfs_iomux0_can0_pins[] = { 4 };
+static const unsigned int mpfs_iomux0_can1_pins[] = { 5 };

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 76

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+static const unsigned int mpfs_iomux0_qspi_pins[] = { 6 };
+static const unsigned int mpfs_iomux0_uart0_pins[] = { 7 };
+static const unsigned int mpfs_iomux0_uart1_pins[] = { 8 };
+static const unsigned int mpfs_iomux0_uart2_pins[] = { 9 };
+static const unsigned int mpfs_iomux0_uart3_pins[] = { 10 };
+static const unsigned int mpfs_iomux0_uart4_pins[] = { 11 };
+static const unsigned int mpfs_iomux0_mdio0_pins[] = { 12 };
+static const unsigned int mpfs_iomux0_mdio1_pins[] = { 13 };
+
+#define MPFS_IOMUX0_GROUP(_name) { \

s/GROUPS/ROUTINGS/

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 85

Quoted 9 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +9 -0
+	.name = #_name "_mssio",	\
+	.pins = mpfs_iomux0_##_name##_pins,	\
+	.mask = BIT(mpfs_iomux0_##_name##_pins[0]),	\
+	.setting = 0x0,	\
+}, { \
+	.name = #_name "_fabric",	\
+	.pins = mpfs_iomux0_##_name##_pins,	\
+	.mask = BIT(mpfs_iomux0_##_name##_pins[0]),	\
+	.setting = BIT(mpfs_iomux0_##_name##_pins[0]),	\

idk what you think of these macros, but I feel like they reduced my changes of making a mistake..

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 88

Quoted 3 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +3 -0
+}
+
+static const struct mpfs_iomux0_pin_group mpfs_iomux0_pin_groups[] = {

s/pin_group/peripheral_routing/

Quoted 7 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +7 -0
+	MPFS_IOMUX0_GROUP(spi0),
+	MPFS_IOMUX0_GROUP(spi1),
+	MPFS_IOMUX0_GROUP(i2c0),
+	MPFS_IOMUX0_GROUP(i2c1),
+	MPFS_IOMUX0_GROUP(can0),
+	MPFS_IOMUX0_GROUP(can1),
+	MPFS_IOMUX0_GROUP(qspi),

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 105

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+	MPFS_IOMUX0_GROUP(uart0),
+	MPFS_IOMUX0_GROUP(uart1),
+	MPFS_IOMUX0_GROUP(uart2),
+	MPFS_IOMUX0_GROUP(uart3),
+	MPFS_IOMUX0_GROUP(uart4),
+	MPFS_IOMUX0_GROUP(mdio0),
+	MPFS_IOMUX0_GROUP(mdio1),
+};
+
+static const char * const mpfs_iomux0_spi0_groups[] = { "spi0_mssio", "spi0_fabric" };

s/groups/routings/

Quoted 28 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +28 -0
+static const char * const mpfs_iomux0_spi1_groups[] = { "spi1_mssio", "spi1_fabric" };
+static const char * const mpfs_iomux0_i2c0_groups[] = { "i2c0_mssio", "i2c0_fabric" };
+static const char * const mpfs_iomux0_i2c1_groups[] = { "i2c1_mssio", "i2c1_fabric" };
+static const char * const mpfs_iomux0_can0_groups[] = { "can0_mssio", "can0_fabric" };
+static const char * const mpfs_iomux0_can1_groups[] = { "can1_mssio", "can1_fabric" };
+static const char * const mpfs_iomux0_qspi_groups[] = { "qspi_mssio", "qspi_fabric" };
+static const char * const mpfs_iomux0_uart0_groups[] = { "uart0_mssio", "uart0_fabric" };
+static const char * const mpfs_iomux0_uart1_groups[] = { "uart1_mssio", "uart1_fabric" };
+static const char * const mpfs_iomux0_uart2_groups[] = { "uart2_mssio", "uart2_fabric" };
+static const char * const mpfs_iomux0_uart3_groups[] = { "uart3_mssio", "uart3_fabric" };
+static const char * const mpfs_iomux0_uart4_groups[] = { "uart4_mssio", "uart4_fabric" };
+static const char * const mpfs_iomux0_mdio0_groups[] = { "mdio0_mssio", "mdio0_fabric" };
+static const char * const mpfs_iomux0_mdio1_groups[] = { "mdio1_mssio", "mdio1_fabric" };
+
+#define MPFS_IOMUX0_FUNCTION(_name) { \
+	.name = #_name,	\
+	.groups = mpfs_iomux0_##_name##_groups,	\
+}
+
+static const struct mpfs_iomux0_function mpfs_iomux0_functions[] = {
+	MPFS_IOMUX0_FUNCTION(spi0),
+	MPFS_IOMUX0_FUNCTION(spi1),
+	MPFS_IOMUX0_FUNCTION(i2c0),
+	MPFS_IOMUX0_FUNCTION(i2c1),
+	MPFS_IOMUX0_FUNCTION(can0),
+	MPFS_IOMUX0_FUNCTION(can1),
+	MPFS_IOMUX0_FUNCTION(qspi),
+	MPFS_IOMUX0_FUNCTION(uart0),

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 143

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+	MPFS_IOMUX0_FUNCTION(uart1),
+	MPFS_IOMUX0_FUNCTION(uart2),
+	MPFS_IOMUX0_FUNCTION(uart3),
+	MPFS_IOMUX0_FUNCTION(uart4),
+	MPFS_IOMUX0_FUNCTION(mdio0),
+	MPFS_IOMUX0_FUNCTION(mdio1),
+};
+
+static void mpfs_iomux0_pin_dbg_show(struct pinctrl_dev *pctrl_dev, struct seq_file *seq,
+				     unsigned int pin)

for this function, pin -> peripheral

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 156

Quoted 13 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +13 -0
+{
+	struct mpfs_iomux0_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
+	u32 val;
+
+	seq_printf(seq, "reg: %x, pin: %u ", MPFS_IOMUX0_REG, pin);
+
+	regmap_read(pctrl->regmap, MPFS_IOMUX0_REG, &val);
+	val = (val & BIT(pin)) >> pin;
+
+	seq_printf(seq, "val: %x\n", val);
+}
+
+static int mpfs_iomux0_groups_count(struct pinctrl_dev *pctldev)

group -> routing

Quoted 12 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +12 -0
+{
+	return ARRAY_SIZE(mpfs_iomux0_pin_groups);
+}
+
+static const char *mpfs_iomux0_group_name(struct pinctrl_dev *pctldev, unsigned int selector)
+{
+	return mpfs_iomux0_pin_groups[selector].name;
+}
+
+static int mpfs_iomux0_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
+				  const unsigned int **pins, unsigned int *num_pins)
+{

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 178

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+	*pins = mpfs_iomux0_pin_groups[selector].pins;
+	*num_pins = 1;
+
+	return 0;
+}
+
+static const struct pinctrl_ops mpfs_iomux0_pinctrl_ops = {
+	.get_groups_count = mpfs_iomux0_groups_count,
+	.get_group_name = mpfs_iomux0_group_name,
+	.get_group_pins = mpfs_iomux0_group_pins,

obviously here, the left hand side wouldn't be changeable if the common pinctrl stuff is to be used.

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 185

Quoted 7 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +7 -0
+	.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
+	.dt_free_map = pinctrl_utils_free_map,
+	.pin_dbg_show = mpfs_iomux0_pin_dbg_show,
+};
+
+static int mpfs_iomux0_pinmux_set_mux(struct pinctrl_dev *pctrl_dev, unsigned int fsel,
+				      unsigned int gsel)

maybe this is s/pinmux_//

Quoted 20 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +20 -0
+{
+	struct mpfs_iomux0_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
+	struct device *dev = pctrl->dev;
+	const struct mpfs_iomux0_pin_group *group;
+	const struct mpfs_iomux0_function *function;
+
+	group = &mpfs_iomux0_pin_groups[gsel];
+	function = &mpfs_iomux0_functions[fsel];
+
+	dev_dbg(dev, "Setting func %s mask %x setting %x\n",
+		function->name, group->mask, group->setting);
+	regmap_assign_bits(pctrl->regmap, MPFS_IOMUX0_REG, group->mask, group->setting);
+
+	return 0;
+}
+
+static int mpfs_iomux0_pinmux_get_funcs_count(struct pinctrl_dev *pctldev)
+{
+	return ARRAY_SIZE(mpfs_iomux0_functions);
+}

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 215

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+
+static const char *mpfs_iomux0_pinmux_get_func_name(struct pinctrl_dev *pctldev,
+						    unsigned int selector)
+{
+	return mpfs_iomux0_functions[selector].name;
+}
+
+static int mpfs_iomux0_pinmux_get_groups(struct pinctrl_dev *pctldev, unsigned int selector,
+					 const char * const **groups,
+					 unsigned int * const num_groups)

groups references here would become routings, as above.

Quoted 20 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +20 -0
+{
+	*groups = mpfs_iomux0_functions[selector].groups;
+	*num_groups = 2;
+
+	return 0;
+}
+
+static const struct pinmux_ops mpfs_iomux0_pinmux_ops = {
+	.get_functions_count = mpfs_iomux0_pinmux_get_funcs_count,
+	.get_function_name = mpfs_iomux0_pinmux_get_func_name,
+	.get_function_groups = mpfs_iomux0_pinmux_get_groups,
+	.set_mux = mpfs_iomux0_pinmux_set_mux,
+};
+
+static int mpfs_iomux0_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct mpfs_iomux0_pinctrl *pctrl;
+
+	pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);

drivers/pinctrl/pinctrl-mpfs-iomux0.c line 245

Quoted 10 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +10 -0
+	if (!pctrl)
+		return -ENOMEM;
+
+	pctrl->regmap = device_node_to_regmap(pdev->dev.parent->of_node);
+	if (IS_ERR(pctrl->regmap))
+		dev_err_probe(dev, PTR_ERR(pctrl->regmap), "Failed to find syscon regmap\n");
+
+	pctrl->desc.name = dev_name(dev);
+	pctrl->desc.pins = mpfs_iomux0_pins;
+	pctrl->desc.npins = ARRAY_SIZE(mpfs_iomux0_pins);

similar here, can't really change the names what's in desc if I want to use the pinctrl core features, right? Well, I suppose I /could/ but it'd have to be the same struct layout and get cast, and I really don't like that idea very much! Or something funny with macros to obfuscate, but I don't think that is ultimately very beneficial either.

Quoted 36 lines
drivers/pinctrl/pinctrl-mpfs-iomux0.c new file +33 -0
+	pctrl->desc.pctlops = &mpfs_iomux0_pinctrl_ops;
+	pctrl->desc.pmxops = &mpfs_iomux0_pinmux_ops;
+	pctrl->desc.owner = THIS_MODULE;
+
+	pctrl->dev = dev;
+
+	platform_set_drvdata(pdev, pctrl);
+
+	pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &pctrl->desc, pctrl);
+	if (IS_ERR(pctrl->pctrl))
+		return PTR_ERR(pctrl->pctrl);
+
+	return 0;
+}
+
+static const struct of_device_id mpfs_iomux0_of_match[] = {
+	{ .compatible = "microchip,mpfs-pinctrl-iomux0" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, mpfs_iomux0_of_match);
+
+static struct platform_driver mpfs_iomux0_driver = {
+	.driver = {
+		.name = "mpfs-pinctrl-iomux0",
+		.of_match_table = mpfs_iomux0_of_match,
+	},
+	.probe = mpfs_iomux0_probe,
+};
+module_platform_driver(mpfs_iomux0_driver);
+
+MODULE_AUTHOR("Conor Dooley <[email protected]>");
+MODULE_DESCRIPTION("Polarfire SoC iomux0 pinctrl driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.51.0
maintainer Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] dt-bindings: pinctrl: document pic64gx "gpio2" pinmux

In reply to Conor Dooley
Quoted 41 lines · Conor Dooley

From: Conor Dooley <[email protected]>

The pic64gx has a second pinmux "downstream" of the iomux0 pinmux. The documentation for the SoC provides no name for this device, but it is used to swap pins between either GPIO controller #2 or select other functions, hence the "gpio2" name. Currently there is no documentation about what each bit actually does that is publicly available, nor (I believe) what pins are affected. That info is as follows:

pin role (1/0)
--- ----------
E14 MAC_0_MDC/GPIO_2_0
E15 MAC_0_MDIO/GPIO_2_1
F16 MAC_1_MDC/GPIO_2_2
F17 MAC_1_MDIO/GPIO_2_3
D19 SPI_0_CLK/GPIO_2_4
B18 SPI_0_SS0/GPIO_2_5
B10 CAN_0_RXBUS/GPIO_2_6
C14 PCIE_PERST_2#/GPIO_2_7
E18 PCIE_WAKE#/GPIO_2_8
D18 PCIE_PERST_1#/GPIO_2_9
E19 SPI_0_DO/GPIO_2_10
C7 SPI_0_DI/GPIO_2_11
D6 QSPI_SS0/GPIO_2_12
D7 QSPI_CLK (B)/GPIO_2_13
C9 QSPI_DATA0/GPIO_2_14
C10 QSPI_DATA1/GPIO_2_15
A5 QSPI_DATA2/GPIO_2_16
A6 QSPI_DATA3/GPIO_2_17
D8 MMUART_3_RXD/GPIO_2_18
D9 MMUART_3_TXD/GPIO_2_19
B8 MMUART_4_RXD/GPIO_2_20
A8 MMUART_4_TXD/GPIO_2_21
C12 CAN_1_TXBUS/GPIO_2_22
B12 CAN_1_RXBUS/GPIO_2_23
A11 CAN_0_TX_EBL_N/GPIO_2_24
A10 CAN_1_TX_EBL_N/GPIO_2_25
D11 MMUART_2_RXD/GPIO_2_26
C11 MMUART_2_TXD/GPIO_2_27
B9 CAN_0_TXBUS/GPIO_2_28

Quoted 6 lines
---
 .../microchip,pic64gx-pinctrl-gpio2.yaml      | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic64gx-pinctrl-gpio2.yaml
maintainer Reviewed-by on v2 3/5
#5 lore raw

Re: [PATCH v2 3/5] dt-bindings: pinctrl: document polarfire soc iomux0 pinmux

In reply to Conor Dooley
Quoted 7 lines · Conor Dooley

From: Conor Dooley <[email protected]>

On Polarfire SoC, iomux0 is responsible for routing functions to either Multiprocessor Subsystem (MSS) IOs or to the FPGA fabric, where they can either interface with custom RTL or be routed to the FPGA fabric's IOs. Document it.

Quoted 7 lines
---
 .../microchip,mpfs-pinctrl-iomux0.yaml        | 88 +++++++++++++++++++
 .../microchip,mpfs-mss-top-sysreg.yaml        | 13 ++-
 2 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,mpfs-pinctrl-iomux0.yaml
#9 lore raw
In reply to Conor Dooley
Quoted 5 lines · Conor Dooley

From: Conor Dooley <[email protected]>

Following from my RFC recently [0] I've got a v2 here that's implemented the change from using the pinmux property to using functions and groups that you asked for Linus.

Overall I'm very happy with what I see, I see there are some comments and my only comment would be to add

depends on ARCH_MICROCHIP || COMPILE_TEST

on the drivers so they get some proper compile testing, and I expect we can apply v3.

Yours,
Linus Walleij

author maintainer
#10 lore raw
Quoted 8 lines · Linus Walleij
Quoted 5 lines · Conor Dooley

From: Conor Dooley <[email protected]>

Following from my RFC recently [0] I've got a v2 here that's implemented the change from using the pinmux property to using functions and groups that you asked for Linus.

Quoted 7 lines

Overall I'm very happy with what I see, I see there are some comments and my only comment would be to add

depends on ARCH_MICROCHIP || COMPILE_TEST

on the drivers so they get some proper compile testing, and I expect we can apply v3.

Oh, that's a silly one to forget about. I'll do that and just delete the TODO line that I had in there, since you've not objected to the macro use.

Thanks,
Conor.