]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: add get_interfaces() platform method
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 1 May 2025 11:45:11 +0000 (12:45 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 3 May 2025 01:25:08 +0000 (18:25 -0700)
Add a get_interfaces() platform method to allow platforms to indicate
to phylink which interface modes they support - which then allows
phylink to validate on initialisation that the configured PHY interface
mode is actually supported.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1uASLn-0021Qd-Mi@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
include/linux/stmmac.h

index ac6ab121eb330ef5518649709ca2590cc659a3f2..5f66f816a24964a6a1311142d1ed6d38ba83817d 100644 (file)
@@ -1283,10 +1283,20 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
        if (mdio_bus_data)
                config->default_an_inband = mdio_bus_data->default_an_inband;
 
-       /* Set the platform/firmware specified interface mode. Note, phylink
-        * deals with the PHY interface mode, not the MAC interface mode.
+       /* Get the PHY interface modes (at the PHY end of the link) that
+        * are supported by the platform.
         */
-       __set_bit(priv->plat->phy_interface, config->supported_interfaces);
+       if (priv->plat->get_interfaces)
+               priv->plat->get_interfaces(priv, priv->plat->bsp_priv,
+                                          config->supported_interfaces);
+
+       /* Set the platform/firmware specified interface mode if the
+        * supported interfaces have not already been provided using
+        * phy_interface as a last resort.
+        */
+       if (phy_interface_empty(config->supported_interfaces))
+               __set_bit(priv->plat->phy_interface,
+                         config->supported_interfaces);
 
        /* If we have an xpcs, it defines which PHY interfaces are supported. */
        if (priv->hw->xpcs)
index 8aed09d65b4a1f5d812f881c018bcb11bd776999..537bced69c46ee957ea9182e6d5455a7354a0656 100644 (file)
@@ -233,6 +233,8 @@ struct plat_stmmacenet_data {
        u8 tx_sched_algorithm;
        struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
        struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
+       void (*get_interfaces)(struct stmmac_priv *priv, void *bsp_priv,
+                              unsigned long *interfaces);
        int (*set_clk_tx_rate)(void *priv, struct clk *clk_tx_i,
                               phy_interface_t interface, int speed);
        void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);