net: dsa: sja1105: use phylink_pcs internally
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 1 Oct 2024 16:04:46 +0000 (17:04 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Oct 2024 00:32:00 +0000 (17:32 -0700)
Use xpcs_create_pcs_mdiodev() to create the XPCS instance, storing
and using the phylink_pcs pointer internally, rather than dw_xpcs.
Use xpcs_destroy_pcs() to destroy the XPCS instance when we've
finished with it.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1svfMk-005ZIj-R3@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/dsa/sja1105/sja1105_mdio.c

index 8c66d3bf61f028167a98fd7025ba6b0f7b3b431d..dceb96ae9c83dbf01dc11024f5e92b88d46a2253 100644 (file)
@@ -278,7 +278,7 @@ struct sja1105_private {
        struct mii_bus *mdio_base_t1;
        struct mii_bus *mdio_base_tx;
        struct mii_bus *mdio_pcs;
-       struct dw_xpcs *xpcs[SJA1105_MAX_NUM_PORTS];
+       struct phylink_pcs *pcs[SJA1105_MAX_NUM_PORTS];
        struct sja1105_ptp_data ptp_data;
        struct sja1105_tas_data tas_data;
 };
index e5918ac862ebfb0bfc4c51f11b941fe138a3163b..af38b8959d8dbcbee6721e47c571b540fee3f55f 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/of.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
-#include <linux/pcs/pcs-xpcs.h>
 #include <linux/netdev_features.h>
 #include <linux/netdevice.h>
 #include <linux/if_bridge.h>
@@ -1358,12 +1357,8 @@ sja1105_mac_select_pcs(struct phylink_config *config, phy_interface_t iface)
 {
        struct dsa_port *dp = dsa_phylink_to_port(config);
        struct sja1105_private *priv = dp->ds->priv;
-       struct dw_xpcs *xpcs = priv->xpcs[dp->index];
 
-       if (xpcs)
-               return &xpcs->pcs;
-
-       return NULL;
+       return priv->pcs[dp->index];
 }
 
 static void sja1105_mac_config(struct phylink_config *config,
@@ -2319,7 +2314,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
                mac_speed[i] = mac[i].speed;
                mac[i].speed = priv->info->port_speed[SJA1105_SPEED_AUTO];
 
-               if (priv->xpcs[i])
+               if (priv->pcs[i])
                        bmcr[i] = mdiobus_c45_read(priv->mdio_pcs, i,
                                                   MDIO_MMD_VEND2, MDIO_CTRL1);
        }
@@ -2376,8 +2371,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
        }
 
        for (i = 0; i < ds->num_ports; i++) {
-               struct dw_xpcs *xpcs = priv->xpcs[i];
-               struct phylink_pcs *pcs;
+               struct phylink_pcs *pcs = priv->pcs[i];
                unsigned int neg_mode;
 
                mac[i].speed = mac_speed[i];
@@ -2385,11 +2379,9 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
                if (rc < 0)
                        goto out;
 
-               if (!xpcs)
+               if (!pcs)
                        continue;
 
-               pcs = &xpcs->pcs;
-
                if (bmcr[i] & BMCR_ANENABLE)
                        neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
                else
index 52ddb4ef259e93b9ddd64663f67b8f06b042fadf..84b7169f297480db1ede1c04c79fae82fe9f4580 100644 (file)
@@ -400,7 +400,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv)
        }
 
        for (port = 0; port < ds->num_ports; port++) {
-               struct dw_xpcs *xpcs;
+               struct phylink_pcs *pcs;
 
                if (dsa_is_unused_port(ds, port))
                        continue;
@@ -409,13 +409,13 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv)
                    priv->phy_mode[port] != PHY_INTERFACE_MODE_2500BASEX)
                        continue;
 
-               xpcs = xpcs_create_mdiodev(bus, port, priv->phy_mode[port]);
-               if (IS_ERR(xpcs)) {
-                       rc = PTR_ERR(xpcs);
+               pcs = xpcs_create_pcs_mdiodev(bus, port);
+               if (IS_ERR(pcs)) {
+                       rc = PTR_ERR(pcs);
                        goto out_pcs_free;
                }
 
-               priv->xpcs[port] = xpcs;
+               priv->pcs[port] = pcs;
        }
 
        priv->mdio_pcs = bus;
@@ -424,11 +424,10 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv)
 
 out_pcs_free:
        for (port = 0; port < ds->num_ports; port++) {
-               if (!priv->xpcs[port])
-                       continue;
-
-               xpcs_destroy(priv->xpcs[port]);
-               priv->xpcs[port] = NULL;
+               if (priv->pcs[port]) {
+                       xpcs_destroy_pcs(priv->pcs[port]);
+                       priv->pcs[port] = NULL;
+               }
        }
 
        mdiobus_unregister(bus);
@@ -446,11 +445,10 @@ static void sja1105_mdiobus_pcs_unregister(struct sja1105_private *priv)
                return;
 
        for (port = 0; port < ds->num_ports; port++) {
-               if (!priv->xpcs[port])
-                       continue;
-
-               xpcs_destroy(priv->xpcs[port]);
-               priv->xpcs[port] = NULL;
+               if (priv->pcs[port]) {
+                       xpcs_destroy_pcs(priv->pcs[port]);
+                       priv->pcs[port] = NULL;
+               }
        }
 
        mdiobus_unregister(priv->mdio_pcs);