]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: skip over ethernet-phy-package nodes 23591/head
authorManuel Stocker <mensi@mensi.ch>
Sat, 30 May 2026 18:46:18 +0000 (20:46 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 31 May 2026 11:07:38 +0000 (13:07 +0200)
When we look up the PHY for each switch port, we traverse to the parent
node to find the corresponding MDIO bus. This approach breaks down
when an explicit ethernet-phy-package is used to bundle multiple
PHYs in the same chip.

Signed-off-by: Manuel Stocker <mensi@mensi.ch>
Link: https://github.com/openwrt/openwrt/pull/23591
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c

index 0775b505d268d9a325b80de2986cf183d3173dc4..6888f86eba19eeef982921fe1a1c9b7663abc2c1 100644 (file)
@@ -749,6 +749,18 @@ static int rtmd_get_phy_info(struct rtmd_ctrl *ctrl, int pn, struct rtmd_phy_inf
        return 0;
 }
 
+static struct fwnode_handle *rtmd_get_bus_node(struct fwnode_handle *phynode)
+{
+       struct fwnode_handle *parent = fwnode_get_parent(phynode);
+
+       if (parent && fwnode_name_eq(parent, "ethernet-phy-package")) {
+               struct fwnode_handle *grandparent = fwnode_get_parent(parent);
+               fwnode_handle_put(parent);
+               return grandparent;
+       }
+       return parent;
+}
+
 static int rtmd_838x_setup_ctrl(struct rtmd_ctrl *ctrl)
 {
        /*
@@ -1007,7 +1019,7 @@ static int rtmd_map_ports(struct device *dev)
                if (smi_addr >= PHY_MAX_ADDR)
                        return dev_err_probe(dev, -EINVAL, "%pfwP illegal phy address\n", fw_phy);
 
-               struct fwnode_handle *fw_bus __free(fwnode_handle) = fwnode_get_parent(fw_phy);
+               struct fwnode_handle *fw_bus __free(fwnode_handle) = rtmd_get_bus_node(fw_phy);
                if (!fw_bus || fwnode_property_read_u32(fw_bus, "reg", &smi_bus))
                        return dev_err_probe(dev, -EINVAL, "%pfwP no bus number\n",
                                             fw_bus ?: fw_phy);