]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: mdio: realtek-rtl9300: Correctly handle ethernet-phy-package
authorManuel Stocker <mensi@mensi.ch>
Wed, 3 Jun 2026 17:59:24 +0000 (19:59 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 6 Jun 2026 01:38:56 +0000 (18:38 -0700)
Realtek Otto switches usually make use of multiport PHYs (e.g. 8 port
1G RTL8218D or 4 port 2.5G RTL8224). The device tree can describe this
fact via an "ethernet-phy-package" node that resides between the bus
and the PHY node.

When looking up the device tree bus node via the chain port->phy->parent
the driver totally ignores the existence of a PHY package. Enhance the
lookup to take care of this feature.

Link: https://github.com/openwrt/openwrt/pull/23591
Signed-off-by: Manuel Stocker <mensi@mensi.ch>
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://patch.msgid.link/20260603175924.123019-8-markus.stockhausen@gmx.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/mdio/mdio-realtek-rtl9300.c

index bd361aa1973989ba76241c048eb4dcb01302149b..92c8f2512476b43a2d25c2f6a7d3020690442237 100644 (file)
@@ -432,6 +432,21 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv
        return 0;
 }
 
+static struct device_node *otto_emdio_get_bus_node(struct device_node *dn)
+{
+       struct device_node *parent = of_get_parent(dn);
+       struct device_node *grandparent;
+
+       if (parent && of_node_name_eq(parent, "ethernet-phy-package")) {
+               grandparent = of_get_parent(parent);
+               of_node_put(parent);
+
+               return grandparent;
+       }
+
+       return parent;
+}
+
 /* The mdio-controller is part of a switch block so we parse the sibling
  * ethernet-ports node and build a mapping of the switch port to MDIO bus/addr
  * based on the phy-handle.
@@ -457,7 +472,7 @@ static int otto_emdio_map_ports(struct device *dev)
                if (!phy_dn)
                        continue;
 
-               bus_dn = of_get_parent(phy_dn);
+               bus_dn = otto_emdio_get_bus_node(phy_dn);
                if (!bus_dn)
                        goto put_nodes;