Skip to contentSkip to conversation

Add support for the NXP S32G SerDes subsystem

RFC PATCH In review Jan Petrous (OSS) 4 participants 19 messages Nov 25

Subsystems (14)
lore
Share & tools
lore

Jan Petrous (OSS)

author maintainer
#0 lore raw

v4 cover Add support for the NXP S32G SerDes subsystem

This series continues the S32G SerDes/XPCS upstreaming started by Vincent Guittot [v2], which I posted as RFC v3 [v3]. The patches originating from his series keep his authorship, with Co-developed-by and his Signed-off-by.

The S32G SoC family has two SerDes subsystems. Each one is built from a DesignWare PCIe controller, two DesignWare XPCS instances and a shared two-lane combo PHY (PMA). The lanes are multiplexed between the PCIe controller and the XPCS instances, so a SerDes instance runs PCIe only, SGMII only, or both, depending on its working mode.

The series adds:
- the device tree bindings (patches 1-3);
- S32G support in pcs-xpcs and the S32G XPCS glue (patches 4-8);
- the SerDes subsystem PHY driver, which owns the shared PMA and sequences the bring-up (patch 9);
- SGMII support in the dwmac-s32 MAC glue (patch 10);
- the S32G2 and S32G3 device tree nodes and two routing variants for the S32G3-VNP-RDB3 board (patches 12-15).

In the PCIe+SGMII modes the XPCS shares the PMA with the PCIe lane, so the reset and bring-up ordering is driven by the SerDes PHY driver, and the XPCS is not a self-contained PCS platform device. The glue exposes each XPCS instance to pcs-xpcs as an MDIO bus over its indirect MMIO window. The SerDes node is a four-cell PHY provider, <lane type instance max-speed>: a PCIe root port references its lanes, a MAC references its lane, the XPCS instance it is wired to and the highest speed the lane is wired for, and gets its PCS from the SerDes through pcs-handle. The mode follows from these references.

The S32G XPCS reports the generic DesignWare PCS ID; what is specific to S32G is the PMA integration. Following the v3 discussion with Coia [id], the series has no synthetic PCS ID. Patch 5 lets a glue driver declare the PCS and PMA IDs through struct dw_xpcs_info, and lets a pcs-xpcs entry name a PMA ID. The S32G glue declares the DesignWare PCS ID together with NXP_S32G_XPCS_PMA_ID, which selects the S32G entry of patch 6. The PCS ID is declared rather than read because the glue creates the PCS before the SerDes clocks run, so the ID registers cannot be read at that point. The alternative is to create the PCS after the SerDes bring-up and declare only the PMA ID; I would welcome an opinion on which is preferred.

Scope: the 1.25 Gbit/s working modes only, i.e. SGMII up to 1G. The S32G GMAC is limited to 1G, so nothing in tree can use the 3.125 Gbit/s modes yet. 2500BASE-X support will follow with its first user: the S32G PFE Ethernet driver or the S32R47 integration. It builds on patch 5:
the glue also declares the PMA reference clock rate, which the 2.5G PLL switch needs.

v3 introduced a transport-agnostic NXP SerDes XPCS core, authored by Clark Wang, as a common base for S32G and a later i.MX9 xPCS port. Following the review of v3, v4 drops it in favour of pcs-xpcs. This does not leave i.MX9 behind: its XPCS is reached over Clause 45 MDIO, which pcs-xpcs supports as it is. No i.MX9 code was part of v3. Thanks to Clark for the shared core work.

Merging: the series is meant for the PHY tree, as v2 and v3 were. Patches 4-8 (pcs-xpcs) and 10 (dwmac-s32) change networking code, and the build depends on them in order, 8 -> 9 -> 10. I would ask for Acks from the PCS and stmmac side on those patches, so that they can go through the PHY tree together with patch 9. The device tree patches 12-15 can go through the NXP SoC tree once the bindings are in.

The series is based on v7.4-rc1. Since v3, Coia Prant's RK3568 XPCS series [rk3568] went in: pcs-xpcs-plat.c is now its own module (PCS_XPCS_PLATFORM), and pcs-xpcs restarts SGMII autonegotiation in xpcs_config_aneg_c37_sgmii() and in xpcs_get_state_c37_sgmii() when the link is down with AN complete latched. The S32G glue of patch 8 takes the same shape as the RK3568 one, an MDIO bus over the register window with the PCS created by pcs-xpcs. The series was retested on the 7.4 merge window state of 2026-10-27, see below; rc1 brought no change to pcs-xpcs, the SerDes PHY driver or dwmac-s32 after that.

The bring-up register sequences come from the vendor driver and the reference manual.

Tested on an S32G399A-RDB3 board, on the merge window base above, with the 15 patches as posted. The XPCS1 runs use the PFE Ethernet MACs, whose driver is not upstream yet.

- SerDes_1 in mode 3 (dual SGMII, 125 MHz): XPCS0 as a 1G fixed link to the on-board SJA1110, XPCS1 with in-band SGMII to an AQR113C. 30 partner speed changes between 100M and 1G without a stale speed, which is the path where pcs-xpcs restarts AN, with the link timer that the PMA hook sets, 935/941 and 942/941 Mbit/s on the two lanes, 94.2 Mbit/s at 100M with no UDP loss, link down/up and driver reload cycles, no kernel errors. The receive path works on both lanes, which shows that the S32G entry, and with it the no-soft-reset quirk, is selected through the declared IDs.

