]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: use bus auto registration
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Tue, 10 Feb 2026 11:55:15 +0000 (12:55 +0100)
committerRobert Marko <robimarko@gmail.com>
Fri, 13 Feb 2026 11:53:46 +0000 (12:53 +0100)
Let the mdio bus autodetect the attached phys by providing a proper
scan mask. Although this breaks the linkage to the DTS it is better
than adding phys manually.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21968
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c

index e846c00b605e06a926bc773d980863506e11d9df..dc97176c93052c687abdd2ef0ecb288d0b34ed72 100644 (file)
@@ -177,7 +177,6 @@ struct rtmdio_ctrl {
        bool raw[RTMDIO_MAX_PORT];
        int smi_bus[RTMDIO_MAX_PORT];
        int smi_addr[RTMDIO_MAX_PORT];
-       struct device_node *dn[RTMDIO_MAX_PORT];
        bool smi_bus_isc45[RTMDIO_MAX_SMI_BUS];
 };
 
@@ -931,6 +930,7 @@ static int rtmdio_probe(struct platform_device *pdev)
        struct rtmdio_ctrl *ctrl;
        struct device_node *dn;
        struct mii_bus *bus;
+       u64 mask = 0ULL;
        int ret, addr;
 
        bus = devm_mdiobus_alloc_size(dev, sizeof(*ctrl));
@@ -967,7 +967,7 @@ static int rtmdio_probe(struct platform_device *pdev)
                if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45"))
                        ctrl->smi_bus_isc45[ctrl->smi_bus[addr]] = true;
 
-               ctrl->dn[addr] = dn;
+               mask |= BIT_ULL(addr);
        }
 
        bus->name = "Realtek MDIO bus";
@@ -977,7 +977,7 @@ static int rtmdio_probe(struct platform_device *pdev)
        bus->read_c45 = rtmdio_read_c45;
        bus->write_c45 = rtmdio_write_c45;
        bus->parent = dev;
-       bus->phy_mask = ~0;
+       bus->phy_mask = ~mask;
        snprintf(bus->id, MII_BUS_ID_SIZE, "realtek-mdio");
 
        device_set_node(&bus->dev, of_fwnode_handle(dev->of_node));
@@ -988,14 +988,6 @@ static int rtmdio_probe(struct platform_device *pdev)
        if (ctrl->cfg->setup_polling)
                ctrl->cfg->setup_polling(bus);
 
-       for (addr = 0; addr < ctrl->cfg->cpu_port; addr++) {
-               if (ctrl->dn[addr]) {
-                       ret = fwnode_mdiobus_register_phy(bus, of_fwnode_handle(ctrl->dn[addr]), addr);
-                       if (ret)
-                               return ret;
-               }
-       }
-
        return 0;
 }