RE: [PATCH v3 net-next 1/3] net: enetc: set the external PHY address in IERB for port MDIO usage

From: Wei Fang

Date: Fri Feb 27 2026 - 22:52:19 EST


> > +static int imx95_enetc_mdio_phyaddr_config(struct platform_device
> > +*pdev) {
> > + struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
> > + struct device_node *np = pdev->dev.of_node;
> > + struct device *dev = &pdev->dev;
> > + int bus_devfn, addr, err;
> > + u32 phy_mask = 0;
> > +
> > + err = netc_get_emdio_phy_mask(np, &phy_mask);
> > + if (err) {
> > + dev_err(dev, "Failed to get PHY address mask\n");
> > + return err;
> > + }
> > +
> > + /* Update the port EMDIO PHY address through parsing phy properties.
> > + * This is needed when using the port EMDIO but it's harmless when
> > + * using the central EMDIO. So apply it on all cases.
> > + */
> > + for_each_child_of_node_scoped(np, child) {
> > + for_each_child_of_node_scoped(child, gchild) {
> > + if (!of_device_is_compatible(gchild, "pci1131,e101"))
> > + continue;
> > +
> > + bus_devfn = netc_of_pci_get_bus_devfn(gchild);
> > + if (bus_devfn < 0) {
> > + dev_err(dev, "Failed to get BDF number\n");
> > + return bus_devfn;
> > + }
> > +
> > + addr = netc_get_phy_addr(gchild);
> > + if (addr < 0) {
> > + dev_err(dev, "Failed to get PHY address\n");
> > + return addr;
> > + }
> > +
> > + if (phy_mask & BIT(addr)) {
>
> ... which will break here if there is an Ethernet PHY using address 0 in
> 'netc_emdio' node.
> See arch/arm64/boot/dts/freescale/imx95-tqma9596sa.dtsi node
> ethernet-phy@0.

AFAIU, the PHY address 0 is a special address, below is the description of
PHYAD from IEEE 802.3 Clause 22.

A PHY that is connected to the station management entity via the
mechanical interface defined in 22.6 shall always respond to transactions
addressed to PHY Address zero <00000>. A station management entity
that is attached to multiple PHYs must have prior knowledge of the
appropriate PHY Address for each PHY.

Therefore, for most PHYs, PHY address 0 is typically used as the broadcast
address or default response address. In designs that control multiple PHYs
via EMDIO, it is recommended to avoid setting a specific PHY to address 0
to prevent bus conflicts.

If the PHY on your board does not use PHY address 0 as the broadcast address
or the default response address, then we should check the PHY address first and
then check the phy_mask in imx95_enetc_mdio_phyaddr_config(), just the same
as imx94_enetc_mdio_phyaddr_config().