- SerDes_1 in mode 2 (PCIe x1 + SGMII, 100 MHz, internal and external reference) together with SerDes_0 in mode 3 (GMAC0 over XPCS0 at 1G):
an Intel 82574L in the PCIe slot (Gen 1 x1, the card's maximum) at 901/941 Mbit/s with its BARs in the 64-bit prefetchable window, the shared-lane XPCS1 at 935/941, GMAC0 at 935/941, NIC and XPCS1 at the same time 898 + 935, 10/10 XPCS1 link down/up under PCIe traffic with the NIC never below 893 Mbit/s, 10/10 GMAC0 down/up, no AER events. The same figures on the external reference (NIC 902/941). The fixed linux,pci-domain puts the slot in domain 1, so its NIC is named enP1p1s0.

- The mode 1 variant of patch 15: SerDes_0 with PCIe_0 on lane 0, on the internal 100 MHz reference, and GMAC0 over XPCS0 on lane 1, with no phy-handle left on GMAC0. An NVMe SSD in the M.2 M-key slot trains at Gen 3 x1 and reads at 511 MB/s, with the data read back intact and no AER events. SerDes_1 derives PCIe x2 from its single PCIe reference. The mode 3 variant brings up SerDes_0 with GMAC0 on a fixed 1G SGMII link to the SJA1110. No GMAC0 traffic with the
variants: the plain RDB3 DT has no SJA1110 firmware loader.

- On v7.4-rc1 itself, with PHY_S32G_SERDES=m and PCIe_0 bound to a SerDes_0 lane, the PCIe controller defers until the module is loaded, and rmmod of the module then fails with "in use".

- The two pcs-xpcs quirks of patch 4 were verified earlier by removing them (see the patch 4 note below).

- With the 2.5G follow-up on top, SerDes_1 mode 3 also passed the 100M/1G/2.5G partner speed cycle at 2.35/2.32 Gbit/s on the 2.5G lane, with the same 1G and 100M figures as above.

Not covered: suspend/resume, GMAC0 at 10M and 100M.

Changes in v4:

- Drop the NXP SerDes XPCS shared core (v3 patch 4) and use pcs-xpcs. The S32G support becomes a pcs-xpcs entry and a platform glue which owns the PMA/PLL bring-up. The review comments on v3 patch 4 no longer apply.

- Drop 2.5G support: no in-tree MAC can use it, and the binding only describes the 1.25 Gbit/s modes.

- Patch 1: the lanes are argument cells of the SerDes node, <lane type instance max-speed>, instead of child nodes (Rob, v2; Frank, v3). The XPCS instance is the third cell: the mux is programmed before any MAC probes, and modes 1 and 2 differ only by it. The cell layout is final. The fourth cell is the highest speed the lane is wired for; this series takes 1000 only, and 2500 comes with the 3.125 Gbit/s modes, which select other SUBSYS_MODE values, reference clocks and PCIe speeds, again at SerDes probe. The driver walks the tree for the references at probe. nxp,xpcs-instance vendor property is gone.
Patches 2, 3, 9, 10, 13 and 15 follow: a MAC carries phys and pcs-handle to the SerDes node, a PCIe root port one phys entry per lane, and the SerDes driver provides one PHY per XPCS instance next to the PCIe one.

- Patch 2: phy-mode "sgmii" requires phys and pcs-handle, and each of them requires the other.

- Patch 3 (v3 patch 3): the example fix is dropped (Frank). What is left allows two phys entries on the root port, one per lane, and updates the example to the cells form.

- New patch 4: quirks mask in struct dw_xpcs_desc (no soft reset, no EEE). Both were checked on RDB3 by removing them. Without the first, the generic BMCR soft reset of xpcs_pre_config() leaves the XPCS stuck in reset on the in-band lane (BMCR_RESET never self-clears and every register then reads 0x8000) and the receive path dead on the lanes where it does complete; the working reset is VR_RST inside the vendor bring-up, which the SerDes PHY driver owns. VR_MII_EEE_MCTRL0/1 read zero and ignore writes, so the second quirk keeps the driver from touching registers the integration does not have.

- New patch 5: a glue driver can declare the PCS and PMA IDs through struct dw_xpcs_info with xpcs_create_pcs_mdiodev_info(); with both declared, no ID register is read. A dw_xpcs_desc entry can name a PMA ID, and such an entry takes precedence over one for the same PCS ID that matches any PMA. No functional change for existing users. This replaces the synthetic PCS ID discussed in the v3 thread [id], which Coia asked to avoid; the value proposed then, 0x30, is also used by the Qualcomm Nord RFC.

- New patch 6: S32G entry in pcs-xpcs, for the DesignWare PCS ID with NXP_S32G_XPCS_PMA_ID. SGMII only, with the PMA hook in pcs-xpcs-s32g.c. The hook sets the SGMII link timer to the 1.6 ms that phylink_get_link_timer_ns() gives for SGMII, converted with the reference manual formula, then sets CL37_TMR_OVR_RIDE, and restarts AN when it is enabled, so that the negotiation runs with the new timer. v3 wrote 0x7a1, the vendor 2500BASE-X value. The hook does not touch the PLLs and does not flush the PCS: the lane is on MPLLA from the SerDes bring-up, and the 1G sequence of the reference manual has no such steps. The quirks stay on the entry: Coia suggested glue-set flags, and they would move there without further change if that is preferred.

- New patch 7: with in-band SGMII, report the link down until AN completes, as the S32G XPCS keeps the previous SGMII link word until then. The v3 XPCS driver did the same. The gate also ran ungated on RDB3 with the same result; it stays behind the quirk only because it has been seen on S32G alone. It is independent of the AN restart that pcs-xpcs now does in the same function: that one acts once the link is down and AN complete is latched, this one keeps a stale link word from being reported before AN has completed.

- Patch 8 (v3 patch 5):
- PCS_NXP_S32G_XPCS is a hidden symbol, selected by the SerDes PHY driver, in the "if PCS_XPCS" block that the RK3568 series added.
- DW_VR_RST and DW_PSEQ_ST* come from pcs-xpcs.h.
- The regmap is replaced by a mutex protected indirect accessor. Each XPCS instance is an mii_bus, and the PCS comes from xpcs_create_pcs_mdiodev_info() with the IDs of patch 5 declared. The glue does not emulate the MDIO ID registers; the hardware reports the generic DesignWare XPCS ID 0x7996ced0 (checked on RDB3).
- Use MII_BMCR/BMCR_* and DW_VR_MII_DIG_CTRL1 instead of private defines (Andrew).
- The exported bring-up steps have kernel-doc; the indirect window accessors use guard(mutex); the BMCR writes before VR_RST are gone, as the XPCS state is set after the reset.

- Patch 9:
- PHY_S32G_SERDES depends on NETDEVICES, which its PCS select needs.
- The PCIe PHY provider is registered on the SerDes device.
- Return -EBUSY from set_mode while the PHY is powered on.
- Drop the redundant reference clock check. Print the selected mode once at probe instead of on every resume.
- Set .owner on the PCIe PHY ops, so a bound PCIe controller pins the module.
- Use the reference manual field names and named delays in the PCIe PHY register path; drop the unused max_speed.

- Patch 10:
- Select PHY_S32G_SERDES instead of "depends on PHY_S32G_SERDES || PHY_S32G_SERDES=n". PHY_S32G_SERDES (patch 9) now selects PCS_XPCS and PCS_NXP_S32G_XPCS instead of depending on them (Maxime).
- Store the PCS in priv->hw->phylink_pcs (Maxime).
- Do not add RMII and MII to the interface selector (Maxime).
- Keep the MAC transmit clock at 125 MHz with SGMII. The generic

    stmmac_set_clk_tx_rate() set 25 MHz / 2.5 MHz at 100M / 10M.

- Look up the PCS for SGMII only; an SGMII MAC without pcs-handle fails to probe.
- Compute the interface selector once at probe, so an unsupported phy-mode fails the probe.
- Disable EEE with SGMII: the S32G XPCS has no EEE, but stmmac assumes LPI works through any external PCS.

- Patch 11: drop the shared core entry, add pcs-xpcs-s32g.c. The entry and the binding name the same maintainers.

- Patch 13: keep the S32G3 SoC nodes sorted by unit address.

- Patch 14: fixed linux,pci-domain on both PCIe controllers.

- Patch 15: the routing variants are full .dts files that include the board DT, not overlays, as they drop the phy-handle of GMAC0 and /delete-property/ has no effect in an overlay.

- sashiko-bot review of v3:
- Patch 2: pcs-handle only adds maxItems: 1 to the inherited type.
- Patch 14: mark the window above 4 GiB as 64-bit prefetchable (0x43000000), as the other DesignWare hosts do. A non-prefetchable window above 4 GiB cannot be used behind the root port.
- Patch 9:
- Register the PCIe PHY provider at the end of probe, after the clocks are up.
- Return -ENODEV for an XPCS instance which was not set up, instead of deferring forever.
- Track the clock state, so that suspend and unbind do not disable the clocks again after a failed resume.
- Set suppress_bind_attrs.
- The "sleep in atomic context" report is a false positive: noirq callbacks run in process context.

- Commit messages and code comments are shortened throughout. Patch 12 has no other change.

To: Vincent Guittot <[email protected]>
To: Ghennadi Procopciuc <[email protected]>
To: Ciprian Marian Costea <[email protected]>
To: NXP S32 Linux Team <[email protected]>
To: Vinod Koul <[email protected]>
To: Neil Armstrong <[email protected]>
To: Manivannan Sadhasivam <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Andrew Lunn <[email protected]>
To: David S. Miller <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Bjorn Helgaas <[email protected]>
To: Lorenzo Pieralisi <[email protected]>
To: Krzysztof Wilczyński <[email protected]>
To: Bogdan Hamciuc <[email protected]>
To: Ionut Vicovan <[email protected]>
To: Andrew Lunn <[email protected]>
To: Heiner Kallweit <[email protected]>
To: Russell King <[email protected]>
To: Philipp Zabel <[email protected]>
To: Maxime Chevallier <[email protected]>
To: Maxime Coquelin <[email protected]>
To: Alexandre Torgue <[email protected]>
To: Chester Lin <[email protected]>
To: Matthias Brugger <[email protected]>
To: Frank Li <[email protected]>
To: Sascha Hauer <[email protected]>
To: Pengutronix Kernel Team <[email protected]>
To: Fabio Estevam <[email protected]>
To: Richard Cochran <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Jan Petrous (OSS) (12):
dt-bindings: phy: Add NXP S32G SerDes subsystem
dt-bindings: net: nxp,s32-dwmac: Document pcs-handle
dt-bindings: PCI: nxp,s32g-pcie: One PHY per lane
net: pcs: xpcs: allow a PCS to opt out of soft reset and EEE
net: pcs: xpcs: let a glue driver declare the PCS and PMA IDs
net: pcs: xpcs: add NXP S32G SerDes XPCS support
net: pcs: xpcs: wait for SGMII AN to complete in-band
net: stmmac: s32: Add SGMII support
arm64: dts: s32g: Add SCMI reset controller
arm64: dts: s32g: Add SerDes controller nodes
arm64: dts: s32g: Add PCIe controller nodes
arm64: dts: s32g: Add S32G3-RDB3 SerDes routing variants

Vincent Guittot (3):
net: pcs: Add NXP S32G XPCS glue
phy: freescale: s32g: Add SerDes subsystem PHY
MAINTAINERS: Add NXP S32G SerDes entry

 .../devicetree/bindings/net/nxp,s32-dwmac.yaml     |   30 +-
 .../devicetree/bindings/pci/nxp,s32g-pcie.yaml     |    6 +-
 .../devicetree/bindings/phy/nxp,s32g-serdes.yaml   |  137 +++
 MAINTAINERS                                        |   16 +
 arch/arm64/boot/dts/freescale/Makefile             |    2 +
 arch/arm64/boot/dts/freescale/s32g2.dtsi           |  116 ++
 arch/arm64/boot/dts/freescale/s32g3.dtsi           |  116 ++
 .../dts/freescale/s32g399a-rdb3-serdes-mode1.dts   |   65 ++
 .../dts/freescale/s32g399a-rdb3-serdes-mode3.dts   |   40 +
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |    1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c    |   81 +-
 drivers/net/pcs/Kconfig                            |    7 +
 drivers/net/pcs/Makefile                           |    4 +-
 drivers/net/pcs/pcs-nxp-s32g-xpcs.c                |  569 ++++++++++
 drivers/net/pcs/pcs-xpcs-s32g.c                    |   48 +
 drivers/net/pcs/pcs-xpcs.c                         |  149 ++-
 drivers/net/pcs/pcs-xpcs.h                         |    5 +
 drivers/phy/freescale/Kconfig                      |   13 +
 drivers/phy/freescale/Makefile                     |    1 +
 drivers/phy/freescale/phy-nxp-s32g-serdes.c        | 1132 ++++++++++++++++++++
 include/linux/pcs/pcs-nxp-s32g-xpcs.h              |   41 +
 include/linux/pcs/pcs-xpcs.h                       |    4 +
 include/linux/phy/nxp-s32g-serdes.h                |   25 +
 23 files changed, 2578 insertions(+), 30 deletions(-)

---
base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
change-id: 20260918-s32g_serdes-7807070de807

Best regards,

Signature · 1 line
Jan Petrous (OSS) <[email protected]>
author maintainer
#1 lore raw

RFC PATCH v4 1/15 dt-bindings: phy: Add NXP S32G SerDes subsystem

The S32G SerDes subsystem multiplexes two lanes between a PCIe PHY and two DesignWare XPCS instances. Describe it with one node per SerDes, which is a four-cell PHY provider: <lane type instance max-speed>.

There is no mode property. SS_RW_REG_0[SUBSYS_MODE] follows from the phys references of the consumers: a PCIe root port references its lanes with PHY_TYPE_PCIE, an Ethernet controller references its lane with PHY_TYPE_SGMII, the XPCS instance it is wired to and the highest speed the lane is wired for, and takes the PCS from the SerDes node through pcs-handle. Each mode described here has a unique lane mux. A lane that no consumer references takes the function it has in the first matching mode.

The XPCS instance is a cell rather than derived from the MAC: the mux is programmed at SerDes probe, before any MAC exists, and "XPCS0 alone on lane 1" (mode 1 with the PCIe lane idle) and "XPCS1 alone on lane 1" (mode 2) are different routings of the same pins. The cell layout is final.

The speed is a cell for the same reason. The 3.125 Gbit/s configurations select other SUBSYS_MODE values, reference clocks and PCIe speeds, all decided at SerDes probe, and the MAC's phy-mode does not tell: an in-band SGMII link to a 2.5G PHY is "sgmii" and moves to 2500BASE-X at runtime. Only the 1.25 Gbit/s modes are described, so 1000 is the only accepted speed; 2500 comes with the 3.125 Gbit/s modes without a change of #phy-cells.

The mode tables differ per SoC and per SerDes instance, so S32G2 and S32G3 have no common fallback, and each instance has its own compatible with the per-SoC one as fallback.

---
 .../devicetree/bindings/phy/nxp,s32g-serdes.yaml   | 137 +++++++++++++++++++++
 1 file changed, 137 insertions(+)
Documentation/devicetree/bindings/phy/nxp,s32g-serdes.yaml new file +137 -0
new file mode 100644
index 000000000000..a06becfcc4e4
@@ -0,0 +1,137 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/nxp,s32g-serdes.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP S32G2xxx/S32G3xxx SerDes PHY subsystem
+
+maintainers:
+  - Ghennadi Procopciuc <[email protected]>
+  - Ciprian Marian Costea <[email protected]>
+  - Jan Petrous <[email protected]>
+
+description: |
+  The SerDes subsystem multiplexes two lanes between one PCIe controller PHY
+  and two Synopsys DesignWare XPCS (Ethernet PCS) instances, behind a shared
+  2-lane combo PHY. The routing is selected by SS_RW_REG_0[SUBSYS_MODE].
+  The 1.25 Gbit/s modes are:
+
+  Mode  Lane0   Lane1   PHY refclk (MHz)  Description
+  ------------------------------------------------------------
+  0     PCIe    PCIe    100               PCIe x2
+  1     PCIe    XPCS0   100               PCIe x1 + SGMII
+  2     PCIe    XPCS1   100               PCIe x1 + SGMII
+  3     XPCS0   XPCS1   100 or 125        dual SGMII, 1.25 Gbit/s
+
+  The mode is not a property. It follows from the phys references of the
+  consumers: each one names the lane, the PHY type and, for an XPCS lane,
+  the XPCS instance and the highest speed the lane is wired for. Each mode
+  has a unique lane mux. A lane that no consumer references takes the
+  function it has in the first matching mode of the table.
+
+  A PCIe root port references one lane per link width. An Ethernet MAC
+  references its lane with phys and takes its PCS from the same SerDes
+  node through pcs-handle.
+
+  Which MAC an XPCS instance feeds is fixed by the SoC integration. On S32G3
+  SerDes_0, XPCS0 feeds GMAC0 and XPCS1 feeds PFE_MAC2; on SerDes_1 they feed
+  PFE_MAC0 and PFE_MAC1.
+
+  The mode tables differ per SoC and per SerDes instance: on S32G3 the
+  3.125 Gbit/s dual-XPCS mode exists on SerDes_1 only, and on S32G2 only
+  SerDes_1 reaches 3.125 Gbit/s. S32G2 and S32G3 therefore have no common
+  fallback, and each instance has its own compatible, with the per-SoC one
+  as fallback.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - nxp,s32g2-serdes0
+              - nxp,s32g2-serdes1
+          - const: nxp,s32g2-serdes
+      - items:
+          - enum:
+              - nxp,s32g3-serdes0
+              - nxp,s32g3-serdes1
+          - const: nxp,s32g3-serdes
+
+  reg:
+    maxItems: 4
+
+  reg-names:
+    items:
+      - const: ss-pcie
+      - const: pcie-phy
+      - const: xpcs0
+      - const: xpcs1
+
+  clocks:
+    minItems: 4
+    maxItems: 5
+
+  clock-names:
+    minItems: 4
+    items:
+      - const: axi
+      - const: aux
+      - const: apb
+      - const: ref
+      - const: ext
+    description:
+      The combo PHY reference can be taken from the internal reference
+      clock ("ref") or from the external reference pad ("ext"). A board
+      that routes the external pad lists both; the external reference is
+      then the one used.
+
+  resets:
+    maxItems: 2
+
+  reset-names:
+    items:
+      - const: serdes
+      - const: pcie
+
+  '#phy-cells':
+    const: 4
+    description: |
+      The first cell is the lane, 0 or 1. The second cell is the PHY type,
+      PHY_TYPE_PCIE or PHY_TYPE_SGMII from dt-bindings/phy/phy.h. The third
+      cell is the XPCS instance, 0 or 1, and the fourth the highest
+      Ethernet speed the lane is wired for, in Mbit/s: 1000 for a 1.25
+      Gbit/s lane, 2500 for a 3.125 Gbit/s one. Both are 0 for
+      PHY_TYPE_PCIE.
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  # Consumers select the mode. PCIe x1 on lane 0 plus 1G SGMII on lane 1 via
+  # XPCS0 (mode 1) is, on the PCIe root port and the MAC:
+  #   phys = <&serdes0 0 PHY_TYPE_PCIE 0 0>;
+  #   phys = <&serdes0 1 PHY_TYPE_SGMII 0 1000>; pcs-handle = <&serdes0>;
+  - |
+    serdes0: serdes@40480000 {
+        compatible = "nxp,s32g3-serdes0", "nxp,s32g3-serdes";
+        reg = <0x40480000 0x108>,
+              <0x40483008 0x10>,
+              <0x40482000 0x800>,
+              <0x40482800 0x800>;
+        reg-names = "ss-pcie", "pcie-phy", "xpcs0", "xpcs1";
+        clocks = <&clks 1>, <&clks 2>, <&clks 3>, <&clks 4>;
+        clock-names = "axi", "aux", "apb", "ref";
+        resets = <&scmi_reset 1>, <&scmi_reset 0>;
+        reset-names = "serdes", "pcie";
+        #phy-cells = <4>;
+    };
Signature · 1 line
2.55.0
author maintainer
#2 lore raw

RFC PATCH v4 2/15 dt-bindings: net: nxp,s32-dwmac: Document pcs-handle

In reply to Jan Petrous (OSS)

With SGMII, the PCS is one of the SerDes XPCS instances. The MAC references its SerDes lane through phys, with the lane, the PHY type, the XPCS instance and the highest speed in the argument cells, and the SerDes node that provides the PCS through pcs-handle.

The pcs-handle type comes from ethernet-controller.yaml. Only
maxItems: 1 is added, as the MAC has a single PCS.

phy-mode "sgmii" requires both properties, and each of them requires the other.

---
 .../devicetree/bindings/net/nxp,s32-dwmac.yaml     | 30 +++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml +29 -1
index fcad2274302d..219a033b889d 100644
@@ -15,7 +15,8 @@ description:
   The SoC series S32G2xx and S32G3xx feature one DWMAC instance,
   the SoC S32R45 has two instances. The devices can use RGMII/RMII/MII
   interface over Pinctrl device or the output can be routed
-  to the embedded SerDes for SGMII connectivity.
+  to the embedded SerDes for SGMII connectivity, in which case the
+  SerDes lane is referenced via phys and the PCS via pcs-handle.
   The DWMAC instances have connected all RX/TX queues interrupts,
   enabling load balancing of data traffic across all CPU cores.
 
@@ -81,6 +82,19 @@ properties:
       - const: rx
       - const: ptp_ref
 
+  pcs-handle:
+    maxItems: 1
+    description:
+      phandle pointing to the SerDes node that provides the SGMII PCS for
+      this MAC. See
+      Documentation/devicetree/bindings/phy/nxp,s32g-serdes.yaml.
+
+  phys:
+    maxItems: 1
+    description:
+      The SerDes lane that carries the SGMII link, with the lane, the PHY
+      type, the XPCS instance and the highest speed in the argument cells.
+
   power-domains:
     maxItems: 1
 
@@ -88,8 +102,22 @@ required:
   - clocks
   - clock-names
 
+dependentRequired:
+  pcs-handle: [ phys ]
+  phys: [ pcs-handle ]
+
 allOf:
   - $ref: snps,dwmac.yaml#
+  - if:
+      properties:
+        phy-mode:
+          const: sgmii
+      required:
+        - phy-mode
+    then:
+      required:
+        - pcs-handle
+        - phys
 
 unevaluatedProperties: false
 
Signature · 1 line
2.55.0
author maintainer
#3 lore raw

RFC PATCH v4 3/15 dt-bindings: PCI: nxp,s32g-pcie: One PHY per lane

In reply to Jan Petrous (OSS)

The SerDes binding describes a link with one phys entry per lane, <lane PHY_TYPE_PCIE 0 0>. Allow up to two entries on the root port, and make the example reference lane 0 that way.

---
 Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml +4 -2
index 66a050028278..b90d169f57ed 100644
@@ -57,7 +57,9 @@ properties:
         maxItems: 1
 
       phys:
-        maxItems: 1
+        minItems: 1
+        maxItems: 2
+        description: One entry per SerDes lane of the link.
 
     required:
       - reg
@@ -124,7 +126,7 @@ examples:
                 ranges;
 
                 device_type = "pci";
-                phys = <&serdes0 PHY_TYPE_PCIE 0 0>;
+                phys = <&serdes0 0 PHY_TYPE_PCIE 0 0>;
             };
         };
     };
