From: Jan Petrous via B4 Relay <devnull+jan.petrous.oss.nxp.com@kernel.org>
To: "Vincent Guittot" <vincent.guittot@linaro.org>,
"Ghennadi Procopciuc" <ghennadi.procopciuc@oss.nxp.com>,
"Ciprian Marian Costea" <ciprianmarian.costea@oss.nxp.com>,
"NXP S32 Linux Team" <s32@nxp.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Bogdan Hamciuc" <bogdan.hamciuc@nxp.com>,
"Ionut Vicovan" <ionut.vicovan@nxp.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Chester Lin" <chester62515@gmail.com>,
"Matthias Brugger" <mbrugger@suse.com>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Richard Cochran" <richardcochran@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-pci@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
"Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
Subject: [PATCH RFC v4 10/15] net: stmmac: s32: Add SGMII support
Date: Wed, 25 Nov 2026 10:33:52 +0100 [thread overview]
Message-ID: <20261125-s32g_serdes-v4-10-3bfe0589be8d@oss.nxp.com> (raw)
In-Reply-To: <20261125-s32g_serdes-v4-0-3bfe0589be8d@oss.nxp.com>
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
next prev parent reply other threads:[~2026-11-25 9:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [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 ` [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 ` [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 ` [PATCH RFC v4 06/15] net: pcs: xpcs: add NXP S32G SerDes XPCS support 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
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 ` [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 [this message]
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 ` [PATCH RFC v4 12/15] arm64: dts: s32g: Add SCMI reset controller 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
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 ` [PATCH RFC v4 15/15] arm64: dts: s32g: Add S32G3-RDB3 SerDes routing variants Jan Petrous via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125-s32g_serdes-v4-10-3bfe0589be8d@oss.nxp.com \
--to=devnull+jan.petrous.oss.nxp.com@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=bhelgaas@google.com \
--cc=bogdan.hamciuc@nxp.com \
--cc=chester62515@gmail.com \
--cc=ciprianmarian.costea@oss.nxp.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=festevam@gmail.com \
--cc=ghennadi.procopciuc@oss.nxp.com \
--cc=hkallweit1@gmail.com \
--cc=imx@lists.linux.dev \
--cc=ionut.vicovan@nxp.com \
--cc=jan.petrous@oss.nxp.com \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mbrugger@suse.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=s32@nxp.com \
--cc=vincent.guittot@linaro.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®