]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: add stmmac_get_phy_intf_sel()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 3 Nov 2025 11:50:10 +0000 (11:50 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 5 Nov 2025 00:21:25 +0000 (16:21 -0800)
Provide a function to translate the PHY interface mode to the
phy_intf_sel pin configuration for dwmac1000 and dwmac4 cores that
support multiple interfaces. We currently handle MII, GMII, RGMII,
SGMII, RMII and REVMII, but not TBI, RTBI nor SMII as drivers do not
appear to use these three and the driver doesn't currently support
these.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vFt4c-0000000Choe-3SII@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 3ea680cc63d8169822d85e535ec0b6e75144c503..0ea74c88a779ff6677935b6eb8bad8477872028c 100644 (file)
@@ -396,6 +396,7 @@ void stmmac_ptp_register(struct stmmac_priv *priv);
 void stmmac_ptp_unregister(struct stmmac_priv *priv);
 int stmmac_xdp_open(struct net_device *dev);
 void stmmac_xdp_release(struct net_device *dev);
+int stmmac_get_phy_intf_sel(phy_interface_t interface);
 int stmmac_resume(struct device *dev);
 int stmmac_suspend(struct device *dev);
 void stmmac_dvr_remove(struct device *dev);
index c2a783c8022d9487908ee66d0dd43fd64eb9f184..6d4323d04573292dae0eaf043eee72ac9e2907f0 100644 (file)
@@ -3082,6 +3082,26 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv)
        }
 }
 
+int stmmac_get_phy_intf_sel(phy_interface_t interface)
+{
+       int phy_intf_sel = -EINVAL;
+
+       if (interface == PHY_INTERFACE_MODE_MII ||
+           interface == PHY_INTERFACE_MODE_GMII)
+               phy_intf_sel = PHY_INTF_SEL_GMII_MII;
+       else if (phy_interface_mode_is_rgmii(interface))
+               phy_intf_sel = PHY_INTF_SEL_RGMII;
+       else if (interface == PHY_INTERFACE_MODE_SGMII)
+               phy_intf_sel = PHY_INTF_SEL_SGMII;
+       else if (interface == PHY_INTERFACE_MODE_RMII)
+               phy_intf_sel = PHY_INTF_SEL_RMII;
+       else if (interface == PHY_INTERFACE_MODE_REVMII)
+               phy_intf_sel = PHY_INTF_SEL_REVMII;
+
+       return phy_intf_sel;
+}
+EXPORT_SYMBOL_GPL(stmmac_get_phy_intf_sel);
+
 /**
  * stmmac_init_dma_engine - DMA init.
  * @priv: driver private structure