From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jian Shen <shenjian15@huawei.com>,
Jijie Shao <shaojijie@huawei.com>,
devicetree@vger.kernel.org
Subject: [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link
Date: Tue, 24 Nov 2026 08:24:39 +0800 [thread overview]
Message-ID: <20261124002442.19414-6-mmyangfl@gmail.com> (raw)
In-Reply-To: <20261124002442.19414-1-mmyangfl@gmail.com>
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. Register a fixed PHY from the
node in that case.
With a fixed link declared on the MAC node, of_mdiobus_register() treats
the reg-less fixed-link child as a PHY candidate and walks all 32 bus
addresses, printing "scan phy fixed-link at address X" for each address.
Skip the MDIO bus registration for a fixed link, unless devices are
described under an "mdio" child node, like
commit d0c3601f2c4e ("net: macb: Avoid 20s boot delay by skipping MDIO
bus registration for fixed-link PHY").
of_phy_is_fixed_link() also returns true for managed = "in-band-status";
give phy-handle precedence over it, like fec and gianfar, so nodes with
a phy-handle keep MDIO management.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 63 ++++++++++++-------
1 file changed, 41 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index a176870079e9..b787b7777e92 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -1176,37 +1176,52 @@ 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;
-
mdio_np = of_get_child_by_name(node, "mdio");
- ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
+ if (mdio_np || priv->phy_node != node) {
+ bus = devm_mdiobus_alloc(dev);
+ if (!bus) {
+ ret = -ENOMEM;
+ of_node_put(mdio_np);
+ goto out_phy_node;
+ }
+
+ 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;
+
+ ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
+ if (ret) {
+ of_node_put(mdio_np);
+ goto out_phy_node;
+ }
+ }
of_node_put(mdio_np);
- if (ret)
- goto out_disable_clk;
ret = of_get_phy_mode(node, &priv->phy_mode);
if (ret) {
netdev_err(ndev, "not find phy-mode\n");
- goto out_disable_clk;
- }
-
- 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 out_disable_clk;
+ goto out_phy_node;
}
ndev->irq = platform_get_irq(pdev, 0);
@@ -1271,6 +1286,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 (priv->phy_node == node)
+ of_phy_deregister_fixed_link(node);
of_node_put(priv->phy_node);
out_disable_clk:
clk_disable_unprepare(priv->mac_ifc_clk);
@@ -1291,6 +1308,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 (priv->phy_node == pdev->dev.of_node)
+ of_phy_deregister_fixed_link(pdev->dev.of_node);
of_node_put(priv->phy_node);
}
--
2.53.0
prev parent reply other threads:[~2026-11-24 0:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 0:24 [PATCH net-next v3 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-24 0:24 ` [PATCH net-next v3 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus David Yang
2026-11-24 0:24 ` [PATCH net-next v3 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node David Yang
2026-11-24 0:24 ` [PATCH net-next v3 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists David Yang
2026-11-24 0:24 ` [PATCH net-next v3 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link David Yang
2026-11-24 0:24 ` David Yang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124002442.19414-6-mmyangfl@gmail.com \
--to=mmyangfl@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox