Commit 351066ba authored by Serge Semin's avatar Serge Semin Committed by David S. Miller
Browse files

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: default avatarSerge Semin <fancer.lancer@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9cad7275
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -595,7 +595,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
	/* Intel mgbe SGMII interface uses pcs-xcps */
	if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
	    plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
		plat->mdio_bus_data->has_xpcs = true;
		plat->mdio_bus_data->pcs_mask = BIT(INTEL_MGBE_XPCS_ADDR);
		plat->mdio_bus_data->default_an_inband = true;
		plat->select_pcs = intel_mgbe_select_pcs;
	}
+6 −13
Original line number Diff line number Diff line
@@ -499,8 +499,7 @@ int stmmac_pcs_setup(struct net_device *ndev)
{
	struct dw_xpcs *xpcs = NULL;
	struct stmmac_priv *priv;
	int ret = -ENODEV;
	int mode, addr;
	int addr, mode, ret;

	priv = netdev_priv(ndev);
	mode = priv->plat->phy_interface;
@@ -508,16 +507,10 @@ int stmmac_pcs_setup(struct net_device *ndev)
	if (priv->plat->pcs_init) {
		ret = priv->plat->pcs_init(priv);
	} else if (priv->plat->mdio_bus_data &&
		   priv->plat->mdio_bus_data->has_xpcs) {
		/* Try to probe the XPCS by scanning all addresses */
		for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
		   priv->plat->mdio_bus_data->pcs_mask) {
		addr = ffs(priv->plat->mdio_bus_data->pcs_mask) - 1;
		xpcs = xpcs_create_mdiodev(priv->mii, addr, mode);
			if (IS_ERR(xpcs))
				continue;

			ret = 0;
			break;
		}
		ret = PTR_ERR_OR_ZERO(xpcs);
	} else {
		return 0;
	}
@@ -610,7 +603,7 @@ int stmmac_mdio_register(struct net_device *ndev)
	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s-%x",
		 new_bus->name, priv->plat->bus_id);
	new_bus->priv = ndev;
	new_bus->phy_mask = mdio_bus_data->phy_mask;
	new_bus->phy_mask = mdio_bus_data->phy_mask | mdio_bus_data->pcs_mask;
	new_bus->parent = priv->device;

	err = of_mdiobus_register(new_bus, mdio_node);
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ struct stmmac_priv;

struct stmmac_mdio_bus_data {
	unsigned int phy_mask;
	unsigned int has_xpcs;
	unsigned int pcs_mask;
	unsigned int default_an_inband;
	int *irqs;
	int probed_phy_irq;