On Hi3716cv200 hix5hd2_gmac is found directly linked to another MAC without PHY. The driver didn't take fixed-link into account and failed probe when the node has no phy-handle. Add support for fixed-link. A fixed link has no PHY address, yet of_mdiobus_register() walks all 32 addresses and prints a warning line for every address. Suppress the warning by masking out all PHY address. Signed-off-by: David Yang --- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c index 12a5657653f8..dd4ba6d7a157 100644 --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c @@ -1189,7 +1189,12 @@ static int hix5hd2_dev_probe(struct platform_device *pdev) snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev)); priv->bus = bus; - ret = of_mdiobus_register(bus, node); + if (of_phy_is_fixed_link(node)) { + bus->phy_mask = ~0; + ret = mdiobus_register(bus); + } else { + ret = of_mdiobus_register(bus, node); + } if (ret) goto err_free_mdio; @@ -1199,11 +1204,18 @@ static int hix5hd2_dev_probe(struct platform_device *pdev) goto err_mdiobus; } - priv->phy_node = of_parse_phandle(node, "phy-handle", 0); - if (!priv->phy_node) { - netdev_err(ndev, "not find phy-handle\n"); - ret = -EINVAL; - goto err_mdiobus; + if (of_phy_is_fixed_link(node)) { + ret = of_phy_register_fixed_link(node); + if (ret < 0) + goto err_mdiobus; + priv->phy_node = of_node_get(node); + } else { + priv->phy_node = of_parse_phandle(node, "phy-handle", 0); + if (!priv->phy_node) { + netdev_err(ndev, "not find phy-handle\n"); + ret = -EINVAL; + goto err_mdiobus; + } } ndev->irq = platform_get_irq(pdev, 0); @@ -1268,6 +1280,8 @@ static int hix5hd2_dev_probe(struct platform_device *pdev) netif_napi_del(&priv->napi); hix5hd2_destroy_hw_desc_queue(priv); out_phy_node: + if (of_phy_is_fixed_link(node)) + of_phy_deregister_fixed_link(node); of_node_put(priv->phy_node); err_mdiobus: mdiobus_unregister(bus); @@ -1296,6 +1310,8 @@ static void hix5hd2_dev_remove(struct platform_device *pdev) if (HAS_CAP_TSO(priv->hw_cap)) hix5hd2_destroy_sg_desc_queue(priv); hix5hd2_destroy_hw_desc_queue(priv); + if (of_phy_is_fixed_link(pdev->dev.of_node)) + of_phy_deregister_fixed_link(pdev->dev.of_node); of_node_put(priv->phy_node); free_netdev(ndev); } -- 2.53.0