diff options
| author | Markus Stockhausen | 2026-01-12 16:20:39 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-01-21 22:32:54 +0000 |
| commit | 631e066bc3b58ed40ebdec1fdc8d2349c8074efe (patch) | |
| tree | f2f3faeb10712fa1f1f913f9df6ed10a547ff362 | |
| parent | 84a6288a0849fa0ef56a12e7bf028f07c0c6884f (diff) | |
| download | openwrt-631e066bc3b58ed40ebdec1fdc8d2349c8074efe.tar.gz | |
realtek: mdio: register mdio bus at controller node
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>
| -rw-r--r-- | target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c | 27 | ||||
| -rw-r--r-- | target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c | 13 |
2 files changed, 10 insertions, 30 deletions
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c index 53e79bde82..373ab3728d 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c @@ -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) { diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c index acaed57f3f..83fcb935a4 100644 --- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c +++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c @@ -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 = { |