Signature · 1 line
2.55.0
#4 lore raw

Re: [PATCH RFC v4 03/15] dt-bindings: PCI: nxp,s32g-pcie: One PHY per lane

Quoted 16 lines · On Wed, Nov 25, 2026 at 10:33:45AM +0100, Jan Petrous via B4 Relay wrote:

From: "Jan Petrous (OSS)" <[email protected]>

The SerDes binding describes a link with one phys entry per lane, <lane PHY_TYPE_PCIE 0 0>. Allow up to two entries on the root port, and make the example reference lane 0 that way.

---
 Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml +0 -0
index 66a050028278..b90d169f57ed 100644

Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml properties: · line 62

Quoted 7 lines
Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml +3 -1
@@ -57,7 +57,9 @@ properties:
         maxItems: 1
 
       phys:
-        maxItems: 1
+        minItems: 1
+        maxItems: 2
+        description: One entry per SerDes lane of the link.

Needn't such description, that's native means for phys.

Frank

Quoted 18 lines
Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml +1 -2
     required:
       - reg
@@ -124,7 +126,7 @@ examples:
                 ranges;
 
                 device_type = "pci";
-                phys = <&serdes0 PHY_TYPE_PCIE 0 0>;
+                phys = <&serdes0 0 PHY_TYPE_PCIE 0 0>;
             };
         };
     };
 
--

2.55.0

author maintainer
#5 lore raw

RFC PATCH v4 4/15 net: pcs: xpcs: allow a PCS to opt out of soft reset and EEE

