* [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support
@ 2026-03-18 16:05 Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 1/5] net: stmmac: move default_an_inband to plat_stmmacenet_data Russell King (Oracle)
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Russell King (Oracle) @ 2026-03-18 16:05 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Mohd Ayaan Anwar,
netdev, Paolo Abeni, Vinod Koul
I am losing track of what version we're at, because each time the
series is reworked, changing the approach, which changes the
patches quite a bit, it makes it difficult. We've gone RFC to non-RFC
back to RFC and then to non-RFC again.
This series is the next of the three part series sorting out the PCS
support in stmmac, building on part 2:
net: stmmac: qcom-ethqos: further serdes reorganisation
Similar patches have been posted previously. This series does away with
the common SerDes PHY support, instead using a flag to indicate whether
2500Mbps mode is supported (STMMAC_FLAG_SERDES_SUPPORTS_2500M.) At this
time, I have no plans to resurect the common SerDes PHY support - the
generic PHY layer implementations are just too random to consider that,
and I certainly do not want the extra work of fixing that.
Changes from RFC v3:
- only set default_an_inband if using SGMII/2500BASE-X mode.
Changes from previous non-RFC posting:
- add a patch moving default_an_inband to struct plat_stmmacenet_data
- only include the first four patches from the previous posting
- add pcs_an_restart() support for BASE-X, but only if we have
TBI/RTBI support.
The reasoning here is that these patches should be safe to merge and
should not impact qcom-ethqos in any way.
We can then figure out how to work around qcom-ethqos hacks without
having to keep re-posting these same patches time and time again.
drivers/net/ethernet/stmicro/stmmac/common.h | 4 -
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 12 +-
.../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 11 +-
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 10 +-
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 10 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c | 156 ++++++++++++++++++++-
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 14 +-
include/linux/stmmac.h | 3 +-
10 files changed, 186 insertions(+), 51 deletions(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v2 maybe? 1/5] net: stmmac: move default_an_inband to plat_stmmacenet_data
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
@ 2026-03-18 16:06 ` Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 2/5] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Russell King (Oracle) @ 2026-03-18 16:06 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Mohd Ayaan Anwar,
netdev, Paolo Abeni, Vinod Koul
Move the default_an_inband flag from struct mdio_bus_data to struct
plat_stmmacenet_data. This is to allow platforms that do not use the
integrated MDIO bus to enable inband mode.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++--
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +----
include/linux/stmmac.h | 2 +-
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index f621077c30a4..7898b5075a8b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -298,7 +298,7 @@ static void tgl_get_interfaces(struct stmmac_priv *priv, void *bsp_priv,
if (FIELD_GET(SERDES_LINK_MODE_MASK, data) == SERDES_LINK_MODE_2G5) {
dev_info(priv->device, "Link Speed Mode: 2.5Gbps\n");
- priv->plat->mdio_bus_data->default_an_inband = false;
+ priv->plat->default_an_inband = false;
interface = PHY_INTERFACE_MODE_2500BASEX;
} else {
interface = PHY_INTERFACE_MODE_SGMII;
@@ -700,7 +700,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
plat->mdio_bus_data->pcs_mask = BIT_U32(INTEL_MGBE_XPCS_ADDR);
- plat->mdio_bus_data->default_an_inband = true;
+ plat->default_an_inband = true;
plat->select_pcs = intel_mgbe_select_pcs;
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 0a933aac3f03..90af7212b8d8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1390,7 +1390,6 @@ static int stmmac_init_phy(struct net_device *dev)
static int stmmac_phylink_setup(struct stmmac_priv *priv)
{
- struct stmmac_mdio_bus_data *mdio_bus_data;
struct phylink_config *config;
struct phylink_pcs *pcs;
struct phylink *phylink;
@@ -1415,9 +1414,7 @@ static int stmmac_phylink_setup(struct stmmac_priv *priv)
priv->tx_lpi_clk_stop = priv->plat->flags &
STMMAC_FLAG_EN_TX_LPI_CLOCKGATING;
- mdio_bus_data = priv->plat->mdio_bus_data;
- if (mdio_bus_data)
- config->default_an_inband = mdio_bus_data->default_an_inband;
+ config->default_an_inband = priv->plat->default_an_inband;
/* Get the PHY interface modes (at the PHY end of the link) that
* are supported by the platform.
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 72febd246bdb..565bb394b194 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -89,7 +89,6 @@ struct stmmac_mdio_bus_data {
int *irqs;
int probed_phy_irq;
bool needs_reset;
- bool default_an_inband;
};
struct stmmac_dma_cfg {
@@ -250,6 +249,7 @@ struct plat_stmmacenet_data {
struct stmmac_dma_cfg *dma_cfg;
struct stmmac_safety_feature_cfg *safety_feat_cfg;
int clk_csr;
+ bool default_an_inband;
bool enh_desc;
bool tx_coe;
bool bugged_jumbo;
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 maybe? 2/5] net: stmmac: add struct stmmac_pcs_info
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 1/5] net: stmmac: move default_an_inband to plat_stmmacenet_data Russell King (Oracle)
@ 2026-03-18 16:06 ` Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 3/5] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Russell King (Oracle) @ 2026-03-18 16:06 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Mohd Ayaan Anwar,
netdev, Paolo Abeni, Vinod Koul
We need to describe one more register (offset and field bitmask) to
the PCS code. Move the existing PCS offset and interrupt enable bits
to a new struct and pass that in to stmmac_integrated_pcs_init().
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 9 ++++++---
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ++++++--
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c | 8 ++++----
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 9 +++++++--
4 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index 01f8353eb6ef..c851e3b88ce5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -22,14 +22,17 @@
#include "stmmac_ptp.h"
#include "dwmac1000.h"
+static const struct stmmac_pcs_info dwmac1000_pcs_info = {
+ .pcs_offset = GMAC_PCS_BASE,
+ .int_mask = GMAC_INT_DISABLE_PCSLINK | GMAC_INT_DISABLE_PCSAN,
+};
+
static int dwmac1000_pcs_init(struct stmmac_priv *priv)
{
if (!priv->dma_cap.pcs)
return 0;
- return stmmac_integrated_pcs_init(priv, GMAC_PCS_BASE,
- GMAC_INT_DISABLE_PCSLINK |
- GMAC_INT_DISABLE_PCSAN);
+ return stmmac_integrated_pcs_init(priv, &dwmac1000_pcs_info);
}
static void dwmac1000_core_init(struct mac_device_info *hw,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 4c6fed3ecbcf..ba5393beb7bb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -22,13 +22,17 @@
#include "dwmac4.h"
#include "dwmac5.h"
+static const struct stmmac_pcs_info dwmac4_pcs_info = {
+ .pcs_offset = GMAC_PCS_BASE,
+ .int_mask = GMAC_INT_PCS_LINK | GMAC_INT_PCS_ANE,
+};
+
static int dwmac4_pcs_init(struct stmmac_priv *priv)
{
if (!priv->dma_cap.pcs)
return 0;
- return stmmac_integrated_pcs_init(priv, GMAC_PCS_BASE,
- GMAC_INT_PCS_LINK | GMAC_INT_PCS_ANE);
+ return stmmac_integrated_pcs_init(priv, &dwmac4_pcs_info);
}
static void dwmac4_core_init(struct mac_device_info *hw,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
index 88fa359ea716..2695e0b9ed03 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
@@ -90,8 +90,8 @@ int stmmac_integrated_pcs_get_phy_intf_sel(struct phylink_pcs *pcs,
return -EINVAL;
}
-int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset,
- u32 int_mask)
+int stmmac_integrated_pcs_init(struct stmmac_priv *priv,
+ const struct stmmac_pcs_info *pcs_info)
{
struct stmmac_pcs *spcs;
@@ -100,8 +100,8 @@ int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset,
return -ENOMEM;
spcs->priv = priv;
- spcs->base = priv->ioaddr + offset;
- spcs->int_mask = int_mask;
+ spcs->base = priv->ioaddr + pcs_info->pcs_offset;
+ spcs->int_mask = pcs_info->int_mask;
spcs->pcs.ops = &dwmac_integrated_pcs_ops;
__set_bit(PHY_INTERFACE_MODE_SGMII, spcs->pcs.supported_interfaces);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
index 23bbd4f10bf8..f1ee473d8e3e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
@@ -27,6 +27,11 @@
struct stmmac_priv;
+struct stmmac_pcs_info {
+ unsigned int pcs_offset;
+ u32 int_mask;
+};
+
struct stmmac_pcs {
struct stmmac_priv *priv;
void __iomem *base;
@@ -44,8 +49,8 @@ void stmmac_integrated_pcs_irq(struct stmmac_priv *priv, u32 status,
struct stmmac_extra_stats *x);
int stmmac_integrated_pcs_get_phy_intf_sel(struct phylink_pcs *pcs,
phy_interface_t interface);
-int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset,
- u32 int_mask);
+int stmmac_integrated_pcs_init(struct stmmac_priv *priv,
+ const struct stmmac_pcs_info *pcs_info);
/**
* dwmac_ctrl_ane - To program the AN Control Register.
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 maybe? 3/5] net: stmmac: add support for reading inband SGMII status
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 1/5] net: stmmac: move default_an_inband to plat_stmmacenet_data Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 2/5] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
@ 2026-03-18 16:06 ` Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 4/5] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Russell King (Oracle) @ 2026-03-18 16:06 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Mohd Ayaan Anwar,
netdev, Paolo Abeni, Vinod Koul
Report the link, speed and duplex for SGMII links, read from the
SGMII, RGMII and SMII status and control register.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
rfc->v1: fix setting SGMII's link status - depend on both link status.
v2:
- fill in rsgmii offset and status fields in dwmac cores
- rename new GMAC_RGSMIII_xxx constants to GMAC_RGSMII_xxx
---
.../net/ethernet/stmicro/stmmac/dwmac1000.h | 12 +----
.../ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 10 +---
.../net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +
.../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 49 ++++++++++++++++++-
.../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 4 ++
6 files changed, 58 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
index 9fe639fb06bb..1de1f929d61c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
@@ -70,18 +70,8 @@ enum power_event {
#define GMAC_RGSMIIIS 0x000000d8 /* RGMII/SMII status */
/* SGMII/RGMII status register */
-#define GMAC_RGSMIIIS_LNKMODE BIT(0)
-#define GMAC_RGSMIIIS_SPEED GENMASK(2, 1)
-#define GMAC_RGSMIIIS_LNKSTS BIT(3)
-#define GMAC_RGSMIIIS_JABTO BIT(4)
-#define GMAC_RGSMIIIS_FALSECARDET BIT(5)
+#define GMAC_RSGMIIIS_MASK GENMASK(15, 0)
#define GMAC_RGSMIIIS_SMIDRXS BIT(16)
-/* LNKMOD */
-#define GMAC_RGSMIIIS_LNKMOD_MASK 0x1
-/* LNKSPEED */
-#define GMAC_RGSMIIIS_SPEED_125 0x2
-#define GMAC_RGSMIIIS_SPEED_25 0x1
-#define GMAC_RGSMIIIS_SPEED_2_5 0x0
/* GMAC Configuration defines */
#define GMAC_CONTROL_2K 0x08000000 /* IEEE 802.3as 2K packets */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index c851e3b88ce5..caac85fc08f1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -24,6 +24,8 @@
static const struct stmmac_pcs_info dwmac1000_pcs_info = {
.pcs_offset = GMAC_PCS_BASE,
+ .rgsmii_offset = GMAC_RGSMIIIS,
+ .rgsmii_status_mask = GMAC_RSGMIIIS_MASK,
.int_mask = GMAC_INT_DISABLE_PCSLINK | GMAC_INT_DISABLE_PCSAN,
};
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index d797d936aee1..ffcd036d4c02 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -470,15 +470,7 @@ static inline u32 mtl_low_credx_base_addr(const struct dwmac4_addrs *addrs,
#define GMAC_PHYIF_CTRLSTATUS_TC BIT(0)
#define GMAC_PHYIF_CTRLSTATUS_LUD BIT(1)
#define GMAC_PHYIF_CTRLSTATUS_SMIDRXS BIT(4)
-#define GMAC_PHYIF_CTRLSTATUS_LNKMOD BIT(16)
-#define GMAC_PHYIF_CTRLSTATUS_SPEED GENMASK(18, 17)
-#define GMAC_PHYIF_CTRLSTATUS_LNKSTS BIT(19)
-#define GMAC_PHYIF_CTRLSTATUS_JABTO BIT(20)
-#define GMAC_PHYIF_CTRLSTATUS_FALSECARDET BIT(21)
-/* LNKSPEED */
-#define GMAC_PHYIF_CTRLSTATUS_SPEED_125 0x2
-#define GMAC_PHYIF_CTRLSTATUS_SPEED_25 0x1
-#define GMAC_PHYIF_CTRLSTATUS_SPEED_2_5 0x0
+#define GMAC_PHYIF_CTRLSTATUS_RSGMII_MASK GENMASK(31, 16)
extern const struct stmmac_dma_ops dwmac4_dma_ops;
extern const struct stmmac_dma_ops dwmac410_dma_ops;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index ba5393beb7bb..c6fcfae27c3d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -24,6 +24,8 @@
static const struct stmmac_pcs_info dwmac4_pcs_info = {
.pcs_offset = GMAC_PCS_BASE,
+ .rgsmii_offset = GMAC_PHYIF_CONTROL_STATUS,
+ .rgsmii_status_mask = GMAC_PHYIF_CTRLSTATUS_RSGMII_MASK,
.int_mask = GMAC_INT_PCS_LINK | GMAC_INT_PCS_ANE,
};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
index 2695e0b9ed03..df72f7c5a6a7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
@@ -16,6 +16,16 @@
#define GMAC_ANE_LPA 0x0c /* ANE link partener ability */
#define GMAC_TBI 0x14 /* TBI extend status */
+/*
+ * RGSMII status bitfield definitions.
+ */
+#define GMAC_RGSMII_LNKMOD BIT(0)
+#define GMAC_RGSMII_SPEED_MASK GENMASK(2, 1)
+#define GMAC_RGSMII_SPEED_125 2
+#define GMAC_RGSMII_SPEED_25 1
+#define GMAC_RGSMII_SPEED_2_5 0
+#define GMAC_RGSMII_LNKSTS BIT(3)
+
static int dwmac_integrated_pcs_enable(struct phylink_pcs *pcs)
{
struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
@@ -36,7 +46,42 @@ static void dwmac_integrated_pcs_get_state(struct phylink_pcs *pcs,
unsigned int neg_mode,
struct phylink_link_state *state)
{
- state->link = false;
+ struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
+ u32 status, rgsmii;
+
+ status = readl(spcs->base + GMAC_AN_STATUS);
+
+ if (phy_interface_mode_is_8023z(state->interface)) {
+ state->link = false;
+ } else {
+ rgsmii = field_get(spcs->rgsmii_status_mask,
+ readl(spcs->rgsmii));
+
+ state->link = status & BMSR_LSTATUS &&
+ rgsmii & GMAC_RGSMII_LNKSTS;
+
+ if (state->link && neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
+ state->duplex = rgsmii & GMAC_RGSMII_LNKMOD ?
+ DUPLEX_FULL : DUPLEX_HALF;
+ switch (FIELD_GET(GMAC_RGSMII_SPEED_MASK, rgsmii)) {
+ case GMAC_RGSMII_SPEED_2_5:
+ state->speed = SPEED_10;
+ break;
+
+ case GMAC_RGSMII_SPEED_25:
+ state->speed = SPEED_100;
+ break;
+
+ case GMAC_RGSMII_SPEED_125:
+ state->speed = SPEED_1000;
+ break;
+
+ default:
+ state->link = false;
+ break;
+ }
+ }
+ }
}
static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs,
@@ -101,6 +146,8 @@ int stmmac_integrated_pcs_init(struct stmmac_priv *priv,
spcs->priv = priv;
spcs->base = priv->ioaddr + pcs_info->pcs_offset;
+ spcs->rgsmii = priv->ioaddr + pcs_info->rgsmii_offset;
+ spcs->rgsmii_status_mask = pcs_info->rgsmii_status_mask;
spcs->int_mask = pcs_info->int_mask;
spcs->pcs.ops = &dwmac_integrated_pcs_ops;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
index f1ee473d8e3e..09e609f111b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
@@ -29,12 +29,16 @@ struct stmmac_priv;
struct stmmac_pcs_info {
unsigned int pcs_offset;
+ unsigned int rgsmii_offset;
+ u32 rgsmii_status_mask;
u32 int_mask;
};
struct stmmac_pcs {
struct stmmac_priv *priv;
void __iomem *base;
+ void __iomem *rgsmii;
+ u32 rgsmii_status_mask;
u32 int_mask;
struct phylink_pcs pcs;
};
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 maybe? 4/5] net: stmmac: add BASE-X support to integrated PCS
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
` (2 preceding siblings ...)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 3/5] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
@ 2026-03-18 16:06 ` Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 5/5] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
2026-03-24 0:40 ` [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: Russell King (Oracle) @ 2026-03-18 16:06 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Mohd Ayaan Anwar,
netdev, Paolo Abeni, Vinod Koul
The integrated PCS supports 802.3z (BASE-X) modes when the Synopsys
IP is coupled with an appropriate SerDes to provide the electrical
interface. The PCS presents a TBI interface to the SerDes for this.
Thus, the BASE-X related registers are only present when TBI mode is
supported.
dwmac-qcom-ethqos added support for using 2.5G with the integrated PCS
by calling dwmac_ctrl_ane() directly.
Add support for the following to the integrated PCS:
- 1000BASE-X protocol unconditionally.
- 2500BASE-X if the coupled SerDes supports 2.5G speed.
- The above without autonegotiation.
- If the PCS supports TBI, then optional BASE-X autonegotiation for each
of the above.
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
--
- Add pcs_an_restart() support
---
.../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 103 +++++++++++++++++-
.../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 1 +
include/linux/stmmac.h | 1 +
3 files changed, 101 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
index df72f7c5a6a7..df37af5ab837 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
@@ -26,6 +26,27 @@
#define GMAC_RGSMII_SPEED_2_5 0
#define GMAC_RGSMII_LNKSTS BIT(3)
+static unsigned int dwmac_integrated_pcs_inband_caps(struct phylink_pcs *pcs,
+ phy_interface_t interface)
+{
+ struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
+ unsigned int ib_caps;
+
+ if (phy_interface_mode_is_8023z(interface)) {
+ ib_caps = LINK_INBAND_DISABLE;
+
+ /* If the PCS supports TBI/RTBI, then BASE-X negotiation is
+ * supported.
+ */
+ if (spcs->support_tbi_rtbi)
+ ib_caps |= LINK_INBAND_ENABLE;
+
+ return ib_caps;
+ }
+
+ return 0;
+}
+
static int dwmac_integrated_pcs_enable(struct phylink_pcs *pcs)
{
struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
@@ -47,12 +68,20 @@ static void dwmac_integrated_pcs_get_state(struct phylink_pcs *pcs,
struct phylink_link_state *state)
{
struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
- u32 status, rgsmii;
+ u32 status, lpa, rgsmii;
status = readl(spcs->base + GMAC_AN_STATUS);
if (phy_interface_mode_is_8023z(state->interface)) {
- state->link = false;
+ /* For BASE-X modes, the PCS block supports the advertisement
+ * and link partner advertisement registers using standard
+ * 802.3 format. The status register also has the link status
+ * and AN complete bits in the same bit location. This will
+ * only be used when AN is enabled.
+ */
+ lpa = readl(spcs->base + GMAC_ANE_LPA);
+
+ phylink_mii_c22_pcs_decode_state(state, neg_mode, status, lpa);
} else {
rgsmii = field_get(spcs->rgsmii_status_mask,
readl(spcs->rgsmii));
@@ -84,6 +113,21 @@ static void dwmac_integrated_pcs_get_state(struct phylink_pcs *pcs,
}
}
+static int dwmac_integrated_pcs_config_aneg(struct stmmac_pcs *spcs,
+ phy_interface_t interface,
+ const unsigned long *advertising)
+{
+ bool changed = false;
+ u32 adv;
+
+ adv = phylink_mii_c22_pcs_encode_advertisement(interface, advertising);
+ if (readl(spcs->base + GMAC_ANE_ADV) != adv)
+ changed = true;
+ writel(adv, spcs->base + GMAC_ANE_ADV);
+
+ return changed;
+}
+
static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs,
unsigned int neg_mode,
phy_interface_t interface,
@@ -91,17 +135,46 @@ static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs,
bool permit_pause_to_mac)
{
struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
+ bool changed = false, ane = true;
+
+ /* Only configure the advertisement and allow AN in BASE-X mode if
+ * the core supports TBI/RTBI. AN will be filtered out by via phylink
+ * and the .pcs_inband_caps() method above.
+ */
+ if (phy_interface_mode_is_8023z(interface) &&
+ spcs->support_tbi_rtbi) {
+ ane = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
+
+ changed = dwmac_integrated_pcs_config_aneg(spcs, interface,
+ advertising);
+ }
- dwmac_ctrl_ane(spcs->base, 0, 1, spcs->priv->hw->reverse_sgmii_enable);
+ dwmac_ctrl_ane(spcs->base, 0, ane,
+ spcs->priv->hw->reverse_sgmii_enable);
- return 0;
+ return changed;
+}
+
+static void dwmac_integrated_pcs_an_restart(struct phylink_pcs *pcs)
+{
+ struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
+ void __iomem *an_control = spcs->base + GMAC_AN_CTRL(0);
+ u32 ctrl;
+
+ /* We can only do AN restart if using TBI/RTBI mode */
+ if (spcs->support_tbi_rtbi) {
+ ctrl = readl(an_control) | GMAC_AN_CTRL_RAN;
+ writel(ctrl, an_control);
+ }
}
static const struct phylink_pcs_ops dwmac_integrated_pcs_ops = {
+ .pcs_inband_caps = dwmac_integrated_pcs_inband_caps,
.pcs_enable = dwmac_integrated_pcs_enable,
.pcs_disable = dwmac_integrated_pcs_disable,
.pcs_get_state = dwmac_integrated_pcs_get_state,
.pcs_config = dwmac_integrated_pcs_config,
+ .pcs_an_restart = dwmac_integrated_pcs_an_restart,
};
void stmmac_integrated_pcs_irq(struct stmmac_priv *priv, u32 status,
@@ -129,9 +202,18 @@ void stmmac_integrated_pcs_irq(struct stmmac_priv *priv, u32 status,
int stmmac_integrated_pcs_get_phy_intf_sel(struct phylink_pcs *pcs,
phy_interface_t interface)
{
+ struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
+
if (interface == PHY_INTERFACE_MODE_SGMII)
return PHY_INTF_SEL_SGMII;
+ if (phy_interface_mode_is_8023z(interface)) {
+ if (spcs->support_tbi_rtbi)
+ return PHY_INTF_SEL_TBI;
+ else
+ return PHY_INTF_SEL_SGMII;
+ }
+
return -EINVAL;
}
@@ -151,7 +233,20 @@ int stmmac_integrated_pcs_init(struct stmmac_priv *priv,
spcs->int_mask = pcs_info->int_mask;
spcs->pcs.ops = &dwmac_integrated_pcs_ops;
+ /* If the PCS supports extended status, then it supports BASE-X AN
+ * with a TBI interface to the SerDes. Otherwise, we can support
+ * BASE-X without AN using SGMII, which is required for qcom-ethqos.
+ */
+ if (readl(spcs->base + GMAC_AN_STATUS) & BMSR_ESTATEN)
+ spcs->support_tbi_rtbi = true;
+
__set_bit(PHY_INTERFACE_MODE_SGMII, spcs->pcs.supported_interfaces);
+ __set_bit(PHY_INTERFACE_MODE_1000BASEX, spcs->pcs.supported_interfaces);
+
+ /* Only allow 2500BASE-X if the SerDes has support. */
+ if (priv->plat->flags & STMMAC_FLAG_SERDES_SUPPORTS_2500M)
+ __set_bit(PHY_INTERFACE_MODE_2500BASEX,
+ spcs->pcs.supported_interfaces);
priv->integrated_pcs = spcs;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
index 09e609f111b1..b2b12d34b3dd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
@@ -41,6 +41,7 @@ struct stmmac_pcs {
u32 rgsmii_status_mask;
u32 int_mask;
struct phylink_pcs pcs;
+ bool support_tbi_rtbi;
};
static inline struct stmmac_pcs *
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 565bb394b194..5b2bece81448 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -212,6 +212,7 @@ enum dwmac_core_type {
#define STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP BIT(12)
#define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY BIT(13)
#define STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD BIT(14)
+#define STMMAC_FLAG_SERDES_SUPPORTS_2500M BIT(15)
struct mac_device_info;
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 maybe? 5/5] net: stmmac: use integrated PCS for BASE-X modes
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
` (3 preceding siblings ...)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 4/5] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
@ 2026-03-18 16:06 ` Russell King (Oracle)
2026-03-24 0:40 ` [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: Russell King (Oracle) @ 2026-03-18 16:06 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Mohd Ayaan Anwar,
netdev, Paolo Abeni, Vinod Koul
dwmac-qcom-ethqos supports SGMII and 2500BASE-X using the integrated
PCS, so we need to expand the PCS support to include support for
BASE-X modes.
Add support to the prereset configuration to detect 2500BASE-X, and
arrange for stmmac_mac_select_pcs() to return the integrated PCS if
its supported_interfaces bitmap reports support for the interface mode.
This results in priv->hw->pcs now being write-only, so remove it.
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 4 ----
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++------
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index f1628de8ed18..c9dac55d0c02 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -278,9 +278,6 @@ struct stmmac_safety_stats {
#define FLOW_TX 2
#define FLOW_AUTO (FLOW_TX | FLOW_RX)
-/* PCS defines */
-#define STMMAC_PCS_SGMII (1 << 1)
-
#define SF_DMA_MODE 1 /* DMA STORE-AND-FORWARD Operation Mode */
/* DMA HW feature register fields */
@@ -632,7 +629,6 @@ struct mac_device_info {
unsigned int unicast_filter_entries;
unsigned int mcast_bits_log2;
unsigned int rx_csum;
- unsigned int pcs;
unsigned int num_vlan;
u32 vlan_filter[32];
bool vlan_fail_q_en;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 90af7212b8d8..fba12a7a380e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1027,11 +1027,8 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
return pcs;
}
- /* The PCS control register is only relevant for SGMII, TBI and RTBI
- * modes. We no longer support TBI or RTBI, so only configure this
- * register when operating in SGMII mode with the integrated PCS.
- */
- if (priv->hw->pcs & STMMAC_PCS_SGMII && priv->integrated_pcs)
+ if (priv->integrated_pcs &&
+ test_bit(interface, priv->integrated_pcs->pcs.supported_interfaces))
return &priv->integrated_pcs->pcs;
return NULL;
@@ -1290,7 +1287,6 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) {
netdev_dbg(priv->dev, "PCS SGMII support enabled\n");
- priv->hw->pcs = STMMAC_PCS_SGMII;
switch (speed) {
case SPEED_10:
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
` (4 preceding siblings ...)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 5/5] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
@ 2026-03-24 0:40 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-24 0:40 UTC (permalink / raw)
To: Russell King
Cc: andrew, alexandre.torgue, andrew+netdev, davem, edumazet, kuba,
linux-arm-kernel, linux-stm32, mohd.anwar, netdev, pabeni, vkoul
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 18 Mar 2026 16:05:53 +0000 you wrote:
> I am losing track of what version we're at, because each time the
> series is reworked, changing the approach, which changes the
> patches quite a bit, it makes it difficult. We've gone RFC to non-RFC
> back to RFC and then to non-RFC again.
>
> This series is the next of the three part series sorting out the PCS
> support in stmmac, building on part 2:
>
> [...]
Here is the summary with links:
- [net-next,v2,maybe?,1/5] net: stmmac: move default_an_inband to plat_stmmacenet_data
https://git.kernel.org/netdev/net-next/c/9a475dc71c38
- [net-next,v2,maybe?,2/5] net: stmmac: add struct stmmac_pcs_info
https://git.kernel.org/netdev/net-next/c/7d5a2da501e0
- [net-next,v2,maybe?,3/5] net: stmmac: add support for reading inband SGMII status
https://git.kernel.org/netdev/net-next/c/083757866735
- [net-next,v2,maybe?,4/5] net: stmmac: add BASE-X support to integrated PCS
https://git.kernel.org/netdev/net-next/c/68cff4fff61f
- [net-next,v2,maybe?,5/5] net: stmmac: use integrated PCS for BASE-X modes
https://git.kernel.org/netdev/net-next/c/365c62c8b530
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-24 0:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 16:05 [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 1/5] net: stmmac: move default_an_inband to plat_stmmacenet_data Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 2/5] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 3/5] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 4/5] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
2026-03-18 16:06 ` [PATCH net-next v2 maybe? 5/5] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
2026-03-24 0:40 ` [PATCH net-next v2 maybe? 0/5] net: stmmac: improve PCS support patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox