Re: [PATCH net-next 2/4] net: enetc: netc_blk_ctrl: add i.MX952 support

From: Andrew Lunn

Date: Wed Nov 18 2026 - 08:52:22 EST


> +static int imx952_netcmix_init(struct platform_device *pdev)
> +{
> + struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
> + struct device_node *np = pdev->dev.of_node;
> + phy_interface_t interface;
> + int bus_devfn, mii_proto;
> + u32 val;
> + int err;
> +
> + /* Default setting */
> + val = MII_PROT(0, MII_PROT_RGMII) | MII_PROT(1, MII_PROT_RGMII);
> +
> + /* Update the link MII protocol through parsing phy-mode */
> + 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)
> + return bus_devfn;
> +
> + err = of_get_phy_mode(gchild, &interface);
> + if (err)
> + continue;
> +
> + mii_proto = netc_get_link_mii_protocol(interface);
> + if (mii_proto < 0)
> + return mii_proto;
> +
> + switch (bus_devfn) {
> + case IMX952_ENETC0_BUS_DEVFN:
> + val = u32_replace_bits(val, mii_proto,
> + CFG_LINK_MII_PORT_0);
> + break;
> + case IMX952_ENETC1_BUS_DEVFN:
> + val = u32_replace_bits(val, mii_proto,
> + CFG_LINK_MII_PORT_1);
> + break;
> + default:
> + return -EINVAL;
> + }
> + }
> + }
> +
> + netc_reg_write(priv->netcmix, IMX95_CFG_LINK_MII_PROT, val);
> +
> + return 0;
> +}
> +

This looks very similar to imx95_netcmix_init(), and
imx94_link_config() is similar to the core of this loop.

Can some core refactoring be done to reduce duplication?

Andrew