In reply to Jan Petrous (OSS)

Add a quirks mask to struct dw_xpcs_desc, with two flags:

- DW_XPCS_QUIRK_NO_SOFT_RESET: no soft reset in pcs_pre_config(). When the XPCS shares its PMA with another controller, the reset belongs to a bring-up sequence owned by the platform.

- DW_XPCS_QUIRK_NO_EEE: VR_MII_EEE_MCTRL0/1 are not implemented and must not be written.

No entry sets a quirk yet, so there is no functional change.

---
 drivers/net/pcs/pcs-xpcs.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/pcs/pcs-xpcs.c +19 -0
index 6466e0ff2a98..442c64a731b7 100644
@@ -158,10 +158,20 @@ struct dw_xpcs_compat {
 	int (*pma_config)(struct dw_xpcs *xpcs);
 };
 
+/*
+ * The integration owns the PCS reset sequence: skip the soft reset in
+ * pcs_pre_config(). Only for PCS without Clause 73, whose fault recovery
+ * still resets.
+ */
+#define DW_XPCS_QUIRK_NO_SOFT_RESET	BIT(0)
+/* VR_MII_EEE_MCTRL0/1 are not implemented */
+#define DW_XPCS_QUIRK_NO_EEE		BIT(1)
+
 struct dw_xpcs_desc {
 	u32 id;
 	u32 mask;
 	const struct dw_xpcs_compat *compat;
+	unsigned int quirks;
 };
 
 static const struct dw_xpcs_compat *
@@ -729,6 +739,9 @@ static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface)
 		dev_err(&xpcs->mdiodev->dev, "switch interface failed: %pe\n",
 			ERR_PTR(ret));
 
+	if (xpcs->desc->quirks & DW_XPCS_QUIRK_NO_SOFT_RESET)
+		xpcs->need_reset = false;
+
 	if (!xpcs->need_reset)
 		return;
 
@@ -1318,6 +1331,9 @@ static void xpcs_disable_eee(struct phylink_pcs *pcs)
 {
 	struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs);
 
+	if (xpcs->desc->quirks & DW_XPCS_QUIRK_NO_EEE)
+		return;
+
 	xpcs_config_eee(xpcs, false);
 }
 
@@ -1325,6 +1341,9 @@ static void xpcs_enable_eee(struct phylink_pcs *pcs)
 {
 	struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs);
 
+	if (xpcs->desc->quirks & DW_XPCS_QUIRK_NO_EEE)
+		return;
+
 	xpcs_config_eee(xpcs, true);
 }
 
Signature · 1 line
2.55.0
author maintainer
#6 lore raw

RFC PATCH v4 5/15 net: pcs: xpcs: let a glue driver declare the PCS and PMA IDs

In reply to Jan Petrous (OSS)

pcs-xpcs selects its description entry by the PCS ID read from the device. An XPCS integrated with a vendor PMA reports the generic DesignWare PCS ID, so the entry cannot tell such an integration from a plain XPCS. Glue drivers have answered this so far by returning a synthetic PCS ID from their MDIO bus emulation.

The core already takes declared IDs through struct dw_xpcs_info, which pcs-xpcs-plat passes for PMA generations it cannot read from the device, but only from the platform data of an MDIO device the creator registered itself.

Let a glue driver declare them instead:

- xpcs_create_pcs_mdiodev_info() creates the PCS like xpcs_create_pcs_mdiodev() and takes a struct dw_xpcs_info;

- with both IDs declared, no ID register is read. A glue whose register window is not clocked when it creates the PCS needs that;

- a description entry may name a PMA ID. It then matches only that PMA, and takes precedence over an entry for the same PCS ID that matches any PMA.

No entry names a PMA yet and no existing caller declares both IDs, so there is no functional change.

---
 drivers/net/pcs/pcs-xpcs.c   | 95 ++++++++++++++++++++++++++++++++++----------
 include/linux/pcs/pcs-xpcs.h |  2 +
 2 files changed, 75 insertions(+), 22 deletions(-)
drivers/net/pcs/pcs-xpcs.c +73 -22
index 442c64a731b7..3b5857dc44f3 100644
@@ -170,6 +170,8 @@ struct dw_xpcs_compat {
 struct dw_xpcs_desc {
 	u32 id;
 	u32 mask;
+	/* Match only this PMA ID; 0 matches any PMA */
+	u32 pma;
 	const struct dw_xpcs_compat *compat;
 	unsigned int quirks;
 };
@@ -1366,6 +1368,11 @@ static int xpcs_read_ids(struct dw_xpcs *xpcs)
 	int ret;
 	u32 id;
 
+	/* Both IDs declared by the creator, nothing to read */
+	if (xpcs->info.pcs != DW_XPCS_ID_NATIVE &&
+	    xpcs->info.pma != DW_XPCS_PMA_ID_NATIVE)
+		return 0;
+
 	/* First, search C73 PCS using PCS MMD 3. Return ENODEV if communication
 	 * failed indicating that device couldn't be reached.
 	 */
@@ -1530,22 +1537,36 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = {
 
 static int xpcs_identify(struct dw_xpcs *xpcs)
 {
+	const struct dw_xpcs_desc *match = NULL;
 	int i, ret;
 
 	ret = xpcs_read_ids(xpcs);
 	if (ret < 0)
 		return ret;
 
+	/* An entry for the PMA ID takes precedence over one for any PMA */
 	for (i = 0; i < ARRAY_SIZE(xpcs_desc_list); i++) {
 		const struct dw_xpcs_desc *entry = &xpcs_desc_list[i];
 
-		if ((xpcs->info.pcs & entry->mask) == entry->id) {
-			xpcs->desc = entry;
-			return 0;
+		if ((xpcs->info.pcs & entry->mask) != entry->id)
+			continue;
+
+		if (entry->pma) {
+			if (entry->pma == xpcs->info.pma) {
+				match = entry;
+				break;
+			}
+		} else if (!match) {
+			match = entry;
 		}
 	}
 
-	return -ENODEV;
+	if (!match)
+		return -ENODEV;
+
+	xpcs->desc = match;
+
+	return 0;
 }
 
 static struct dw_xpcs *xpcs_create_data(struct mdio_device *mdiodev)
@@ -1602,11 +1623,10 @@ static void xpcs_clear_clks(struct dw_xpcs *xpcs)
 	clk_bulk_put(DW_XPCS_NUM_CLKS, xpcs->clks);
 }
 
-static int xpcs_init_id(struct dw_xpcs *xpcs)
+static int xpcs_init_id(struct dw_xpcs *xpcs, const struct dw_xpcs_info *info)
 {
-	const struct dw_xpcs_info *info;
-
-	info = dev_get_platdata(&xpcs->mdiodev->dev);
+	if (!info)
+		info = dev_get_platdata(&xpcs->mdiodev->dev);
 	if (!info) {
 		xpcs->info.pcs = DW_XPCS_ID_NATIVE;
 		xpcs->info.pma = DW_XPCS_PMA_ID_NATIVE;
@@ -1617,7 +1637,8 @@ static int xpcs_init_id(struct dw_xpcs *xpcs)
 	return xpcs_identify(xpcs);
 }
 
-static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev)
+static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
+				   const struct dw_xpcs_info *info)
 {
 	struct dw_xpcs *xpcs;
 	int ret;
@@ -1630,7 +1651,7 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev)
 	if (ret)
 		goto out_free_data;
 
-	ret = xpcs_init_id(xpcs);
+	ret = xpcs_init_id(xpcs, info);
 	if (ret)
 		goto out_clear_clks;
 
@@ -1653,16 +1674,8 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev)
 	return ERR_PTR(ret);
 }
 
-/**
- * xpcs_create_mdiodev() - create a DW xPCS instance with the MDIO @addr
- * @bus: pointer to the MDIO-bus descriptor for the device to be looked at
- * @addr: device MDIO-bus ID
- *
- * Return: a pointer to the DW XPCS handle if successful, otherwise -ENODEV if
- * the PCS device couldn't be found on the bus and other negative errno related
- * to the data allocation and MDIO-bus communications.
- */
-struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr)
+static struct dw_xpcs *xpcs_create_mdiodev_info(struct mii_bus *bus, int addr,
+						const struct dw_xpcs_info *info)
 {
 	struct mdio_device *mdiodev;
 	struct dw_xpcs *xpcs;
@@ -1671,7 +1684,7 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr)
 	if (IS_ERR(mdiodev))
 		return ERR_CAST(mdiodev);
 
-	xpcs = xpcs_create(mdiodev);
+	xpcs = xpcs_create(mdiodev, info);
 
 	/* xpcs_create() has taken a refcount on the mdiodev if it was
 	 * successful. If xpcs_create() fails, this will free the mdio
@@ -1683,6 +1696,20 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr)
 
 	return xpcs;
 }
+
+/**
+ * xpcs_create_mdiodev() - create a DW xPCS instance with the MDIO @addr
+ * @bus: pointer to the MDIO-bus descriptor for the device to be looked at
+ * @addr: device MDIO-bus ID
+ *
+ * Return: a pointer to the DW XPCS handle if successful, otherwise -ENODEV if
+ * the PCS device couldn't be found on the bus and other negative errno related
+ * to the data allocation and MDIO-bus communications.
+ */
+struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr)
+{
+	return xpcs_create_mdiodev_info(bus, addr, NULL);
+}
 EXPORT_SYMBOL_GPL(xpcs_create_mdiodev);
 
 struct phylink_pcs *xpcs_create_pcs_mdiodev(struct mii_bus *bus, int addr)
@@ -1697,6 +1724,30 @@ struct phylink_pcs *xpcs_create_pcs_mdiodev(struct mii_bus *bus, int addr)
 }
 EXPORT_SYMBOL_GPL(xpcs_create_pcs_mdiodev);
 
+/**
+ * xpcs_create_pcs_mdiodev_info() - create a DW xPCS PCS with declared IDs
+ * @bus: MDIO bus of the PCS
+ * @addr: MDIO address of the PCS
+ * @info: PCS and PMA IDs; an ID left native is read from the device
+ *
+ * For a glue driver that knows the integration of its XPCS. With both IDs
+ * declared, no ID register is read. @info is copied.
+ *
+ * Return: the phylink PCS, or an ERR_PTR() as for xpcs_create_mdiodev().
+ */
+struct phylink_pcs *xpcs_create_pcs_mdiodev_info(struct mii_bus *bus, int addr,
+						 const struct dw_xpcs_info *info)
+{
+	struct dw_xpcs *xpcs;
+
+	xpcs = xpcs_create_mdiodev_info(bus, addr, info);
+	if (IS_ERR(xpcs))
+		return ERR_CAST(xpcs);
+
+	return &xpcs->pcs;
+}
+EXPORT_SYMBOL_GPL(xpcs_create_pcs_mdiodev_info);
+
 /**
  * xpcs_create_fwnode() - Create a DW xPCS instance from @fwnode
  * @fwnode: fwnode handle poining to the DW XPCS device
@@ -1719,7 +1770,7 @@ struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode)
 	if (!mdiodev)
 		return ERR_PTR(-EPROBE_DEFER);
 
-	xpcs = xpcs_create(mdiodev);
+	xpcs = xpcs_create(mdiodev, NULL);
 
 	/* xpcs_create() has taken a refcount on the mdiodev if it was
 	 * successful. If xpcs_create() fails, this will free the mdio
include/linux/pcs/pcs-xpcs.h +2 -0
index 36073f7b6bb4..f46434958383 100644
@@ -58,6 +58,8 @@ struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode);
 void xpcs_destroy(struct dw_xpcs *xpcs);
 
 struct phylink_pcs *xpcs_create_pcs_mdiodev(struct mii_bus *bus, int addr);
+struct phylink_pcs *xpcs_create_pcs_mdiodev_info(struct mii_bus *bus, int addr,
+						 const struct dw_xpcs_info *info);
 void xpcs_destroy_pcs(struct phylink_pcs *pcs);
 
 #endif /* __LINUX_PCS_XPCS_H */
Signature · 1 line
2.55.0
author maintainer
#7 lore raw

RFC PATCH v4 6/15 net: pcs: xpcs: add NXP S32G SerDes XPCS support

In reply to Jan Petrous (OSS)

The NXP S32G SerDes subsystem has two DesignWare XPCS instances behind an indirect MMIO window, next to a combo PHY which the XPCS lanes may share with a PCIe controller. The S32G SerDes driver exposes each instance as an MDIO bus.

The XPCS reports the generic DesignWare PCS ID; what differs on S32G is the PMA integration. Add NXP_S32G_XPCS_PMA_ID, for the S32G glue driver to declare, and an entry for the DesignWare PCS ID with that PMA. The entry:

- supports SGMII only;

- has a PMA hook which sets the SGMII link timer to the 1.6 ms that phylink gives for SGMII, then sets CL37_TMR_OVR_RIDE, without which the timer value is not used. pcs-xpcs restarted AN before the hook, with the old timer, so the hook restarts it when AN is enabled. The PLLs and the lane's PLL selection are set up once by the SerDes bring-up; the 1G sequence of the RM has no TX/RX request and no PCS flush;

- sets DW_XPCS_QUIRK_NO_SOFT_RESET: the XPCS reset is part of the combo PHY bring-up, which the SerDes driver sequences against the PCIe lane and the other XPCS instance;

- sets DW_XPCS_QUIRK_NO_EEE: VR_MII_EEE_MCTRL0/1 are not implemented.

The PMA hook is in pcs-xpcs-s32g.c, as the Wangxun one is in pcs-xpcs-wx.c.

---
 drivers/net/pcs/Makefile        |  3 ++-
 drivers/net/pcs/pcs-xpcs-s32g.c | 48 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/pcs/pcs-xpcs.c      | 16 ++++++++++++++
 drivers/net/pcs/pcs-xpcs.h      |  5 +++++
 include/linux/pcs/pcs-xpcs.h    |  2 ++
 5 files changed, 73 insertions(+), 1 deletion(-)
drivers/net/pcs/Makefile +2 -1
index f9f6cf2578d7..072b8214446b 100644
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux PCS drivers
 
-pcs_xpcs-$(CONFIG_PCS_XPCS)	:= pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-wx.o
+pcs_xpcs-$(CONFIG_PCS_XPCS)	:= pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-s32g.o \
+				   pcs-xpcs-wx.o
 
 obj-$(CONFIG_PCS_XPCS)		+= pcs_xpcs.o
 obj-$(CONFIG_PCS_XPCS_PLATFORM) += pcs-xpcs-plat.o
drivers/net/pcs/pcs-xpcs-s32g.c new file +48 -0

48 lines not on this page · raw message

drivers/net/pcs/pcs-xpcs.c +16 -0
index 3b5857dc44f3..71e5882f4b0b 100644
@@ -1507,6 +1507,16 @@ static const struct dw_xpcs_compat nxp_sja1110_xpcs_compat[] = {
 	}
 };
 
+static const struct dw_xpcs_compat nxp_s32g_xpcs_compat[] = {
+	{
+		.interface = PHY_INTERFACE_MODE_SGMII,
+		.supported = xpcs_sgmii_features,
+		.an_mode = DW_AN_C37_SGMII,
+		.pma_config = nxp_s32g_sgmii_pma_config,
+	}, {
+	}
+};
+
 static const struct dw_xpcs_desc xpcs_desc_list[] = {
 	{
 		.id = DW_XPCS_ID,
@@ -1520,6 +1530,12 @@ static const struct dw_xpcs_desc xpcs_desc_list[] = {
 		.id = NXP_SJA1110_XPCS_ID,
 		.mask = DW_XPCS_ID_MASK,
 		.compat = nxp_sja1110_xpcs_compat,
+	}, {
+		.id = DW_XPCS_ID,
+		.mask = DW_XPCS_ID_MASK,
+		.pma = NXP_S32G_XPCS_PMA_ID,
+		.compat = nxp_s32g_xpcs_compat,
+		.quirks = DW_XPCS_QUIRK_NO_SOFT_RESET | DW_XPCS_QUIRK_NO_EEE,
 	},
 };
 
drivers/net/pcs/pcs-xpcs.h +5 -0
index 929fa238445e..fb41cdff2b35 100644
@@ -56,6 +56,8 @@
 /* VR MII MMD registers offsets */
 #define DW_VR_MII_DIG_CTRL1		0x8000
 #define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW		BIT(9)
+#define DW_VR_MII_DIG_CTRL1_INIT		BIT(8)
+#define DW_VR_MII_DIG_CTRL1_CL37_TMR_OVR_RIDE	BIT(3)
 #define DW_VR_MII_DIG_CTRL1_2G5_EN		BIT(2)
 #define DW_VR_MII_DIG_CTRL1_PHY_MODE_CTRL	BIT(0)
 
@@ -87,6 +89,8 @@
 #define DW_VR_MII_EEE_RX_EN_CTRL		BIT(7)  /* Rx Control Enable */
 #define DW_VR_MII_EEE_MULT_FACT_100NS		GENMASK(11, 8)
 
+#define DW_VR_MII_LINK_TIMER_CTRL	0x800a
+
 #define DW_VR_MII_EEE_MCTRL1		0x800b
 #define DW_VR_MII_EEE_TRN_LPI		BIT(0)	/* Transparent Mode Enable */
 
@@ -124,4 +128,5 @@ int xpcs_write_vpcs(struct dw_xpcs *xpcs, int reg, u16 val);
 int nxp_sja1105_sgmii_pma_config(struct dw_xpcs *xpcs);
 int nxp_sja1110_sgmii_pma_config(struct dw_xpcs *xpcs);
 int nxp_sja1110_2500basex_pma_config(struct dw_xpcs *xpcs);
+int nxp_s32g_sgmii_pma_config(struct dw_xpcs *xpcs);
 int txgbe_xpcs_switch_mode(struct dw_xpcs *xpcs, phy_interface_t interface);
include/linux/pcs/pcs-xpcs.h +2 -0
index f46434958383..ca17a8c1f23e 100644
@@ -38,6 +38,8 @@ enum dw_xpcs_pma_id {
 	DW_XPCS_PMA_GEN4_6G_ID,
 	DW_XPCS_PMA_GEN5_10G_ID,
 	DW_XPCS_PMA_GEN5_12G_ID,
+	/* NXP S32G SerDes PMA, declared by its glue driver */
+	NXP_S32G_XPCS_PMA_ID,
 	WX_TXGBE_XPCS_PMA_10G_ID = 0xfc806000,
 	/* Meta Platforms OUI 88:25:08, model 0, revision 0 */
 	MP_FBNIC_XPCS_PMA_100G_ID = 0x46904000,
Signature · 1 line
2.55.0
author maintainer
#8 lore raw

RFC PATCH v4 7/15 net: pcs: xpcs: wait for SGMII AN to complete in-band

In reply to Jan Petrous (OSS)

With in-band SGMII, the S32G XPCS keeps the previous SGMII link word in VR_MII_AN_INTR_STS until the next negotiation completes, so phylink can latch a stale speed after the link partner changes speed.

Add DW_XPCS_QUIRK_SGMII_WAIT_AN: with in-band negotiation enabled, report the link down until BMSR reports AN complete. Set it for S32G only.

---
 drivers/net/pcs/pcs-xpcs.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-xpcs.c +19 -2
index 71e5882f4b0b..65597c2d7a89 100644
@@ -166,6 +166,11 @@ struct dw_xpcs_compat {
 #define DW_XPCS_QUIRK_NO_SOFT_RESET	BIT(0)
 /* VR_MII_EEE_MCTRL0/1 are not implemented */
 #define DW_XPCS_QUIRK_NO_EEE		BIT(1)
+/*
+ * With in-band SGMII, VR_MII_AN_INTR_STS keeps the previous SGMII word until
+ * the next negotiation completes; only trust it once BMSR reports AN complete
+ */
+#define DW_XPCS_QUIRK_SGMII_WAIT_AN	BIT(2)
 
 struct dw_xpcs_desc {
 	u32 id;
@@ -1081,6 +1086,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
 }
 
 static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
+				    unsigned int neg_mode,
 				    struct phylink_link_state *state)
 {
 	int ret;
@@ -1092,6 +1098,16 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
 	state->duplex = DUPLEX_UNKNOWN;
 	state->pause = 0;
 
+	if (xpcs->desc->quirks & DW_XPCS_QUIRK_SGMII_WAIT_AN &&
+	    neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
+		ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMSR);
+		if (ret < 0)
+			return ret;
+
+		if (!(ret & BMSR_ANEGCOMPLETE))
+			return 0;
+	}
+
 	/* For C37 SGMII mode, we check DW_VR_MII_AN_INTR_STS for link
 	 * status, speed and duplex.
 	 */
@@ -1218,7 +1234,7 @@ static void xpcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
 				"xpcs_get_state_c73", ERR_PTR(ret));
 		break;
 	case DW_AN_C37_SGMII:
-		ret = xpcs_get_state_c37_sgmii(xpcs, state);
+		ret = xpcs_get_state_c37_sgmii(xpcs, neg_mode, state);
 		if (ret)
 			dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n",
 				"xpcs_get_state_c37_sgmii", ERR_PTR(ret));
