]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: rk: add get_interfaces() implementation
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 12 Jun 2025 15:40:41 +0000 (16:40 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Jun 2025 01:22:58 +0000 (18:22 -0700)
RK platforms support RGMII and/or RMII depending on the SoC. Detect
whether support for a SoC exists by whether the interface specific
set_to functions have been populated, and set the appropriate bits in
phylink's bitmap of interfaces.

This assumes all dwmac interfaces on a SoC have identical support,
but it should be noted that this is not true for RK3528 which only
supports RGMII on GMAC1. However, the existing code structure
permits RGMII to be configured on GMAC0 without complaint, so
preserve this behaviour even though it is incorrect to avoid
functional change.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/E1uPk2j-004CF6-Mf@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

index 700858ff6f7c33fdca08100dd7406aedeff0fc41..8006424ab0275837737d8807f6a66520b6d2fa3b 100644 (file)
@@ -1864,6 +1864,18 @@ static void rk_gmac_powerdown(struct rk_priv_data *gmac)
        gmac_clk_enable(gmac, false);
 }
 
+static void rk_get_interfaces(struct stmmac_priv *priv, void *bsp_priv,
+                             unsigned long *interfaces)
+{
+       struct rk_priv_data *rk = bsp_priv;
+
+       if (rk->ops->set_to_rgmii)
+               phy_interface_set_rgmii(interfaces);
+
+       if (rk->ops->set_to_rmii)
+               __set_bit(PHY_INTERFACE_MODE_RMII, interfaces);
+}
+
 static int rk_set_clk_tx_rate(void *bsp_priv_, struct clk *clk_tx_i,
                              phy_interface_t interface, int speed)
 {
@@ -1919,6 +1931,7 @@ static int rk_gmac_probe(struct platform_device *pdev)
                plat_dat->tx_fifo_size = 2048;
        }
 
+       plat_dat->get_interfaces = rk_get_interfaces;
        plat_dat->set_clk_tx_rate = rk_set_clk_tx_rate;
 
        plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data);