Commit 246953f3 authored by Wei Fang's avatar Wei Fang Committed by Paolo Abeni
Browse files

net: enetc: fix incorrect fallback PHY address handling



The current netc_get_phy_addr() implementation falls back to PHY address
0 when the "mdio" node or the PHY child node is missing. On i.MX95, this
causes failures when a real PHY is actually assigned address 0 and is
managed through the EMDIO interface. Because the bit 0 of phy_mask will
be set, leading imx95_enetc_mdio_phyaddr_config() to return an error, and
the netc_blk_ctrl driver probe subsequently fails. Fix this by returning
-ENODEV when neither an "mdio" node nor any PHY node is present, it means
that ENETC port MDIO is not used to manage the PHY, so there is no need
to configure LaBCR[MDIO_PHYAD_PRTAD].

Reported-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
Closes: https://lore.kernel.org/all/7825188.GXAFRqVoOG@steina-w


Fixes: 6633df05 ("net: enetc: set the external PHY address in IERB for port MDIO usage")
Reviewed-by: default avatarClark Wang <xiaoning.wang@nxp.com>
Tested-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20260305031211.904812-2-wei.fang@nxp.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 0d9a60a0
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -333,11 +333,13 @@ static int netc_get_phy_addr(struct device_node *np)

	mdio_node = of_get_child_by_name(np, "mdio");
	if (!mdio_node)
		return 0;
		return -ENODEV;

	phy_node = of_get_next_child(mdio_node, NULL);
	if (!phy_node)
	if (!phy_node) {
		err = -ENODEV;
		goto of_put_mdio_node;
	}

	err = of_property_read_u32(phy_node, "reg", &addr);
	if (err)
@@ -423,6 +425,9 @@ static int imx95_enetc_mdio_phyaddr_config(struct platform_device *pdev)

			addr = netc_get_phy_addr(gchild);
			if (addr < 0) {
				if (addr == -ENODEV)
					continue;

				dev_err(dev, "Failed to get PHY address\n");
				return addr;
			}
@@ -578,6 +583,9 @@ static int imx94_enetc_mdio_phyaddr_config(struct netc_blk_ctrl *priv,

	addr = netc_get_phy_addr(np);
	if (addr < 0) {
		if (addr == -ENODEV)
			return 0;

		dev_err(dev, "Failed to get PHY address\n");
		return addr;
	}