@@ -1535,7 +1551,8 @@ static const struct dw_xpcs_desc xpcs_desc_list[] = {
 		.mask = DW_XPCS_ID_MASK,
 		.pma = NXP_S32G_XPCS_PMA_ID,
 		.compat = nxp_s32g_xpcs_compat,
-		.quirks = DW_XPCS_QUIRK_NO_SOFT_RESET | DW_XPCS_QUIRK_NO_EEE,
+		.quirks = DW_XPCS_QUIRK_NO_SOFT_RESET | DW_XPCS_QUIRK_NO_EEE |
+			  DW_XPCS_QUIRK_SGMII_WAIT_AN,
 	},
 };
 
Signature · 1 line
2.55.0
author maintainer
#9 lore raw

RFC PATCH v4 8/15 net: pcs: Add NXP S32G XPCS glue

In reply to Jan Petrous (OSS)

From: Vincent Guittot <[email protected]>

Each S32G SerDes subsystem has two DesignWare XPCS instances, driven as phylink PCS by pcs-xpcs. Add the S32G glue around them.

The XPCS registers sit behind an indirect MMIO window: a page register selects which 256 registers of the Clause 45 address space the window shows. Expose each instance to pcs-xpcs as an MDIO bus over that window, and create the PCS with the generic DesignWare PCS ID and NXP_S32G_XPCS_PMA_ID declared, which selects the S32G entry of pcs-xpcs. With both IDs declared pcs-xpcs reads no ID register, which matters here: the instances are created before the SerDes clocks run.

In the PCIe+SGMII modes the XPCS shares the combo PHY with the PCIe lane, so it cannot own its reset and PMA/PLL bring-up. The glue exports the bring-up steps to the SerDes PHY driver, which owns the shared PMA and orders them, e.g. XPCS1 before XPCS0 in the dual-SGMII mode.

---
 drivers/net/pcs/Kconfig               |   7 +
 drivers/net/pcs/Makefile              |   1 +
 drivers/net/pcs/pcs-nxp-s32g-xpcs.c   | 569 ++++++++++++++++++++++++++++++++++
 include/linux/pcs/pcs-nxp-s32g-xpcs.h |  41 +++
 4 files changed, 618 insertions(+)
drivers/net/pcs/Kconfig +7 -0
index 108d47257bee..2c29ecbd9c70 100644
@@ -33,6 +33,13 @@ config PCS_XPCS_ROCKCHIP
 
 	  If you have a Rockchip SoC with this interface, say Y or M here.
 
+config PCS_NXP_S32G_XPCS
+	tristate
+	help
+	  Glue between the XPCS instances of the NXP S32G SerDes subsystem
+	  and the Synopsys DesignWare XPCS driver. Selected by the S32G
+	  SerDes PHY driver.
+
 endif # PCS_XPCS
 
 config PCS_LYNX
drivers/net/pcs/Makefile +1 -0
index 072b8214446b..53c583f8e04d 100644
@@ -10,3 +10,4 @@ obj-$(CONFIG_PCS_XPCS_ROCKCHIP) += pcs-xpcs-rk.o
 obj-$(CONFIG_PCS_LYNX)		+= pcs-lynx.o
 obj-$(CONFIG_PCS_MTK_LYNXI)	+= pcs-mtk-lynxi.o
 obj-$(CONFIG_PCS_RZN1_MIIC)	+= pcs-rzn1-miic.o
+obj-$(CONFIG_PCS_NXP_S32G_XPCS)	+= pcs-nxp-s32g-xpcs.o
drivers/net/pcs/pcs-nxp-s32g-xpcs.c new file +569 -0

569 lines not on this page · raw message

include/linux/pcs/pcs-nxp-s32g-xpcs.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.55.0
author maintainer
#10 lore raw

RFC PATCH v4 9/15 phy: freescale: s32g: Add SerDes subsystem PHY

In reply to Jan Petrous (OSS)

From: Vincent Guittot <[email protected]>

Each S32G SerDes subsystem is made of one PCIe controller, two XPCS and a shared 2-lane combo PHY. The lanes carry PCIe and/or SGMII.

Add the SerDes subsystem driver: the PCIe PHY, the combo PHY bring-up and the setup of the XPCS instances. A MAC gets its phylink PCS through s32g_serdes_pcs_create(), which also creates a device link, so that the MAC is unbound and suspended before the SerDes.

SS_RW_REG_0[SUBSYS_MODE] is derived at probe from the consumers' phys references to the SerDes node, <lane type instance max-speed>: a PCIe root port names its lanes, a MAC names its lane, the XPCS instance it is wired to and the highest speed the lane is wired for, 1000 in this series. The driver walks the tree for them, as the mux is programmed before the reset is released, long before the consumers probe. Each supported mode has a unique lane mux; a lane nobody references takes the function it has in the first matching mode. The reference clock rate is validated against the derived mode.

The SerDes provides one PHY for the PCIe link, whatever its width, and one PHY per XPCS instance in use. The XPCS lane PHY has no operations:
the lane is brought up with the SerDes, and the MAC drives it through the PCS, which it gets from s32g_serdes_pcs_create() with its own node.

After the subsystem reset is released, the PHY needs up to 5.2 ms to become operational (MPLL_STATE). Poll it before any further PHY or XPCS PMA access, in every mode.

---
 drivers/phy/freescale/Kconfig               |   13 +
 drivers/phy/freescale/Makefile              |    1 +
 drivers/phy/freescale/phy-nxp-s32g-serdes.c | 1132 +++++++++++++++++++++++++++
 include/linux/phy/nxp-s32g-serdes.h         |   25 +
 4 files changed, 1171 insertions(+)
drivers/phy/freescale/Kconfig +13 -0
index 7557b624be8f..a32249db5c8a 100644
@@ -77,3 +77,16 @@ config PHY_FSL_LYNX_28G
 	  found on NXP's Layerscape platforms such as LX2160A.
 	  Used to change the protocol running on SerDes lanes at runtime.
 	  Only useful for a restricted set of Ethernet protocols.
+
+config PHY_S32G_SERDES
+	tristate "NXP S32G SERDES support"
+	depends on ARCH_S32 || COMPILE_TEST
+	depends on NETDEVICES
+	select GENERIC_PHY
+	select PCS_XPCS
+	select PCS_NXP_S32G_XPCS
+	help
+	  Enable this to support the SerDes subsystems of the NXP S32G2 and
+	  S32G3 SoCs. Each one has a two-lane combo PHY shared between a PCIe
+	  controller and two XPCS instances, used by the PCIe host driver
+	  and, for SGMII, by the GMAC Ethernet driver.
drivers/phy/freescale/Makefile +1 -0
index 5b0e180d6972..1a0aec790917 100644
@@ -8,3 +8,4 @@ obj-$(CONFIG_PHY_FSL_LYNX_CORE)		+= phy-fsl-lynx-core.o
 obj-$(CONFIG_PHY_FSL_LYNX_10G)		+= phy-fsl-lynx-10g.o
 obj-$(CONFIG_PHY_FSL_LYNX_28G)		+= phy-fsl-lynx-28g.o
 obj-$(CONFIG_PHY_FSL_SAMSUNG_HDMI_PHY)	+= phy-fsl-samsung-hdmi.o
+obj-$(CONFIG_PHY_S32G_SERDES)		+= phy-nxp-s32g-serdes.o
drivers/phy/freescale/phy-nxp-s32g-serdes.c new file +1132 -0

1,132 lines not on this page · raw message

include/linux/phy/nxp-s32g-serdes.h new file +25 -0
new file mode 100644
index 000000000000..d14fcde1d933
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2021-2026 NXP
+ */
+#ifndef PHY_NXP_S32G_SERDES_H
+#define PHY_NXP_S32G_SERDES_H
+
+#include <linux/err.h>
+
+struct device;
+struct device_node;
+struct phylink_pcs;
+
+#if IS_REACHABLE(CONFIG_PHY_S32G_SERDES)
+struct phylink_pcs *s32g_serdes_pcs_create(struct device *dev,
+					   struct device_node *np);
+#else
+static inline struct phylink_pcs *
+s32g_serdes_pcs_create(struct device *dev, struct device_node *np)
+{
+	return ERR_PTR(-ENODEV);
+}
+#endif
+
+#endif /* PHY_NXP_S32G_SERDES_H */
Signature · 1 line
2.55.0
#11 lore raw

Re: [PATCH RFC v4 09/15] phy: freescale: s32g: Add SerDes subsystem PHY

Hi Jan,

Quoted 42 lines · On Wed, Nov 25, 2026 at 10:33:51AM +0100, Jan Petrous via B4 Relay wrote:

From: Vincent Guittot <[email protected]>

Each S32G SerDes subsystem is made of one PCIe controller, two XPCS and a shared 2-lane combo PHY. The lanes carry PCIe and/or SGMII.

Add the SerDes subsystem driver: the PCIe PHY, the combo PHY bring-up and the setup of the XPCS instances. A MAC gets its phylink PCS through s32g_serdes_pcs_create(), which also creates a device link, so that the MAC is unbound and suspended before the SerDes.

SS_RW_REG_0[SUBSYS_MODE] is derived at probe from the consumers' phys references to the SerDes node, <lane type instance max-speed>: a PCIe root port names its lanes, a MAC names its lane, the XPCS instance it is wired to and the highest speed the lane is wired for, 1000 in this series. The driver walks the tree for them, as the mux is programmed before the reset is released, long before the consumers probe. Each supported mode has a unique lane mux; a lane nobody references takes the function it has in the first matching mode. The reference clock rate is validated against the derived mode.

