]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: meson8b: use stmmac_get_phy_intf_sel()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 10 Nov 2025 14:42:53 +0000 (14:42 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 12 Nov 2025 01:53:18 +0000 (17:53 -0800)
Use stmmac_get_phy_intf_sel() to decode the PHY interface mode to the
phy_intf_sel value, validate the result and use that to set the
control register to select the operating mode for the DWMAC core.

Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vIT6b-0000000DpPX-1LQ0@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c

index 865cd61661342e2166a4c90fb97862316c98df3b..e4d5c41294f4edd24cbb4b44ed15aaefc1235d53 100644 (file)
@@ -238,22 +238,12 @@ static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)
 {
        int phy_intf_sel;
 
-       switch (dwmac->phy_mode) {
-       case PHY_INTERFACE_MODE_RGMII:
-       case PHY_INTERFACE_MODE_RGMII_RXID:
-       case PHY_INTERFACE_MODE_RGMII_ID:
-       case PHY_INTERFACE_MODE_RGMII_TXID:
-               /* enable RGMII mode */
-               phy_intf_sel = PHY_INTF_SEL_RGMII;
-               break;
-       case PHY_INTERFACE_MODE_RMII:
-               /* disable RGMII mode -> enables RMII mode */
-               phy_intf_sel = PHY_INTF_SEL_RMII;
-               break;
-       default:
+       phy_intf_sel = stmmac_get_phy_intf_sel(dwmac->phy_mode);
+       if (phy_intf_sel != PHY_INTF_SEL_RGMII &&
+           phy_intf_sel != PHY_INTF_SEL_RMII) {
                dev_err(dwmac->dev, "fail to set phy-mode %s\n",
                        phy_modes(dwmac->phy_mode));
-               return -EINVAL;
+               return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
        }
 
        meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_EXT_PHY_MODE_MASK,