Skip to content

Commit 351066b

Browse files
fancerdavem330
authored andcommitted
net: stmmac: Create DW XPCS device with particular address
Currently the only STMMAC platform driver using the DW XPCS code is the Intel mGBE device driver. (It can be determined by finding all the drivers having the stmmac_mdio_bus_data::has_xpcs flag set.) At the same time the low-level platform driver masks out the DW XPCS MDIO-address from being auto-detected as PHY by the MDIO subsystem core. Seeing the PCS MDIO ID is known the procedure of the DW XPCS device creation can be simplified by dropping the loop over all the MDIO IDs. From now the DW XPCS device descriptor will be created for the MDIO-bus address pre-defined by the platform drivers via the stmmac_mdio_bus_data::pcs_mask field. Note besides this shall speed up a bit the Intel mGBE probing. Signed-off-by: Serge Semin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9cad727 commit 351066b

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
595595
/* Intel mgbe SGMII interface uses pcs-xcps */
596596
if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
597597
plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
598-
plat->mdio_bus_data->has_xpcs = true;
598+
plat->mdio_bus_data->pcs_mask = BIT(INTEL_MGBE_XPCS_ADDR);
599599
plat->mdio_bus_data->default_an_inband = true;
600600
plat->select_pcs = intel_mgbe_select_pcs;
601601
}

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -499,25 +499,18 @@ int stmmac_pcs_setup(struct net_device *ndev)
499499
{
500500
struct dw_xpcs *xpcs = NULL;
501501
struct stmmac_priv *priv;
502-
int ret = -ENODEV;
503-
int mode, addr;
502+
int addr, mode, ret;
504503

505504
priv = netdev_priv(ndev);
506505
mode = priv->plat->phy_interface;
507506

508507
if (priv->plat->pcs_init) {
509508
ret = priv->plat->pcs_init(priv);
510509
} else if (priv->plat->mdio_bus_data &&
511-
priv->plat->mdio_bus_data->has_xpcs) {
512-
/* Try to probe the XPCS by scanning all addresses */
513-
for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
514-
xpcs = xpcs_create_mdiodev(priv->mii, addr, mode);
515-
if (IS_ERR(xpcs))
516-
continue;
517-
518-
ret = 0;
519-
break;
520-
}
510+
priv->plat->mdio_bus_data->pcs_mask) {
511+
addr = ffs(priv->plat->mdio_bus_data->pcs_mask) - 1;
512+
xpcs = xpcs_create_mdiodev(priv->mii, addr, mode);
513+
ret = PTR_ERR_OR_ZERO(xpcs);
521514
} else {
522515
return 0;
523516
}
@@ -610,7 +603,7 @@ int stmmac_mdio_register(struct net_device *ndev)
610603
snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s-%x",
611604
new_bus->name, priv->plat->bus_id);
612605
new_bus->priv = ndev;
613-
new_bus->phy_mask = mdio_bus_data->phy_mask;
606+
new_bus->phy_mask = mdio_bus_data->phy_mask | mdio_bus_data->pcs_mask;
614607
new_bus->parent = priv->device;
615608

616609
err = of_mdiobus_register(new_bus, mdio_node);

include/linux/stmmac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct stmmac_priv;
8282

8383
struct stmmac_mdio_bus_data {
8484
unsigned int phy_mask;
85-
unsigned int has_xpcs;
85+
unsigned int pcs_mask;
8686
unsigned int default_an_inband;
8787
int *irqs;
8888
int probed_phy_irq;

0 commit comments

Comments
 (0)