The SerDes provides one PHY for the PCIe link, whatever its width, and one PHY per XPCS instance in use. The XPCS lane PHY has no operations:
the lane is brought up with the SerDes, and the MAC drives it through the PCS, which it gets from s32g_serdes_pcs_create() with its own node.

After the subsystem reset is released, the PHY needs up to 5.2 ms to become operational (MPLL_STATE). Poll it before any further PHY or XPCS PMA access, in every mode.

Quoted 1 line

---

I am trying to spend some time to understand this design. I have a few basic questions:

- Simply explained, what do you gain by integrating with the Generic PHY framework? The XPCS has a dummy phy_ops. Clearly this means phy_init(), phy_power_on(), phy_set_mode_ext() etc will do nothing for it. Who and why is better off if it exists?

- If you have 2 physical lanes, why do you have 3 Generic PHY objects? Why not a Generic PHY object per lane?

- Does the lane mux need to be programmed by the kernel driver? Does it ever need to change at runtime? How do previous boot layers use the SerDes? If you leave the lane mux set by a previous boot layer, and make the device tree describe that configuration as read-only, what doesn't work for your use cases?

author maintainer
#12 lore raw

RFC PATCH v4 10/15 net: stmmac: s32: Add SGMII support

In reply to Jan Petrous (OSS)

Let the MAC run SGMII over a SerDes lane, with a SerDes XPCS instance as the PCS:

- Select the PHY interface from phy_interface instead of hard-coding RGMII, and add SGMII. RMII and MII stay unsupported. The selector is computed once at probe, so an unsupported phy-mode fails the probe instead of every init and resume.

- With SGMII, get the PCS in pcs_init from s32g_serdes_pcs_create() with the MAC node: pcs-handle points at the SerDes, phys names the lane and the XPCS instance. An SGMII MAC without pcs-handle fails to probe. There is no exit hook: the PCS is owned by the SerDes device, and s32g_serdes_pcs_create() creates a device link to it.

- Keep the MAC transmit clock at 125 MHz for every speed with SGMII:
10M and 100M use symbol replication in the PCS, while stmmac_set_clk_tx_rate() would set 25 MHz / 2.5 MHz.

- Disable EEE with SGMII: the SerDes XPCS does not implement it, but stmmac assumes that LPI works through any external PCS.

- Select PHY_S32G_SERDES.

As with dwmac-rzn1 and dwmac-intel, a select_pcs callback means the core no longer falls back to the integrated PCS.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig     |  1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c | 81 ++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +1 -0
index c6559e749c0c..26dec3f61ea7 100644
@@ -193,6 +193,7 @@ config DWMAC_S32
 	tristate "NXP S32G/S32R GMAC support"
 	default ARCH_S32
 	depends on OF && (ARCH_S32 || COMPILE_TEST)
+	select PHY_S32G_SERDES
 	help
 	  Support for ethernet controller on NXP S32CC SOCs.
 
drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c +78 -3

135 lines not on this page · raw message

Signature · 1 line
2.55.0
author maintainer
#13 lore raw

RFC PATCH v4 11/15 MAINTAINERS: Add NXP S32G SerDes entry

In reply to Jan Petrous (OSS)

From: Vincent Guittot <[email protected]>

Add an entry for the S32G SerDes PHY driver, the S32G XPCS glue, the S32G part of pcs-xpcs, their headers and the SerDes binding. netdev is listed because the PCS code lives in drivers/net/pcs/.

[jan.petrous: dropped the shared core entry along with the core]
---
 MAINTAINERS | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
MAINTAINERS +16 -0
index 742c4e6b291f..cb465ba42d73 100644
@@ -3449,6 +3449,22 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml
 F:	drivers/pci/controller/dwc/pcie-nxp-s32g*
 
+ARM/NXP S32G SERDES DRIVER
+M:	Ghennadi Procopciuc <[email protected]>
+M:	Ciprian Marian Costea <[email protected]>
+M:	Jan Petrous <[email protected]>
+R:	NXP S32 Linux Team <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/nxp,s32g-serdes.yaml
+F:	drivers/net/pcs/pcs-nxp-s32g-xpcs.c
+F:	drivers/net/pcs/pcs-xpcs-s32g.c
+F:	drivers/phy/freescale/phy-nxp-s32g-serdes.c
+F:	include/linux/pcs/pcs-nxp-s32g-xpcs.h
+F:	include/linux/phy/nxp-s32g-serdes.h
+
 ARM/NXP S32G/S32R DWMAC ETHERNET DRIVER
 M:	Jan Petrous <[email protected]>
 R:	[email protected]
Signature · 1 line
2.55.0
author maintainer
#14 lore raw

RFC PATCH v4 12/15 arm64: dts: s32g: Add SCMI reset controller

In reply to Jan Petrous (OSS)

Add the SCMI reset domain protocol node (protocol@16) for S32G2 and S32G3, so that on-SoC controllers can use SCMI resets.

---
 arch/arm64/boot/dts/freescale/s32g2.dtsi | 5 +++++
 arch/arm64/boot/dts/freescale/s32g3.dtsi | 5 +++++
 2 files changed, 10 insertions(+)
arch/arm64/boot/dts/freescale/s32g2.dtsi +5 -0
index a7e5977bc146..ff5d2a061d50 100644
@@ -100,6 +100,11 @@ clks: protocol@14 {
 				reg = <0x14>;
 				#clock-cells = <1>;
 			};
+
+			scmi_reset: protocol@16 {
+				reg = <0x16>;
+				#reset-cells = <1>;
+			};
 		};
 
 		psci {
arch/arm64/boot/dts/freescale/s32g3.dtsi +5 -0
index 0770af61a2c4..fbe87475bcf6 100644
@@ -139,6 +139,11 @@ clks: protocol@14 {
 				reg = <0x14>;
 				#clock-cells = <1>;
 			};
+
+			scmi_reset: protocol@16 {
+				reg = <0x16>;
+				#reset-cells = <1>;
+			};
 		};
 
 		psci: psci {
Signature · 1 line
2.55.0
author maintainer
#15 lore raw

RFC PATCH v4 13/15 arm64: dts: s32g: Add SerDes controller nodes

In reply to Jan Petrous (OSS)

Add the two SerDes subsystem nodes of S32G2 and S32G3, disabled. Each is a four-cell PHY provider; a board device tree enables an instance and describes the routing through the phys references of the PCIe root ports and Ethernet controllers.

---
 arch/arm64/boot/dts/freescale/s32g2.dtsi | 30 ++++++++++++++++++++++++++++++
 arch/arm64/boot/dts/freescale/s32g3.dtsi | 30 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
arch/arm64/boot/dts/freescale/s32g2.dtsi +30 -0
index ff5d2a061d50..0b070f7b5f22 100644
@@ -877,6 +877,36 @@ gmac0mdio: mdio {
 			};
 		};
 
+		serdes0: serdes@40480000 {
+			compatible = "nxp,s32g2-serdes0", "nxp,s32g2-serdes";
+			reg = <0x40480000 0x108>,
+			      <0x40483008 0x10>,
+			      <0x40482000 0x800>,
+			      <0x40482800 0x800>;
+			reg-names = "ss-pcie", "pcie-phy", "xpcs0", "xpcs1";
+			clocks = <&clks 1>, <&clks 2>, <&clks 3>, <&clks 4>;
+			clock-names = "axi", "aux", "apb", "ref";
+			resets = <&scmi_reset 9>, <&scmi_reset 8>;
+			reset-names = "serdes", "pcie";
+			#phy-cells = <4>;
+			status = "disabled";
+		};
+
+		serdes1: serdes@44180000 {
+			compatible = "nxp,s32g2-serdes1", "nxp,s32g2-serdes";
+			reg = <0x44180000 0x108>,
+			      <0x44183008 0x10>,
+			      <0x44182000 0x800>,
+			      <0x44182800 0x800>;
+			reg-names = "ss-pcie", "pcie-phy", "xpcs0", "xpcs1";
+			clocks = <&clks 1>, <&clks 2>, <&clks 3>, <&clks 4>;
+			clock-names = "axi", "aux", "apb", "ref";
+			resets = <&scmi_reset 11>, <&scmi_reset 10>;
+			reset-names = "serdes", "pcie";
+			#phy-cells = <4>;
+			status = "disabled";
+		};
+
 		gic: interrupt-controller@50800000 {
 			compatible = "arm,gic-v3";
 			reg = <0x50800000 0x10000>,
arch/arm64/boot/dts/freescale/s32g3.dtsi +30 -0
index fbe87475bcf6..0d03daa881bf 100644
@@ -956,6 +956,21 @@ gmac0mdio: mdio {
 			};
 		};
 
