mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override
@ 2026-11-15 13:27 Vincent Jardin via B4 Relay
  2026-11-15 13:27 ` [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux Vincent Jardin via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-15 13:27 UTC (permalink / raw)
  To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer
  Cc: linux-gpio, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, Vladimir Oltean, Ioana Ciornei,
	Vincent Jardin

The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ and EVT pads from
fields of the RCW. They are read-only in RCWSR12..14 of DCFG, and are
changed at runtime through the override registers in the DCSR view of
DCFG, which read 0 until written.

Since commit 8a1365c7bbc1 ("arm64: dts: lx2160a: add pinmux and i2c
gpio to support bus recovery"), fsl-lx216x.dtsi drives the override
registers with pinctrl-single for the I2C bus recovery. Its first pin
state clears every other field of the word: a board whose RCW programs
a non-zero pad mux loses those pads at the first I2C probe.

This series reads the fields in effect from RCWSR and writes RCWCR, as
fsl_guts_rcw_rmw() already does for the SerDes protocols:

- patches 1 and 2 describe the pad mux as a child of the DCFG node
- patch 3 exports the RCW override of fsl-guts for the pad-mux fields
  only
- patch 4 adds the pinctrl driver: one group per RCW field, one
  function per encoding
- patch 5 moves the pad muxes of fsl-lx216x.dtsi under DCFG, which
  gains its DCSR view. Labels and pin node names stay, so no board
  file changes, and the pinctrl-single node is removed

Patch 4 uses the exports of patch 3, so it cannot be applied alone:
patches 1 to 4 could be for the the pinctrl tree with an Ack of
the soc/fsl maintainer on patch 3,
and patch 5 through the i.MX tree once the driver is in,
since the I2C pin states of fsl-lx216x.dtsi then belong to it.

DTBs built before patch 5 keep their pinctrl-single node and behave as
before. There is no Fixes: tag, since patch 5 depends on a new driver.
I did not believe it should be backported then.

Tested on a Nodebox v3 (LX2160A) whose RCW muxes XSPI1_A_DATA[7:4],
SDHC1 and IIC5 are not set with the defaults, so I could confirm:
 - with pinctrl-single the first I2C probe cleared those fields
 - with this series RCWSR12..14 read after boot exactly what the RCW and
   the board's pin states select
 - all I2C controllers come up with their recovery states and a
   forced bus recovery on IIC1 (multi-master enabled for the test)
   changes only that field
 - RCWSR27 reads what the RCW selects for EC1, EC2, USB_EXT, GTX_CLK
   and SDHC1_DS. Selecting SDHC1_DS again from debugfs is the first
   override of that word, and keeps its other fields

Thanks to Vladimir Oltean for pointing at fsl_guts_rcw_rmw() when I
tried to prime the override registers from the RCW instead:
https://github.com/nxp-qoriq/rcw/pull/8

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
Changes in v6:
- pinctrl: the driver is no longer specific to the LX2160A, so that
  other Layerscape SoCs can be added to it: pinctrl-layerscape-rcw.c
  (suggested by Vladimir Oltean)
- Patches 1, 2 and 5 are not changed
- Link to v5: https://lore.kernel.org/r/20261115-for-upstream-lx2160a-rcw-pinmux-v1-v5-0-d246166ea469@free.fr

Changes in v5:
- soc: fsl: guts: the exports become fsl_guts_pmux_read(),
  fsl_guts_pmux_override() and fsl_guts_pmux_override_supported(). guts
  lists the pad-mux fields of the LX2160A and refuses any other field
  or register, so the serdes fields cannot be changed (Vladimir Oltean)
- dt-bindings, pinctrl, dts: add the EC1, EC2, USB_EXT, GTX_CLK and
  SDHC1_DS pad muxes of RCWSR27, the second reg of the node (Vladimir Oltean)
- Patch 3 is reworked: drop the review tags, new round of review is
  needed (TBC, from Christophe Leroy and Frank Li)
- Patch 1 gets a reg, 5 groups and 4 functions:
  same drop the the Reviewed-by of Rob Herring and Frank Li
- Patch 2: its description names RCWSR27 too, I assume the
  Reviewed-by of Rob Herring can remain
- Link to v4: https://lore.kernel.org/r/20261114-for-upstream-lx2160a-rcw-pinmux-v1-v4-0-eefcea066a55@free.fr

Changes in v4:
- pinctrl: MAINTAINERS with imx@lists.linux.dev
  FUNC and GROUP macros with LX2160A_PMUX_ prefix (Frank Li)
- Add the Reviewed and Ack tags of Rob Herring and Frank Li
- Patches 1, 2, 3 and 5 are not changed
- Link to v3: https://lore.kernel.org/r/20261108-for-upstream-lx2160a-rcw-pinmux-v1-v3-0-5a0063f1da9e@free.fr

Changes in v3:
- dt-bindings, dts: the pad-mux child is bus-addressed like the
  clock-controller child of the LS1028A dcfg: its reg is the RCWSR12
  to RCWSR14 window, under #address-cells, #size-cells and ranges on
  the dcfg node, the override registers stay the DCSR view of the
  parent (Krzysztof Kozlowski)
- cover letter: patch 4 cannot be applied without patch 3 (Linus Walleij)
- Patches 3 and 4 are unchanged
- Link to v2: https://lore.kernel.org/r/20261103-for-upstream-lx2160a-rcw-pinmux-v1-v2-0-3aad0860b984@free.fr

Changes in v2:
- dt-bindings: list, for each function, the groups, so the
  schema refuses the associations the driver refuses (Frank Li)
- Patches 2 to 5 are unchanged
- Link to v1: https://lore.kernel.org/r/20261103-for-upstream-lx2160a-rcw-pinmux-v1-v1-0-0a61a9837744@free.fr

---
Vincent Jardin (5):
      dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux
      dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child
      soc: fsl: guts: add the RCW override of the pad muxes
      pinctrl: freescale: add the Layerscape RCW pad-mux driver
      arm64: dts: lx2160a: describe the pad muxes as the DCFG RCW override

 .../bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml   | 309 +++++++++++++++
 .../bindings/soc/fsl/fsl,layerscape-dcfg.yaml      |  18 +
 MAINTAINERS                                        |   8 +
 arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi      | 377 +++++++++---------
 drivers/pinctrl/freescale/Kconfig                  |  15 +
 drivers/pinctrl/freescale/Makefile                 |   1 +
 drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c | 427 +++++++++++++++++++++
 drivers/soc/fsl/guts.c                             | 125 +++++-
 include/linux/fsl/guts.h                           |   3 +
 9 files changed, 1107 insertions(+), 176 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261103-for-upstream-lx2160a-rcw-pinmux-v1-31f9ad97dc86

Best regards,
-- 
Vincent Jardin <vjardin@free.fr>



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux
  2026-11-15 13:27 [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override Vincent Jardin via B4 Relay
@ 2026-11-15 13:27 ` Vincent Jardin via B4 Relay
  2026-11-16 17:02   ` Frank Li
  2026-11-15 13:27 ` [PATCH v6 2/5] dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child Vincent Jardin via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-15 13:27 UTC (permalink / raw)
  To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer
  Cc: linux-gpio, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, Vladimir Oltean, Ioana Ciornei,
	Vincent Jardin

From: Vincent Jardin <vjardin@free.fr>

The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ, EVT, EC and USB pads
from fields of the RCW: read-only in RCWSR12..14 and RCWSR27 of DCFG,
changed at runtime through the override registers of its DCSR view.

Describe the pad mux as a child of DCFG at its RCWSR12 to RCWSR14 and
RCWSR27 windows: the override registers are at the same offsets of the
DCSR view of the parent. One group per RCW field, one function per
encoding.

Each function lists the groups that take it, so a pair the driver
would refuse, such as can on iic1, is refused by the schema.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 .../bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml   | 309 +++++++++++++++++++++
 1 file changed, 309 insertions(+)

diff --git a/Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml b/Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml
new file mode 100644
index 000000000000..f835ebe332a9
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml
@@ -0,0 +1,309 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/fsl,lx2160a-rcw-pinmux.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP LX2160A RCW pad muxes
+
+maintainers:
+  - Vincent Jardin <vjardin@free.fr>
+
+description:
+  The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ, EVT, EC and USB pads based
+  on its RCW. The related fields are from the read-only RCWSR12 to RCWSR14 and
+  RCWSR27 registers of DCFG, and can be changed at runtime by writing the RCW
+  override registers in the DCSR view of DCFG. The node is a child of the DCFG
+  node, which owns both views. Its reg are the RCWSR12 to RCWSR14 and the
+  RCWSR27 windows of the CCSR view, and the override registers are at the same
+  offsets of the DCSR view.
+
+properties:
+  compatible:
+    const: fsl,lx2160a-rcw-pinmux
+
+  reg:
+    items:
+      - description: RCWSR12 to RCWSR14
+      - description: RCWSR27
+
+patternProperties:
+  '-pins$':
+    type: object
+    $ref: pinmux-node.yaml#
+    additionalProperties: false
+
+    properties:
+      function:
+        enum: [ asleep, can, evt, flexspi, flextimer, gpio, gtx-clk, i2c,
+                irq, reset-req, rgmii, sdhc, sdhc-clk, sdhc-data, sdhc-data4,
+                sdhc-spi, spi, tsec-1588, uart, uart3, uart4, usb ]
+
+      groups:
+        items:
+          enum: [ iic1, iic2, iic3, iic4, iic5, iic6, xspi1-data74,
+                  xspi1-data30, xspi1-base, sdhc1-base, sdhc1-dir,
+                  sdhc2-data74, sdhc2-base, uart1-soutsin, uart1-rtscts,
+                  uart2-soutsin, uart2-rtscts, irq11-8, irq7-4, irq3-0,
+                  evt4-3, evt2-0, clk-out, asleep, reset-req, ec1, ec2,
+                  usb-ext, gtx-clk, sdhc1-ds ]
+
+    required:
+      - function
+      - groups
+
+    allOf:
+      - if:
+          properties:
+            function:
+              const: asleep
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ asleep ]
+
+      - if:
+          properties:
+            function:
+              const: can
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic3, iic4 ]
+
+      - if:
+          properties:
+            function:
+              const: evt
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic3, iic4, evt4-3, evt2-0, asleep ]
+
+      - if:
+          properties:
+            function:
+              const: flexspi
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ xspi1-data74, xspi1-data30, xspi1-base,
+                        sdhc2-data74, sdhc2-base ]
+
+      - if:
+          properties:
+            function:
+              const: flextimer
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic2, irq7-4, irq3-0, evt4-3, evt2-0, clk-out ]
+
+      - if:
+          properties:
+            function:
+              const: gpio
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic2, iic3, iic4, iic5, iic6, xspi1-data74,
+                        xspi1-data30, xspi1-base, sdhc1-base, sdhc1-dir,
+                        sdhc2-data74, sdhc2-base, uart1-soutsin,
+                        uart1-rtscts, uart2-soutsin, uart2-rtscts,
+                        irq11-8, irq7-4, irq3-0, evt4-3, evt2-0, clk-out,
+                        asleep, reset-req, iic1, ec1, ec2, usb-ext, gtx-clk,
+                        sdhc1-ds ]
+
+      - if:
+          properties:
+            function:
+              const: gtx-clk
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ gtx-clk ]
+
+      - if:
+          properties:
+            function:
+              const: i2c
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic2, iic3, iic4, iic5, iic6, sdhc2-data74, iic1 ]
+
+      - if:
+          properties:
+            function:
+              const: irq
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ irq11-8, irq7-4, irq3-0 ]
+
+      - if:
+          properties:
+            function:
+              const: reset-req
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ reset-req ]
+
+      - if:
+          properties:
+            function:
+              const: rgmii
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ ec1, ec2 ]
+
+      - if:
+          properties:
+            function:
+              const: sdhc
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic2, sdhc1-base, sdhc1-dir, sdhc2-data74,
+                        sdhc2-base, sdhc1-ds ]
+
+      - if:
+          properties:
+            function:
+              const: sdhc-clk
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic5, iic6 ]
+
+      - if:
+          properties:
+            function:
+              const: sdhc-data
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ sdhc1-dir ]
+
+      - if:
+          properties:
+            function:
+              const: sdhc-data4
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ sdhc1-base ]
+
+      - if:
+          properties:
+            function:
+              const: sdhc-spi
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ sdhc1-base ]
+
+      - if:
+          properties:
+            function:
+              const: spi
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ iic5, sdhc1-base, sdhc1-dir, sdhc2-base, sdhc1-ds ]
+
+      - if:
+          properties:
+            function:
+              const: tsec-1588
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ ec2 ]
+
+      - if:
+          properties:
+            function:
+              const: uart
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ uart1-soutsin, uart1-rtscts, uart2-soutsin,
+                        uart2-rtscts ]
+
+      - if:
+          properties:
+            function:
+              const: uart3
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ uart1-rtscts ]
+
+      - if:
+          properties:
+            function:
+              const: uart4
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ uart2-rtscts ]
+
+      - if:
+          properties:
+            function:
+              const: usb
+        then:
+          properties:
+            groups:
+              items:
+                enum: [ usb-ext ]
+
+required:
+  - compatible
+  - reg
+
+allOf:
+  - $ref: pinctrl.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    pinctrl@12c {
+        compatible = "fsl,lx2160a-rcw-pinmux";
+        reg = <0x12c 0xc>, <0x168 0x4>;
+
+        iic3-i2c-pins {
+            function = "i2c";
+            groups = "iic3";
+        };
+
+        iic3-gpio-pins {
+            function = "gpio";
+            groups = "iic3";
+        };
+    };

