@@ -311,6 +311,7 @@ enum stmmac_state {
int stmmac_mdio_unregister(struct net_device *ndev);
int stmmac_mdio_register(struct net_device *ndev);
int stmmac_mdio_reset(struct mii_bus *mii);
+int stmmac_xpcs_setup(struct mii_bus *mii);
void stmmac_set_ethtool_ops(struct net_device *netdev);
void stmmac_ptp_register(struct stmmac_priv *priv);
@@ -7002,6 +7002,12 @@ int stmmac_dvr_probe(struct device *device,
}
}
+ if (priv->plat->mdio_bus_data->has_xpcs) {
+ ret = stmmac_xpcs_setup(priv->mii);
+ if (ret)
+ goto error_xpcs_setup;
+ }
+
ret = stmmac_phy_setup(priv);
if (ret) {
netdev_err(ndev, "failed to setup phy (%d)\n", ret);
@@ -7038,6 +7044,7 @@ int stmmac_dvr_probe(struct device *device,
unregister_netdev(ndev);
error_netdev_register:
phylink_destroy(priv->phylink);
+error_xpcs_setup:
error_phy_setup:
if (priv->hw->pcs != STMMAC_PCS_TBI &&
priv->hw->pcs != STMMAC_PCS_RTBI)
@@ -397,6 +397,44 @@ int stmmac_mdio_reset(struct mii_bus *bus)
return 0;
}
+int stmmac_xpcs_setup(struct mii_bus *bus)
+{
+ int mode, max_addr, addr, found, ret;
+ struct net_device *ndev = bus->priv;
+ struct mdio_xpcs_args *xpcs;
+ struct stmmac_priv *priv;
+
+ priv = netdev_priv(ndev);
+ xpcs = &priv->hw->xpcs_args;
+ mode = priv->plat->phy_interface;
+ max_addr = PHY_MAX_ADDR;
+
+ priv->hw->xpcs = mdio_xpcs_get_ops();
+ if (!priv->hw->xpcs)
+ return -ENODEV;
+
+ /* Try to probe the XPCS by scanning all addresses. */
+ xpcs->bus = bus;
+ found = 0;
+
+ for (addr = 0; addr < max_addr; addr++) {
+ xpcs->addr = addr;
+
+ ret = stmmac_xpcs_probe(priv, xpcs, mode);
+ if (!ret) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ dev_warn(priv->device, "No xPCS found\n");
+ return -ENODEV;
+ }
+
+ return ret;
+}
+
/**
* stmmac_mdio_register
* @ndev: net device structure
@@ -444,14 +482,6 @@ int stmmac_mdio_register(struct net_device *ndev)
max_addr = PHY_MAX_ADDR;
}
- if (mdio_bus_data->has_xpcs) {
- priv->hw->xpcs = mdio_xpcs_get_ops();
- if (!priv->hw->xpcs) {
- err = -ENODEV;
- goto bus_register_fail;
- }
- }
-
if (mdio_bus_data->needs_reset)
new_bus->reset = &stmmac_mdio_reset;
@@ -509,38 +539,11 @@ int stmmac_mdio_register(struct net_device *ndev)
goto no_phy_found;
}
- /* Try to probe the XPCS by scanning all addresses. */
- if (priv->hw->xpcs) {
- struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args;
- int ret, mode = priv->plat->phy_interface;
- max_addr = PHY_MAX_ADDR;
-
- xpcs->bus = new_bus;
-
- found = 0;
- for (addr = 0; addr < max_addr; addr++) {
- xpcs->addr = addr;
-
- ret = stmmac_xpcs_probe(priv, xpcs, mode);
- if (!ret) {
- found = 1;
- break;
- }
- }
-
- if (!found && !mdio_node) {
- 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: