Skip to contentSkip to conversation

net: stmmac: report active phy interface

PATCH Applied Russell King (Oracle) 4 participants 6 messages Jan 28 – Jan 30

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover net: stmmac: report active phy interface

The original patch needs dwmac-thead fixed so the PHY_INTF* definitions do not clash.

 drivers/net/ethernet/stmicro/stmmac/common.h       |  6 +++
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c  | 10 ++---
 .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c    |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c   |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h     |  1 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c |  1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 52 ++++++++++++++++++++++
 7 files changed, 69 insertions(+), 5 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

PATCH 1/2 net: stmmac: thead: avoid conflicts with PHY_INTF_* definitions

Avoid conflicts between stmmac PHY_INTF_* and GMAC_INTF_CTRL register definitions by replacing the PHY_ prefix with GMAC_.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c +5 -5
index e291028ba56e..0d46a6c3f077 100644
@@ -37,9 +37,9 @@
 #define GMAC_GTXCLK_SEL			0x18
 #define  GMAC_GTXCLK_SEL_PLL		BIT(0)
 #define GMAC_INTF_CTRL			0x1c
-#define  PHY_INTF_MASK			BIT(0)
-#define  PHY_INTF_RGMII			FIELD_PREP(PHY_INTF_MASK, 1)
-#define  PHY_INTF_MII_GMII		FIELD_PREP(PHY_INTF_MASK, 0)
+#define  GMAC_INTF_MASK			BIT(0)
+#define  GMAC_INTF_RGMII		FIELD_PREP(GMAC_INTF_MASK, 1)
+#define  GMAC_INTF_MII_GMII		FIELD_PREP(GMAC_INTF_MASK, 0)
 #define GMAC_TXCLK_OEN			0x20
 #define  TXCLK_DIR_MASK			BIT(0)
 #define  TXCLK_DIR_OUTPUT		FIELD_PREP(TXCLK_DIR_MASK, 0)
@@ -58,13 +58,13 @@ static int thead_dwmac_set_phy_if(struct plat_stmmacenet_data *plat)
 
 	switch (plat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
-		phyif = PHY_INTF_MII_GMII;
+		phyif = GMAC_INTF_MII_GMII;
 		break;
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
-		phyif = PHY_INTF_RGMII;
+		phyif = GMAC_INTF_RGMII;
 		break;
 	default:
 		dev_err(dwmac->dev, "unsupported phy interface %s\n",
Signature · 1 line
2.47.3
#3 lore raw

PATCH 2/2 net: stmmac: report active PHY interface

In reply to Russell King (Oracle)

Report the active PHY interface from the point of view of the dwmac hardware to the kernel log, where the core supports reading this.

---
 drivers/net/ethernet/stmicro/stmmac/common.h  |  6 +++
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   |  2 +
 .../net/ethernet/stmicro/stmmac/dwmac4_dma.c  |  2 +
 .../net/ethernet/stmicro/stmmac/dwxgmac2.h    |  1 +
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |  1 +
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 52 +++++++++++++++++++
 6 files changed, 64 insertions(+)
drivers/net/ethernet/stmicro/stmmac/common.h +6 -0
index 49df46be3669..1c5a4af85b58 100644
@@ -323,6 +323,10 @@ struct stmmac_safety_stats {
 #define PHY_INTF_SEL_SMII	6
 #define PHY_INTF_SEL_REVMII	7
 
+/* XGMAC uses a different encoding - from the AgileX5 documentation */
+#define PHY_INTF_GMII		0
+#define PHY_INTF_RGMII		1
+
 /* MSI defines */
 #define STMMAC_MSI_VEC_MAX	32
 
@@ -512,6 +516,8 @@ struct dma_features {
 	unsigned int dbgmem;
 	/* Number of Policing Counters */
 	unsigned int pcsel;
+	/* Active PHY interface, PHY_INTF_SEL_xxx */
+	u8 actphyif;
 };
 
 /* RX Buffer size must be multiple of 4/8/16 bytes */
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +2 -0
index a62f1271b6ea..3ac7a7949529 100644
@@ -239,6 +239,8 @@ static int dwmac1000_get_hw_feature(void __iomem *ioaddr,
 	/* Alternate (enhanced) DESC mode */
 	dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
 
+	dma_cap->actphyif = FIELD_GET(DMA_HW_FEAT_ACTPHYIF, hw_cap);
+
 	return 0;
 }
 
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +2 -0
index aaa83e9ff4f0..60b880cdd9da 100644
@@ -382,6 +382,8 @@ static int dwmac4_get_hw_feature(void __iomem *ioaddr,
 	dma_cap->vlins = (hw_cap & GMAC_HW_FEAT_SAVLANINS) >> 27;
 	dma_cap->arpoffsel = (hw_cap & GMAC_HW_FEAT_ARPOFFSEL) >> 9;
 
+	dma_cap->actphyif = FIELD_GET(DMA_HW_FEAT_ACTPHYIF, hw_cap);
+
 	/* MAC HW feature1 */
 	hw_cap = readl(ioaddr + GMAC_HW_FEATURE1);
 	dma_cap->l3l4fnum = (hw_cap & GMAC_HW_FEAT_L3L4FNUM) >> 27;
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +1 -0
index b5c91c109c43..51943705a2b0 100644
@@ -107,6 +107,7 @@
 #define XGMAC_HWFEAT_VXN		BIT(29)
 #define XGMAC_HWFEAT_SAVLANINS		BIT(27)
 #define XGMAC_HWFEAT_TSSTSSEL		GENMASK(26, 25)
+#define XGMAC_HWFEAT_PHYSEL		GENMASK(24, 23)
 #define XGMAC_HWFEAT_ADDMACADRSEL	GENMASK(22, 18)
 #define XGMAC_HWFEAT_RXCOESEL		BIT(16)
 #define XGMAC_HWFEAT_TXCOESEL		BIT(14)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +1 -0
index 9bb547f3c3c9..03437f1cf3df 100644
@@ -364,6 +364,7 @@ static int dwxgmac2_get_hw_feature(void __iomem *ioaddr,
 	dma_cap->vxn = (hw_cap & XGMAC_HWFEAT_VXN) >> 29;
 	dma_cap->vlins = (hw_cap & XGMAC_HWFEAT_SAVLANINS) >> 27;
 	dma_cap->tssrc = (hw_cap & XGMAC_HWFEAT_TSSTSSEL) >> 25;
+	dma_cap->actphyif = FIELD_GET(XGMAC_HWFEAT_PHYSEL, hw_cap);
 	dma_cap->multi_addr = (hw_cap & XGMAC_HWFEAT_ADDMACADRSEL) >> 18;
 	dma_cap->rx_coe = (hw_cap & XGMAC_HWFEAT_RXCOESEL) >> 16;
 	dma_cap->tx_coe = (hw_cap & XGMAC_HWFEAT_TXCOESEL) >> 14;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +52 -0

70 lines not on this page · raw message

Signature · 1 line
2.47.3
maintainer Reviewed-by Tested-by on v1 2/2
#4 lore raw

Re: [PATCH net-next 2/2] net: stmmac: report active PHY interface

Hi,

Quoted 4 lines · Russell King (Oracle)

Report the active PHY interface from the point of view of the dwmac hardware to the kernel log, where the core supports reading this.

Tested with dwmac-socfpga on CycloneV :

RGMII interface :

[    0.898925] socfpga-dwmac ff700000.ethernet: Active PHY interface: RGMII (1)

1000BaseX/SGMII interface connected to Lynx PCS :

[    1.003223] socfpga-dwmac ff702000.ethernet: Active PHY interface: GMII/MII (0)

Nice.

Thanks,

Maxime

#5 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 28 Jan 2026 10:47:43 +0000 you wrote:

The original patch needs dwmac-thead fixed so the PHY_INTF* definitions do not clash.

 drivers/net/ethernet/stmicro/stmmac/common.h       |  6 +++
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c  | 10 ++---
 .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c    |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c   |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h     |  1 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c |  1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 52 ++++++++++++++++++++++
 7 files changed, 69 insertions(+), 5 deletions(-)

Here is the summary with links:
- [net-next,1/2] net: stmmac: thead: avoid conflicts with PHY_INTF_* definitions

    https://git.kernel.org/netdev/net-next/c/88afa0dd655c
  - [net-next,2/2] net: stmmac: report active PHY interface
    https://git.kernel.org/netdev/net-next/c/d9009f72ed88

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html