回覆: [PATCH net-next v2 3/6] net: ftgmac100: Enable AST2700 RMII support

From: Jacky Chou

Date: Thu Oct 08 2026 - 01:42:30 EST


Hi Andrew,

Thank you for your review.

> > static void ftgmac100_start_hw(struct ftgmac100 *priv) {
> > u32 maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR);
> > + struct phy_device *phydev = priv->netdev->phydev;
>
> Is it safe to assume there is a phydev? The AI is better at this sort of logic, but
> looking at ftgmac100_probe_dt() is think it is possible to not have a phydev.
> And ftgmac100_phy_disconnect() does guard against not having one.
>

I think that needs to adjust the ftgmac100_probe_dt() at the return of the end.
```
static int ftgmac100_probe_dt()
{
...
if (of_get_property(np, "use-ncsi", NULL))
return ftgmac100_probe_ncsi(netdev, priv, pdev);

if (of_phy_is_fixed_link(np) ||
....
return 0;
}

if (!ftgmac100_has_child_node(np, "mdio")) {
err = ftgmac100_mii_probe(netdev);
if (err) {
dev_err(priv->dev, "MII probe failed!\n");
return err;
}
Return 0; <-- add new
}

return -ENODEV; <-- change to -ENODEV
}
```
The applications of device tree in ftgmac100 have 'use-ncsi', 'fixed-link'/'phy-handle'
and legacy mdio probing for AST2400/2500.

The 'use-ncsi' will bind a fixed-link phy device on speed 100 and RMII, so it will include
phydev for netdev.
The 'fixed-link' also bind a fixed-link phy device for phydev in netdev.
The 'phy-handle' will return the actual phy device instance for phydev.
The legacy mdio method also returns phydev if the MAC node includes mdio in dts
and find the phy device by mdc/mdio.

Therefore, in the current code, the devices tree does not include 'phy-handle', 'use-ncsi',
'fixed-link and 'mdio' properties, the ftgmac100_probe_dt() still returns 0 as success at the
end, and the phydev in netdev will be NULL.

All applications in ftgmac100 must get the phy device handle, regardless of the actual
phy device or the virtual fixed-link phy device.

I would like to add a patch to adjust the ftgmac100_probe_dt(), once the
device tree lacks one of them will return the corresponding error or no device error to
make probing failed.

Thanks,
Jacky