-- 
2.43.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 2/5] dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child
  2026-11-15 13:27 [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override Vincent Jardin via B4 Relay
  2026-11-15 13:27 ` [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux Vincent Jardin via B4 Relay
@ 2026-11-15 13:27 ` Vincent Jardin via B4 Relay
  2026-11-16 17:04   ` Frank Li
  2026-11-15 13:27 ` [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes Vincent Jardin via B4 Relay
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-15 13:27 UTC (permalink / raw)
  To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer
  Cc: linux-gpio, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, Vladimir Oltean, Ioana Ciornei,
	Vincent Jardin

From: Vincent Jardin <vjardin@free.fr>

On the LX2160A the DCFG node holds the pad mux, overridden through its
DCSR view. Allow fsl,lx2160a-dcfg with simple-mfd, so that the child is
populated, and the pinctrl child, on the LX2160A only.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 .../bindings/soc/fsl/fsl,layerscape-dcfg.yaml          | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml b/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml
index fc14fd0bf84b..bb9dbcfec188 100644
--- a/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml
+++ b/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml
@@ -32,6 +32,7 @@ properties:
       - items:
           - enum:
               - fsl,ls1028a-dcfg
+              - fsl,lx2160a-dcfg
           - const: syscon
           - const: simple-mfd
 
@@ -66,10 +67,27 @@ patternProperties:
   "^clock-controller@[0-9a-f]+$":
     $ref: /schemas/clock/fsl,flexspi-clock.yaml#
 
+  "^pinctrl@[0-9a-f]+$":
+    $ref: /schemas/pinctrl/fsl,lx2160a-rcw-pinmux.yaml#
+    description:
+      The pad muxes of the RCW on the LX2160A, at their RCWSR12 to RCWSR14
+      and RCWSR27 windows, overridden through the DCSR view of this block.
+
 required:
   - compatible
   - reg
 
+allOf:
+  - if:
+      not:
+        properties:
+          compatible:
+            contains:
+              const: fsl,lx2160a-dcfg
+    then:
+      patternProperties:
+        "^pinctrl@[0-9a-f]+$": false
+
 additionalProperties: false
 
 examples:

-- 
2.43.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes
  2026-11-15 13:27 [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override Vincent Jardin via B4 Relay
  2026-11-15 13:27 ` [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux Vincent Jardin via B4 Relay
  2026-11-15 13:27 ` [PATCH v6 2/5] dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child Vincent Jardin via B4 Relay
@ 2026-11-15 13:27 ` Vincent Jardin via B4 Relay
  2026-11-16 17:08   ` Frank Li
  2026-11-15 13:27 ` [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver Vincent Jardin via B4 Relay
  2026-11-15 13:27 ` [PATCH v6 5/5] arm64: dts: lx2160a: describe the pad muxes as the DCFG RCW override Vincent Jardin via B4 Relay
  4 siblings, 1 reply; 13+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-15 13:27 UTC (permalink / raw)
  To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer
  Cc: linux-gpio, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, Vladimir Oltean, Ioana Ciornei,
	Vincent Jardin

From: Vincent Jardin <vjardin@free.fr>

fsl_guts_rcw_rmw() only serves the SerDes lane modes. Export it for
the pad-mux fields of the RCW, and for them only:
 - fsl_guts_pmux_read() reads the pad-mux fields of a status register
 - fsl_guts_pmux_override() changes pad-mux fields of one under
   rcwcr_lock and waits for the status register to follow
 - fsl_guts_pmux_override_supported() tells whether the SoC has pad-mux
   fields and whether the DCSR view of DCFG, which holds the override
   registers, is mapped

Each SoC lists in its fsl_soc_data the fields that can be overridden,
per RCWSR: a register or a field outside of this list is refused, so
the SerDes protocols stay with fsl_guts_lane_set_mode(). The LX2160A
lists the pad muxes of RCWSR12 to RCWSR14 and of RCWSR27.

Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 drivers/soc/fsl/guts.c   | 125 ++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/fsl/guts.h |   3 ++
 2 files changed, 127 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index 28361c63e26c..a4b767f1e297 100644
--- a/drivers/soc/fsl/guts.c
+++ b/drivers/soc/fsl/guts.c
@@ -53,6 +53,12 @@ struct fsl_soc_serdes_rcw_override {
 	int val;
 };
 
+/* Pad-mux fields of the one-based RCWSRn, the ones that may be overridden */
+struct fsl_soc_pmux_mask {
+	unsigned int rcwsr;
+	u32 mask;
+};
+
 struct fsl_soc_data {
 	const char *sfp_compat;
 	u32 uid_offset;
@@ -62,6 +68,7 @@ struct fsl_soc_data {
 	int (*serdes_get_rcw_override)(int index, int lane,
 				       enum lynx_lane_mode lane_mode,
 				       struct fsl_soc_serdes_rcw_override *override);
+	const struct fsl_soc_pmux_mask *pmux;
 };
 
 enum qoriq_die {
@@ -369,6 +376,110 @@ int fsl_guts_lane_set_mode(int serdes_idx, int lane, enum lynx_lane_mode lane_mo
 }
 EXPORT_SYMBOL_NS_GPL(fsl_guts_lane_set_mode, "FSL_GUTS");
 
+static const struct fsl_soc_pmux_mask *
+fsl_guts_get_pmux_mask(unsigned int rcwsr)
+{
+	const struct fsl_soc_pmux_mask *pmux;
+
+	if (!soc.data || !soc.data->pmux)
+		return NULL;
+
+	for (pmux = soc.data->pmux; pmux->rcwsr; pmux++) {
+		if (pmux->rcwsr == rcwsr)
+			return pmux;
+	}
+
+	return NULL;
+}
+
+/**
+ * fsl_guts_pmux_read() - read the pad-mux fields of a RCW status register
+ * @rcwsr: one-based index of the status register, as in RCWSR12
+ * @val: the pad-mux fields read, the other fields of the register are 0
+ *
+ * Return: 0 on success, -ENODEV before the DCFG block is mapped, -EINVAL
+ * when the register holds no pad-mux field on this SoC
+ */
+int fsl_guts_pmux_read(unsigned int rcwsr, u32 *val)
+{
+	const struct fsl_soc_pmux_mask *pmux;
+
+	if (!soc.dcfg_ccsr)
+		return -ENODEV;
+
+	pmux = fsl_guts_get_pmux_mask(rcwsr);
+	if (!pmux)
+		return -EINVAL;
+
+	*val = fsl_guts_read(&soc.dcfg_ccsr->rcwsr[rcwsr - 1]) & pmux->mask;
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(fsl_guts_pmux_read, "FSL_GUTS");
+
+/**
+ * fsl_guts_pmux_override() - override pad-mux fields of the RCW
+ * @rcwsr: one-based index of the RCWSR and RCWCR pair, as in RCWSR12
+ * @val: the new value of the fields, in place
+ * @mask: the fields to change
+ *
+ * Only the pad-mux fields that the SoC lists can be changed: a SerDes
+ * protocol is changed with fsl_guts_lane_set_mode(), and the other fields
+ * of the RCW are refused.
+ *
+ * The fields outside @mask keep the value the status register shows. The
+ * override register is written and the status register polled until it
+ * shows the result, as fsl_guts_lane_set_mode() does for a SerDes lane.
+ *
+ * Context: takes rcwcr_lock, shared with fsl_guts_lane_set_mode(), and
+ * busy-polls the status register a bounded number of times. Does not
+ * sleep, shall not be called from interrupt context.
+ *
+ * Return:
+ * * 0 on success
+ * * -ENODEV before the DCFG block is mapped
+ * * -EOPNOTSUPP without a DCSR mapping of DCFG
+ * * -EINVAL when @mask is not made of pad-mux fields of the register
+ * * negative error otherwise
+ */
+int fsl_guts_pmux_override(unsigned int rcwsr, u32 val, u32 mask)
+{
+	const struct fsl_soc_pmux_mask *pmux;
+	int err;
+
+	if (!soc.dcfg_ccsr)
+		return -ENODEV;
+	if (!soc.dcfg_dcsr)
+		return -EOPNOTSUPP;
+
+	pmux = fsl_guts_get_pmux_mask(rcwsr);
+	if (!pmux || !mask || (mask & ~pmux->mask))
+		return -EINVAL;
+
+	spin_lock(&soc.rcwcr_lock);
+	err = fsl_guts_rcw_rmw(rcwsr - 1, val & mask, mask);
+	spin_unlock(&soc.rcwcr_lock);
+	if (err)
+		pr_err("RCW override of RCWSR%u failed: %pe\n", rcwsr,
+		       ERR_PTR(err));
+
+	return err;
+}
+EXPORT_SYMBOL_NS_GPL(fsl_guts_pmux_override, "FSL_GUTS");
+
+/**
+ * fsl_guts_pmux_override_supported() - can the pad muxes be overridden?
+ *
+ * Return: true when the SoC lists pad-mux fields and the DCFG block is
+ * mapped with its DCSR view, the second reg of the dcfg node, which holds
+ * the override registers
+ */
+bool fsl_guts_pmux_override_supported(void)
+{
+	return soc.dcfg_ccsr && soc.dcfg_dcsr && soc.data && soc.data->pmux;
+}
+EXPORT_SYMBOL_NS_GPL(fsl_guts_pmux_override_supported, "FSL_GUTS");
+
 static u64 fsl_guts_get_soc_uid(const char *compat, unsigned int offset)
 {
 	struct device_node *np;
@@ -579,6 +690,18 @@ static const struct fsl_soc_data ls1028a_data = {
 	.num_serdes_lanes = 4,
 };
 
+static const struct fsl_soc_pmux_mask lx2160a_pmux[] = {
+	{ 12, GENMASK(29, 0) },	/* IIC2..SDHC1_DIR */
+	{ 13, GENMASK(29, 0) },	/* SDHC2_DAT74..EVT43 */
+	{ 14, GENMASK(10, 0) },	/* EVT20..IIC1 */
+	{ 27, GENMASK(7, 0) },	/* EC1, EC2, USB_EXT, GTX_CLK, SDHC1_DS */
+	{}
+};
+
+static const struct fsl_soc_data lx2160a_data = {
+	.pmux = lx2160a_pmux,
+};
+
 /*
  * Table for matching compatible strings, for device tree
  * guts node, for Freescale QorIQ SOCs.
@@ -606,7 +729,7 @@ static const struct of_device_id fsl_guts_of_match[] = {
 	{ .compatible = "fsl,ls1088a-dcfg", .data = &ls1088a_data},
 	{ .compatible = "fsl,ls1012a-dcfg", },
 	{ .compatible = "fsl,ls1046a-dcfg", .data = &ls1046a_data},
-	{ .compatible = "fsl,lx2160a-dcfg", },
+	{ .compatible = "fsl,lx2160a-dcfg", .data = &lx2160a_data},
 	{ .compatible = "fsl,ls1028a-dcfg", .data = &ls1028a_data},
 	{}
 };
diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h
index 8d5ffb985fee..ae245afeb7b9 100644
--- a/include/linux/fsl/guts.h
+++ b/include/linux/fsl/guts.h
@@ -142,6 +142,9 @@ int fsl_guts_lane_validate(int serdes_idx, int lane,
 			   enum lynx_lane_mode lane_mode);
 int fsl_guts_lane_set_mode(int serdes_idx, int lane,
 			   enum lynx_lane_mode lane_mode);
+int fsl_guts_pmux_read(unsigned int rcwsr, u32 *val);
+int fsl_guts_pmux_override(unsigned int rcwsr, u32 val, u32 mask);
+bool fsl_guts_pmux_override_supported(void);
 
 /* Alternate function signal multiplex control */
 #define MPC85xx_PMUXCR_QE(x) (0x8000 >> (x))

-- 
2.43.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver
  2026-11-15 13:27 [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override Vincent Jardin via B4 Relay
                   ` (2 preceding siblings ...)
  2026-11-15 13:27 ` [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes Vincent Jardin via B4 Relay
@ 2026-11-15 13:27 ` Vincent Jardin via B4 Relay
  2026-11-16 17:12   ` Frank Li
  2026-11-16 17:36   ` Vladimir Oltean
  2026-11-15 13:27 ` [PATCH v6 5/5] arm64: dts: lx2160a: describe the pad muxes as the DCFG RCW override Vincent Jardin via B4 Relay
  4 siblings, 2 replies; 13+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-15 13:27 UTC (permalink / raw)
  To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer
  Cc: linux-gpio, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, Vladimir Oltean, Ioana Ciornei,
	Vincent Jardin

From: Vincent Jardin <vjardin@free.fr>

The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ and EVT pads from
fields of the RCW, read-only in RCWSR12..14 of DCFG and changed at
runtime through the same fields of the override registers in its DCSR
view, which read 0 until written.

Since commit 8a1365c7bbc1 ("arm64: dts: lx2160a: add pinmux and i2c
gpio to support bus recovery") Linux drives them with pinctrl-single on
the override registers, so its first pin state clears every other field
of the word: a board whose RCW programs a non-zero pad mux loses those
pads at the first I2C probe.

Add a generic Layerscape driver for the pad mux as a child of the DCFG
node. The fields and their encoding are per-SoC tables selected by
the compatible, so that other Layerscape SoCs can be added to it.

Only the LX2160A is done: the fields of RCWSR12..14 and the EC1, EC2,
USB_EXT, GTX_CLK and SDHC1_DS ones of RCWSR27.

Then pin states select them with the generic function and groups
properties, and every change goes through the RCW override
of fsl-guts, which reads the status register, writes the override and
waits for the status register to follow.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 MAINTAINERS                                        |   8 +
 drivers/pinctrl/freescale/Kconfig                  |  15 +
 drivers/pinctrl/freescale/Makefile                 |   1 +
 drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c | 427 +++++++++++++++++++++
 4 files changed, 451 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..2df4866d37bb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20207,6 +20207,14 @@ F:	Documentation/devicetree/bindings/clock/*imx*
 F:	drivers/clk/imx/
 F:	include/dt-bindings/clock/*imx*
 
+NXP LAYERSCAPE RCW PAD-MUX DRIVER
+M:	Vincent Jardin <vjardin@free.fr>
+L:	linux-gpio@vger.kernel.org
+L:	imx@lists.linux.dev
+S:	Maintained
+F:	Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml
+F:	drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c
+
 NXP NETC ETHERNET SWITCH DRIVER
 M:	Wei Fang <wei.fang@nxp.com>
 R:	Clark Wang <xiaoning.wang@nxp.com>
diff --git a/drivers/pinctrl/freescale/Kconfig b/drivers/pinctrl/freescale/Kconfig
index fd53cf5bb843..8e964cf620b0 100644
--- a/drivers/pinctrl/freescale/Kconfig
+++ b/drivers/pinctrl/freescale/Kconfig
@@ -283,3 +283,18 @@ config PINCTRL_IMXRT1170
 	select PINCTRL_IMX
 	help
 	  Say Y here to enable the imxrt1170 pinctrl driver
+
+config PINCTRL_LAYERSCAPE_RCW
+	bool "NXP Layerscape RCW pad-mux driver"
+	depends on OF
+	depends on ARCH_LAYERSCAPE || COMPILE_TEST
+	default ARCH_LAYERSCAPE
+	select FSL_GUTS
+	select GENERIC_PINCTRL_GROUPS
+	select GENERIC_PINMUX_FUNCTIONS
+	select GENERIC_PINCONF
+	help
+	  Say Y here to mux the pads of the Layerscape SoCs at runtime. The
+	  pads are muxed by fields of the RCW: the driver changes it in the
+	  DCSR view of the DCFG that fsl-guts drives.
+	  The I2C bus recovery needs it to switch the pads of a bus to GPIO.
diff --git a/drivers/pinctrl/freescale/Makefile b/drivers/pinctrl/freescale/Makefile
index d27085c2b4c4..34309ac7411d 100644
--- a/drivers/pinctrl/freescale/Makefile
+++ b/drivers/pinctrl/freescale/Makefile
@@ -35,3 +35,4 @@ obj-$(CONFIG_PINCTRL_IMX25)	+= pinctrl-imx25.o
 obj-$(CONFIG_PINCTRL_IMX28)	+= pinctrl-imx28.o
 obj-$(CONFIG_PINCTRL_IMXRT1050)	+= pinctrl-imxrt1050.o
 obj-$(CONFIG_PINCTRL_IMXRT1170)	+= pinctrl-imxrt1170.o
+obj-$(CONFIG_PINCTRL_LAYERSCAPE_RCW)	+= pinctrl-layerscape-rcw.o
diff --git a/drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c b/drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c
new file mode 100644
index 000000000000..46686c6923c3
--- /dev/null
+++ b/drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c
@@ -0,0 +1,427 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Layerscape pad muxes: fields of the RCW, changed at runtime.
+ *
+ * Copyright 2026 Free Mobile - Vincent Jardin
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/fsl/guts.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/seq_file.h>
+
+#include "../core.h"
+#include "../pinmux.h"
+
+struct rcw_pmux_func {
+	const char *name;
+	u8 val;
+};
+
+struct rcw_pmux_group {
+	const char *name;
+	u8 rcwsr; /* one-based, as in RCWSR12 */
+	u8 shift;
+	u8 width;
+	const struct rcw_pmux_func *funcs;
+	u8 nfuncs;
+};
+
+/* The pad-mux groups of a SoC, one per field of its RCW */
+struct rcw_pmux_soc {
+	const struct rcw_pmux_group *groups;
+	unsigned int ngroups;
+};
+
+#define RCW_PMUX_FUNC(_name, _val)	{ .name = _name, .val = _val }
+#define RCW_PMUX_GROUP(_name, _rcwsr, _shift, _width, _funcs)		\
+	{								\
+		.name = _name, .rcwsr = _rcwsr,				\
+		.shift = _shift, .width = _width,			\
+		.funcs = _funcs, .nfuncs = ARRAY_SIZE(_funcs),		\
+	}
+
+/* LX2160A: RCWSR12..14 and RCWSR27 */
+static const struct rcw_pmux_func lx2160a_iic2_funcs[] = {
+	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("flextimer", 2), RCW_PMUX_FUNC("sdhc", 6),
+};
+
+static const struct rcw_pmux_func lx2160a_iic3_funcs[] = {
+	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("can", 2), RCW_PMUX_FUNC("evt", 6),
+};
+
+static const struct rcw_pmux_func lx2160a_iic5_funcs[] = {
+	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("sdhc-clk", 2), RCW_PMUX_FUNC("spi", 3),
+};
+
+static const struct rcw_pmux_func lx2160a_iic6_funcs[] = {
+	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("sdhc-clk", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_xspi1_funcs[] = {
+	RCW_PMUX_FUNC("flexspi", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_sdhc1_base_funcs[] = {
+	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("spi", 2), RCW_PMUX_FUNC("sdhc-spi", 3),
+	RCW_PMUX_FUNC("sdhc-data4", 4),
+};
+
+static const struct rcw_pmux_func lx2160a_sdhc1_dir_funcs[] = {
+	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("spi", 3), RCW_PMUX_FUNC("sdhc-data", 4),
+};
+
+static const struct rcw_pmux_func lx2160a_sdhc2_data74_funcs[] = {
+	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("i2c", 2), RCW_PMUX_FUNC("flexspi", 6),
+};
+
+static const struct rcw_pmux_func lx2160a_sdhc2_base_funcs[] = {
+	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("spi", 2), RCW_PMUX_FUNC("flexspi", 6),
+};
+
+static const struct rcw_pmux_func lx2160a_uart_funcs[] = {
+	RCW_PMUX_FUNC("uart", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_uart1_rtscts_funcs[] = {
+	RCW_PMUX_FUNC("uart", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("uart3", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_uart2_rtscts_funcs[] = {
+	RCW_PMUX_FUNC("uart", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("uart4", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_irq_funcs[] = {
+	RCW_PMUX_FUNC("irq", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_irq_flextimer_funcs[] = {
+	RCW_PMUX_FUNC("irq", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("flextimer", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_evt_funcs[] = {
+	RCW_PMUX_FUNC("evt", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("flextimer", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_clk_out_funcs[] = {
+	RCW_PMUX_FUNC("gpio", 1), RCW_PMUX_FUNC("flextimer", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_asleep_funcs[] = {
+	RCW_PMUX_FUNC("asleep", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("evt", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_reset_req_funcs[] = {
+	RCW_PMUX_FUNC("reset-req", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_iic1_funcs[] = {
+	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_ec1_funcs[] = {
+	RCW_PMUX_FUNC("rgmii", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_ec2_funcs[] = {
+	RCW_PMUX_FUNC("rgmii", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("tsec-1588", 2),
+};
+
+static const struct rcw_pmux_func lx2160a_usb_ext_funcs[] = {
+	RCW_PMUX_FUNC("usb", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_gtx_clk_funcs[] = {
+	RCW_PMUX_FUNC("gtx-clk", 0), RCW_PMUX_FUNC("gpio", 1),
+};
+
+static const struct rcw_pmux_func lx2160a_sdhc1_ds_funcs[] = {
+	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
+	RCW_PMUX_FUNC("spi", 2),
+};
+
+static const struct rcw_pmux_group lx2160a_groups[] = {
+	/* RCWSR12 */
+	RCW_PMUX_GROUP("iic2", 12, 0, 3, lx2160a_iic2_funcs),
+	RCW_PMUX_GROUP("iic3", 12, 3, 3, lx2160a_iic3_funcs),
+	RCW_PMUX_GROUP("iic4", 12, 6, 3, lx2160a_iic3_funcs),
+	RCW_PMUX_GROUP("iic5", 12, 9, 3, lx2160a_iic5_funcs),
+	RCW_PMUX_GROUP("iic6", 12, 12, 3, lx2160a_iic6_funcs),
+	RCW_PMUX_GROUP("xspi1-data74", 12, 15, 3, lx2160a_xspi1_funcs),
+	RCW_PMUX_GROUP("xspi1-data30", 12, 18, 3, lx2160a_xspi1_funcs),
+	RCW_PMUX_GROUP("xspi1-base", 12, 21, 3, lx2160a_xspi1_funcs),
+	RCW_PMUX_GROUP("sdhc1-base", 12, 24, 3, lx2160a_sdhc1_base_funcs),
+	RCW_PMUX_GROUP("sdhc1-dir", 12, 27, 3, lx2160a_sdhc1_dir_funcs),
+	/* RCWSR13 */
+	RCW_PMUX_GROUP("sdhc2-data74", 13, 0, 3, lx2160a_sdhc2_data74_funcs),
+	RCW_PMUX_GROUP("sdhc2-base", 13, 3, 3, lx2160a_sdhc2_base_funcs),
+	RCW_PMUX_GROUP("uart1-soutsin", 13, 6, 3, lx2160a_uart_funcs),
+	RCW_PMUX_GROUP("uart1-rtscts", 13, 9, 3, lx2160a_uart1_rtscts_funcs),
+	RCW_PMUX_GROUP("uart2-soutsin", 13, 12, 3, lx2160a_uart_funcs),
+	RCW_PMUX_GROUP("uart2-rtscts", 13, 15, 3, lx2160a_uart2_rtscts_funcs),
+	RCW_PMUX_GROUP("irq11-8", 13, 18, 3, lx2160a_irq_funcs),
+	RCW_PMUX_GROUP("irq7-4", 13, 21, 3, lx2160a_irq_flextimer_funcs),
+	RCW_PMUX_GROUP("irq3-0", 13, 24, 3, lx2160a_irq_flextimer_funcs),
+	RCW_PMUX_GROUP("evt4-3", 13, 27, 3, lx2160a_evt_funcs),
+	/* RCWSR14 */
+	RCW_PMUX_GROUP("evt2-0", 14, 0, 3, lx2160a_evt_funcs),
+	RCW_PMUX_GROUP("clk-out", 14, 3, 3, lx2160a_clk_out_funcs),
+	RCW_PMUX_GROUP("asleep", 14, 6, 3, lx2160a_asleep_funcs),
+	RCW_PMUX_GROUP("reset-req", 14, 9, 1, lx2160a_reset_req_funcs),
+	RCW_PMUX_GROUP("iic1", 14, 10, 1, lx2160a_iic1_funcs),
+	/* RCWSR27 */
+	RCW_PMUX_GROUP("ec1", 27, 0, 2, lx2160a_ec1_funcs),
+	RCW_PMUX_GROUP("ec2", 27, 2, 2, lx2160a_ec2_funcs),
+	RCW_PMUX_GROUP("usb-ext", 27, 4, 1, lx2160a_usb_ext_funcs),
+	RCW_PMUX_GROUP("gtx-clk", 27, 5, 1, lx2160a_gtx_clk_funcs),
+	RCW_PMUX_GROUP("sdhc1-ds", 27, 6, 2, lx2160a_sdhc1_ds_funcs),
+};
+
+static const struct rcw_pmux_soc lx2160a_soc = {
+	.groups = lx2160a_groups,
+	.ngroups = ARRAY_SIZE(lx2160a_groups),
+};
+
+struct rcw_pmux {
+	struct device *dev;
+	struct pinctrl_dev *pctl;
+	struct pinctrl_desc desc;
+	const struct rcw_pmux_soc *soc;
+	struct pinctrl_pin_desc *pins;
+};
+
+static u32 rcw_pmux_group_mask(const struct rcw_pmux_group *group)
+{
+	return GENMASK(group->shift + group->width - 1, group->shift);
+}
+
+static const struct rcw_pmux_func *
+rcw_pmux_find_func(const struct rcw_pmux_group *group, const char *name)
+{
+	unsigned int i;
+
+	for (i = 0; i < group->nfuncs; i++) {
+		if (!strcmp(group->funcs[i].name, name))
+			return &group->funcs[i];
+	}
+
+	return NULL;
+}
+
+static void rcw_pmux_pin_dbg_show(struct pinctrl_dev *pctldev,
+				  struct seq_file *s, unsigned int pin)
+{
+	struct rcw_pmux *pmux = pinctrl_dev_get_drvdata(pctldev);
+	const struct rcw_pmux_group *group = &pmux->soc->groups[pin];
+	unsigned int i;
+	u32 val;
+
+	if (fsl_guts_pmux_read(group->rcwsr, &val))
+		return;
+
+	val = field_get(rcw_pmux_group_mask(group), val);
+	for (i = 0; i < group->nfuncs; i++) {
+		if (group->funcs[i].val == val) {
+			seq_puts(s, group->funcs[i].name);
+			return;
+		}
+	}
+	seq_printf(s, "0x%x", val);
+}
+
+static const struct pinctrl_ops rcw_pmux_pctlops = {
+	.get_groups_count = pinctrl_generic_get_group_count,
+	.get_group_name = pinctrl_generic_get_group_name,
+	.get_group_pins = pinctrl_generic_get_group_pins,
+	.pin_dbg_show = rcw_pmux_pin_dbg_show,
+	.dt_node_to_map = pinconf_generic_dt_node_to_map_group,
+	.dt_free_map = pinconf_generic_dt_free_map,
+};
+
+static int rcw_pmux_set_mux(struct pinctrl_dev *pctldev,
+			    unsigned int fsel, unsigned int gsel)
+{
+	struct rcw_pmux *pmux = pinctrl_dev_get_drvdata(pctldev);
+	const struct function_desc *func;
+	const struct rcw_pmux_group *group;
+	const struct rcw_pmux_func *mux;
+	const struct group_desc *grp;
+	u32 mask;
+
+	func = pinmux_generic_get_function(pctldev, fsel);
+	grp = pinctrl_generic_get_group(pctldev, gsel);
+	if (!func || !grp)
+		return -EINVAL;
+	group = grp->data;
+
+	mux = rcw_pmux_find_func(group, func->func->name);
+	if (!mux) {
+		dev_err(pmux->dev, "%s has no %s function\n",
+			group->name, func->func->name);
+		return -EINVAL;
+	}
+
+	mask = rcw_pmux_group_mask(group);
+
+	return fsl_guts_pmux_override(group->rcwsr, field_prep(mask, mux->val),
+				      mask);
+}
+
+static const struct pinmux_ops rcw_pmux_pmxops = {
+	.get_functions_count = pinmux_generic_get_function_count,
+	.get_function_name = pinmux_generic_get_function_name,
+	.get_function_groups = pinmux_generic_get_function_groups,
+	.set_mux = rcw_pmux_set_mux,
+	.strict = true,
+};
+
+static int rcw_pmux_add_functions(struct rcw_pmux *pmux)
+{
+	const struct rcw_pmux_soc *soc = pmux->soc;
+	const struct rcw_pmux_group *group;
+	const char **groups;
+	unsigned int i, j, k, n;
+	int ret;
+
+	for (i = 0; i < soc->ngroups; i++) {
+		group = &soc->groups[i];
+		for (j = 0; j < group->nfuncs; j++) {
+			const char *name = group->funcs[j].name;
+
+			/* already added from an earlier group? */
+			for (k = 0; k < i; k++) {
+				if (rcw_pmux_find_func(&soc->groups[k], name))
+					break;
+			}
+			if (k < i)
+				continue;
+
+			groups = devm_kcalloc(pmux->dev, soc->ngroups,
+					      sizeof(*groups), GFP_KERNEL);
+			if (!groups)
+				return -ENOMEM;
+			n = 0;
+			for (k = i; k < soc->ngroups; k++) {
+				if (rcw_pmux_find_func(&soc->groups[k], name))
+					groups[n++] = soc->groups[k].name;
+			}
+			ret = pinmux_generic_add_function(pmux->pctl, name,
+							  groups, n, NULL);
+			if (ret < 0)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int rcw_pmux_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	const struct rcw_pmux_soc *soc;
+	struct rcw_pmux *pmux;
+	unsigned int i;
+	u32 val;
+	int ret;
+
+	/* The override needs the DCSR view of DCFG, mapped by fsl-guts */
+	if (!fsl_guts_pmux_override_supported())
+		return dev_err_probe(dev, -ENODEV,
+				     "no RCW override through fsl-guts: the dcfg node needs its DCSR reg\n");
+
+	soc = device_get_match_data(dev);
+	if (!soc)
+		return -ENODEV;
+
+	pmux = devm_kzalloc(dev, sizeof(*pmux), GFP_KERNEL);
+	if (!pmux)
+		return -ENOMEM;
+	pmux->dev = dev;
+	pmux->soc = soc;
+
+	pmux->pins = devm_kcalloc(dev, soc->ngroups, sizeof(*pmux->pins),
+				  GFP_KERNEL);
+	if (!pmux->pins)
+		return -ENOMEM;
+
+	for (i = 0; i < soc->ngroups; i++) {
+		pmux->pins[i].number = i;
+		pmux->pins[i].name = soc->groups[i].name;
+	}
+	pmux->desc.name = dev_name(dev);
+	pmux->desc.pins = pmux->pins;
+	pmux->desc.npins = soc->ngroups;
+	pmux->desc.pctlops = &rcw_pmux_pctlops;
+	pmux->desc.pmxops = &rcw_pmux_pmxops;
+	pmux->desc.owner = THIS_MODULE;
+
+	ret = devm_pinctrl_register_and_init(dev, &pmux->desc, pmux,
+					     &pmux->pctl);
+	if (ret)
+		return dev_err_probe(dev, ret, "pinctrl registration failed\n");
+
+	for (i = 0; i < soc->ngroups; i++) {
+		ret = pinctrl_generic_add_group(pmux->pctl, soc->groups[i].name,
+						&pmux->pins[i].number, 1,
+						(void *)&soc->groups[i]);
+		if (ret < 0)
+			return ret;
+	}
+
+	ret = rcw_pmux_add_functions(pmux);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < soc->ngroups; i++) {
+		u8 rcwsr = soc->groups[i].rcwsr;
+
+		if (i && rcwsr == soc->groups[i - 1].rcwsr)
+			continue;
+		if (!fsl_guts_pmux_read(rcwsr, &val))
+			dev_dbg(dev, "pad muxes of RCWSR%u = 0x%08x\n", rcwsr,
+				val);
+	}
+
+	return pinctrl_enable(pmux->pctl);
+}
+
+static const struct of_device_id rcw_pmux_of_match[] = {
+	{ .compatible = "fsl,lx2160a-rcw-pinmux", .data = &lx2160a_soc },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rcw_pmux_of_match);
+
+static struct platform_driver rcw_pmux_driver = {
+	.driver = {
+		.name = "layerscape-rcw-pinmux",
+		.of_match_table = rcw_pmux_of_match,
+	},
+	.probe = rcw_pmux_probe,
+};
+module_platform_driver(rcw_pmux_driver);
+
+MODULE_AUTHOR("Vincent Jardin <vjardin@free.fr>");
+MODULE_DESCRIPTION("NXP Layerscape RCW pad-mux driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("FSL_GUTS");

-- 
2.43.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 5/5] arm64: dts: lx2160a: describe the pad muxes as the DCFG RCW override
  2026-11-15 13:27 [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override Vincent Jardin via B4 Relay
                   ` (3 preceding siblings ...)
  2026-11-15 13:27 ` [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver Vincent Jardin via B4 Relay
@ 2026-11-15 13:27 ` Vincent Jardin via B4 Relay
  4 siblings, 0 replies; 13+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-15 13:27 UTC (permalink / raw)
  To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer
  Cc: linux-gpio, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, Vladimir Oltean, Ioana Ciornei,
	Vincent Jardin

From: Vincent Jardin <vjardin@free.fr>

The pad muxes are fields of the RCW: read-only in RCWSR12..14, changed
at runtime through the override registers in the DCSR view of DCFG,
which read 0 until written.

pinctrl-single on those registers, since commit 8a1365c7bbc1
("arm64: dts: lx2160a: add pinmux and i2c gpio to support bus recovery"),
clears every other field of the word with its first pin state:
a board whose RCW programs a non-zero pad mux loses those pads at the
first I2C probe.

Describe the pad mux as a child of the dcfg node, which gains its DCSR
view and, as on the LS1028A, the addressing of its children:
the child is at its RCWSR12 to RCWSR14 and RCWSR27 windows, one group
per RCW field, one function per encoding, driven by
fsl,lx2160a-rcw-pinmux using fsl-guts. Labels and pin node names stay,
so no consumer changes.
The pinctrl-single node goes.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi | 377 ++++++++++++++------------
 1 file changed, 202 insertions(+), 175 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
index 2085362ab0ea..b0bb7bf94405 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
@@ -669,9 +669,209 @@ clockgen: clock-controller@1300000 {
 		};
 
 		dcfg: syscon@1e00000 {
-			compatible = "fsl,lx2160a-dcfg", "syscon";
-			reg = <0x0 0x1e00000 0x0 0x10000>;
+			compatible = "fsl,lx2160a-dcfg", "syscon", "simple-mfd";
+			reg = <0x0 0x1e00000 0x0 0x10000>,
+			      <0x7 0x00100000 0x0 0x10000>;
+			reg-names = "dcfg_ccsr", "dcfg_dcsr";
+			ranges = <0x0 0x0 0x1e00000 0x10000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
 			little-endian;
+
+			pinmux_i2crv: pinctrl@12c {
+				compatible = "fsl,lx2160a-rcw-pinmux";
+				reg = <0x12c 0xc>, <0x168 0x4>;
+
+				i2c1_pins: iic2-i2c-pins {
+					function = "i2c";
+					groups = "iic2";
+				};
+
+				gpio0_31_30_pins: iic2-gpio-pins {
+					function = "gpio";
+					groups = "iic2";
+				};
+
+				ftm0_ch10_pins: iic2-ftm-pins {
+					function = "flextimer";
+					groups = "iic2";
+				};
+
+				esdhc0_cd_wp_pins: iic2-sdhc-pins {
+					function = "sdhc";
+					groups = "iic2";
+				};
+
+				i2c2_pins: iic3-i2c-pins {
+					function = "i2c";
+					groups = "iic3";
+				};
+
+				gpio0_29_28_pins: iic3-gpio-pins {
+					function = "gpio";
+					groups = "iic3";
+				};
+
+				can0_pins: iic3-can-pins {
+					function = "can";
+					groups = "iic3";
+				};
+
+				event65_pins: iic3-event-pins {
+					function = "evt";
+					groups = "iic3";
+				};
+
+				i2c3_pins: iic4-i2c-pins {
+					function = "i2c";
+					groups = "iic4";
+				};
+
+				gpio0_27_26_pins: iic4-gpio-pins {
+					function = "gpio";
+					groups = "iic4";
+				};
+
+				can1_pins: iic4-can-pins {
+					function = "can";
+					groups = "iic4";
+				};
+
+				event87_pins: iic4-event-pins {
+					function = "evt";
+					groups = "iic4";
+				};
+
+				i2c4_pins: iic5-i2c-pins {
+					function = "i2c";
+					groups = "iic5";
+				};
+
+				gpio0_25_24_pins: iic5-gpio-pins {
+					function = "gpio";
+					groups = "iic5";
+				};
+
+				esdhc0_clksync_pins: iic5-sdhc-clk-pins {
+					function = "sdhc-clk";
+					groups = "iic5";
+				};
+
+				dspi2_miso_mosi_pins: iic5-spi3-pins {
+					function = "spi";
+					groups = "iic5";
+				};
+
+				i2c5_pins: iic6-i2c-pins {
+					function = "i2c";
+					groups = "iic6";
+				};
+
+				gpio0_23_22_pins: iic6-gpio-pins {
+					function = "gpio";
+					groups = "iic6";
+				};
+
+				esdhc1_clksync_pins: iic6-sdhc-clk-pins {
+					function = "sdhc-clk";
+					groups = "iic6";
+				};
+
+				fspi_data74_pins: xspi1-data74-pins {
+					function = "flexspi";
+					groups = "xspi1-data74";
+				};
+
+				gpio1_31_28_pins: xspi1-data74-gpio-pins {
+					function = "gpio";
+					groups = "xspi1-data74";
+				};
+
+				fspi_data30_pins: xspi1-data30-pins {
+					function = "flexspi";
+					groups = "xspi1-data30";
+				};
+
+				gpio1_27_24_pins: xspi1-data30-gpio-pins {
+					function = "gpio";
+					groups = "xspi1-data30";
+				};
+
+				fspi_dqs_sck_cs10_pins: xspi1-base-pins {
+					function = "flexspi";
+					groups = "xspi1-base";
+				};
+
+				gpio1_23_20_pins: xspi1-base-gpio-pins {
+					function = "gpio";
+					groups = "xspi1-base";
+				};
+
+				esdhc0_cmd_data30_clk_vsel_pins: sdhc1-base-sdhc-vsel-pins {
+					function = "sdhc";
+					groups = "sdhc1-base";
+				};
+
+				gpio0_21_15_pins: sdhc1-base-gpio-pins {
+					function = "gpio";
+					groups = "sdhc1-base";
+				};
+
+				dspi0_pins: sdhc1-base-spi1-pins {
+					function = "spi";
+					groups = "sdhc1-base";
+				};
+
+				esdhc0_cmd_data30_clk_dspi2_cs0_pins: sdhc1-base-sdhc-spi3-pins {
+					function = "sdhc-spi";
+					groups = "sdhc1-base";
+				};
+
+				esdhc0_cmd_data30_clk_data4_pins: sdhc1-base-sdhc-data4-pins {
+					function = "sdhc-data4";
+					groups = "sdhc1-base";
+				};
+
+				esdhc0_dir_pins: sdhc1-dir-pins {
+					function = "sdhc";
+					groups = "sdhc1-dir";
+				};
+
+				gpio0_14_12_pins: sdhc1-dir-gpio-pins {
+					function = "gpio";
+					groups = "sdhc1-dir";
+				};
+
+				dspi2_cs31_pins: sdhc1-dir-spi3-pins {
+					function = "spi";
+					groups = "sdhc1-dir";
+				};
+
+				esdhc0_data75_pins: sdhc1-dir-sdhc-pins {
+					function = "sdhc-data";
+					groups = "sdhc1-dir";
+				};
+
+				gpio1_18_15_pins: iic8-iic7-gpio-pins {
+					function = "gpio";
+					groups = "sdhc2-data74";
+				};
+
+				i2c6_i2c7_pins: iic8-iic7-i2c-pins {
+					function = "i2c";
+					groups = "sdhc2-data74";
+				};
+
+				i2c0_pins: iic1-i2c-pins {
+					function = "i2c";
+					groups = "iic1";
+				};
+
+				gpio0_3_2_pins: iic1-gpio-pins {
+					function = "gpio";
+					groups = "iic1";
+				};
+			};
 		};
 
 		sfp: efuse@1e80000 {
@@ -1531,179 +1731,6 @@ pcs18: ethernet-phy@0 {
 			};
 		};
 
-		pinmux_i2crv: pinmux@70010012c {
-			compatible = "pinctrl-single";
-			reg = <0x00000007 0x0010012c 0x0 0xc>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			#pinctrl-cells = <2>;
-			pinctrl-single,bit-per-mux;
-			pinctrl-single,register-width = <32>;
-			pinctrl-single,function-mask = <0x7>;
-
-			/* RCWSR12 */
-			i2c1_pins: iic2-i2c-pins {
-				pinctrl-single,bits = <0x0 0x0 0x7>;
-			};
-
-			gpio0_31_30_pins: iic2-gpio-pins {
-				pinctrl-single,bits = <0x0 0x1 0x7>;
-			};
-
-			ftm0_ch10_pins: iic2-ftm-pins {
-				pinctrl-single,bits = <0x0 0x2 0x7>;
-			};
-
-			esdhc0_cd_wp_pins: iic2-sdhc-pins {
-				pinctrl-single,bits = <0x0 0x6 0x7>;
-			};
-
-			i2c2_pins: iic3-i2c-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 3)>;
-			};
-
-			gpio0_29_28_pins: iic3-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 3) (0x7 << 3)>;
-			};
-
-			can0_pins: iic3-can-pins {
-				pinctrl-single,bits = <0x0 (0x2 << 3) (0x7 << 3)>;
-			};
-
-			event65_pins: iic3-event-pins {
-				pinctrl-single,bits = <0x0 (0x6 << 3) (0x7 << 3)>;
-			};
-
-			i2c3_pins: iic4-i2c-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 6)>;
-			};
-
-			gpio0_27_26_pins: iic4-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 6) (0x7 << 6)>;
-			};
-
-			can1_pins: iic4-can-pins {
-				pinctrl-single,bits = <0x0 (0x2 << 6) (0x7 << 6)>;
-			};
-
-			event87_pins: iic4-event-pins {
-				pinctrl-single,bits = <0x0 (0x6 << 6) (0x7 << 6)>;
-			};
-
-			i2c4_pins: iic5-i2c-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 9)>;
-			};
-
-			gpio0_25_24_pins: iic5-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 9) (0x7 << 9)>;
-			};
-
-			esdhc0_clksync_pins: iic5-sdhc-clk-pins {
-				pinctrl-single,bits = <0x0 (0x2 << 9) (0x7 << 9)>;
-			};
-
-			dspi2_miso_mosi_pins: iic5-spi3-pins {
-				pinctrl-single,bits = <0x0 (0x3 << 9) (0x7 << 9)>;
-			};
-
-			i2c5_pins: iic6-i2c-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 12)>;
-			};
-
-			gpio0_23_22_pins: iic6-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 12) (0x7 << 12)>;
-			};
-
-			esdhc1_clksync_pins: iic6-sdhc-clk-pins {
-				pinctrl-single,bits = <0x0 (0x2 << 12) (0x7 << 12)>;
-			};
-
-			fspi_data74_pins: xspi1-data74-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 15)>;
-			};
-
-			gpio1_31_28_pins: xspi1-data74-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 15) (0x7 << 15)>;
-			};
-
-			fspi_data30_pins: xspi1-data30-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 18)>;
-			};
-
-			gpio1_27_24_pins: xspi1-data30-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 18) (0x7 << 18)>;
-			};
-
-			fspi_dqs_sck_cs10_pins: xspi1-base-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 21)>;
-			};
-
-			gpio1_23_20_pins: xspi1-base-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 21) (0x7 << 21)>;
-			};
-
-			esdhc0_cmd_data30_clk_vsel_pins: sdhc1-base-sdhc-vsel-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 24)>;
-			};
-
-			gpio0_21_15_pins: sdhc1-base-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 24) (0x7 << 24)>;
-			};
-
-			dspi0_pins: sdhc1-base-spi1-pins {
-				pinctrl-single,bits = <0x0 (0x2 << 24) (0x7 << 24)>;
-			};
-
-			esdhc0_cmd_data30_clk_dspi2_cs0_pins: sdhc1-base-sdhc-spi3-pins {
-				pinctrl-single,bits = <0x0 (0x3 << 24) (0x7 << 24)>;
-			};
-
-			esdhc0_cmd_data30_clk_data4_pins: sdhc1-base-sdhc-data4-pins {
-				pinctrl-single,bits = <0x0 (0x4 << 24) (0x7 << 24)>;
-			};
-
-			esdhc0_dir_pins: sdhc1-dir-pins {
-				pinctrl-single,bits = <0x0 0x0 (0x7 << 27)>;
-			};
-
-			gpio0_14_12_pins: sdhc1-dir-gpio-pins {
-				pinctrl-single,bits = <0x0 (0x1 << 27) (0x7 << 27)>;
-			};
-
-			dspi2_cs31_pins: sdhc1-dir-spi3-pins {
-				pinctrl-single,bits = <0x0 (0x3 << 27) (0x7 << 27)>;
-			};
-
-			esdhc0_data75_pins: sdhc1-dir-sdhc-pins {
-				pinctrl-single,bits = <0x0 (0x4 << 27) (0x7 << 27)>;
-			};
-
-			/* RCWSR13 */
-			gpio1_18_15_pins: iic8-iic7-gpio-pins {
-				pinctrl-single,bits = <0x4 0x1 0x7>;
-			};
-
-			i2c6_i2c7_pins: iic8-iic7-i2c-pins {
-				pinctrl-single,bits = <0x4 0x2 0x7>;
-			};
-
-			/* RCWSR14 */
-			/*
-			 * IIC1_PMUX is a single bit at RCWSR14[10], but bit-per-mux
-			 * uses the mask for the field to clear before applying the
-			 * value.
-			 * So bits 11 and 12, which are reserved, are written as 0
-			 * on every mux switch, it is harmless.
-			 */
-			i2c0_pins: iic1-i2c-pins {
-				pinctrl-single,bits = <0x8 0x0 (0x7 << 10)>;
-			};
-
-			gpio0_3_2_pins: iic1-gpio-pins {
-				pinctrl-single,bits = <0x8 (0x1 << 10) (0x7 << 10)>;
-			};
-		};
-
 		fsl_mc: fsl-mc@80c000000 {
 			compatible = "fsl,qoriq-mc";
 			reg = <0x00000008 0x0c000000 0 0x40>,

-- 
2.43.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux
  2026-11-15 13:27 ` [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux Vincent Jardin via B4 Relay
@ 2026-11-16 17:02   ` Frank Li
  0 siblings, 0 replies; 13+ messages in thread
From: Frank Li @ 2026-11-16 17:02 UTC (permalink / raw)
  To: vjardin
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Vladimir Oltean,
	Ioana Ciornei

On Sun, Nov 15, 2026 at 02:27:31PM +0100, Vincent Jardin via B4 Relay wrote:
> From: Vincent Jardin <vjardin@free.fr>
>
> The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ, EVT, EC and USB pads
> from fields of the RCW: read-only in RCWSR12..14 and RCWSR27 of DCFG,
> changed at runtime through the override registers of its DCSR view.
>
> Describe the pad mux as a child of DCFG at its RCWSR12 to RCWSR14 and
> RCWSR27 windows: the override registers are at the same offsets of the
> DCSR view of the parent. One group per RCW field, one function per
> encoding.
>
> Each function lists the groups that take it, so a pair the driver
> would refuse, such as can on iic1, is refused by the schema.
>
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  .../bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml   | 309 +++++++++++++++++++++
>  1 file changed, 309 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml b/Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml
> new file mode 100644
> index 000000000000..f835ebe332a9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml
> @@ -0,0 +1,309 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/pinctrl/fsl,lx2160a-rcw-pinmux.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NXP LX2160A RCW pad muxes
> +
> +maintainers:
> +  - Vincent Jardin <vjardin@free.fr>
> +
> +description:
> +  The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ, EVT, EC and USB pads based
> +  on its RCW. The related fields are from the read-only RCWSR12 to RCWSR14 and
> +  RCWSR27 registers of DCFG, and can be changed at runtime by writing the RCW
> +  override registers in the DCSR view of DCFG. The node is a child of the DCFG
> +  node, which owns both views. Its reg are the RCWSR12 to RCWSR14 and the
> +  RCWSR27 windows of the CCSR view, and the override registers are at the same
> +  offsets of the DCSR view.
> +
> +properties:
> +  compatible:
> +    const: fsl,lx2160a-rcw-pinmux
> +
> +  reg:
> +    items:
> +      - description: RCWSR12 to RCWSR14
> +      - description: RCWSR27
> +
> +patternProperties:
> +  '-pins$':
> +    type: object
> +    $ref: pinmux-node.yaml#
> +    additionalProperties: false
> +
> +    properties:
> +      function:
> +        enum: [ asleep, can, evt, flexspi, flextimer, gpio, gtx-clk, i2c,
> +                irq, reset-req, rgmii, sdhc, sdhc-clk, sdhc-data, sdhc-data4,
> +                sdhc-spi, spi, tsec-1588, uart, uart3, uart4, usb ]
> +
> +      groups:
> +        items:
> +          enum: [ iic1, iic2, iic3, iic4, iic5, iic6, xspi1-data74,
> +                  xspi1-data30, xspi1-base, sdhc1-base, sdhc1-dir,
> +                  sdhc2-data74, sdhc2-base, uart1-soutsin, uart1-rtscts,
> +                  uart2-soutsin, uart2-rtscts, irq11-8, irq7-4, irq3-0,
> +                  evt4-3, evt2-0, clk-out, asleep, reset-req, ec1, ec2,
> +                  usb-ext, gtx-clk, sdhc1-ds ]
> +
> +    required:
> +      - function
> +      - groups
> +
> +    allOf:
> +      - if:
> +          properties:
> +            function:
> +              const: asleep
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ asleep ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: can
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic3, iic4 ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: evt
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic3, iic4, evt4-3, evt2-0, asleep ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: flexspi
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ xspi1-data74, xspi1-data30, xspi1-base,
> +                        sdhc2-data74, sdhc2-base ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: flextimer
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic2, irq7-4, irq3-0, evt4-3, evt2-0, clk-out ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: gpio
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic2, iic3, iic4, iic5, iic6, xspi1-data74,
> +                        xspi1-data30, xspi1-base, sdhc1-base, sdhc1-dir,
> +                        sdhc2-data74, sdhc2-base, uart1-soutsin,
> +                        uart1-rtscts, uart2-soutsin, uart2-rtscts,
> +                        irq11-8, irq7-4, irq3-0, evt4-3, evt2-0, clk-out,
> +                        asleep, reset-req, iic1, ec1, ec2, usb-ext, gtx-clk,
> +                        sdhc1-ds ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: gtx-clk
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ gtx-clk ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: i2c
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic2, iic3, iic4, iic5, iic6, sdhc2-data74, iic1 ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: irq
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ irq11-8, irq7-4, irq3-0 ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: reset-req
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ reset-req ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: rgmii
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ ec1, ec2 ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: sdhc
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic2, sdhc1-base, sdhc1-dir, sdhc2-data74,
> +                        sdhc2-base, sdhc1-ds ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: sdhc-clk
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic5, iic6 ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: sdhc-data
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ sdhc1-dir ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: sdhc-data4
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ sdhc1-base ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: sdhc-spi
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ sdhc1-base ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: spi
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ iic5, sdhc1-base, sdhc1-dir, sdhc2-base, sdhc1-ds ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: tsec-1588
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ ec2 ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: uart
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ uart1-soutsin, uart1-rtscts, uart2-soutsin,
> +                        uart2-rtscts ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: uart3
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ uart1-rtscts ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: uart4
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ uart2-rtscts ]
> +
> +      - if:
> +          properties:
> +            function:
> +              const: usb
> +        then:
> +          properties:
> +            groups:
> +              items:
> +                enum: [ usb-ext ]
> +
> +required:
> +  - compatible
> +  - reg
> +
> +allOf:
> +  - $ref: pinctrl.yaml#
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    pinctrl@12c {
> +        compatible = "fsl,lx2160a-rcw-pinmux";
> +        reg = <0x12c 0xc>, <0x168 0x4>;
> +
> +        iic3-i2c-pins {
> +            function = "i2c";
> +            groups = "iic3";
> +        };
> +
> +        iic3-gpio-pins {
> +            function = "gpio";
> +            groups = "iic3";
> +        };
> +    };
>
> --
> 2.43.0
>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 2/5] dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child
  2026-11-15 13:27 ` [PATCH v6 2/5] dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child Vincent Jardin via B4 Relay
@ 2026-11-16 17:04   ` Frank Li
  0 siblings, 0 replies; 13+ messages in thread
From: Frank Li @ 2026-11-16 17:04 UTC (permalink / raw)
  To: vjardin
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Vladimir Oltean,
	Ioana Ciornei

On Sun, Nov 15, 2026 at 02:27:32PM +0100, Vincent Jardin via B4 Relay wrote:
> From: Vincent Jardin <vjardin@free.fr>
>
> On the LX2160A the DCFG node holds the pad mux, overridden through its
> DCSR view. Allow fsl,lx2160a-dcfg with simple-mfd, so that the child is
> populated, and the pinctrl child, on the LX2160A only.
>
> Reviewed-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  .../bindings/soc/fsl/fsl,layerscape-dcfg.yaml          | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml b/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml
> index fc14fd0bf84b..bb9dbcfec188 100644
> --- a/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml
> +++ b/Documentation/devicetree/bindings/soc/fsl/fsl,layerscape-dcfg.yaml
> @@ -32,6 +32,7 @@ properties:
>        - items:
>            - enum:
>                - fsl,ls1028a-dcfg
> +              - fsl,lx2160a-dcfg
>            - const: syscon
>            - const: simple-mfd
>
> @@ -66,10 +67,27 @@ patternProperties:
>    "^clock-controller@[0-9a-f]+$":
>      $ref: /schemas/clock/fsl,flexspi-clock.yaml#
>
> +  "^pinctrl@[0-9a-f]+$":
> +    $ref: /schemas/pinctrl/fsl,lx2160a-rcw-pinmux.yaml#
> +    description:
> +      The pad muxes of the RCW on the LX2160A, at their RCWSR12 to RCWSR14
> +      and RCWSR27 windows, overridden through the DCSR view of this block.
> +
>  required:
>    - compatible
>    - reg
>
> +allOf:
> +  - if:
> +      not:
> +        properties:
> +          compatible:
> +            contains:
> +              const: fsl,lx2160a-dcfg
> +    then:
> +      patternProperties:
> +        "^pinctrl@[0-9a-f]+$": false
> +
>  additionalProperties: false
>
>  examples:
>
> --
> 2.43.0
>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes
  2026-11-15 13:27 ` [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes Vincent Jardin via B4 Relay
@ 2026-11-16 17:08   ` Frank Li
  2026-11-16 17:29     ` Vincent Jardin
  0 siblings, 1 reply; 13+ messages in thread
From: Frank Li @ 2026-11-16 17:08 UTC (permalink / raw)
  To: vjardin
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Vladimir Oltean,
	Ioana Ciornei

On Sun, Nov 15, 2026 at 02:27:33PM +0100, Vincent Jardin via B4 Relay wrote:
> From: Vincent Jardin <vjardin@free.fr>
>
> fsl_guts_rcw_rmw() only serves the SerDes lane modes. Export it for
> the pad-mux fields of the RCW, and for them only:
>  - fsl_guts_pmux_read() reads the pad-mux fields of a status register
>  - fsl_guts_pmux_override() changes pad-mux fields of one under
>    rcwcr_lock and waits for the status register to follow
>  - fsl_guts_pmux_override_supported() tells whether the SoC has pad-mux
>    fields and whether the DCSR view of DCFG, which holds the override
>    registers, is mapped
>
> Each SoC lists in its fsl_soc_data the fields that can be overridden,
> per RCWSR: a register or a field outside of this list is refused, so
> the SerDes protocols stay with fsl_guts_lane_set_mode(). The LX2160A
> lists the pad muxes of RCWSR12 to RCWSR14 and of RCWSR27.
>
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
> ---

You missed my tag?

Acked-by: Frank Li <Frank.li@nxp.com>

>  drivers/soc/fsl/guts.c   | 125 ++++++++++++++++++++++++++++++++++++++++++++++-
>  include/linux/fsl/guts.h |   3 ++
>  2 files changed, 127 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
> index 28361c63e26c..a4b767f1e297 100644
> --- a/drivers/soc/fsl/guts.c
> +++ b/drivers/soc/fsl/guts.c
> @@ -53,6 +53,12 @@ struct fsl_soc_serdes_rcw_override {
>  	int val;
>  };
>
> +/* Pad-mux fields of the one-based RCWSRn, the ones that may be overridden */
> +struct fsl_soc_pmux_mask {
> +	unsigned int rcwsr;
> +	u32 mask;
> +};
> +
>  struct fsl_soc_data {
>  	const char *sfp_compat;
>  	u32 uid_offset;
> @@ -62,6 +68,7 @@ struct fsl_soc_data {
>  	int (*serdes_get_rcw_override)(int index, int lane,
>  				       enum lynx_lane_mode lane_mode,
>  				       struct fsl_soc_serdes_rcw_override *override);
> +	const struct fsl_soc_pmux_mask *pmux;
>  };
>
>  enum qoriq_die {
> @@ -369,6 +376,110 @@ int fsl_guts_lane_set_mode(int serdes_idx, int lane, enum lynx_lane_mode lane_mo
>  }
>  EXPORT_SYMBOL_NS_GPL(fsl_guts_lane_set_mode, "FSL_GUTS");
>
> +static const struct fsl_soc_pmux_mask *
> +fsl_guts_get_pmux_mask(unsigned int rcwsr)
> +{
> +	const struct fsl_soc_pmux_mask *pmux;
> +
> +	if (!soc.data || !soc.data->pmux)
> +		return NULL;
> +
> +	for (pmux = soc.data->pmux; pmux->rcwsr; pmux++) {
> +		if (pmux->rcwsr == rcwsr)
> +			return pmux;
> +	}
> +
> +	return NULL;
> +}
> +
> +/**
> + * fsl_guts_pmux_read() - read the pad-mux fields of a RCW status register
> + * @rcwsr: one-based index of the status register, as in RCWSR12
> + * @val: the pad-mux fields read, the other fields of the register are 0
> + *
> + * Return: 0 on success, -ENODEV before the DCFG block is mapped, -EINVAL
> + * when the register holds no pad-mux field on this SoC
> + */
> +int fsl_guts_pmux_read(unsigned int rcwsr, u32 *val)
> +{
> +	const struct fsl_soc_pmux_mask *pmux;
> +
> +	if (!soc.dcfg_ccsr)
> +		return -ENODEV;
> +
> +	pmux = fsl_guts_get_pmux_mask(rcwsr);
> +	if (!pmux)
> +		return -EINVAL;
> +
> +	*val = fsl_guts_read(&soc.dcfg_ccsr->rcwsr[rcwsr - 1]) & pmux->mask;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_NS_GPL(fsl_guts_pmux_read, "FSL_GUTS");
> +
> +/**
> + * fsl_guts_pmux_override() - override pad-mux fields of the RCW
> + * @rcwsr: one-based index of the RCWSR and RCWCR pair, as in RCWSR12
> + * @val: the new value of the fields, in place
> + * @mask: the fields to change
> + *
> + * Only the pad-mux fields that the SoC lists can be changed: a SerDes
> + * protocol is changed with fsl_guts_lane_set_mode(), and the other fields
> + * of the RCW are refused.
> + *
> + * The fields outside @mask keep the value the status register shows. The
> + * override register is written and the status register polled until it
> + * shows the result, as fsl_guts_lane_set_mode() does for a SerDes lane.
> + *
> + * Context: takes rcwcr_lock, shared with fsl_guts_lane_set_mode(), and
> + * busy-polls the status register a bounded number of times. Does not
> + * sleep, shall not be called from interrupt context.
> + *
> + * Return:
> + * * 0 on success
> + * * -ENODEV before the DCFG block is mapped
> + * * -EOPNOTSUPP without a DCSR mapping of DCFG
> + * * -EINVAL when @mask is not made of pad-mux fields of the register
> + * * negative error otherwise
> + */
> +int fsl_guts_pmux_override(unsigned int rcwsr, u32 val, u32 mask)
> +{
> +	const struct fsl_soc_pmux_mask *pmux;
> +	int err;
> +
> +	if (!soc.dcfg_ccsr)
> +		return -ENODEV;
> +	if (!soc.dcfg_dcsr)
> +		return -EOPNOTSUPP;
> +
> +	pmux = fsl_guts_get_pmux_mask(rcwsr);
> +	if (!pmux || !mask || (mask & ~pmux->mask))
> +		return -EINVAL;
> +
> +	spin_lock(&soc.rcwcr_lock);
> +	err = fsl_guts_rcw_rmw(rcwsr - 1, val & mask, mask);
> +	spin_unlock(&soc.rcwcr_lock);
> +	if (err)
> +		pr_err("RCW override of RCWSR%u failed: %pe\n", rcwsr,
> +		       ERR_PTR(err));
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_NS_GPL(fsl_guts_pmux_override, "FSL_GUTS");
> +
> +/**
> + * fsl_guts_pmux_override_supported() - can the pad muxes be overridden?
> + *
> + * Return: true when the SoC lists pad-mux fields and the DCFG block is
> + * mapped with its DCSR view, the second reg of the dcfg node, which holds
> + * the override registers
> + */
> +bool fsl_guts_pmux_override_supported(void)
> +{
> +	return soc.dcfg_ccsr && soc.dcfg_dcsr && soc.data && soc.data->pmux;
> +}
> +EXPORT_SYMBOL_NS_GPL(fsl_guts_pmux_override_supported, "FSL_GUTS");
> +
>  static u64 fsl_guts_get_soc_uid(const char *compat, unsigned int offset)
>  {
>  	struct device_node *np;
> @@ -579,6 +690,18 @@ static const struct fsl_soc_data ls1028a_data = {
>  	.num_serdes_lanes = 4,
>  };
>
> +static const struct fsl_soc_pmux_mask lx2160a_pmux[] = {
> +	{ 12, GENMASK(29, 0) },	/* IIC2..SDHC1_DIR */
> +	{ 13, GENMASK(29, 0) },	/* SDHC2_DAT74..EVT43 */
> +	{ 14, GENMASK(10, 0) },	/* EVT20..IIC1 */
> +	{ 27, GENMASK(7, 0) },	/* EC1, EC2, USB_EXT, GTX_CLK, SDHC1_DS */
> +	{}
> +};
> +
> +static const struct fsl_soc_data lx2160a_data = {
> +	.pmux = lx2160a_pmux,
> +};
> +
>  /*
>   * Table for matching compatible strings, for device tree
>   * guts node, for Freescale QorIQ SOCs.
> @@ -606,7 +729,7 @@ static const struct of_device_id fsl_guts_of_match[] = {
>  	{ .compatible = "fsl,ls1088a-dcfg", .data = &ls1088a_data},
>  	{ .compatible = "fsl,ls1012a-dcfg", },
>  	{ .compatible = "fsl,ls1046a-dcfg", .data = &ls1046a_data},
> -	{ .compatible = "fsl,lx2160a-dcfg", },
> +	{ .compatible = "fsl,lx2160a-dcfg", .data = &lx2160a_data},
>  	{ .compatible = "fsl,ls1028a-dcfg", .data = &ls1028a_data},
>  	{}
>  };
> diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h
> index 8d5ffb985fee..ae245afeb7b9 100644
> --- a/include/linux/fsl/guts.h
> +++ b/include/linux/fsl/guts.h
> @@ -142,6 +142,9 @@ int fsl_guts_lane_validate(int serdes_idx, int lane,
>  			   enum lynx_lane_mode lane_mode);
>  int fsl_guts_lane_set_mode(int serdes_idx, int lane,
>  			   enum lynx_lane_mode lane_mode);
> +int fsl_guts_pmux_read(unsigned int rcwsr, u32 *val);
> +int fsl_guts_pmux_override(unsigned int rcwsr, u32 val, u32 mask);
> +bool fsl_guts_pmux_override_supported(void);
>
>  /* Alternate function signal multiplex control */
>  #define MPC85xx_PMUXCR_QE(x) (0x8000 >> (x))
>
> --
> 2.43.0
>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver
  2026-11-15 13:27 ` [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver Vincent Jardin via B4 Relay
@ 2026-11-16 17:12   ` Frank Li
  2026-11-16 17:36   ` Vladimir Oltean
  1 sibling, 0 replies; 13+ messages in thread
From: Frank Li @ 2026-11-16 17:12 UTC (permalink / raw)
  To: vjardin
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Vladimir Oltean,
	Ioana Ciornei

On Sun, Nov 15, 2026 at 02:27:34PM +0100, Vincent Jardin via B4 Relay wrote:
> From: Vincent Jardin <vjardin@free.fr>
>
> The LX2160A muxes its IIC, XSPI, SDHC, UART, IRQ and EVT pads from
> fields of the RCW, read-only in RCWSR12..14 of DCFG and changed at
> runtime through the same fields of the override registers in its DCSR
> view, which read 0 until written.
>
> Since commit 8a1365c7bbc1 ("arm64: dts: lx2160a: add pinmux and i2c
> gpio to support bus recovery") Linux drives them with pinctrl-single on
> the override registers, so its first pin state clears every other field
> of the word: a board whose RCW programs a non-zero pad mux loses those
> pads at the first I2C probe.
>
> Add a generic Layerscape driver for the pad mux as a child of the DCFG
> node. The fields and their encoding are per-SoC tables selected by
> the compatible, so that other Layerscape SoCs can be added to it.
>
> Only the LX2160A is done: the fields of RCWSR12..14 and the EC1, EC2,
> USB_EXT, GTX_CLK and SDHC1_DS ones of RCWSR27.
>
> Then pin states select them with the generic function and groups
> properties, and every change goes through the RCW override
> of fsl-guts, which reads the status register, writes the override and
> waits for the status register to follow.
>
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  MAINTAINERS                                        |   8 +
>  drivers/pinctrl/freescale/Kconfig                  |  15 +
>  drivers/pinctrl/freescale/Makefile                 |   1 +
>  drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c | 427 +++++++++++++++++++++
>  4 files changed, 451 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 93abbb315065..2df4866d37bb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -20207,6 +20207,14 @@ F:	Documentation/devicetree/bindings/clock/*imx*
>  F:	drivers/clk/imx/
>  F:	include/dt-bindings/clock/*imx*
>
> +NXP LAYERSCAPE RCW PAD-MUX DRIVER
> +M:	Vincent Jardin <vjardin@free.fr>
> +L:	linux-gpio@vger.kernel.org
> +L:	imx@lists.linux.dev
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/pinctrl/fsl,lx2160a-rcw-pinmux.yaml
> +F:	drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c
> +
>  NXP NETC ETHERNET SWITCH DRIVER
>  M:	Wei Fang <wei.fang@nxp.com>
>  R:	Clark Wang <xiaoning.wang@nxp.com>
> diff --git a/drivers/pinctrl/freescale/Kconfig b/drivers/pinctrl/freescale/Kconfig
> index fd53cf5bb843..8e964cf620b0 100644
> --- a/drivers/pinctrl/freescale/Kconfig
> +++ b/drivers/pinctrl/freescale/Kconfig
> @@ -283,3 +283,18 @@ config PINCTRL_IMXRT1170
>  	select PINCTRL_IMX
>  	help
>  	  Say Y here to enable the imxrt1170 pinctrl driver
> +
> +config PINCTRL_LAYERSCAPE_RCW
> +	bool "NXP Layerscape RCW pad-mux driver"
> +	depends on OF
> +	depends on ARCH_LAYERSCAPE || COMPILE_TEST
> +	default ARCH_LAYERSCAPE
> +	select FSL_GUTS
> +	select GENERIC_PINCTRL_GROUPS
> +	select GENERIC_PINMUX_FUNCTIONS
> +	select GENERIC_PINCONF
> +	help
> +	  Say Y here to mux the pads of the Layerscape SoCs at runtime. The
> +	  pads are muxed by fields of the RCW: the driver changes it in the
> +	  DCSR view of the DCFG that fsl-guts drives.
> +	  The I2C bus recovery needs it to switch the pads of a bus to GPIO.
> diff --git a/drivers/pinctrl/freescale/Makefile b/drivers/pinctrl/freescale/Makefile
> index d27085c2b4c4..34309ac7411d 100644
> --- a/drivers/pinctrl/freescale/Makefile
> +++ b/drivers/pinctrl/freescale/Makefile
> @@ -35,3 +35,4 @@ obj-$(CONFIG_PINCTRL_IMX25)	+= pinctrl-imx25.o
>  obj-$(CONFIG_PINCTRL_IMX28)	+= pinctrl-imx28.o
>  obj-$(CONFIG_PINCTRL_IMXRT1050)	+= pinctrl-imxrt1050.o
>  obj-$(CONFIG_PINCTRL_IMXRT1170)	+= pinctrl-imxrt1170.o
> +obj-$(CONFIG_PINCTRL_LAYERSCAPE_RCW)	+= pinctrl-layerscape-rcw.o
> diff --git a/drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c b/drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c
> new file mode 100644
> index 000000000000..46686c6923c3
> --- /dev/null
> +++ b/drivers/pinctrl/freescale/pinctrl-layerscape-rcw.c
> @@ -0,0 +1,427 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Layerscape pad muxes: fields of the RCW, changed at runtime.
> + *
> + * Copyright 2026 Free Mobile - Vincent Jardin
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> +#include <linux/fsl/guts.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/pinctrl/pinconf-generic.h>
> +#include <linux/pinctrl/pinctrl.h>
> +#include <linux/pinctrl/pinmux.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/seq_file.h>
> +
> +#include "../core.h"
> +#include "../pinmux.h"
> +
> +struct rcw_pmux_func {
> +	const char *name;
> +	u8 val;
> +};
> +
> +struct rcw_pmux_group {
> +	const char *name;
> +	u8 rcwsr; /* one-based, as in RCWSR12 */
> +	u8 shift;
> +	u8 width;
> +	const struct rcw_pmux_func *funcs;
> +	u8 nfuncs;
> +};
> +
> +/* The pad-mux groups of a SoC, one per field of its RCW */
> +struct rcw_pmux_soc {
> +	const struct rcw_pmux_group *groups;
> +	unsigned int ngroups;
> +};
> +
> +#define RCW_PMUX_FUNC(_name, _val)	{ .name = _name, .val = _val }
> +#define RCW_PMUX_GROUP(_name, _rcwsr, _shift, _width, _funcs)		\
> +	{								\
> +		.name = _name, .rcwsr = _rcwsr,				\
> +		.shift = _shift, .width = _width,			\
> +		.funcs = _funcs, .nfuncs = ARRAY_SIZE(_funcs),		\
> +	}
> +
> +/* LX2160A: RCWSR12..14 and RCWSR27 */
> +static const struct rcw_pmux_func lx2160a_iic2_funcs[] = {
> +	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("flextimer", 2), RCW_PMUX_FUNC("sdhc", 6),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_iic3_funcs[] = {
> +	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("can", 2), RCW_PMUX_FUNC("evt", 6),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_iic5_funcs[] = {
> +	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("sdhc-clk", 2), RCW_PMUX_FUNC("spi", 3),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_iic6_funcs[] = {
> +	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("sdhc-clk", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_xspi1_funcs[] = {
> +	RCW_PMUX_FUNC("flexspi", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_sdhc1_base_funcs[] = {
> +	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("spi", 2), RCW_PMUX_FUNC("sdhc-spi", 3),
> +	RCW_PMUX_FUNC("sdhc-data4", 4),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_sdhc1_dir_funcs[] = {
> +	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("spi", 3), RCW_PMUX_FUNC("sdhc-data", 4),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_sdhc2_data74_funcs[] = {
> +	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("i2c", 2), RCW_PMUX_FUNC("flexspi", 6),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_sdhc2_base_funcs[] = {
> +	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("spi", 2), RCW_PMUX_FUNC("flexspi", 6),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_uart_funcs[] = {
> +	RCW_PMUX_FUNC("uart", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_uart1_rtscts_funcs[] = {
> +	RCW_PMUX_FUNC("uart", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("uart3", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_uart2_rtscts_funcs[] = {
> +	RCW_PMUX_FUNC("uart", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("uart4", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_irq_funcs[] = {
> +	RCW_PMUX_FUNC("irq", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_irq_flextimer_funcs[] = {
> +	RCW_PMUX_FUNC("irq", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("flextimer", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_evt_funcs[] = {
> +	RCW_PMUX_FUNC("evt", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("flextimer", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_clk_out_funcs[] = {
> +	RCW_PMUX_FUNC("gpio", 1), RCW_PMUX_FUNC("flextimer", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_asleep_funcs[] = {
> +	RCW_PMUX_FUNC("asleep", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("evt", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_reset_req_funcs[] = {
> +	RCW_PMUX_FUNC("reset-req", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_iic1_funcs[] = {
> +	RCW_PMUX_FUNC("i2c", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_ec1_funcs[] = {
> +	RCW_PMUX_FUNC("rgmii", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_ec2_funcs[] = {
> +	RCW_PMUX_FUNC("rgmii", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("tsec-1588", 2),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_usb_ext_funcs[] = {
> +	RCW_PMUX_FUNC("usb", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_gtx_clk_funcs[] = {
> +	RCW_PMUX_FUNC("gtx-clk", 0), RCW_PMUX_FUNC("gpio", 1),
> +};
> +
> +static const struct rcw_pmux_func lx2160a_sdhc1_ds_funcs[] = {
> +	RCW_PMUX_FUNC("sdhc", 0), RCW_PMUX_FUNC("gpio", 1),
> +	RCW_PMUX_FUNC("spi", 2),
> +};
> +
> +static const struct rcw_pmux_group lx2160a_groups[] = {
> +	/* RCWSR12 */
> +	RCW_PMUX_GROUP("iic2", 12, 0, 3, lx2160a_iic2_funcs),
> +	RCW_PMUX_GROUP("iic3", 12, 3, 3, lx2160a_iic3_funcs),
> +	RCW_PMUX_GROUP("iic4", 12, 6, 3, lx2160a_iic3_funcs),
> +	RCW_PMUX_GROUP("iic5", 12, 9, 3, lx2160a_iic5_funcs),
> +	RCW_PMUX_GROUP("iic6", 12, 12, 3, lx2160a_iic6_funcs),
> +	RCW_PMUX_GROUP("xspi1-data74", 12, 15, 3, lx2160a_xspi1_funcs),
> +	RCW_PMUX_GROUP("xspi1-data30", 12, 18, 3, lx2160a_xspi1_funcs),
> +	RCW_PMUX_GROUP("xspi1-base", 12, 21, 3, lx2160a_xspi1_funcs),
> +	RCW_PMUX_GROUP("sdhc1-base", 12, 24, 3, lx2160a_sdhc1_base_funcs),
> +	RCW_PMUX_GROUP("sdhc1-dir", 12, 27, 3, lx2160a_sdhc1_dir_funcs),
> +	/* RCWSR13 */
> +	RCW_PMUX_GROUP("sdhc2-data74", 13, 0, 3, lx2160a_sdhc2_data74_funcs),
> +	RCW_PMUX_GROUP("sdhc2-base", 13, 3, 3, lx2160a_sdhc2_base_funcs),
> +	RCW_PMUX_GROUP("uart1-soutsin", 13, 6, 3, lx2160a_uart_funcs),
> +	RCW_PMUX_GROUP("uart1-rtscts", 13, 9, 3, lx2160a_uart1_rtscts_funcs),
> +	RCW_PMUX_GROUP("uart2-soutsin", 13, 12, 3, lx2160a_uart_funcs),
> +	RCW_PMUX_GROUP("uart2-rtscts", 13, 15, 3, lx2160a_uart2_rtscts_funcs),
> +	RCW_PMUX_GROUP("irq11-8", 13, 18, 3, lx2160a_irq_funcs),
> +	RCW_PMUX_GROUP("irq7-4", 13, 21, 3, lx2160a_irq_flextimer_funcs),
> +	RCW_PMUX_GROUP("irq3-0", 13, 24, 3, lx2160a_irq_flextimer_funcs),
> +	RCW_PMUX_GROUP("evt4-3", 13, 27, 3, lx2160a_evt_funcs),
> +	/* RCWSR14 */
> +	RCW_PMUX_GROUP("evt2-0", 14, 0, 3, lx2160a_evt_funcs),
> +	RCW_PMUX_GROUP("clk-out", 14, 3, 3, lx2160a_clk_out_funcs),
> +	RCW_PMUX_GROUP("asleep", 14, 6, 3, lx2160a_asleep_funcs),
> +	RCW_PMUX_GROUP("reset-req", 14, 9, 1, lx2160a_reset_req_funcs),
> +	RCW_PMUX_GROUP("iic1", 14, 10, 1, lx2160a_iic1_funcs),
> +	/* RCWSR27 */
> +	RCW_PMUX_GROUP("ec1", 27, 0, 2, lx2160a_ec1_funcs),
> +	RCW_PMUX_GROUP("ec2", 27, 2, 2, lx2160a_ec2_funcs),
> +	RCW_PMUX_GROUP("usb-ext", 27, 4, 1, lx2160a_usb_ext_funcs),
> +	RCW_PMUX_GROUP("gtx-clk", 27, 5, 1, lx2160a_gtx_clk_funcs),
> +	RCW_PMUX_GROUP("sdhc1-ds", 27, 6, 2, lx2160a_sdhc1_ds_funcs),
> +};
> +
> +static const struct rcw_pmux_soc lx2160a_soc = {
> +	.groups = lx2160a_groups,
> +	.ngroups = ARRAY_SIZE(lx2160a_groups),
> +};
> +
> +struct rcw_pmux {
> +	struct device *dev;
> +	struct pinctrl_dev *pctl;
> +	struct pinctrl_desc desc;
> +	const struct rcw_pmux_soc *soc;
> +	struct pinctrl_pin_desc *pins;
> +};
> +
> +static u32 rcw_pmux_group_mask(const struct rcw_pmux_group *group)
> +{
> +	return GENMASK(group->shift + group->width - 1, group->shift);
> +}
> +
> +static const struct rcw_pmux_func *
> +rcw_pmux_find_func(const struct rcw_pmux_group *group, const char *name)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < group->nfuncs; i++) {
> +		if (!strcmp(group->funcs[i].name, name))
> +			return &group->funcs[i];
> +	}
> +
> +	return NULL;
> +}
> +
> +static void rcw_pmux_pin_dbg_show(struct pinctrl_dev *pctldev,
> +				  struct seq_file *s, unsigned int pin)
> +{
> +	struct rcw_pmux *pmux = pinctrl_dev_get_drvdata(pctldev);
> +	const struct rcw_pmux_group *group = &pmux->soc->groups[pin];
> +	unsigned int i;
> +	u32 val;
> +
> +	if (fsl_guts_pmux_read(group->rcwsr, &val))
> +		return;
> +
> +	val = field_get(rcw_pmux_group_mask(group), val);
> +	for (i = 0; i < group->nfuncs; i++) {
> +		if (group->funcs[i].val == val) {
> +			seq_puts(s, group->funcs[i].name);
> +			return;
> +		}
> +	}
> +	seq_printf(s, "0x%x", val);
> +}
> +
> +static const struct pinctrl_ops rcw_pmux_pctlops = {
> +	.get_groups_count = pinctrl_generic_get_group_count,
> +	.get_group_name = pinctrl_generic_get_group_name,
> +	.get_group_pins = pinctrl_generic_get_group_pins,
> +	.pin_dbg_show = rcw_pmux_pin_dbg_show,
> +	.dt_node_to_map = pinconf_generic_dt_node_to_map_group,
> +	.dt_free_map = pinconf_generic_dt_free_map,
> +};
> +
> +static int rcw_pmux_set_mux(struct pinctrl_dev *pctldev,
> +			    unsigned int fsel, unsigned int gsel)
> +{
> +	struct rcw_pmux *pmux = pinctrl_dev_get_drvdata(pctldev);
> +	const struct function_desc *func;
> +	const struct rcw_pmux_group *group;
> +	const struct rcw_pmux_func *mux;
> +	const struct group_desc *grp;
> +	u32 mask;
> +
> +	func = pinmux_generic_get_function(pctldev, fsel);
> +	grp = pinctrl_generic_get_group(pctldev, gsel);
> +	if (!func || !grp)
> +		return -EINVAL;
> +	group = grp->data;
> +
> +	mux = rcw_pmux_find_func(group, func->func->name);
> +	if (!mux) {
> +		dev_err(pmux->dev, "%s has no %s function\n",
> +			group->name, func->func->name);
> +		return -EINVAL;
> +	}
> +
> +	mask = rcw_pmux_group_mask(group);
> +
> +	return fsl_guts_pmux_override(group->rcwsr, field_prep(mask, mux->val),
> +				      mask);
> +}
> +
> +static const struct pinmux_ops rcw_pmux_pmxops = {
> +	.get_functions_count = pinmux_generic_get_function_count,
> +	.get_function_name = pinmux_generic_get_function_name,
> +	.get_function_groups = pinmux_generic_get_function_groups,
> +	.set_mux = rcw_pmux_set_mux,
> +	.strict = true,
> +};
> +
> +static int rcw_pmux_add_functions(struct rcw_pmux *pmux)
> +{
> +	const struct rcw_pmux_soc *soc = pmux->soc;
> +	const struct rcw_pmux_group *group;
> +	const char **groups;
> +	unsigned int i, j, k, n;
> +	int ret;
> +
> +	for (i = 0; i < soc->ngroups; i++) {
> +		group = &soc->groups[i];
> +		for (j = 0; j < group->nfuncs; j++) {
> +			const char *name = group->funcs[j].name;
> +
> +			/* already added from an earlier group? */
> +			for (k = 0; k < i; k++) {
> +				if (rcw_pmux_find_func(&soc->groups[k], name))
> +					break;
> +			}
> +			if (k < i)
> +				continue;
> +
> +			groups = devm_kcalloc(pmux->dev, soc->ngroups,
> +					      sizeof(*groups), GFP_KERNEL);
> +			if (!groups)
> +				return -ENOMEM;
> +			n = 0;
> +			for (k = i; k < soc->ngroups; k++) {
> +				if (rcw_pmux_find_func(&soc->groups[k], name))
> +					groups[n++] = soc->groups[k].name;
> +			}
> +			ret = pinmux_generic_add_function(pmux->pctl, name,
> +							  groups, n, NULL);
> +			if (ret < 0)
> +				return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcw_pmux_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	const struct rcw_pmux_soc *soc;
> +	struct rcw_pmux *pmux;
> +	unsigned int i;
> +	u32 val;
> +	int ret;
> +
> +	/* The override needs the DCSR view of DCFG, mapped by fsl-guts */
> +	if (!fsl_guts_pmux_override_supported())
> +		return dev_err_probe(dev, -ENODEV,
> +				     "no RCW override through fsl-guts: the dcfg node needs its DCSR reg\n");
> +
> +	soc = device_get_match_data(dev);
> +	if (!soc)
> +		return -ENODEV;
> +
> +	pmux = devm_kzalloc(dev, sizeof(*pmux), GFP_KERNEL);
> +	if (!pmux)
> +		return -ENOMEM;
> +	pmux->dev = dev;
> +	pmux->soc = soc;
> +
> +	pmux->pins = devm_kcalloc(dev, soc->ngroups, sizeof(*pmux->pins),
> +				  GFP_KERNEL);
> +	if (!pmux->pins)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < soc->ngroups; i++) {
> +		pmux->pins[i].number = i;
> +		pmux->pins[i].name = soc->groups[i].name;
> +	}
> +	pmux->desc.name = dev_name(dev);
> +	pmux->desc.pins = pmux->pins;
> +	pmux->desc.npins = soc->ngroups;
> +	pmux->desc.pctlops = &rcw_pmux_pctlops;
> +	pmux->desc.pmxops = &rcw_pmux_pmxops;
> +	pmux->desc.owner = THIS_MODULE;
> +
> +	ret = devm_pinctrl_register_and_init(dev, &pmux->desc, pmux,
> +					     &pmux->pctl);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "pinctrl registration failed\n");
> +
> +	for (i = 0; i < soc->ngroups; i++) {
> +		ret = pinctrl_generic_add_group(pmux->pctl, soc->groups[i].name,
> +						&pmux->pins[i].number, 1,
> +						(void *)&soc->groups[i]);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
> +	ret = rcw_pmux_add_functions(pmux);
> +	if (ret)
> +		return ret;
> +
> +	for (i = 0; i < soc->ngroups; i++) {
> +		u8 rcwsr = soc->groups[i].rcwsr;
> +
> +		if (i && rcwsr == soc->groups[i - 1].rcwsr)
> +			continue;
> +		if (!fsl_guts_pmux_read(rcwsr, &val))
> +			dev_dbg(dev, "pad muxes of RCWSR%u = 0x%08x\n", rcwsr,
> +				val);
> +	}
> +
> +	return pinctrl_enable(pmux->pctl);
> +}
> +
> +static const struct of_device_id rcw_pmux_of_match[] = {
> +	{ .compatible = "fsl,lx2160a-rcw-pinmux", .data = &lx2160a_soc },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, rcw_pmux_of_match);
> +
> +static struct platform_driver rcw_pmux_driver = {
> +	.driver = {
> +		.name = "layerscape-rcw-pinmux",
> +		.of_match_table = rcw_pmux_of_match,
> +	},
> +	.probe = rcw_pmux_probe,
> +};
> +module_platform_driver(rcw_pmux_driver);
> +
> +MODULE_AUTHOR("Vincent Jardin <vjardin@free.fr>");
> +MODULE_DESCRIPTION("NXP Layerscape RCW pad-mux driver");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS("FSL_GUTS");
>
> --
> 2.43.0
>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes
  2026-11-16 17:08   ` Frank Li
@ 2026-11-16 17:29     ` Vincent Jardin
  0 siblings, 0 replies; 13+ messages in thread
From: Vincent Jardin @ 2026-11-16 17:29 UTC (permalink / raw)
  To: Frank Li
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Vladimir Oltean,
	Ioana Ciornei

Hi Frank, Vladimir, Christophe,

> > Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > Signed-off-by: Vincent Jardin <vjardin@free.fr>
> > ---
> 
> You missed my tag?

Frank,

No, it was on purpose since I did many changes after Vladimir's comments.
The goal is still idempontent for lx2160, but the design is now more NXP
CPU generic.

Thanks for re-ack-ing.

Next, let's make sure that Vlaidmir is ok with 4/5 (if the driver is
generic enough).

And, let's Christophe review/ack the 3/5 regarding pinctrl.

I guess that 1/5 needs Rob on the devicetree, not sure ?

Then, since it was unclear for me if the patch 1..4 are through
pinctrl and 5 thru imx (please, Linus Walleij) ?

I hope it'll go thru the proper reviewers,
  Vincent

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver
  2026-11-15 13:27 ` [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver Vincent Jardin via B4 Relay
  2026-11-16 17:12   ` Frank Li
@ 2026-11-16 17:36   ` Vladimir Oltean
  2026-11-16 18:51     ` Vincent Jardin
  1 sibling, 1 reply; 13+ messages in thread
From: Vladimir Oltean @ 2026-11-16 17:36 UTC (permalink / raw)
  To: vjardin
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Ioana Ciornei

On Sun, Nov 15, 2026 at 02:27:34PM +0100, Vincent Jardin via B4 Relay wrote:
> +static const struct rcw_pmux_func lx2160a_clk_out_funcs[] = {
> +	RCW_PMUX_FUNC("gpio", 1), RCW_PMUX_FUNC("flextimer", 2),
> +};

I was testing the /sys/kernel/debug/pinctrl/1e0012c.pinctrl/pins
debugfs, and I just noticed the clk-out pin group gets printed as raw 0x0.

I think you've uncovered a documentation bug here. The primary function
of CLK_OUT_PMUX should be 000, aka CLK_OUT (this is a debugging signal
of the SoC, along with ASLEEP). I may be missing some context as to why
the reference manual says this value is reserved, but it clearly does
something - because table 19 with the hardcoded RCW bits lists 000 as
the default value for this field. So the RM contradicts itself.

Also, I see the debugfs thinks our pin groups are individual pins:

cat /sys/kernel/debug/pinctrl/1e0012c.pinctrl/pins
registered pins: 30
pin 0 (iic2) 0:? sdhc
pin 1 (iic3) 0:? can
pin 2 (iic4) 0:? can
pin 3 (iic5) 0:? i2c
pin 4 (iic6) 0:? i2c
pin 5 (xspi1-data74) 0:? flexspi
pin 6 (xspi1-data30) 0:? flexspi
pin 7 (xspi1-base) 0:? flexspi
pin 8 (sdhc1-base) 0:? sdhc
pin 9 (sdhc1-dir) 0:? sdhc
pin 10 (sdhc2-data74) 0:? sdhc
pin 11 (sdhc2-base) 0:? sdhc
pin 12 (uart1-soutsin) 0:? uart
pin 13 (uart1-rtscts) 0:? uart
pin 14 (uart2-soutsin) 0:? uart
pin 15 (uart2-rtscts) 0:? uart
pin 16 (irq11-8) 0:? irq
pin 17 (irq7-4) 0:? irq
pin 18 (irq3-0) 0:? irq
pin 19 (evt4-3) 0:? evt
pin 20 (evt2-0) 0:? evt
pin 21 (clk-out) 0:? 0x0
pin 22 (asleep) 0:? asleep
pin 23 (reset-req) 0:? reset-req
pin 24 (iic1) 0:? i2c
pin 25 (ec1) 0:? rgmii
pin 26 (ec2) 0:? rgmii
pin 27 (usb-ext) 0:? usb
pin 28 (gtx-clk) 0:? gtx-clk
pin 29 (sdhc1-ds) 0:? sdhc

(which they're not - iic2 is a group consisting of SCL and SDA, whose
function cannot be selected independently, which is why you've grouped
them together).

I suppose this is OK? Not really a pinctrl expert here (and it predates
your work - pinctrl-simple worked the same way).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver
  2026-11-16 17:36   ` Vladimir Oltean
@ 2026-11-16 18:51     ` Vincent Jardin
  0 siblings, 0 replies; 13+ messages in thread
From: Vincent Jardin @ 2026-11-16 18:51 UTC (permalink / raw)
  To: Vladimir Oltean, Linus Walleij
  Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
	Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, linux-gpio, devicetree, linux-kernel,
	linuxppc-dev, linux-arm-kernel, imx, Ioana Ciornei

Hi Linus,

regarding Vladimir's question:

> (which they're not - iic2 is a group consisting of SCL and SDA, whose
> function cannot be selected independently, which is why you've grouped
> them together).
> 
> I suppose this is OK? Not really a pinctrl expert here (and it predates
> your work - pinctrl-simple worked the same way).

either way is ok for me too, I do not properly understand the guidelines
that would fit best the kernel. What would you prefer ?
  - muxes per pad ?
  - 1 pin per field ?

thank you,
  Vincent

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-11-16 18:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 13:27 [PATCH v6 0/5] lx2160a: change the pad muxes through the RCW override Vincent Jardin via B4 Relay
2026-11-15 13:27 ` [PATCH v6 1/5] dt-bindings: pinctrl: add the NXP LX2160A RCW pad mux Vincent Jardin via B4 Relay
2026-11-16 17:02   ` Frank Li
2026-11-15 13:27 ` [PATCH v6 2/5] dt-bindings: soc: fsl: layerscape-dcfg: add the LX2160A pad-mux child Vincent Jardin via B4 Relay
2026-11-16 17:04   ` Frank Li
2026-11-15 13:27 ` [PATCH v6 3/5] soc: fsl: guts: add the RCW override of the pad muxes Vincent Jardin via B4 Relay
2026-11-16 17:08   ` Frank Li
2026-11-16 17:29     ` Vincent Jardin
2026-11-15 13:27 ` [PATCH v6 4/5] pinctrl: freescale: add the Layerscape RCW pad-mux driver Vincent Jardin via B4 Relay
2026-11-16 17:12   ` Frank Li
2026-11-16 17:36   ` Vladimir Oltean
2026-11-16 18:51     ` Vincent Jardin
2026-11-15 13:27 ` [PATCH v6 5/5] arm64: dts: lx2160a: describe the pad muxes as the DCFG RCW override Vincent Jardin via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®