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>
This commit is contained in:
Markus Stockhausen 2026-01-12 17:20:39 +01:00 committed by Hauke Mehrtens
parent 84a6288a08
commit 631e066bc3
2 changed files with 11 additions and 31 deletions

View file

@ -241,32 +241,23 @@ 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;
}
priv->parent_bus = of_mdio_find_bus(mii_np);
if (!priv->parent_bus) {
dev_dbg(priv->dev, "Deferring probe of mdio bus\n");
return -EPROBE_DEFER;
}
if (!of_device_is_available(mii_np))
if (!of_device_is_available(dn))
ret = -ENODEV;
priv->parent_bus = of_mdio_find_bus(dn);
if (!priv->parent_bus)
return -EPROBE_DEFER;
bus = devm_mdiobus_alloc(priv->ds->dev);
if (!bus)
return -ENOMEM;
@ -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) {

View 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 = {