aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
diff options
context:
space:
mode:
authorVoon Weifeng <weifeng.voon@intel.com>2021-06-08 11:51:56 +0800
committerDavid S. Miller <davem@davemloft.net>2021-06-08 14:31:43 -0700
commit597a68ce32167e7d07bf40648e1501f786f60f99 (patch)
treef954de48a3e1b9de82024aae9f1da6aed627f99c /drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
parentMerge tag 'batadv-next-pullrequest-20210608' of git://git.open-mesh.org/linux-merge (diff)
downloadlinux-dev-597a68ce32167e7d07bf40648e1501f786f60f99.tar.xz
linux-dev-597a68ce32167e7d07bf40648e1501f786f60f99.zip
net: stmmac: split xPCS setup from mdio register
This patch is a preparation patch for the enabling of Intel mGbE 2.5Gbps link speed. The Intel mGbR link speed configuration (1G/2.5G) is depends on a mdio ADHOC register which can be configured in the bios menu. As PHY interface might be different for 1G and 2.5G, the mdio bus need be ready to check the link speed and select the PHY interface before probing the xPCS. Signed-off-by: Voon Weifeng <weifeng.voon@intel.com> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 6312a152c8ad..bc900e240da2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -397,6 +397,41 @@ int stmmac_mdio_reset(struct mii_bus *bus)
return 0;
}
+int stmmac_xpcs_setup(struct mii_bus *bus)
+{
+ int mode, addr;
+ struct net_device *ndev = bus->priv;
+ struct mdio_xpcs_args *xpcs;
+ struct stmmac_priv *priv;
+ struct mdio_device *mdiodev;
+
+ priv = netdev_priv(ndev);
+ mode = priv->plat->phy_interface;
+
+ /* Try to probe the XPCS by scanning all addresses. */
+ for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
+ mdiodev = mdio_device_create(bus, addr);
+ if (IS_ERR(mdiodev))
+ continue;
+
+ xpcs = xpcs_create(mdiodev, mode);
+ if (IS_ERR_OR_NULL(xpcs)) {
+ mdio_device_free(mdiodev);
+ continue;
+ }
+
+ priv->hw->xpcs = xpcs;
+ break;
+ }
+
+ if (!priv->hw->xpcs) {
+ dev_warn(priv->device, "No xPCS found\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
/**
* stmmac_mdio_register
* @ndev: net device structure
@@ -501,40 +536,11 @@ int stmmac_mdio_register(struct net_device *ndev)
goto no_phy_found;
}
- /* Try to probe the XPCS by scanning all addresses. */
- if (mdio_bus_data->has_xpcs) {
- int mode = priv->plat->phy_interface;
- struct mdio_device *mdiodev;
- struct mdio_xpcs_args *xpcs;
-
- for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
- mdiodev = mdio_device_create(new_bus, addr);
- if (IS_ERR(mdiodev))
- continue;
-
- xpcs = xpcs_create(mdiodev, mode);
- if (IS_ERR_OR_NULL(xpcs)) {
- mdio_device_free(mdiodev);
- continue;
- }
-
- priv->hw->xpcs = xpcs;
- break;
- }
-
- if (!priv->hw->xpcs) {
- dev_warn(dev, "No XPCS found\n");
- err = -ENODEV;
- goto no_xpcs_found;
- }
- }
-
bus_register_done:
priv->mii = new_bus;
return 0;
-no_xpcs_found:
no_phy_found:
mdiobus_unregister(new_bus);
bus_register_fail: