]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: register mdio bus at controller node
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Mon, 12 Jan 2026 16:20:39 +0000 (17:20 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Wed, 21 Jan 2026 22:32:54 +0000 (23:32 +0100)
In the future the mdio controller will have multiple busses
defined in the dts below the controller node. Nevertheless
it will still hand out only one single bus to the kernel.
Attach the (exported) bus to the controller node instead of
the single (dts) bus subnode.

With this change the mdio lookup in the dsa driver must
be changed to point to the mdio controller node too.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21438
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c

index 53e79bde82264795bef948d2ffc823e9d817be3c..373ab3728d2b73c52e82728223ac74f16e527d28 100644 (file)
@@ -241,31 +241,22 @@ static int rtldsa_bus_c45_write(struct mii_bus *bus, int addr, int devad, int re
 
 static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
 {
-       struct device_node *dn, *phy_node, *pcs_node, *led_node, *np, *mii_np;
+       struct device_node *dn, *phy_node, *pcs_node, *led_node;
        struct device *dev = priv->dev;
        struct mii_bus *bus;
        int ret;
        u32 pn;
 
-       np = of_find_compatible_node(NULL, NULL, "realtek,otto-mdio");
-       if (!np) {
-               dev_err(priv->dev, "mdio controller node not found");
+       dn = of_find_compatible_node(NULL, NULL, "realtek,otto-mdio");
+       if (!dn)
                return -ENODEV;
-       }
 
-       mii_np = of_get_child_by_name(np, "mdio-bus");
-       if (!mii_np) {
-               dev_err(priv->dev, "mdio-bus subnode not found");
-               return -ENODEV;
-       }
+       if (!of_device_is_available(dn))
+               ret = -ENODEV;
 
-       priv->parent_bus = of_mdio_find_bus(mii_np);
-       if (!priv->parent_bus) {
-               dev_dbg(priv->dev, "Deferring probe of mdio bus\n");
+       priv->parent_bus = of_mdio_find_bus(dn);
+       if (!priv->parent_bus)
                return -EPROBE_DEFER;
-       }
-       if (!of_device_is_available(mii_np))
-               ret = -ENODEV;
 
        bus = devm_mdiobus_alloc(priv->ds->dev);
        if (!bus)
@@ -284,10 +275,8 @@ static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
        priv->ds->user_mii_bus->priv = priv;
 
        ret = mdiobus_register(priv->ds->user_mii_bus);
-       if (ret && mii_np) {
-               of_node_put(dn);
+       if (ret)
                return ret;
-       }
 
        dn = of_find_compatible_node(NULL, NULL, "realtek,rtl83xx-switch");
        if (!dn) {
index acaed57f3fef37e6a7b9661697a72d2cebda27b1..83fcb935a407460979895da843ce32aa98052440 100644 (file)
@@ -1012,21 +1012,12 @@ static int rtmdio_reset(struct mii_bus *bus)
 
 static int rtmdio_probe(struct platform_device *pdev)
 {
-       struct device_node *dn, *mii_np;
+       struct device_node *dn;
        struct device *dev = &pdev->dev;
        struct rtmdio_bus_priv *priv;
        struct mii_bus *bus;
        u32 pn;
 
-       mii_np = of_get_child_by_name(dev->of_node, "mdio-bus");
-       if (!mii_np)
-               return -ENODEV;
-
-       if (!of_device_is_available(mii_np)) {
-               of_node_put(mii_np);
-               return -ENODEV;
-       }
-
        bus = devm_mdiobus_alloc_size(dev, sizeof(*priv));
        if (!bus)
                return -ENOMEM;
@@ -1082,7 +1073,7 @@ static int rtmdio_probe(struct platform_device *pdev)
 
        snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev));
 
-       return devm_of_mdiobus_register(dev, bus, mii_np);
+       return devm_of_mdiobus_register(dev, bus, dev->of_node);
 }
 
 static const struct rtmdio_config rtmdio_838x_cfg = {