From 267886991a71fc35d70e0b600581bf11a03c1dda Mon Sep 17 00:00:00 2001 From: Manuel Stocker Date: Sat, 30 May 2026 20:46:18 +0200 Subject: [PATCH] realtek: mdio: skip over ethernet-phy-package nodes 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 Link: https://github.com/openwrt/openwrt/pull/23591 Signed-off-by: Markus Stockhausen --- .../drivers/net/mdio/mdio-realtek-otto.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c index 0775b505d26..6888f86eba1 100644 --- a/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c +++ b/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c @@ -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); -- 2.47.3