Skip to content

Commit 5fc7cf1

Browse files
daviddaneydavem330
authored andcommitted
net: thunderx: Cleanup PHY probing code.
Remove the call to force the octeon-mdio driver to be loaded. Allow the standard driver loading mechanisms to load the PHY drivers, and use -EPROBE_DEFER to cause the BGX driver to be probed only after the PHY drivers are available. Reorder the setting of MAC addresses and PHY probing to allow BGX LMACs with no attached PHY to still be assigned a MAC address. Signed-off-by: David Daney <david.daney@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0df83e7 commit 5fc7cf1

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/net/ethernet/cavium/thunder/thunder_bgx.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -978,27 +978,37 @@ static int bgx_init_of_phy(struct bgx *bgx)
978978
const char *mac;
979979

980980
device_for_each_child_node(&bgx->pdev->dev, fwn) {
981+
struct phy_device *pd;
981982
struct device_node *phy_np;
982983
struct device_node *node = to_of_node(fwn);
983984

984-
/* If it is not an OF node we cannot handle it yet, so
985-
* exit the loop.
985+
/* Should always be an OF node. But if it is not, we
986+
* cannot handle it, so exit the loop.
986987
*/
987988
if (!node)
988989
break;
989990

990-
phy_np = of_parse_phandle(node, "phy-handle", 0);
991-
if (!phy_np)
992-
continue;
993-
994-
bgx->lmac[lmac].phydev = of_phy_find_device(phy_np);
995-
996991
mac = of_get_mac_address(node);
997992
if (mac)
998993
ether_addr_copy(bgx->lmac[lmac].mac, mac);
999994

1000995
SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev);
1001996
bgx->lmac[lmac].lmacid = lmac;
997+
998+
phy_np = of_parse_phandle(node, "phy-handle", 0);
999+
/* If there is no phy or defective firmware presents
1000+
* this cortina phy, for which there is no driver
1001+
* support, ignore it.
1002+
*/
1003+
if (phy_np &&
1004+
!of_device_is_compatible(phy_np, "cortina,cs4223-slice")) {
1005+
/* Wait until the phy drivers are available */
1006+
pd = of_phy_find_device(phy_np);
1007+
if (!pd)
1008+
return -EPROBE_DEFER;
1009+
bgx->lmac[lmac].phydev = pd;
1010+
}
1011+
10021012
lmac++;
10031013
if (lmac == MAX_LMAC_PER_BGX) {
10041014
of_node_put(node);
@@ -1032,9 +1042,6 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10321042
struct bgx *bgx = NULL;
10331043
u8 lmac;
10341044

1035-
/* Load octeon mdio driver */
1036-
octeon_mdiobus_force_mod_depencency();
1037-
10381045
bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL);
10391046
if (!bgx)
10401047
return -ENOMEM;

0 commit comments

Comments
 (0)