* [PATCH RFC v4 01/15] dt-bindings: phy: Add NXP S32G SerDes subsystem
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 02/15] dt-bindings: net: nxp,s32-dwmac: Document pcs-handle Jan Petrous via B4 Relay
` (14 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Co-developed-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
.../devicetree/bindings/phy/nxp,s32g-serdes.yaml | 137 +++++++++++++++++++++
1 file changed, 137 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/nxp,s32g-serdes.yaml b/Documentation/devicetree/bindings/phy/nxp,s32g-serdes.yaml
new file mode 100644
index 000000000000..a06becfcc4e4
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/nxp,s32g-serdes.yaml
@@ -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 <ghennadi.procopciuc@oss.nxp.com>
+ - Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
+ - Jan Petrous <jan.petrous@oss.nxp.com>
+
+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>;
+ };
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 02/15] dt-bindings: net: nxp,s32-dwmac: Document pcs-handle
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 01/15] dt-bindings: phy: Add " Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 03/15] dt-bindings: PCI: nxp,s32g-pcie: One PHY per lane Jan Petrous via B4 Relay
` (13 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
.../devicetree/bindings/net/nxp,s32-dwmac.yaml | 30 +++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml b/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml
index fcad2274302d..219a033b889d 100644
--- a/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml
@@ -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
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 03/15] dt-bindings: PCI: nxp,s32g-pcie: One PHY per lane
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 01/15] dt-bindings: phy: Add " Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 02/15] dt-bindings: net: nxp,s32-dwmac: Document pcs-handle Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 04/15] net: pcs: xpcs: allow a PCS to opt out of soft reset and EEE Jan Petrous via B4 Relay
` (12 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml b/Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml
index 66a050028278..b90d169f57ed 100644
--- a/Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/nxp,s32g-pcie.yaml
@@ -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>;
};
};
};
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 04/15] net: pcs: xpcs: allow a PCS to opt out of soft reset and EEE
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (2 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 03/15] dt-bindings: PCI: nxp,s32g-pcie: One PHY per lane Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 05/15] net: pcs: xpcs: let a glue driver declare the PCS and PMA IDs Jan Petrous via B4 Relay
` (11 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
drivers/net/pcs/pcs-xpcs.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 6466e0ff2a98..442c64a731b7 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -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);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 05/15] net: pcs: xpcs: let a glue driver declare the PCS and PMA IDs
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (3 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 04/15] net: pcs: xpcs: allow a PCS to opt out of soft reset and EEE Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 06/15] net: pcs: xpcs: add NXP S32G SerDes XPCS support Jan Petrous via B4 Relay
` (10 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
drivers/net/pcs/pcs-xpcs.c | 95 ++++++++++++++++++++++++++++++++++----------
include/linux/pcs/pcs-xpcs.h | 2 +
2 files changed, 75 insertions(+), 22 deletions(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 442c64a731b7..3b5857dc44f3 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -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
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index 36073f7b6bb4..f46434958383 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -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 */
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 06/15] net: pcs: xpcs: add NXP S32G SerDes XPCS support
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (4 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 05/15] net: pcs: xpcs: let a glue driver declare the PCS and PMA IDs Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 07/15] net: pcs: xpcs: wait for SGMII AN to complete in-band Jan Petrous via B4 Relay
` (9 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
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(-)
diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile
index f9f6cf2578d7..072b8214446b 100644
--- a/drivers/net/pcs/Makefile
+++ b/drivers/net/pcs/Makefile
@@ -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
diff --git a/drivers/net/pcs/pcs-xpcs-s32g.c b/drivers/net/pcs/pcs-xpcs-s32g.c
new file mode 100644
index 000000000000..9283c5931f1b
--- /dev/null
+++ b/drivers/net/pcs/pcs-xpcs-s32g.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * NXP S32G SerDes XPCS support for pcs-xpcs
+ *
+ * Copyright 2026 NXP
+ */
+#include <linux/math.h>
+#include <linux/mii.h>
+#include <linux/pcs/pcs-xpcs.h>
+#include <linux/phylink.h>
+#include "pcs-xpcs.h"
+
+/*
+ * DW_VR_MII_LINK_TIMER_CTRL holds bits [23:8] of a 24 bit count of 8 ns
+ * cycles; the low byte is fixed at 0x7d.
+ */
+#define S32G_LINK_TIMER_CYCLE_NS 8
+#define S32G_LINK_TIMER_LOW 0x7d
+
+int nxp_s32g_sgmii_pma_config(struct dw_xpcs *xpcs)
+{
+ int cycles = phylink_get_link_timer_ns(PHY_INTERFACE_MODE_SGMII) /
+ S32G_LINK_TIMER_CYCLE_NS;
+ int ret;
+
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_LINK_TIMER_CTRL,
+ DIV_ROUND_CLOSEST(cycles - S32G_LINK_TIMER_LOW, 256));
+ if (ret < 0)
+ return ret;
+
+ /* The timer value is used only once the override is set after it */
+ ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1,
+ DW_VR_MII_DIG_CTRL1_CL37_TMR_OVR_RIDE,
+ DW_VR_MII_DIG_CTRL1_CL37_TMR_OVR_RIDE);
+ if (ret < 0)
+ return ret;
+
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR);
+ if (ret < 0)
+ return ret;
+
+ if (!(ret & BMCR_ANENABLE))
+ return 0;
+
+ /* pcs-xpcs restarted AN before this hook, with the old timer */
+ return xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART,
+ BMCR_ANRESTART);
+}
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 3b5857dc44f3..71e5882f4b0b 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -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,
},
};
diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h
index 929fa238445e..fb41cdff2b35 100644
--- a/drivers/net/pcs/pcs-xpcs.h
+++ b/drivers/net/pcs/pcs-xpcs.h
@@ -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);
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index f46434958383..ca17a8c1f23e 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -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,
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 07/15] net: pcs: xpcs: wait for SGMII AN to complete in-band
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (5 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 06/15] net: pcs: xpcs: add NXP S32G SerDes XPCS support Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 08/15] net: pcs: Add NXP S32G XPCS glue Jan Petrous via B4 Relay
` (8 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
drivers/net/pcs/pcs-xpcs.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 71e5882f4b0b..65597c2d7a89 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -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,
},
};
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 08/15] net: pcs: Add NXP S32G XPCS glue
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (6 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 07/15] net: pcs: xpcs: wait for SGMII AN to complete in-band Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 09/15] phy: freescale: s32g: Add SerDes subsystem PHY Jan Petrous via B4 Relay
` (7 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS),
Alexandru-Catalin Ionita, Ghennadi Procopciuc, Ionut Vicovan,
Bogdan Roman
From: Vincent Guittot <vincent.guittot@linaro.org>
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.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Co-developed-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Co-developed-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com>
Signed-off-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com>
Co-developed-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
Co-developed-by: Ionut Vicovan <Ionut.Vicovan@nxp.com>
Signed-off-by: Ionut Vicovan <Ionut.Vicovan@nxp.com>
Co-developed-by: Bogdan Roman <bogdan-gabriel.roman@nxp.com>
Signed-off-by: Bogdan Roman <bogdan-gabriel.roman@nxp.com>
[jan.petrous: moved onto pcs-xpcs, the transport becomes an MDIO bus]
Co-developed-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
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(+)
diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig
index 108d47257bee..2c29ecbd9c70 100644
--- a/drivers/net/pcs/Kconfig
+++ b/drivers/net/pcs/Kconfig
@@ -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
diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile
index 072b8214446b..53c583f8e04d 100644
--- a/drivers/net/pcs/Makefile
+++ b/drivers/net/pcs/Makefile
@@ -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
diff --git a/drivers/net/pcs/pcs-nxp-s32g-xpcs.c b/drivers/net/pcs/pcs-nxp-s32g-xpcs.c
new file mode 100644
index 000000000000..3a0e85e1695d
--- /dev/null
+++ b/drivers/net/pcs/pcs-nxp-s32g-xpcs.c
@@ -0,0 +1,569 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2021-2026 NXP
+ *
+ * S32G SerDes XPCS glue: the indirect register window of each XPCS instance
+ * exposed as an MDIO bus for pcs-xpcs, plus the PMA/PLL bring-up steps that
+ * the SerDes PHY driver sequences across both instances.
+ */
+
+#include <linux/bitfield.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/mdio.h>
+#include <linux/mii.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/pcs/pcs-nxp-s32g-xpcs.h>
+#include <linux/pcs/pcs-xpcs.h>
+#include <linux/phy.h>
+#include <linux/phylink.h>
+#include <linux/units.h>
+
+#include "pcs-xpcs.h"
+
+struct s32g_xpcs {
+ void __iomem *base;
+ struct device *dev;
+ unsigned char id;
+ /* Serialises the two step access through the indirect window */
+ struct mutex lock;
+ bool ext_clk;
+ bool mhz125;
+ enum s32g_xpcs_shared pcie_shared;
+ struct phylink_pcs *pcs;
+};
+
+#define XPCS_TIMEOUT_US (300 * USEC_PER_MSEC)
+#define XPCS_POLL_SLEEP_US 100
+
+/* Page select register of the indirect access window */
+#define S32G_XPCS_VIEWPORT 0x3fc
+
+/* DW_VR_MII_DIG_CTRL1 bit used by the bring-up, next to DW_VR_RST */
+#define BYP_PWRUP BIT(1)
+/* Holds the DW_PSEQ_ST power sequencer state */
+#define VR_MII_DIG_STS 0x8010
+#define VR_MII_GEN5_12G_16G_TX_RATE_CTRL 0x8034
+#define TX0_RATE_MASK GENMASK(2, 0)
+#define TX0_BAUD_DIV_4 2
+#define VR_MII_GEN5_12G_16G_TX_EQ_CTRL0 0x8036
+#define TX_EQ_MAIN_MASK GENMASK(13, 8)
+#define VR_MII_CONSUMER_10G_TX_TERM_CTRL 0x803c
+#define TX0_TERM_MASK GENMASK(2, 0)
+#define VR_MII_GEN5_12G_16G_RX_GENCTRL1 0x8051
+#define RX_RST_0 BIT(4)
+#define VR_MII_GEN5_12G_16G_RX_RATE_CTRL 0x8054
+#define RX0_RATE_MASK GENMASK(1, 0)
+#define RX0_BAUD_DIV_8 0x3
+#define VR_MII_GEN5_12G_16G_CDR_CTRL 0x8056
+#define VCO_LOW_FREQ_0 BIT(8)
+#define VR_MII_GEN5_12G_16G_MPLL_CMN_CTRL 0x8070
+#define MPLLB_SEL_0 BIT(4)
+#define VR_MII_GEN5_12G_16G_MPLLA_CTRL0 0x8071
+#define MPLLA_CAL_DISABLE BIT(15)
+#define MLLA_MULTIPLIER_MASK GENMASK(7, 0)
+#define VR_MII_GEN5_12G_MPLLA_CTRL1 0x8072
+#define MPLLA_FRACN_CTRL_MASK GENMASK(15, 5)
+#define VR_MII_GEN5_12G_16G_MPLLA_CTRL2 0x8073
+#define MPLLA_TX_CLK_DIV_MASK GENMASK(13, 11)
+#define MPLLA_DIV10_CLK_EN BIT(9)
+#define VR_MII_GEN5_12G_16G_MPLLB_CTRL0 0x8074
+#define MPLLB_CAL_DISABLE BIT(15)
+#define MLLB_MULTIPLIER_MASK GENMASK(7, 0)
+#define VR_MII_GEN5_12G_MPLLB_CTRL1 0x8075
+#define MPLLB_FRACN_CTRL_MASK GENMASK(15, 5)
+#define VR_MII_GEN5_12G_16G_MPLLB_CTRL2 0x8076
+#define MPLLB_TX_CLK_DIV_MASK GENMASK(13, 11)
+#define MPLLB_DIV10_CLK_EN BIT(9)
+#define VR_MII_GEN5_12G_MPLLA_CTRL3 0x8077
+#define MPLLA_BANDWIDTH_MASK GENMASK(15, 0)
+#define VR_MII_GEN5_12G_MPLLB_CTRL3 0x8078
+#define MPLLB_BANDWIDTH_MASK GENMASK(15, 0)
+#define VR_MII_GEN5_12G_16G_REF_CLK_CTRL 0x8091
+#define REF_USE_PAD BIT(1)
+#define REF_CLK_DIV2 BIT(2)
+#define REF_RANGE_MASK GENMASK(5, 3) /* shared by both PLLs */
+#define RANGE_26_53_MHZ 0x1
+#define RANGE_52_78_MHZ 0x2
+#define REF_MPLLA_DIV2 BIT(6)
+#define REF_MPLLB_DIV2 BIT(7)
+#define VR_MII_GEN5_12G_16G_VCO_CAL_LD0 0x8092
+#define VCO_LD_VAL_0_MASK GENMASK(12, 0)
+#define VR_MII_GEN5_12G_VCO_CAL_REF0 0x8096
+#define VCO_REF_LD_0_MASK GENMASK(5, 0)
+
+/*
+ * The XPCS registers are reached through a 256 register window: the upper
+ * bits of the Clause 45 address "(devad << 16) | reg" select the page in
+ * S32G_XPCS_VIEWPORT, the low byte the register within the page. Registers
+ * are 16 bit wide, on a 4 byte stride.
+ */
+static void __iomem *s32g_xpcs_select(struct s32g_xpcs *xpcs, u16 reg)
+{
+ u32 addr = FIELD_PREP(GENMASK(20, 16), MDIO_MMD_VEND2) | reg;
+
+ lockdep_assert_held(&xpcs->lock);
+
+ writew(addr >> 8, xpcs->base + S32G_XPCS_VIEWPORT);
+
+ return xpcs->base + (addr & 0xff) * 4;
+}
+
+static u16 s32g_xpcs_read(struct s32g_xpcs *xpcs, u16 reg)
+{
+ guard(mutex)(&xpcs->lock);
+
+ return readw(s32g_xpcs_select(xpcs, reg));
+}
+
+static void s32g_xpcs_write(struct s32g_xpcs *xpcs, u16 reg, u16 val)
+{
+ guard(mutex)(&xpcs->lock);
+
+ writew(val, s32g_xpcs_select(xpcs, reg));
+}
+
+static void s32g_xpcs_write_bits(struct s32g_xpcs *xpcs, u16 reg, u16 mask,
+ u16 value)
+{
+ void __iomem *data;
+ u16 val;
+
+ guard(mutex)(&xpcs->lock);
+
+ data = s32g_xpcs_select(xpcs, reg);
+ val = readw(data);
+ writew((val & ~mask) | (value & mask), data);
+}
+
+/* MDIO bus view of one XPCS instance, for pcs-xpcs: MDIO_MMD_VEND2 only */
+static int s32g_xpcs_mdio_read_c45(struct mii_bus *bus, int addr, int devad,
+ int reg)
+{
+ struct s32g_xpcs *xpcs = bus->priv;
+
+ if (addr != 0 || devad != MDIO_MMD_VEND2)
+ return 0xffff;
+
+ return s32g_xpcs_read(xpcs, reg);
+}
+
+static int s32g_xpcs_mdio_write_c45(struct mii_bus *bus, int addr, int devad,
+ int reg, u16 val)
+{
+ struct s32g_xpcs *xpcs = bus->priv;
+
+ if (addr != 0 || devad != MDIO_MMD_VEND2)
+ return -EINVAL;
+
+ s32g_xpcs_write(xpcs, reg, val);
+
+ return 0;
+}
+
+/*
+ * "Step N" refers to the XPCS initialization sequence of the S32G reference
+ * manual, SerDes subsystem chapter.
+ */
+
+static int s32g_xpcs_wait_power_good_state(struct s32g_xpcs *xpcs)
+{
+ u16 val;
+
+ return read_poll_timeout(s32g_xpcs_read, val,
+ (val & DW_PSEQ_ST) == DW_PSEQ_ST_GOOD,
+ XPCS_POLL_SLEEP_US, XPCS_TIMEOUT_US, false,
+ xpcs, VR_MII_DIG_STS);
+}
+
+/**
+ * s32g_xpcs_vreset() - start the vendor specific soft reset (step 19)
+ * @xpcs: handle from s32g_xpcs_create()
+ *
+ * Call after s32g_xpcs_init_plls(), then wait with s32g_xpcs_wait_vreset().
+ *
+ * Context: may sleep.
+ */
+void s32g_xpcs_vreset(struct s32g_xpcs *xpcs)
+{
+ s32g_xpcs_write_bits(xpcs, DW_VR_MII_DIG_CTRL1, DW_VR_RST, DW_VR_RST);
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_vreset);
+
+/**
+ * s32g_xpcs_wait_vreset() - wait for the soft reset to complete (step 20)
+ * @xpcs: handle from s32g_xpcs_create()
+ *
+ * Context: may sleep, for up to 300 ms.
+ *
+ * Return: 0, or -ETIMEDOUT if the XPCS stays in reset.
+ */
+int s32g_xpcs_wait_vreset(struct s32g_xpcs *xpcs)
+{
+ u16 val;
+ int ret;
+
+ ret = read_poll_timeout(s32g_xpcs_read, val, !(val & DW_VR_RST),
+ XPCS_POLL_SLEEP_US, XPCS_TIMEOUT_US, false,
+ xpcs, DW_VR_MII_DIG_CTRL1);
+ if (ret)
+ dev_err(xpcs->dev, "XPCS%d is in reset\n", xpcs->id);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_wait_vreset);
+
+/**
+ * s32g_xpcs_reset_rx() - reset the receive path (steps 21 and 22)
+ * @xpcs: handle from s32g_xpcs_create()
+ *
+ * Call after s32g_xpcs_wait_vreset(). Unless the lane is shared with PCIe,
+ * this first waits for the power sequencer to reach POWER_GOOD.
+ *
+ * Context: may sleep, for up to 300 ms.
+ *
+ * Return: 0, or -ETIMEDOUT if POWER_GOOD is not reached.
+ */
+int s32g_xpcs_reset_rx(struct s32g_xpcs *xpcs)
+{
+ int ret = 0;
+
+ /*
+ * On the shared 1G lane the PCIe side gates the PMA power-up and
+ * BYP_PWRUP stays set, so the sequencer never reaches POWER_GOOD.
+ */
+ if (xpcs->pcie_shared != S32G_PCIE_XPCS_1G) {
+ ret = s32g_xpcs_wait_power_good_state(xpcs);
+ if (ret) {
+ dev_err(xpcs->dev, "Failed to enter in PGOOD state after vendor reset\n");
+ return ret;
+ }
+ }
+
+ /* Step 21 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_RX_GENCTRL1,
+ RX_RST_0, RX_RST_0);
+
+ /* Step 22 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_RX_GENCTRL1,
+ RX_RST_0, 0);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_reset_rx);
+
+static void s32g_xpcs_electrical_configure(struct s32g_xpcs *xpcs)
+{
+ /* Step 2 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_TX_EQ_CTRL0,
+ TX_EQ_MAIN_MASK, FIELD_PREP(TX_EQ_MAIN_MASK, 0xc));
+
+ /* Step 3 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_CONSUMER_10G_TX_TERM_CTRL,
+ TX0_TERM_MASK, FIELD_PREP(TX0_TERM_MASK, 0x4));
+}
+
+static void s32g_xpcs_vco_cfg(struct s32g_xpcs *xpcs)
+{
+ unsigned int vco_ld, vco_ref;
+
+ if (xpcs->mhz125) {
+ vco_ld = FIELD_PREP(VCO_LD_VAL_0_MASK, 1360);
+ vco_ref = FIELD_PREP(VCO_REF_LD_0_MASK, 17);
+ } else {
+ vco_ld = FIELD_PREP(VCO_LD_VAL_0_MASK, 1350);
+ vco_ref = FIELD_PREP(VCO_REF_LD_0_MASK, 27);
+ }
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_VCO_CAL_LD0,
+ VCO_LD_VAL_0_MASK, vco_ld);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_VCO_CAL_REF0,
+ VCO_REF_LD_0_MASK, vco_ref);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_TX_RATE_CTRL,
+ TX0_RATE_MASK,
+ FIELD_PREP(TX0_RATE_MASK, TX0_BAUD_DIV_4));
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_RX_RATE_CTRL,
+ RX0_RATE_MASK,
+ FIELD_PREP(RX0_RATE_MASK, RX0_BAUD_DIV_8));
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_CDR_CTRL,
+ VCO_LOW_FREQ_0, 0);
+}
+
+static void s32g_xpcs_init_mplla(struct s32g_xpcs *xpcs)
+{
+ unsigned int val;
+
+ /* Step 7 */
+ val = 0;
+ if (xpcs->ext_clk)
+ val |= REF_USE_PAD;
+
+ if (xpcs->mhz125) {
+ val |= REF_MPLLA_DIV2;
+ val |= REF_CLK_DIV2;
+ val |= FIELD_PREP(REF_RANGE_MASK, RANGE_52_78_MHZ);
+ } else {
+ val |= FIELD_PREP(REF_RANGE_MASK, RANGE_26_53_MHZ);
+ }
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_REF_CLK_CTRL,
+ REF_MPLLA_DIV2 | REF_USE_PAD | REF_RANGE_MASK |
+ REF_CLK_DIV2, val);
+
+ /* Step 8 */
+ if (xpcs->mhz125)
+ val = FIELD_PREP(MLLA_MULTIPLIER_MASK, 80);
+ else
+ val = FIELD_PREP(MLLA_MULTIPLIER_MASK, 25);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_MPLLA_CTRL0,
+ MPLLA_CAL_DISABLE | MLLA_MULTIPLIER_MASK,
+ val);
+
+ /* Step 9 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_MPLLA_CTRL1,
+ MPLLA_FRACN_CTRL_MASK, 0);
+
+ /* Step 10 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_MPLLA_CTRL2,
+ MPLLA_TX_CLK_DIV_MASK | MPLLA_DIV10_CLK_EN,
+ FIELD_PREP(MPLLA_TX_CLK_DIV_MASK, 1) | MPLLA_DIV10_CLK_EN);
+
+ /* Step 11 */
+ if (xpcs->mhz125)
+ val = FIELD_PREP(MPLLA_BANDWIDTH_MASK, 43);
+ else
+ val = FIELD_PREP(MPLLA_BANDWIDTH_MASK, 357);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_MPLLA_CTRL3,
+ MPLLA_BANDWIDTH_MASK, val);
+}
+
+static void s32g_xpcs_init_mpllb(struct s32g_xpcs *xpcs)
+{
+ unsigned int val;
+
+ /* Step 7 */
+ val = 0;
+ if (xpcs->ext_clk)
+ val |= REF_USE_PAD;
+
+ if (xpcs->mhz125) {
+ val |= REF_MPLLB_DIV2;
+ val |= REF_CLK_DIV2;
+ val |= FIELD_PREP(REF_RANGE_MASK, RANGE_52_78_MHZ);
+ } else {
+ val |= FIELD_PREP(REF_RANGE_MASK, RANGE_26_53_MHZ);
+ }
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_REF_CLK_CTRL,
+ REF_MPLLB_DIV2 | REF_USE_PAD | REF_RANGE_MASK |
+ REF_CLK_DIV2, val);
+
+ /* Step 8 */
+ if (xpcs->mhz125)
+ val = FIELD_PREP(MLLB_MULTIPLIER_MASK, 125);
+ else
+ val = FIELD_PREP(MLLB_MULTIPLIER_MASK, 39);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_MPLLB_CTRL0,
+ MPLLB_CAL_DISABLE | MLLB_MULTIPLIER_MASK,
+ val);
+
+ /* Step 9 */
+ if (xpcs->mhz125)
+ val = FIELD_PREP(MPLLB_FRACN_CTRL_MASK, 0);
+ else
+ val = FIELD_PREP(MPLLB_FRACN_CTRL_MASK, 1044);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_MPLLB_CTRL1,
+ MPLLB_FRACN_CTRL_MASK, val);
+
+ /* Step 10 */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_MPLLB_CTRL2,
+ MPLLB_TX_CLK_DIV_MASK | MPLLB_DIV10_CLK_EN,
+ FIELD_PREP(MPLLB_TX_CLK_DIV_MASK, 5) | MPLLB_DIV10_CLK_EN);
+
+ /* Step 11 */
+ if (xpcs->mhz125)
+ val = FIELD_PREP(MPLLB_BANDWIDTH_MASK, 68);
+ else
+ val = FIELD_PREP(MPLLB_BANDWIDTH_MASK, 102);
+
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_MPLLB_CTRL3,
+ MPLLB_BANDWIDTH_MASK, val);
+}
+
+/**
+ * s32g_xpcs_init_plls() - configure the PMA and both PLLs (steps 1 to 18)
+ * @xpcs: handle from s32g_xpcs_create()
+ *
+ * First step of the bring-up, followed by s32g_xpcs_vreset(). The lane is
+ * put on MPLLA, the 1G PLL.
+ *
+ * Context: may sleep, for up to 300 ms with an external reference clock.
+ *
+ * Return: 0, or -ETIMEDOUT if POWER_GOOD is not reached.
+ */
+int s32g_xpcs_init_plls(struct s32g_xpcs *xpcs)
+{
+ int ret;
+
+ if (!xpcs->ext_clk) {
+ /* Step 1 */
+ s32g_xpcs_write_bits(xpcs, DW_VR_MII_DIG_CTRL1, BYP_PWRUP,
+ BYP_PWRUP);
+ } else if (xpcs->pcie_shared == S32G_NOT_SHARED) {
+ ret = s32g_xpcs_wait_power_good_state(xpcs);
+ if (ret)
+ return ret;
+ }
+
+ s32g_xpcs_electrical_configure(xpcs);
+
+ /* The lane runs from MPLLA */
+ s32g_xpcs_write_bits(xpcs, VR_MII_GEN5_12G_16G_MPLL_CMN_CTRL,
+ MPLLB_SEL_0, 0);
+ s32g_xpcs_init_mplla(xpcs);
+ s32g_xpcs_init_mpllb(xpcs);
+ s32g_xpcs_vco_cfg(xpcs);
+
+ /*
+ * Step 18: clear BYP_PWRUP (Step 1) so that the PMA powers up. The
+ * shared 1G lane keeps it set: PCIe drives its power-up.
+ */
+ if (!xpcs->ext_clk && xpcs->pcie_shared != S32G_PCIE_XPCS_1G)
+ s32g_xpcs_write_bits(xpcs, DW_VR_MII_DIG_CTRL1, BYP_PWRUP, 0);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_init_plls);
+
+/**
+ * s32g_xpcs_disable_an() - leave the XPCS in full duplex, AN off
+ * @xpcs: handle from s32g_xpcs_create()
+ *
+ * Last step of the bring-up. DW_VR_RST restores the BMCR defaults, so this
+ * has to follow s32g_xpcs_reset_rx(). pcs-xpcs enables AN again if the MAC
+ * uses in-band mode.
+ *
+ * Context: may sleep.
+ */
+void s32g_xpcs_disable_an(struct s32g_xpcs *xpcs)
+{
+ s32g_xpcs_write_bits(xpcs, MII_BMCR, BMCR_FULLDPLX, BMCR_FULLDPLX);
+ s32g_xpcs_write_bits(xpcs, MII_BMCR, BMCR_ANENABLE, 0);
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_disable_an);
+
+/*
+ * The XPCS reports the generic DesignWare PCS ID; the S32G PMA integration
+ * selects the S32G pcs-xpcs entry. Both are declared, as the instances are
+ * created before the SerDes clocks run and pcs-xpcs then reads no ID.
+ */
+DW_XPCS_INFO_DECLARE(s32g_xpcs_info, DW_XPCS_ID, NXP_S32G_XPCS_PMA_ID);
+
+static void s32g_xpcs_pcs_destroy(void *pcs)
+{
+ xpcs_destroy_pcs(pcs);
+}
+
+/**
+ * s32g_xpcs_create() - set up one XPCS instance
+ * @dev: the SerDes device the XPCS belongs to
+ * @id: XPCS instance within the SerDes subsystem (0 or 1)
+ * @base: mapped register block of the instance
+ * @ext_clk: the reference comes from the external pad
+ * @rate: reference clock rate, 100 or 125 MHz
+ * @pcie_shared: whether the lane shares the combo PHY with PCIe
+ *
+ * The instance is devm-managed against @dev.
+ *
+ * Return: the XPCS handle, or an ERR_PTR() on failure.
+ */
+struct s32g_xpcs *s32g_xpcs_create(struct device *dev, unsigned char id,
+ void __iomem *base, bool ext_clk,
+ unsigned long rate,
+ enum s32g_xpcs_shared pcie_shared)
+{
+ struct phylink_pcs *pcs;
+ struct s32g_xpcs *xpcs;
+ struct mii_bus *bus;
+ int ret;
+
+ if (rate != (125 * HZ_PER_MHZ) && rate != (100 * HZ_PER_MHZ)) {
+ dev_err(dev, "XPCS cannot operate @%lu HZ\n", rate);
+ return ERR_PTR(-EINVAL);
+ }
+
+ xpcs = devm_kzalloc(dev, sizeof(*xpcs), GFP_KERNEL);
+ if (!xpcs)
+ return ERR_PTR(-ENOMEM);
+
+ ret = devm_mutex_init(dev, &xpcs->lock);
+ if (ret)
+ return ERR_PTR(ret);
+
+ xpcs->base = base;
+ xpcs->ext_clk = ext_clk;
+ xpcs->id = id;
+ xpcs->dev = dev;
+ xpcs->pcie_shared = pcie_shared;
+ xpcs->mhz125 = rate == (125 * HZ_PER_MHZ);
+
+ bus = devm_mdiobus_alloc(dev);
+ if (!bus)
+ return ERR_PTR(-ENOMEM);
+
+ bus->name = "NXP S32G XPCS";
+ snprintf(bus->id, MII_BUS_ID_SIZE, "%s-xpcs%u", dev_name(dev), id);
+ bus->read_c45 = s32g_xpcs_mdio_read_c45;
+ bus->write_c45 = s32g_xpcs_mdio_write_c45;
+ bus->priv = xpcs;
+ bus->parent = dev;
+ /* The XPCS is the only device on the bus, at address 0; no scan */
+ bus->phy_mask = ~0;
+
+ ret = devm_mdiobus_register(dev, bus);
+ if (ret)
+ return ERR_PTR(dev_err_probe(dev, ret,
+ "Failed to register XPCS%u MDIO bus\n",
+ id));
+
+ pcs = xpcs_create_pcs_mdiodev_info(bus, 0, &s32g_xpcs_info);
+ if (IS_ERR(pcs))
+ return ERR_PTR(dev_err_probe(dev, PTR_ERR(pcs),
+ "Failed to create XPCS%u PCS\n", id));
+
+ ret = devm_add_action_or_reset(dev, s32g_xpcs_pcs_destroy, pcs);
+ if (ret)
+ return ERR_PTR(ret);
+
+ xpcs->pcs = pcs;
+
+ return xpcs;
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_create);
+
+/**
+ * s32g_xpcs_pcs() - the phylink PCS of an XPCS instance
+ * @xpcs: handle from s32g_xpcs_create()
+ *
+ * Return: the phylink_pcs, owned by the SerDes device.
+ */
+struct phylink_pcs *s32g_xpcs_pcs(struct s32g_xpcs *xpcs)
+{
+ return xpcs->pcs;
+}
+EXPORT_SYMBOL_GPL(s32g_xpcs_pcs);
+
+MODULE_DESCRIPTION("NXP S32G SerDes XPCS driver");
+MODULE_AUTHOR("Jan Petrous (OSS) <jan.petrous@oss.nxp.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/pcs/pcs-nxp-s32g-xpcs.h b/include/linux/pcs/pcs-nxp-s32g-xpcs.h
new file mode 100644
index 000000000000..721c5ca4c54c
--- /dev/null
+++ b/include/linux/pcs/pcs-nxp-s32g-xpcs.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2021-2026 NXP
+ */
+#ifndef PCS_NXP_S32G_XPCS_H
+#define PCS_NXP_S32G_XPCS_H
+
+#include <linux/types.h>
+
+struct device;
+struct phylink_pcs;
+
+struct s32g_xpcs;
+
+/*
+ * Whether the XPCS shares the combo PHY with the PCIe lane. If it does, the
+ * PMA power-up is driven from the PCIe side.
+ */
+enum s32g_xpcs_shared {
+ S32G_NOT_SHARED,
+ S32G_PCIE_XPCS_1G,
+};
+
+struct s32g_xpcs *s32g_xpcs_create(struct device *dev, unsigned char id,
+ void __iomem *base, bool ext_clk,
+ unsigned long rate,
+ enum s32g_xpcs_shared pcie_shared);
+struct phylink_pcs *s32g_xpcs_pcs(struct s32g_xpcs *xpcs);
+
+/*
+ * Bring-up steps, called by the SerDes PHY driver in the order below. With
+ * both lanes on XPCS, the instance without control over the PHY common
+ * signals goes first.
+ */
+int s32g_xpcs_init_plls(struct s32g_xpcs *xpcs);
+void s32g_xpcs_vreset(struct s32g_xpcs *xpcs);
+int s32g_xpcs_wait_vreset(struct s32g_xpcs *xpcs);
+int s32g_xpcs_reset_rx(struct s32g_xpcs *xpcs);
+void s32g_xpcs_disable_an(struct s32g_xpcs *xpcs);
+
+#endif /* PCS_NXP_S32G_XPCS_H */
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 09/15] phy: freescale: s32g: Add SerDes subsystem PHY
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (7 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 08/15] net: pcs: Add NXP S32G XPCS glue Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 14:44 ` Vladimir Oltean
2026-11-25 9:33 ` [PATCH RFC v4 10/15] net: stmmac: s32: Add SGMII support Jan Petrous via B4 Relay
` (6 subsequent siblings)
15 siblings, 1 reply; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS),
Alexandru-Catalin Ionita, Ghennadi Procopciuc, Ionut Vicovan,
Bogdan Roman
From: Vincent Guittot <vincent.guittot@linaro.org>
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.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Co-developed-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Co-developed-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com>
Signed-off-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com>
Co-developed-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
Co-developed-by: Ionut Vicovan <Ionut.Vicovan@nxp.com>
Signed-off-by: Ionut Vicovan <Ionut.Vicovan@nxp.com>
Co-developed-by: Bogdan Roman <bogdan-gabriel.roman@nxp.com>
Signed-off-by: Bogdan Roman <bogdan-gabriel.roman@nxp.com>
Co-developed-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
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(+)
diff --git a/drivers/phy/freescale/Kconfig b/drivers/phy/freescale/Kconfig
index 7557b624be8f..a32249db5c8a 100644
--- a/drivers/phy/freescale/Kconfig
+++ b/drivers/phy/freescale/Kconfig
@@ -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.
diff --git a/drivers/phy/freescale/Makefile b/drivers/phy/freescale/Makefile
index 5b0e180d6972..1a0aec790917 100644
--- a/drivers/phy/freescale/Makefile
+++ b/drivers/phy/freescale/Makefile
@@ -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
diff --git a/drivers/phy/freescale/phy-nxp-s32g-serdes.c b/drivers/phy/freescale/phy-nxp-s32g-serdes.c
new file mode 100644
index 000000000000..07242cf3109e
--- /dev/null
+++ b/drivers/phy/freescale/phy-nxp-s32g-serdes.c
@@ -0,0 +1,1132 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * SerDes driver for S32G SoCs
+ *
+ * Copyright 2021-2026 NXP
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/iopoll.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/pcs/pcs-nxp-s32g-xpcs.h>
+#include <linux/phy/nxp-s32g-serdes.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/reset.h>
+#include <linux/units.h>
+
+#define S32G_SERDES_XPCS_MAX 2
+
+#define EXTERNAL_CLK_NAME "ext"
+#define INTERNAL_CLK_NAME "ref"
+
+/* Serdes Sub system registers */
+
+#define S32G_PCIE_PHY_GEN_CTRL 0x0
+#define REF_USE_PAD BIT(17)
+#define RX_SRIS_MODE BIT(9)
+
+#define S32G_PCIE_PHY_MPLLA_CTRL 0x10
+#define MPLL_STATE BIT(30)
+
+#define S32G_SS_RW_REG_0 0xF0
+#define SUBMODE_MASK GENMASK(2, 0)
+#define CLKEN_MASK BIT(23)
+#define PHY0_CR_PARA_SEL BIT(9)
+
+/* PCIe phy subsystem registers */
+
+#define S32G_PHY_REG_ADDR 0x0
+#define PHY_REG_EN BIT(31)
+
+#define S32G_PHY_REG_DATA 0x4
+
+#define S32G_PHY_REG_SETTLE_MIN_US 100
+#define S32G_PHY_REG_SETTLE_MAX_US 110
+
+#define RAWLANE0_DIG_PCS_XF_RX_EQ_DELTA_IQ_OVRD_IN 0x3019
+#define RAWLANE1_DIG_PCS_XF_RX_EQ_DELTA_IQ_OVRD_IN 0x3119
+#define RX_EQ_DELTA_IQ_OVRD_VAL GENMASK(3, 0)
+#define RX_EQ_DELTA_IQ_OVRD_EN BIT(4)
+
+#define S32G_PCIE_RX_EQ_DELTA_IQ 3
+
+#define S32G_SS_MODE_SETTLE_MIN_US 100
+#define S32G_SS_MODE_SETTLE_MAX_US 110
+
+/*
+ * PCIe reference clock architecture, the submode of
+ * phy_set_mode_ext(PHY_MODE_PCIE). Driver private, not PHY_MODE_PCIE_*.
+ */
+enum pcie_phy_mode {
+ CRNS = 0, /* Common Reference Clock, No Spread Spectrum */
+ CRSS = 1, /* Common Reference Clock, Spread Spectrum */
+ SRNS = 2, /* Separate Reference Clock, No Spread Spectrum */
+ SRIS = 3 /* Separate Reference Clock, Spread Spectrum */
+};
+
+/*
+ * phys = <&serdes lane type instance max-speed>; SS_RW_REG_0[SUBSYS_MODE]
+ * is derived from the consumers' references.
+ */
+#define S32G_SERDES_PHY_CELLS 4
+#define S32G_SERDES_LANE_SPEED_1G 1000
+#define S32G_SERDES_LANE_SPEED_2G5 2500
+
+enum s32g_lane_fn {
+ S32G_LANE_UNUSED = 0,
+ S32G_LANE_PCIE,
+ S32G_LANE_XPCS,
+};
+
+struct s32g_lane_desc {
+ enum s32g_lane_fn fn;
+ u32 xpcs_instance; /* valid iff fn == S32G_LANE_XPCS */
+};
+
+struct s32g_serdes_mode {
+ u32 submode; /* SS_RW_REG_0[SUBSYS_MODE] value */
+ struct s32g_lane_desc lane[2];
+ unsigned long refclk[2]; /* allowed rates in Hz, 0-terminated */
+};
+
+struct s32g_serdes_soc_data {
+ const struct s32g_serdes_mode *modes;
+ unsigned int n_modes;
+};
+
+#define S32G_LANE_IS_PCIE { .fn = S32G_LANE_PCIE }
+#define S32G_LANE_IS_XPCS(i) { .fn = S32G_LANE_XPCS, .xpcs_instance = (i) }
+
+#define S32G_REFCLK_100MHZ (100 * HZ_PER_MHZ)
+#define S32G_REFCLK_125MHZ (125 * HZ_PER_MHZ)
+
+/* S32G2/S32G3 1G modes. PCIe needs 100 MHz; mode 3 also takes 125 MHz. */
+static const struct s32g_serdes_mode s32g_serdes_modes[] = {
+ { 0, { S32G_LANE_IS_PCIE, S32G_LANE_IS_PCIE },
+ { S32G_REFCLK_100MHZ } },
+ { 1, { S32G_LANE_IS_PCIE, S32G_LANE_IS_XPCS(0) },
+ { S32G_REFCLK_100MHZ } },
+ { 2, { S32G_LANE_IS_PCIE, S32G_LANE_IS_XPCS(1) },
+ { S32G_REFCLK_100MHZ } },
+ { 3, { S32G_LANE_IS_XPCS(0), S32G_LANE_IS_XPCS(1) },
+ { S32G_REFCLK_100MHZ, S32G_REFCLK_125MHZ } },
+};
+
+/* S32G2 and S32G3 share the 1G table; the full tables differ per SoC. */
+static const struct s32g_serdes_soc_data s32g2_serdes_soc_data = {
+ .modes = s32g_serdes_modes,
+ .n_modes = ARRAY_SIZE(s32g_serdes_modes),
+};
+
+static const struct s32g_serdes_soc_data s32g3_serdes_soc_data = {
+ .modes = s32g_serdes_modes,
+ .n_modes = ARRAY_SIZE(s32g_serdes_modes),
+};
+
+struct s32g_serdes_ctrl {
+ void __iomem *ss_base;
+ struct reset_control *rst;
+ struct clk_bulk_data *clks;
+ int nclks;
+ u32 ss_mode;
+ unsigned long ref_clk_rate;
+ bool ext_clk;
+ /* Clocks on; cleared by suspend, never set by a failed init */
+ bool enabled;
+};
+
+struct s32g_pcie_ctrl {
+ void __iomem *phy_base;
+ struct reset_control *rst;
+ struct phy *phy;
+ enum pcie_phy_mode phy_mode;
+ bool powered_on;
+};
+
+struct s32g_xpcs_ctrl {
+ struct s32g_xpcs *phys[2]; /* indexed by XPCS instance */
+ void __iomem *base[2]; /* xpcs0 / xpcs1 register blocks */
+ struct phy *lane_phy[2]; /* generic PHY per XPCS instance */
+};
+
+struct s32g_serdes {
+ struct s32g_serdes_ctrl ctrl;
+ struct s32g_pcie_ctrl pcie;
+ struct s32g_xpcs_ctrl xpcs;
+ struct s32g_lane_desc lane[2];
+ const struct s32g_serdes_soc_data *soc_data;
+ struct device *dev;
+};
+
+/*
+ * MPLL_STATE sets within 3.4 ms (100 MHz reference) to 5.2 ms (125 MHz) of
+ * the reset release.
+ */
+#define S32G_SERDES_LOCK_TIMEOUT_US (10 * USEC_PER_MSEC)
+#define S32G_SERDES_LOCK_SLEEP_US 50
+
+static int s32g_serdes_wait_phy_operational(struct s32g_serdes *serdes)
+{
+ void __iomem *reg = serdes->ctrl.ss_base + S32G_PCIE_PHY_MPLLA_CTRL;
+ u32 val;
+ int ret;
+
+ ret = readl_poll_timeout(reg, val, (val & MPLL_STATE),
+ S32G_SERDES_LOCK_SLEEP_US,
+ S32G_SERDES_LOCK_TIMEOUT_US);
+ if (ret)
+ dev_err(serdes->dev, "SerDes PHY not operational\n");
+
+ return ret;
+}
+
+static int s32g_pcie_phy_power_on_common(struct s32g_serdes *serdes)
+{
+ struct s32g_serdes_ctrl *sctrl = &serdes->ctrl;
+ struct s32g_pcie_ctrl *pcie = &serdes->pcie;
+ u32 reg;
+ int ret;
+
+ reg = readl(sctrl->ss_base + S32G_PCIE_PHY_GEN_CTRL);
+
+ if (pcie->phy_mode == SRIS)
+ reg |= RX_SRIS_MODE;
+ else
+ reg &= ~RX_SRIS_MODE;
+
+ if (sctrl->ext_clk)
+ reg |= REF_USE_PAD;
+ else
+ reg &= ~REF_USE_PAD;
+
+ writel(reg, sctrl->ss_base + S32G_PCIE_PHY_GEN_CTRL);
+
+ ret = s32g_serdes_wait_phy_operational(serdes);
+ if (ret)
+ return ret;
+
+ reg = readl(sctrl->ss_base + S32G_SS_RW_REG_0);
+ reg |= PHY0_CR_PARA_SEL;
+ writel(reg, sctrl->ss_base + S32G_SS_RW_REG_0);
+
+ return 0;
+}
+
+static void s32g_pcie_phy_write(struct s32g_serdes *serdes, u32 reg, u32 val)
+{
+ writel(PHY_REG_EN, serdes->pcie.phy_base + S32G_PHY_REG_ADDR);
+ writel(reg | PHY_REG_EN, serdes->pcie.phy_base + S32G_PHY_REG_ADDR);
+ usleep_range(S32G_PHY_REG_SETTLE_MIN_US, S32G_PHY_REG_SETTLE_MAX_US);
+ writel(val, serdes->pcie.phy_base + S32G_PHY_REG_DATA);
+ usleep_range(S32G_PHY_REG_SETTLE_MIN_US, S32G_PHY_REG_SETTLE_MAX_US);
+ writel(0, serdes->pcie.phy_base + S32G_PHY_REG_ADDR);
+}
+
+static void s32g_pcie_phy_iq_ovrd(struct s32g_serdes *serdes, u32 reg)
+{
+ u32 val = FIELD_PREP(RX_EQ_DELTA_IQ_OVRD_VAL, S32G_PCIE_RX_EQ_DELTA_IQ);
+
+ s32g_pcie_phy_write(serdes, reg, val);
+ s32g_pcie_phy_write(serdes, reg, val | RX_EQ_DELTA_IQ_OVRD_EN);
+}
+
+static int s32g_pcie_phy_power_on(struct s32g_serdes *serdes)
+{
+ struct s32g_pcie_ctrl *pcie = &serdes->pcie;
+ struct s32g_serdes_ctrl *ctrl = &serdes->ctrl;
+ int ret;
+
+ ret = s32g_pcie_phy_power_on_common(serdes);
+ if (ret)
+ return ret;
+
+ s32g_pcie_phy_iq_ovrd(serdes, RAWLANE0_DIG_PCS_XF_RX_EQ_DELTA_IQ_OVRD_IN);
+ if (ctrl->ss_mode == 0)
+ s32g_pcie_phy_iq_ovrd(serdes,
+ RAWLANE1_DIG_PCS_XF_RX_EQ_DELTA_IQ_OVRD_IN);
+
+ pcie->powered_on = true;
+
+ return 0;
+}
+
+static int s32g_serdes_phy_power_on(struct phy *p)
+{
+ struct s32g_serdes *serdes = phy_get_drvdata(p);
+
+ return s32g_pcie_phy_power_on(serdes);
+}
+
+static int s32g_serdes_phy_power_off(struct phy *p)
+{
+ struct s32g_serdes *serdes = phy_get_drvdata(p);
+
+ serdes->pcie.powered_on = false;
+
+ return 0;
+}
+
+static bool is_pcie_phy_mode_valid(int mode)
+{
+ switch (mode) {
+ case CRNS:
+ case CRSS:
+ case SRNS:
+ case SRIS:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static int s32g_serdes_phy_set_mode_ext(struct phy *p,
+ enum phy_mode mode, int submode)
+{
+ struct s32g_serdes *serdes = phy_get_drvdata(p);
+
+ if (mode != PHY_MODE_PCIE)
+ return -EINVAL;
+
+ if (!is_pcie_phy_mode_valid(submode))
+ return -EINVAL;
+
+ /*
+ * Spread spectrum clocking needs the external reference and cannot
+ * be combined with an SGMII lane.
+ */
+ if ((submode == CRSS || submode == SRIS) &&
+ (serdes->ctrl.ss_mode != 0 || !serdes->ctrl.ext_clk))
+ return -EINVAL;
+
+ /* The reference clock architecture is applied at power on */
+ if (serdes->pcie.powered_on)
+ return -EBUSY;
+
+ serdes->pcie.phy_mode = submode;
+
+ return 0;
+}
+
+static const struct phy_ops serdes_pcie_ops = {
+ .owner = THIS_MODULE,
+ .power_on = s32g_serdes_phy_power_on,
+ .power_off = s32g_serdes_phy_power_off,
+ .set_mode = s32g_serdes_phy_set_mode_ext,
+};
+
+static int s32g_serdes_xpcs_setup(struct s32g_serdes *serdes, u32 instance)
+{
+ struct s32g_serdes_ctrl *ctrl = &serdes->ctrl;
+ struct s32g_xpcs_ctrl *xpcs_ctrl = &serdes->xpcs;
+ enum s32g_xpcs_shared shared = S32G_NOT_SHARED;
+ struct device *dev = serdes->dev;
+ struct s32g_xpcs *xpcs;
+
+ if (ctrl->ss_mode == 1 || ctrl->ss_mode == 2)
+ shared = S32G_PCIE_XPCS_1G;
+
+ xpcs = s32g_xpcs_create(dev, instance, xpcs_ctrl->base[instance],
+ ctrl->ext_clk, ctrl->ref_clk_rate, shared);
+ if (IS_ERR(xpcs))
+ return PTR_ERR(xpcs);
+
+ xpcs_ctrl->phys[instance] = xpcs;
+
+ return 0;
+}
+
+static int s32g_serdes_init_xpcs(struct s32g_serdes *serdes)
+{
+ struct s32g_serdes_ctrl *ctrl = &serdes->ctrl;
+ struct s32g_xpcs_ctrl *xpcs = &serdes->xpcs;
+ struct s32g_xpcs *order[2];
+ size_t i;
+ int ret;
+
+ /*
+ * In mode 3, XPCS0 controls the PHY common signals, so the RM has
+ * XPCS1 configured and reset first.
+ */
+ switch (ctrl->ss_mode) {
+ case 0:
+ return 0;
+ case 1:
+ order[0] = xpcs->phys[0];
+ order[1] = NULL;
+ break;
+ case 2:
+ order[0] = xpcs->phys[1];
+ order[1] = NULL;
+ break;
+ case 3:
+ order[0] = xpcs->phys[1];
+ order[1] = xpcs->phys[0];
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(order); i++) {
+ if (!order[i])
+ continue;
+
+ ret = s32g_xpcs_init_plls(order[i]);
+ if (ret)
+ return ret;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(order); i++) {
+ if (!order[i])
+ continue;
+
+ s32g_xpcs_vreset(order[i]);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(order); i++) {
+ if (!order[i])
+ continue;
+
+ ret = s32g_xpcs_wait_vreset(order[i]);
+ if (ret)
+ return ret;
+
+ ret = s32g_xpcs_reset_rx(order[i]);
+ if (ret)
+ return ret;
+
+ s32g_xpcs_disable_an(order[i]);
+ }
+
+ return 0;
+}
+
+static int s32g_serdes_assert_reset(struct s32g_serdes *serdes)
+{
+ struct device *dev = serdes->dev;
+ int ret;
+
+ ret = reset_control_assert(serdes->pcie.rst);
+ if (ret) {
+ dev_err(dev, "Failed to assert PCIE reset: %d\n", ret);
+ return ret;
+ }
+
+ ret = reset_control_assert(serdes->ctrl.rst);
+ if (ret) {
+ dev_err(dev, "Failed to assert SerDes reset: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int s32g_serdes_deassert_reset(struct s32g_serdes *serdes)
+{
+ struct device *dev = serdes->dev;
+ int ret;
+
+ ret = reset_control_deassert(serdes->pcie.rst);
+ if (ret) {
+ dev_err(dev, "Failed to deassert PCIE reset: %d\n", ret);
+ return ret;
+ }
+
+ ret = reset_control_deassert(serdes->ctrl.rst);
+ if (ret) {
+ dev_err(dev, "Failed to deassert SerDes reset: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static bool s32g_serdes_lane_matches(const struct s32g_lane_desc *mode_lane,
+ const struct s32g_lane_desc *req_lane)
+{
+ /* A lane without a consumer takes the function of the first match */
+ if (req_lane->fn == S32G_LANE_UNUSED)
+ return true;
+
+ if (mode_lane->fn != req_lane->fn)
+ return false;
+
+ if (mode_lane->fn == S32G_LANE_XPCS)
+ return mode_lane->xpcs_instance == req_lane->xpcs_instance;
+
+ return true;
+}
+
+static const char *s32g_lane_fn_str(const struct s32g_lane_desc *lane)
+{
+ switch (lane->fn) {
+ case S32G_LANE_PCIE:
+ return "PCIe";
+ case S32G_LANE_XPCS:
+ return lane->xpcs_instance ? "XPCS1" : "XPCS0";
+ default:
+ return "unused";
+ }
+}
+
+static int s32g_serdes_derive_mode(struct s32g_serdes *serdes)
+{
+ const struct s32g_serdes_mode *match = NULL;
+ unsigned int i;
+ bool refclk_ok = false;
+
+ if (serdes->lane[0].fn == S32G_LANE_UNUSED &&
+ serdes->lane[1].fn == S32G_LANE_UNUSED)
+ return dev_err_probe(serdes->dev, -EINVAL,
+ "No consumer references this SerDes\n");
+
+ for (i = 0; i < serdes->soc_data->n_modes; i++) {
+ const struct s32g_serdes_mode *m = &serdes->soc_data->modes[i];
+
+ if (s32g_serdes_lane_matches(&m->lane[0], &serdes->lane[0]) &&
+ s32g_serdes_lane_matches(&m->lane[1], &serdes->lane[1])) {
+ match = m;
+ break;
+ }
+ }
+
+ if (!match)
+ return dev_err_probe(serdes->dev, -EINVAL,
+ "No SerDes mode matches the lane configuration\n");
+
+ for (i = 0; i < ARRAY_SIZE(match->refclk) && match->refclk[i]; i++) {
+ if (serdes->ctrl.ref_clk_rate == match->refclk[i]) {
+ refclk_ok = true;
+ break;
+ }
+ }
+
+ if (!refclk_ok)
+ return dev_err_probe(serdes->dev, -EINVAL,
+ "Reference clock %lu Hz invalid for mode %u\n",
+ serdes->ctrl.ref_clk_rate, match->submode);
+
+ serdes->ctrl.ss_mode = match->submode;
+
+ dev_info(serdes->dev,
+ "SerDes mode %u selected: lane0=%s lane1=%s, ref-clk %lu MHz (%s)\n",
+ match->submode,
+ s32g_lane_fn_str(&serdes->lane[0]),
+ s32g_lane_fn_str(&serdes->lane[1]),
+ serdes->ctrl.ref_clk_rate / HZ_PER_MHZ,
+ serdes->ctrl.ext_clk ? "external" : "internal");
+
+ return 0;
+}
+
+static int s32g_serdes_init(struct s32g_serdes *serdes)
+{
+ struct s32g_serdes_ctrl *ctrl = &serdes->ctrl;
+ u32 reg0;
+ int ret;
+
+ ret = clk_bulk_prepare_enable(ctrl->nclks, ctrl->clks);
+ if (ret) {
+ dev_err(serdes->dev, "Failed to enable SerDes clocks\n");
+ return ret;
+ }
+
+ ret = s32g_serdes_assert_reset(serdes);
+ if (ret)
+ goto disable_clks;
+
+ reg0 = readl(ctrl->ss_base + S32G_SS_RW_REG_0);
+ reg0 &= ~SUBMODE_MASK;
+ reg0 |= FIELD_PREP(SUBMODE_MASK, ctrl->ss_mode);
+ writel(reg0, ctrl->ss_base + S32G_SS_RW_REG_0);
+
+ reg0 = readl(ctrl->ss_base + S32G_SS_RW_REG_0);
+ if (ctrl->ext_clk)
+ reg0 &= ~CLKEN_MASK;
+ else
+ reg0 |= CLKEN_MASK;
+
+ writel(reg0, ctrl->ss_base + S32G_SS_RW_REG_0);
+
+ /*
+ * Route the reference before the XPCS bring-up: with the wrong one the
+ * PMA never powers up and VR_RST never clears.
+ */
+ reg0 = readl(ctrl->ss_base + S32G_PCIE_PHY_GEN_CTRL);
+ if (ctrl->ext_clk)
+ reg0 |= REF_USE_PAD;
+ else
+ reg0 &= ~REF_USE_PAD;
+ writel(reg0, ctrl->ss_base + S32G_PCIE_PHY_GEN_CTRL);
+
+ usleep_range(S32G_SS_MODE_SETTLE_MIN_US, S32G_SS_MODE_SETTLE_MAX_US);
+
+ ret = s32g_serdes_deassert_reset(serdes);
+ if (ret)
+ goto disable_clks;
+
+ ret = s32g_serdes_wait_phy_operational(serdes);
+ if (ret)
+ goto disable_clks;
+
+ ret = s32g_serdes_init_xpcs(serdes);
+ if (ret) {
+ dev_err(serdes->dev, "XPCS init failed\n");
+ goto disable_clks;
+ }
+
+ ctrl->enabled = true;
+
+ return 0;
+
+disable_clks:
+ s32g_serdes_assert_reset(serdes);
+ clk_bulk_disable_unprepare(serdes->ctrl.nclks,
+ serdes->ctrl.clks);
+
+ return ret;
+}
+
+static void s32g_serdes_disable(void *data)
+{
+ struct s32g_serdes *serdes = data;
+
+ s32g_serdes_assert_reset(serdes);
+
+ if (serdes->ctrl.enabled) {
+ clk_bulk_disable_unprepare(serdes->ctrl.nclks,
+ serdes->ctrl.clks);
+ serdes->ctrl.enabled = false;
+ }
+}
+
+static int s32g_serdes_get_ctrl_resources(struct platform_device *pdev,
+ struct s32g_serdes *serdes)
+{
+ struct s32g_serdes_ctrl *ctrl = &serdes->ctrl;
+ struct device *dev = &pdev->dev;
+ int ret, idx, i;
+
+ ctrl->ss_base = devm_platform_ioremap_resource_byname(pdev, "ss-pcie");
+ if (IS_ERR(ctrl->ss_base))
+ return dev_err_probe(dev, PTR_ERR(ctrl->ss_base),
+ "Failed to map 'ss-pcie'\n");
+
+ ctrl->rst = devm_reset_control_get_exclusive(dev, "serdes");
+ if (IS_ERR(ctrl->rst))
+ return dev_err_probe(dev, PTR_ERR(ctrl->rst),
+ "Failed to get 'serdes' reset control\n");
+
+ ctrl->nclks = devm_clk_bulk_get_all(dev, &ctrl->clks);
+ if (ctrl->nclks < 1) {
+ ret = ctrl->nclks ? : -EINVAL;
+ return dev_err_probe(dev, ret,
+ "Failed to get SerDes clocks\n");
+ }
+
+ idx = -1;
+ for (i = 0; i < ctrl->nclks; i++) {
+ if (!ctrl->clks[i].id)
+ continue;
+
+ if (!strcmp(ctrl->clks[i].id, EXTERNAL_CLK_NAME)) {
+ idx = i;
+ ctrl->ext_clk = true;
+ break;
+ }
+
+ if (!strcmp(ctrl->clks[i].id, INTERNAL_CLK_NAME))
+ idx = i;
+ }
+
+ if (idx < 0) {
+ dev_err(dev, "Failed to get Phy reference clock source\n");
+ return -EINVAL;
+ }
+
+ ctrl->ref_clk_rate = clk_get_rate(ctrl->clks[idx].clk);
+ if (!ctrl->ref_clk_rate) {
+ dev_err(dev, "Failed to get Phy reference clock rate\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int s32g_serdes_get_pcie_resources(struct platform_device *pdev,
+ struct s32g_serdes *serdes)
+{
+ struct s32g_pcie_ctrl *pcie = &serdes->pcie;
+ struct device *dev = &pdev->dev;
+
+ pcie->phy_base = devm_platform_ioremap_resource_byname(pdev,
+ "pcie-phy");
+ if (IS_ERR(pcie->phy_base))
+ return dev_err_probe(dev, PTR_ERR(pcie->phy_base),
+ "Failed to map 'pcie-phy'\n");
+
+ pcie->rst = devm_reset_control_get_exclusive(dev, "pcie");
+ if (IS_ERR(pcie->rst))
+ return dev_err_probe(dev, PTR_ERR(pcie->rst),
+ "Failed to get 'pcie' reset control\n");
+
+ return 0;
+}
+
+static int s32g_serdes_get_xpcs_resources(struct platform_device *pdev,
+ struct s32g_serdes *serdes)
+{
+ struct s32g_xpcs_ctrl *xpcs = &serdes->xpcs;
+ struct device *dev = &pdev->dev;
+
+ xpcs->base[0] = devm_platform_ioremap_resource_byname(pdev, "xpcs0");
+ if (IS_ERR(xpcs->base[0]))
+ return dev_err_probe(dev, PTR_ERR(xpcs->base[0]),
+ "Failed to map 'xpcs0'\n");
+
+ xpcs->base[1] = devm_platform_ioremap_resource_byname(pdev, "xpcs1");
+ if (IS_ERR(xpcs->base[1]))
+ return dev_err_probe(dev, PTR_ERR(xpcs->base[1]),
+ "Failed to map 'xpcs1'\n");
+
+ return 0;
+}
+
+/* Walk up to the root: a consumer below a disabled node is disabled too */
+static bool s32g_serdes_consumer_available(struct device_node *np)
+{
+ struct device_node *parent;
+
+ for (np = of_node_get(np); np; np = parent) {
+ if (!of_device_is_available(np)) {
+ of_node_put(np);
+ return false;
+ }
+ parent = of_get_parent(np);
+ of_node_put(np);
+ }
+
+ return true;
+}
+
+static int s32g_serdes_add_ref(struct s32g_serdes *serdes,
+ struct device_node *consumer,
+ const struct of_phandle_args *args)
+{
+ struct device *dev = serdes->dev;
+ struct s32g_lane_desc *desc;
+ u32 lane, type, instance, speed;
+
+ if (args->args_count != S32G_SERDES_PHY_CELLS)
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: phys needs %d cells\n",
+ consumer, S32G_SERDES_PHY_CELLS);
+
+ lane = args->args[0];
+ type = args->args[1];
+ instance = args->args[2];
+ speed = args->args[3];
+
+ if (lane >= ARRAY_SIZE(serdes->lane))
+ return dev_err_probe(dev, -EINVAL, "%pOF: invalid lane %u\n",
+ consumer, lane);
+
+ desc = &serdes->lane[lane];
+ if (desc->fn != S32G_LANE_UNUSED)
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: lane %u referenced twice\n",
+ consumer, lane);
+
+ switch (type) {
+ case PHY_TYPE_PCIE:
+ if (instance || speed)
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: PCIe takes no instance or speed\n",
+ consumer);
+ desc->fn = S32G_LANE_PCIE;
+ return 0;
+ case PHY_TYPE_SGMII:
+ if (instance >= S32G_SERDES_XPCS_MAX)
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: invalid XPCS instance %u\n",
+ consumer, instance);
+ if (speed == S32G_SERDES_LANE_SPEED_2G5)
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: lane %u: 2.5G is not supported yet\n",
+ consumer, lane);
+ if (speed != S32G_SERDES_LANE_SPEED_1G)
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: lane %u: invalid speed %u\n",
+ consumer, lane, speed);
+ desc->fn = S32G_LANE_XPCS;
+ desc->xpcs_instance = instance;
+ return 0;
+ default:
+ return dev_err_probe(dev, -EINVAL,
+ "%pOF: unsupported PHY type %u\n",
+ consumer, type);
+ }
+}
+
+/*
+ * The consumers describe the lane routing through their phys references.
+ * SUBSYS_MODE is written before the reset release, long before they probe,
+ * so collect them here.
+ */
+static int s32g_serdes_scan_consumers(struct s32g_serdes *serdes)
+{
+ struct device_node *np = serdes->dev->of_node;
+ struct device_node *consumer;
+ struct of_phandle_args args;
+ int i, count, ret;
+
+ for_each_node_with_property(consumer, "phys") {
+ if (!s32g_serdes_consumer_available(consumer))
+ continue;
+
+ count = of_count_phandle_with_args(consumer, "phys",
+ "#phy-cells");
+ for (i = 0; i < count; i++) {
+ ret = of_parse_phandle_with_args(consumer, "phys",
+ "#phy-cells", i,
+ &args);
+ if (ret)
+ continue;
+
+ ret = 0;
+ if (args.np == np)
+ ret = s32g_serdes_add_ref(serdes, consumer,
+ &args);
+ of_node_put(args.np);
+ if (ret) {
+ of_node_put(consumer);
+ return ret;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static const struct phy_ops serdes_xpcs_lane_ops = {
+ .owner = THIS_MODULE,
+};
+
+/*
+ * One PHY for the PCIe link, whatever its width, and one 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.
+ */
+static int s32g_serdes_create_phys(struct s32g_serdes *serdes)
+{
+ struct device *dev = serdes->dev;
+ struct phy *phy;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(serdes->lane); i++) {
+ const struct s32g_lane_desc *lane = &serdes->lane[i];
+
+ switch (lane->fn) {
+ case S32G_LANE_PCIE:
+ if (serdes->pcie.phy)
+ break;
+
+ phy = devm_phy_create(dev, NULL, &serdes_pcie_ops);
+ if (IS_ERR(phy))
+ return PTR_ERR(phy);
+
+ phy_set_drvdata(phy, serdes);
+ phy->attrs.mode = PHY_MODE_PCIE;
+ serdes->pcie.phy = phy;
+ break;
+ case S32G_LANE_XPCS:
+ phy = devm_phy_create(dev, NULL, &serdes_xpcs_lane_ops);
+ if (IS_ERR(phy))
+ return PTR_ERR(phy);
+
+ phy_set_drvdata(phy, serdes);
+ serdes->xpcs.lane_phy[lane->xpcs_instance] = phy;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static struct phy *s32g_serdes_xlate(struct device *dev,
+ const struct of_phandle_args *args)
+{
+ struct s32g_serdes *serdes = dev_get_drvdata(dev);
+ const struct s32g_lane_desc *lane;
+ u32 instance;
+
+ if (args->args_count != S32G_SERDES_PHY_CELLS ||
+ args->args[0] >= ARRAY_SIZE(serdes->lane))
+ return ERR_PTR(-EINVAL);
+
+ lane = &serdes->lane[args->args[0]];
+ instance = args->args[2];
+
+ switch (args->args[1]) {
+ case PHY_TYPE_PCIE:
+ if (lane->fn != S32G_LANE_PCIE || !serdes->pcie.phy)
+ return ERR_PTR(-ENODEV);
+ return serdes->pcie.phy;
+ case PHY_TYPE_SGMII:
+ if (lane->fn != S32G_LANE_XPCS ||
+ instance >= S32G_SERDES_XPCS_MAX ||
+ lane->xpcs_instance != instance ||
+ !serdes->xpcs.lane_phy[instance])
+ return ERR_PTR(-ENODEV);
+ return serdes->xpcs.lane_phy[instance];
+ default:
+ return ERR_PTR(-EINVAL);
+ }
+}
+
+static int s32g_serdes_setup_xpcs_lanes(struct s32g_serdes *serdes)
+{
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < ARRAY_SIZE(serdes->lane); i++) {
+ if (serdes->lane[i].fn != S32G_LANE_XPCS)
+ continue;
+
+ ret = s32g_serdes_xpcs_setup(serdes,
+ serdes->lane[i].xpcs_instance);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int s32g_serdes_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ const struct s32g_serdes_soc_data *soc_data;
+ struct phy_provider *phy_provider;
+ struct s32g_serdes *serdes;
+ int ret;
+
+ serdes = devm_kzalloc(dev, sizeof(*serdes), GFP_KERNEL);
+ if (!serdes)
+ return -ENOMEM;
+
+ serdes->dev = dev;
+
+ soc_data = device_get_match_data(dev);
+ if (!soc_data)
+ return -EINVAL;
+
+ serdes->soc_data = soc_data;
+
+ ret = s32g_serdes_get_ctrl_resources(pdev, serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_get_pcie_resources(pdev, serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_get_xpcs_resources(pdev, serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_scan_consumers(serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_derive_mode(serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_setup_xpcs_lanes(serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_init(serdes);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(dev, s32g_serdes_disable, serdes);
+ if (ret)
+ return ret;
+
+ ret = s32g_serdes_create_phys(serdes);
+ if (ret)
+ return ret;
+
+ /*
+ * drvdata only now: s32g_serdes_pcs_create() looks it up before the
+ * provider exists and must defer until the PLLs are up.
+ */
+ platform_set_drvdata(pdev, serdes);
+
+ phy_provider = devm_of_phy_provider_register(dev, s32g_serdes_xlate);
+ if (IS_ERR(phy_provider))
+ return PTR_ERR(phy_provider);
+
+ return 0;
+}
+
+static int s32g_serdes_suspend(struct device *device)
+{
+ struct s32g_serdes *serdes = dev_get_drvdata(device);
+
+ if (serdes->ctrl.enabled) {
+ clk_bulk_disable_unprepare(serdes->ctrl.nclks,
+ serdes->ctrl.clks);
+ serdes->ctrl.enabled = false;
+ }
+
+ return 0;
+}
+
+static int s32g_serdes_resume(struct device *device)
+{
+ struct s32g_serdes *serdes = dev_get_drvdata(device);
+ struct s32g_pcie_ctrl *pcie = &serdes->pcie;
+ int ret;
+
+ ret = s32g_serdes_init(serdes);
+ if (ret) {
+ dev_err(device, "Failed to initialize\n");
+ return ret;
+ }
+
+ if (pcie->powered_on) {
+ ret = s32g_pcie_phy_power_on(serdes);
+ if (ret)
+ dev_err(device, "Failed to power-on PCIe phy\n");
+ }
+
+ return ret;
+}
+
+/**
+ * s32g_serdes_pcs_create() - get the phylink PCS behind a MAC's SerDes lane
+ * @dev: the MAC device, consumer of the device link
+ * @np: the MAC's node, carrying pcs-handle and the phys reference to the
+ * SerDes, <lane PHY_TYPE_SGMII instance max-speed>
+ *
+ * Return: the phylink_pcs of the XPCS instance the MAC references,
+ * -EPROBE_DEFER until the SerDes has probed, -ENODEV if the instance is not
+ * in use, or another ERR_PTR().
+ */
+struct phylink_pcs *s32g_serdes_pcs_create(struct device *dev,
+ struct device_node *np)
+{
+ struct platform_device *pdev;
+ struct device_node *pcs_np;
+ struct of_phandle_args args;
+ struct s32g_serdes *serdes;
+ struct device_link *link;
+ u32 instance = S32G_SERDES_XPCS_MAX;
+ int i, count;
+
+ pcs_np = of_parse_phandle(np, "pcs-handle", 0);
+ if (!pcs_np)
+ return ERR_PTR(-ENODEV);
+
+ /* The XPCS instance is in the MAC's phys reference to the SerDes */
+ count = of_count_phandle_with_args(np, "phys", "#phy-cells");
+ for (i = 0; i < count; i++) {
+ if (of_parse_phandle_with_args(np, "phys", "#phy-cells", i,
+ &args))
+ continue;
+
+ if (args.np == pcs_np &&
+ args.args_count == S32G_SERDES_PHY_CELLS &&
+ args.args[1] == PHY_TYPE_SGMII)
+ instance = args.args[2];
+ of_node_put(args.np);
+
+ if (instance < S32G_SERDES_XPCS_MAX)
+ break;
+ }
+
+ if (instance >= S32G_SERDES_XPCS_MAX) {
+ of_node_put(pcs_np);
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (!of_device_is_available(pcs_np)) {
+ of_node_put(pcs_np);
+ return ERR_PTR(-ENODEV);
+ }
+
+ pdev = of_find_device_by_node(pcs_np);
+ of_node_put(pcs_np);
+ if (!pdev)
+ return ERR_PTR(-EPROBE_DEFER);
+
+ serdes = platform_get_drvdata(pdev);
+ if (!serdes) {
+ put_device(&pdev->dev);
+ return ERR_PTR(-EPROBE_DEFER);
+ }
+
+ /* Probe is complete: an instance not set up now never will be */
+ if (!serdes->xpcs.phys[instance]) {
+ put_device(&pdev->dev);
+ return ERR_PTR(-ENODEV);
+ }
+
+ link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
+ put_device(&pdev->dev);
+ if (!link)
+ return ERR_PTR(-EINVAL);
+
+ return s32g_xpcs_pcs(serdes->xpcs.phys[instance]);
+}
+EXPORT_SYMBOL_GPL(s32g_serdes_pcs_create);
+
+static const struct of_device_id s32g_serdes_match[] = {
+ {
+ .compatible = "nxp,s32g2-serdes",
+ .data = &s32g2_serdes_soc_data,
+ },
+ {
+ .compatible = "nxp,s32g3-serdes",
+ .data = &s32g3_serdes_soc_data,
+ },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, s32g_serdes_match);
+
+/*
+ * noirq: the SerDes must be back before the PCIe controller's noirq resume
+ * powers its PHY.
+ */
+static const struct dev_pm_ops s32g_serdes_pm_ops = {
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(s32g_serdes_suspend,
+ s32g_serdes_resume)
+};
+
+static struct platform_driver s32g_serdes_driver = {
+ .probe = s32g_serdes_probe,
+ .driver = {
+ .name = "phy-s32g-serdes",
+ .of_match_table = s32g_serdes_match,
+ /*
+ * The PCIe controller holds the PHY through a stateless link;
+ * do not allow unbinding under it.
+ */
+ .suppress_bind_attrs = true,
+ .pm = pm_sleep_ptr(&s32g_serdes_pm_ops),
+ },
+};
+module_platform_driver(s32g_serdes_driver);
+
+MODULE_AUTHOR("Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>");
+MODULE_DESCRIPTION("NXP S32G SerDes driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/phy/nxp-s32g-serdes.h b/include/linux/phy/nxp-s32g-serdes.h
new file mode 100644
index 000000000000..d14fcde1d933
--- /dev/null
+++ b/include/linux/phy/nxp-s32g-serdes.h
@@ -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 */
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC v4 09/15] phy: freescale: s32g: Add SerDes subsystem PHY
2026-11-25 9:33 ` [PATCH RFC v4 09/15] phy: freescale: s32g: Add SerDes subsystem PHY Jan Petrous via B4 Relay
@ 2026-11-25 14:44 ` Vladimir Oltean
0 siblings, 0 replies; 18+ messages in thread
From: Vladimir Oltean @ 2026-11-25 14:44 UTC (permalink / raw)
To: jan.petrous
Cc: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran, linux-arm-kernel, linux-phy,
netdev, devicetree, linux-kernel, imx, linux-pci, linux-stm32,
Alexandru-Catalin Ionita, Ghennadi Procopciuc, Bogdan Roman
Hi Jan,
On Wed, Nov 25, 2026 at 10:33:51AM +0100, Jan Petrous via B4 Relay wrote:
> From: Vincent Guittot <vincent.guittot@linaro.org>
>
> 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.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> Co-developed-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
> Co-developed-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com>
> Signed-off-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com>
> Co-developed-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
> Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
> Co-developed-by: Ionut Vicovan <Ionut.Vicovan@nxp.com>
> Signed-off-by: Ionut Vicovan <Ionut.Vicovan@nxp.com>
> Co-developed-by: Bogdan Roman <bogdan-gabriel.roman@nxp.com>
> Signed-off-by: Bogdan Roman <bogdan-gabriel.roman@nxp.com>
> Co-developed-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
> Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
> ---
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?
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH RFC v4 10/15] net: stmmac: s32: Add SGMII support
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (8 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 09/15] phy: freescale: s32g: Add SerDes subsystem PHY Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 11/15] MAINTAINERS: Add NXP S32G SerDes entry Jan Petrous via B4 Relay
` (5 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 +
drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c | 81 ++++++++++++++++++++++++-
2 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index c6559e749c0c..26dec3f61ea7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -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.
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
index 1f51df491370..1b1e2e2adb77 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
@@ -16,12 +16,14 @@
#include <linux/of_mdio.h>
#include <linux/of_address.h>
#include <linux/phy.h>
+#include <linux/phy/nxp-s32g-serdes.h>
#include <linux/phylink.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/stmmac.h>
#include "stmmac_platform.h"
+#include "stmmac.h"
#define GMAC_INTF_RATE_125M 125000000 /* 125MHz */
@@ -38,25 +40,82 @@ struct s32_priv_data {
unsigned int sts_offset;
struct device *dev;
phy_interface_t *intf_mode;
+ u32 intf_sel;
struct clk *tx_clk;
struct clk *rx_clk;
};
+static int s32_gmac_phy_intf_sel(phy_interface_t interface)
+{
+ switch (interface) {
+ case PHY_INTERFACE_MODE_SGMII:
+ return S32_PHY_INTF_SEL_SGMII;
+ case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ return S32_PHY_INTF_SEL_RGMII;
+ default:
+ return -EINVAL;
+ }
+}
+
static int s32_gmac_write_phy_intf_select(struct s32_priv_data *gmac)
{
int ret = 0;
if (gmac->ctrl_sts)
- writel(S32_PHY_INTF_SEL_RGMII, gmac->ctrl_sts);
+ writel(gmac->intf_sel, gmac->ctrl_sts);
else
ret = regmap_write(gmac->sts_regmap, gmac->sts_offset,
- S32_PHY_INTF_SEL_RGMII);
+ gmac->intf_sel);
dev_dbg(gmac->dev, "PHY mode set to %s\n", phy_modes(*gmac->intf_mode));
return ret;
}
+static int s32_gmac_pcs_init(struct stmmac_priv *priv)
+{
+ struct s32_priv_data *gmac = priv->plat->bsp_priv;
+ struct device_node *np = gmac->dev->of_node;
+ struct phylink_pcs *pcs;
+
+ if (*gmac->intf_mode != PHY_INTERFACE_MODE_SGMII)
+ return 0;
+
+ if (!of_property_present(np, "pcs-handle"))
+ return dev_err_probe(gmac->dev, -EINVAL,
+ "SGMII needs a pcs-handle\n");
+
+ pcs = s32g_serdes_pcs_create(gmac->dev, np);
+ if (IS_ERR(pcs))
+ return PTR_ERR(pcs);
+
+ priv->hw->phylink_pcs = pcs;
+
+ return 0;
+}
+
+static struct phylink_pcs *s32_gmac_select_pcs(struct stmmac_priv *priv,
+ phy_interface_t interface)
+{
+ return priv->hw->phylink_pcs;
+}
+
+static int s32_gmac_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+ phy_interface_t interface, int speed)
+{
+ /*
+ * With SGMII the MAC transmit clock stays at the 125 MHz set in
+ * s32_gmac_init(): 10M and 100M use symbol replication in the PCS.
+ */
+ if (interface == PHY_INTERFACE_MODE_SGMII)
+ return 0;
+
+ return stmmac_set_clk_tx_rate(bsp_priv, clk_tx_i, interface, speed);
+}
+
static int s32_gmac_init(struct device *dev, void *priv)
{
struct s32_priv_data *gmac = priv;
@@ -192,11 +251,25 @@ static int s32_dwmac_probe(struct platform_device *pdev)
gmac->intf_mode = &plat->phy_interface;
gmac->ioaddr = res.addr;
+ ret = s32_gmac_phy_intf_sel(plat->phy_interface);
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Unsupported phy interface mode: %s\n",
+ phy_modes(plat->phy_interface));
+ gmac->intf_sel = ret;
+
/* S32CC core feature set */
plat->core_type = DWMAC_CORE_GMAC4;
plat->pmt = true;
plat->flags |= STMMAC_FLAG_SPH_DISABLE;
+ /*
+ * The SerDes XPCS has no EEE support, but stmmac assumes LPI works
+ * through any external PCS.
+ */
+ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII)
+ plat->flags |= STMMAC_FLAG_EEE_DISABLE;
+
s32_gmac_setup_multi_irq(dev, plat, &res);
plat->rx_fifo_size = 20480;
@@ -204,9 +277,11 @@ static int s32_dwmac_probe(struct platform_device *pdev)
plat->init = s32_gmac_init;
plat->exit = s32_gmac_exit;
+ plat->pcs_init = s32_gmac_pcs_init;
+ plat->select_pcs = s32_gmac_select_pcs;
plat->clk_tx_i = gmac->tx_clk;
- plat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+ plat->set_clk_tx_rate = s32_gmac_set_clk_tx_rate;
plat->bsp_priv = gmac;
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 11/15] MAINTAINERS: Add NXP S32G SerDes entry
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (9 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 10/15] net: stmmac: s32: Add SGMII support Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 12/15] arm64: dts: s32g: Add SCMI reset controller Jan Petrous via B4 Relay
` (4 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: Vincent Guittot <vincent.guittot@linaro.org>
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/.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
[jan.petrous: dropped the shared core entry along with the core]
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
MAINTAINERS | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 742c4e6b291f..cb465ba42d73 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <ghennadi.procopciuc@oss.nxp.com>
+M: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
+M: Jan Petrous <jan.petrous@oss.nxp.com>
+R: NXP S32 Linux Team <s32@nxp.com>
+L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+L: linux-phy@lists.infradead.org
+L: netdev@vger.kernel.org
+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 <jan.petrous@oss.nxp.com>
R: s32@nxp.com
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 12/15] arm64: dts: s32g: Add SCMI reset controller
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (10 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 11/15] MAINTAINERS: Add NXP S32G SerDes entry Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 13/15] arm64: dts: s32g: Add SerDes controller nodes Jan Petrous via B4 Relay
` (3 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
Add the SCMI reset domain protocol node (protocol@16) for S32G2 and
S32G3, so that on-SoC controllers can use SCMI resets.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
arch/arm64/boot/dts/freescale/s32g2.dtsi | 5 +++++
arch/arm64/boot/dts/freescale/s32g3.dtsi | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/s32g2.dtsi b/arch/arm64/boot/dts/freescale/s32g2.dtsi
index a7e5977bc146..ff5d2a061d50 100644
--- a/arch/arm64/boot/dts/freescale/s32g2.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g2.dtsi
@@ -100,6 +100,11 @@ clks: protocol@14 {
reg = <0x14>;
#clock-cells = <1>;
};
+
+ scmi_reset: protocol@16 {
+ reg = <0x16>;
+ #reset-cells = <1>;
+ };
};
psci {
diff --git a/arch/arm64/boot/dts/freescale/s32g3.dtsi b/arch/arm64/boot/dts/freescale/s32g3.dtsi
index 0770af61a2c4..fbe87475bcf6 100644
--- a/arch/arm64/boot/dts/freescale/s32g3.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g3.dtsi
@@ -139,6 +139,11 @@ clks: protocol@14 {
reg = <0x14>;
#clock-cells = <1>;
};
+
+ scmi_reset: protocol@16 {
+ reg = <0x16>;
+ #reset-cells = <1>;
+ };
};
psci: psci {
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 13/15] arm64: dts: s32g: Add SerDes controller nodes
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (11 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 12/15] arm64: dts: s32g: Add SCMI reset controller Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 14/15] arm64: dts: s32g: Add PCIe " Jan Petrous via B4 Relay
` (2 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
arch/arm64/boot/dts/freescale/s32g2.dtsi | 30 ++++++++++++++++++++++++++++++
arch/arm64/boot/dts/freescale/s32g3.dtsi | 30 ++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/s32g2.dtsi b/arch/arm64/boot/dts/freescale/s32g2.dtsi
index ff5d2a061d50..0b070f7b5f22 100644
--- a/arch/arm64/boot/dts/freescale/s32g2.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g2.dtsi
@@ -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>,
diff --git a/arch/arm64/boot/dts/freescale/s32g3.dtsi b/arch/arm64/boot/dts/freescale/s32g3.dtsi
index fbe87475bcf6..0d03daa881bf 100644
--- a/arch/arm64/boot/dts/freescale/s32g3.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g3.dtsi
@@ -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>;
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 14/15] arm64: dts: s32g: Add PCIe controller nodes
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (12 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 13/15] arm64: dts: s32g: Add SerDes controller nodes Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:33 ` [PATCH RFC v4 15/15] arm64: dts: s32g: Add S32G3-RDB3 SerDes routing variants Jan Petrous via B4 Relay
2026-11-25 9:46 ` [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem sashiko-bot
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
arch/arm64/boot/dts/freescale/s32g2.dtsi | 81 ++++++++++++++++++++++++++++++++
arch/arm64/boot/dts/freescale/s32g3.dtsi | 81 ++++++++++++++++++++++++++++++++
2 files changed, 162 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/s32g2.dtsi b/arch/arm64/boot/dts/freescale/s32g2.dtsi
index 0b070f7b5f22..1b6affb15d03 100644
--- a/arch/arm64/boot/dts/freescale/s32g2.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g2.dtsi
@@ -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";
+ };
+ };
};
diff --git a/arch/arm64/boot/dts/freescale/s32g3.dtsi b/arch/arm64/boot/dts/freescale/s32g3.dtsi
index 0d03daa881bf..9eed2428732a 100644
--- a/arch/arm64/boot/dts/freescale/s32g3.dtsi
+++ b/arch/arm64/boot/dts/freescale/s32g3.dtsi
@@ -1056,6 +1056,7 @@ serdes1: serdes@44180000 {
gic: interrupt-controller@50800000 {
compatible = "arm,gic-v3";
+ #address-cells = <0>;
#interrupt-cells = <3>;
interrupt-controller;
reg = <0x50800000 0x10000>,
@@ -1067,6 +1068,86 @@ gic: interrupt-controller@50800000 {
};
};
+ /*
+ * 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,s32g3-pcie", "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,s32g3-pcie", "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";
+ };
+ };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <&gic>;
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC v4 15/15] arm64: dts: s32g: Add S32G3-RDB3 SerDes routing variants
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (13 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 14/15] arm64: dts: s32g: Add PCIe " Jan Petrous via B4 Relay
@ 2026-11-25 9:33 ` Jan Petrous via B4 Relay
2026-11-25 9:46 ` [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem sashiko-bot
15 siblings, 0 replies; 18+ messages in thread
From: Jan Petrous via B4 Relay @ 2026-11-25 9:33 UTC (permalink / raw)
To: Vincent Guittot, Ghennadi Procopciuc, Ciprian Marian Costea,
NXP S32 Linux Team, Vinod Koul, Neil Armstrong,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bogdan Hamciuc, Ionut Vicovan,
Andrew Lunn, Heiner Kallweit, Russell King, Philipp Zabel,
Maxime Chevallier, Maxime Coquelin, Alexandre Torgue, Chester Lin,
Matthias Brugger, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Richard Cochran
Cc: linux-arm-kernel, linux-phy, netdev, devicetree, linux-kernel,
imx, linux-pci, linux-stm32, Jan Petrous (OSS)
From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
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.
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
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(+)
diff --git a/arch/arm64/boot/dts/freescale/Makefile b/arch/arm64/boot/dts/freescale/Makefile
index a80cccf34eb5..f92670254c6a 100644
--- a/arch/arm64/boot/dts/freescale/Makefile
+++ b/arch/arm64/boot/dts/freescale/Makefile
@@ -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
diff --git a/arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode1.dts b/arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode1.dts
new file mode 100644
index 000000000000..c881376db27a
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode1.dts
@@ -0,0 +1,65 @@
+// 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 1: PCIe x1 (lane 0) + 1G SGMII via GMAC0 (XPCS0, lane 1).
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include "s32g399a-rdb3.dts"
+
+/ {
+ model = "NXP S32G3 Reference Design Board 3 (S32G-VNP-RDB3), SerDes_0 Mode 1";
+};
+
+&serdes0 {
+ status = "okay";
+};
+
+/*
+ * SerDes_1: PCIe_1 on lane 0. Lane 1 (PFE) has no consumer, so the first
+ * matching mode, PCIe x2, is used.
+ */
+&serdes1 {
+ status = "okay";
+};
+
+/*
+ * PCIe_0 reaches the M.2 slots (M-key or E-key) when board switch SW17-2 is
+ * ON, PCIe_1 the PCIe card slot.
+ */
+&pcie0 {
+ status = "okay";
+};
+
+&pcie0_rp {
+ num-lanes = <1>;
+ phys = <&serdes0 0 PHY_TYPE_PCIE 0 0>;
+};
+
+&pcie1 {
+ status = "okay";
+};
+
+&pcie1_rp {
+ num-lanes = <1>;
+ phys = <&serdes1 0 PHY_TYPE_PCIE 0 0>;
+};
+
+&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 1 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;
+ };
+};
diff --git a/arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode3.dts b/arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode3.dts
new file mode 100644
index 000000000000..8b90d5f14d2a
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/s32g399a-rdb3-serdes-mode3.dts
@@ -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;
+ };
+};
--
2.55.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem
2026-11-25 9:33 [PATCH RFC v4 00/15] Add support for the NXP S32G SerDes subsystem Jan Petrous via B4 Relay
` (14 preceding siblings ...)
2026-11-25 9:33 ` [PATCH RFC v4 15/15] arm64: dts: s32g: Add S32G3-RDB3 SerDes routing variants Jan Petrous via B4 Relay
@ 2026-11-25 9:46 ` sashiko-bot
15 siblings, 0 replies; 18+ messages in thread
From: sashiko-bot @ 2026-11-25 9:46 UTC (permalink / raw)
To: Jan Petrous (OSS); +Cc: linux-pci
Sashiko has finished reviewing this 15-patch series:
- Patches 1-10 and 12-15: no issues found.
- Patch 11: skipped (not reviewed).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-s32g_serdes-v4-0-3bfe0589be8d@oss.nxp.com
^ permalink raw reply [flat|nested] 18+ messages in thread