+		serdes0: serdes@40480000 {
+			compatible = "nxp,s32g3-serdes0", "nxp,s32g3-serdes";
+			reg = <0x40480000 0x108>,
+			      <0x40483008 0x10>,
+			      <0x40482000 0x800>,
+			      <0x40482800 0x800>;
+			reg-names = "ss-pcie", "pcie-phy", "xpcs0", "xpcs1";
+			clocks = <&clks 1>, <&clks 2>, <&clks 3>, <&clks 4>;
+			clock-names = "axi", "aux", "apb", "ref";
+			resets = <&scmi_reset 9>, <&scmi_reset 8>;
+			reset-names = "serdes", "pcie";
+			#phy-cells = <4>;
+			status = "disabled";
+		};
+
 		swt8: watchdog@40500000 {
 			compatible = "nxp,s32g3-swt", "nxp,s32g2-swt";
 			reg = <0x40500000 0x1000>;
@@ -1024,6 +1039,21 @@ stm11: timer@4052c000 {
 			status = "disabled";
 		};
 
+		serdes1: serdes@44180000 {
+			compatible = "nxp,s32g3-serdes1", "nxp,s32g3-serdes";
+			reg = <0x44180000 0x108>,
+			      <0x44183008 0x10>,
+			      <0x44182000 0x800>,
+			      <0x44182800 0x800>;
+			reg-names = "ss-pcie", "pcie-phy", "xpcs0", "xpcs1";
+			clocks = <&clks 1>, <&clks 2>, <&clks 3>, <&clks 4>;
+			clock-names = "axi", "aux", "apb", "ref";
+			resets = <&scmi_reset 11>, <&scmi_reset 10>;
+			reset-names = "serdes", "pcie";
+			#phy-cells = <4>;
+			status = "disabled";
+		};
+
 		gic: interrupt-controller@50800000 {
 			compatible = "arm,gic-v3";
 			#interrupt-cells = <3>;
Signature · 1 line
2.55.0
author maintainer
#16 lore raw

RFC PATCH v4 14/15 arm64: dts: s32g: Add PCIe controller nodes

In reply to Jan Petrous (OSS)

Add the two PCIe controllers of S32G2 and S32G3, disabled. PCIe_0 pairs with SerDes_0 and PCIe_1 with SerDes_1. A board device tree enables a controller and references the lanes of the matching SerDes from its root port, one phys entry per lane. The nodes of both SoCs differ only in the compatible.

The configuration space (0x5f_ffffe000 and 0x4f_ffffe000) lies above the 32-bit window mapped by soc@0, so the controllers sit at the device tree root.

The root ports are labelled (pcie0_rp, pcie1_rp), so that boards and overlays can extend them by label.

Add '#address-cells = <0>' to the GIC nodes: the PCIe interrupt-map entries name the GIC as their interrupt parent, and dtc warns without it.

---
 arch/arm64/boot/dts/freescale/s32g2.dtsi | 81 ++++++++++++++++++++++++++++++++
 arch/arm64/boot/dts/freescale/s32g3.dtsi | 81 ++++++++++++++++++++++++++++++++
 2 files changed, 162 insertions(+)
arch/arm64/boot/dts/freescale/s32g2.dtsi +81 -0
index 0b070f7b5f22..1b6affb15d03 100644
@@ -916,7 +916,88 @@ gic: interrupt-controller@50800000 {
 			      <0x50420000 0x2000>;
 			interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_HIGH>;
 			interrupt-controller;
+			#address-cells = <0>;
 			#interrupt-cells = <3>;
 		};
 	};
+
+	/*
+	 * The PCIe config space (0x5f_ffffe000 / 0x4f_ffffe000) lies above the
+	 * 32-bit window mapped by soc@0, so the controllers are not under it.
+	 */
+	pcie0: pcie@40400000 {
+		compatible = "nxp,s32g2-pcie";
+		reg = <0x00 0x40400000 0x0 0x00001000>,	/* dbi */
+		      <0x00 0x40420000 0x0 0x00001000>,	/* dbi2 */
+		      <0x00 0x40460000 0x0 0x00001000>,	/* atu */
+		      <0x00 0x40470000 0x0 0x00001000>,	/* dma */
+		      <0x00 0x40481000 0x0 0x000000f8>,	/* ctrl */
+		      <0x5f 0xffffe000 0x0 0x00002000>;	/* config */
+		reg-names = "dbi", "dbi2", "atu", "dma", "ctrl", "config";
+		dma-coherent;
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x01000000 0x0 0x00000000 0x5f 0xfffe0000 0x0 0x00010000>,
+			 <0x02000000 0x0 0x00000000 0x58 0x00000000 0x0 0x80000000>,
+			 <0x43000000 0x1 0x00000000 0x59 0x00000000 0x6 0xfffe0000>;
+		bus-range = <0x0 0xff>;
+		linux,pci-domain = <0>;
+		interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "msi", "dma";
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0x7>;
+		interrupt-map = <0 0 0 1 &gic GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>,
+				<0 0 0 2 &gic GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>,
+				<0 0 0 3 &gic GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>,
+				<0 0 0 4 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+
+		pcie0_rp: pcie@0 {
+			reg = <0x0 0x0 0x0 0x0 0x0>;
+			#address-cells = <3>;
+			#size-cells = <2>;
+			ranges;
+			device_type = "pci";
+		};
+	};
+
+	pcie1: pcie@44100000 {
+		compatible = "nxp,s32g2-pcie";
+		reg = <0x00 0x44100000 0x0 0x00001000>,	/* dbi */
+		      <0x00 0x44120000 0x0 0x00001000>,	/* dbi2 */
+		      <0x00 0x44160000 0x0 0x00001000>,	/* atu */
+		      <0x00 0x44170000 0x0 0x00001000>,	/* dma */
+		      <0x00 0x44181000 0x0 0x000000f8>,	/* ctrl */
+		      <0x4f 0xffffe000 0x0 0x00002000>;	/* config */
+		reg-names = "dbi", "dbi2", "atu", "dma", "ctrl", "config";
+		dma-coherent;
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x01000000 0x0 0x00000000 0x4f 0xfffe0000 0x0 0x00010000>,
+			 <0x02000000 0x0 0x00000000 0x48 0x00000000 0x0 0x80000000>,
+			 <0x43000000 0x1 0x00000000 0x49 0x00000000 0x6 0xfffe0000>;
+		bus-range = <0x0 0xff>;
+		linux,pci-domain = <1>;
+		interrupts = <GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "msi", "dma";
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0x7>;
+		interrupt-map = <0 0 0 1 &gic GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH>,
+				<0 0 0 2 &gic GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH>,
+				<0 0 0 3 &gic GIC_SPI 221 IRQ_TYPE_LEVEL_HIGH>,
+				<0 0 0 4 &gic GIC_SPI 222 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+
+		pcie1_rp: pcie@0 {
+			reg = <0x0 0x0 0x0 0x0 0x0>;
+			#address-cells = <3>;
+			#size-cells = <2>;
+			ranges;
+			device_type = "pci";
+		};
+	};
 };
arch/arm64/boot/dts/freescale/s32g3.dtsi +81 -0

93 lines not on this page · raw message

Signature · 1 line
2.55.0
author maintainer
#17 lore raw

RFC PATCH v4 15/15 arm64: dts: s32g: Add S32G3-RDB3 SerDes routing variants

In reply to Jan Petrous (OSS)

The S32G3-VNP-RDB3 wires GMAC0 to an on-board KSZ9031 RGMII PHY by default. Add two board variants which route GMAC0 over SerDes_0 for SGMII instead:

- mode 1: PCIe x1 on lane 0, GMAC0 SGMII (XPCS0) on lane 1;
- mode 3: GMAC0 SGMII (XPCS0) on lane 0. Lane 1 (XPCS1, PFE_MAC2) has no consumer, as there is no PFE driver, and is not described.

The variants are full .dts files that include s32g399a-rdb3.dts, not
overlays: they drop the phy-handle of GMAC0, and /delete-property/ has no effect in an overlay.

The routing is described by the consumers: the PCIe root ports reference lane 0 with PHY_TYPE_PCIE, GMAC0 references its lane with PHY_TYPE_SGMII and XPCS0, and takes the PCS from the SerDes through pcs-handle.

The mode 1 variant also enables both PCIe root complexes: PCIe_0 reaches the M.2 slots when board switch SW17-2 is ON, PCIe_1 the PCIe card slot. SerDes_1 carries only PCIe_1 on lane 0, as there is no PFE driver to reference lane 1, and runs the first matching mode, PCIe x2, with an x1 link.

The SGMII lane goes to the on-board SJA1110 switch, which the variants do not describe, so the MAC side is a fixed 1G link.

---
 arch/arm64/boot/dts/freescale/Makefile             |  2 +
 .../dts/freescale/s32g399a-rdb3-serdes-mode1.dts   | 65 ++++++++++++++++++++++
 .../dts/freescale/s32g399a-rdb3-serdes-mode3.dts   | 40 +++++++++++++
 3 files changed, 107 insertions(+)
arch/arm64/boot/dts/freescale/Makefile +2 -0
index a80cccf34eb5..f92670254c6a 100644
@@ -1047,5 +1047,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx8mm-phygate-tauri-l-rs232-rs485.dtb
 dtb-$(CONFIG_ARCH_S32) += s32g274a-evb.dtb
 dtb-$(CONFIG_ARCH_S32) += s32g274a-rdb2.dtb
 dtb-$(CONFIG_ARCH_S32) += s32g399a-rdb3.dtb
+dtb-$(CONFIG_ARCH_S32) += s32g399a-rdb3-serdes-mode1.dtb
+dtb-$(CONFIG_ARCH_S32) += s32g399a-rdb3-serdes-mode3.dtb
 dtb-$(CONFIG_ARCH_S32) += s32n79-rdb.dtb
 dtb-$(CONFIG_ARCH_S32) += s32v234-evb.dtb
arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode1.dts new file +65 -0

65 lines not on this page · raw message

arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode3.dts new file +40 -0
new file mode 100644
index 000000000000..8b90d5f14d2a
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+/*
+ * Copyright 2021-2026 NXP
+ *
+ * NXP S32G3 Reference Design Board 3 (S32G-VNP-RDB3),
+ * SerDes_0 Mode 3: 1G SGMII via GMAC0 (XPCS0, lane 0). Lane 1 (XPCS1,
+ * PFE_MAC2) is not described.
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include "s32g399a-rdb3.dts"
+
+/ {
+	model = "NXP S32G3 Reference Design Board 3 (S32G-VNP-RDB3), SerDes_0 Mode 3";
+};
+
+/*
+ * SerDes_0 mode 3: GMAC0 via XPCS0 on lane 0. Lane 1, PFE_MAC2 via XPCS1,
+ * has no consumer, as there is no PFE driver.
+ */
+&serdes0 {
+	status = "okay";
+};
+
+&gmac0 {
+	/delete-property/ phy-handle;
+	clocks = <&clks 24>, <&clks 17>, <&clks 16>, <&clks 15>;
+	clock-names = "stmmaceth", "tx", "rx", "ptp_ref";
+	phy-mode = "sgmii";
+	phys = <&serdes0 0 PHY_TYPE_SGMII 0 1000>;
+	pcs-handle = <&serdes0>;
+	status = "okay";
+
+	/* The lane goes to the on-board SJA1110 switch, not described here */
+	fixed-link {
+		speed = <1000>;
+		full-duplex;
+		pause;
+	};
+};
Signature · 1 line
2.55.0