> @@ -1176,37 +1176,55 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
> hix5hd2_phy_reset(priv);
> }
>
> - bus = devm_mdiobus_alloc(dev);
> - if (bus == NULL) {
> - ret = -ENOMEM;
> + priv->phy_node = of_parse_phandle(node, "phy-handle", 0);
> +
> + /* In the case of a fixed PHY, the DT node associated
> + * to the PHY is the Ethernet MAC DT node.
> + */
> + if (!priv->phy_node && of_phy_is_fixed_link(node)) {
> + ret = of_phy_register_fixed_link(node);
> + if (ret < 0)
> + goto out_disable_clk;
> + priv->phy_node = of_node_get(node);
> + } else if (!priv->phy_node) {
> + netdev_err(ndev, "not find phy-handle\n");
> + ret = -EINVAL;
> goto out_disable_clk;
> }
>
> - bus->priv = priv;
> - bus->name = "hix5hd2_mii_bus";
> - bus->read = hix5hd2_mdio_read;
> - bus->write = hix5hd2_mdio_write;
> - bus->parent = &pdev->dev;
> - snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
> - priv->bus = bus;
> -
> + bus = NULL;
> mdio_np = of_get_available_child_by_name(node, "mdio");
> - ret = of_mdiobus_register(bus, mdio_np ?: node);
> + if (mdio_np || (priv->phy_node != node &&
> + !of_phy_is_fixed_link(node))) {
> + bus = devm_mdiobus_alloc(dev);
Fixed link and mdio are not mutually exclusive.
If there is a fixed link, and no mdio node, you should bail out early
and return EINVAL. The DT blob is invalid. But i would always expect
to register the MDIO bus for all valid configurations.
Andrew