realtek: dts: rearrange mdio-bus below mdio-controller

The mdio controller got its own dts node with a dedicated bus node.
Until now it still searches the phy nodes in the ethernet node.

Change the driver so it searches the nodes at the right location.
For this to work move the phy nodes in all dts/dtsi over to the new
bus node. Use the following replacement rule:

Replace old full declaration

&ethernet0 {
  mdio-bus {
    ...
  };
};

and old abbreviated declaration

&mdio {
  ...
};

simply with the new declaration

&mdio_bus0 {
  ...
};

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/19986
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Markus Stockhausen 2025-09-08 05:53:16 -04:00 committed by Hauke Mehrtens
parent 616559b6d3
commit 57b2706845
50 changed files with 908 additions and 1139 deletions

View File

@ -75,13 +75,7 @@
status = "okay";
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -93,7 +87,6 @@
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};
};
&switch0 {

View File

@ -174,13 +174,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -192,7 +186,6 @@
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};
};
&switch0 {

View File

@ -57,13 +57,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -75,7 +69,6 @@
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};
};
&switch0 {

View File

@ -148,13 +148,7 @@
status = "okay";
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -165,7 +159,6 @@
INTERNAL_PHY(15)
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};
};
&switch0 {

View File

@ -51,13 +51,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -66,7 +60,6 @@
INTERNAL_PHY(13)
INTERNAL_PHY(14)
INTERNAL_PHY(15)
};
};
&spi0 {

View File

@ -54,7 +54,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(16)
EXTERNAL_PHY(17)
};

View File

@ -45,7 +45,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(16)
EXTERNAL_PHY(24)
};

View File

@ -49,7 +49,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};

View File

@ -74,13 +74,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -91,7 +85,6 @@
INTERNAL_PHY(15)
INTERNAL_PHY_SDS(24, 4)
};
};
&switch0 {

View File

@ -52,7 +52,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};

View File

@ -87,13 +87,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -102,7 +96,6 @@
INTERNAL_PHY(13)
INTERNAL_PHY(14)
INTERNAL_PHY(15)
};
};
&switch0 {

View File

@ -96,13 +96,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -111,7 +105,6 @@
INTERNAL_PHY(13)
INTERNAL_PHY(14)
INTERNAL_PHY(15)
};
};
&switch0 {

View File

@ -199,13 +199,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -228,7 +222,6 @@
EXTERNAL_SFP_PHY_FULL(25, 1)
EXTERNAL_SFP_PHY_FULL(26, 2)
EXTERNAL_SFP_PHY_FULL(27, 3)
};
};
&switch0 {

View File

@ -74,13 +74,7 @@
status = "okay";
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -92,7 +86,6 @@
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};
};
&switch0 {

View File

@ -9,13 +9,7 @@
model = "D-Link DGS-1210-16";
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -38,7 +32,6 @@
EXTERNAL_SFP_PHY(25)
EXTERNAL_SFP_PHY(26)
EXTERNAL_SFP_PHY(27)
};
};
&switch0 {

View File

@ -9,13 +9,7 @@
model = "D-Link DGS-1210-20";
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -38,7 +32,6 @@
EXTERNAL_SFP_PHY(25)
EXTERNAL_SFP_PHY(26)
EXTERNAL_SFP_PHY(27)
};
};
&switch0 {

View File

@ -45,13 +45,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -81,7 +75,6 @@
INTERNAL_PHY_SDS(24, 4)
INTERNAL_PHY_SDS(26, 5)
};
};
&switch0 {

View File

@ -1,12 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -39,7 +33,6 @@
EXTERNAL_SFP_PHY_FULL(25, 1)
EXTERNAL_SFP_PHY_FULL(26, 2)
EXTERNAL_SFP_PHY_FULL(27, 3)
};
};
&switch0 {

View File

@ -7,7 +7,7 @@
model = "HPE 1920-24G (JG924A)";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)

View File

@ -96,13 +96,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -125,5 +119,4 @@
EXTERNAL_SFP_PHY_FULL(25, 1)
EXTERNAL_SFP_PHY_FULL(26, 2)
EXTERNAL_SFP_PHY_FULL(27, 3)
};
};

View File

@ -85,13 +85,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -111,7 +105,6 @@
EXTERNAL_PHY(23)
EXTERNAL_PHY(24)
};
};
&switch0 {

View File

@ -121,13 +121,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -154,7 +148,6 @@
EXTERNAL_PHY(21)
EXTERNAL_PHY(22)
EXTERNAL_PHY(23)
};
};
&switch0 {

View File

@ -105,12 +105,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY(8)
INTERNAL_PHY(9)
INTERNAL_PHY(10)
@ -129,7 +124,6 @@
EXTERNAL_PHY(21)
EXTERNAL_PHY(22)
EXTERNAL_PHY(23)
};
};
&switch0 {

View File

@ -106,12 +106,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -139,7 +134,6 @@
EXTERNAL_PHY(21)
EXTERNAL_PHY(22)
EXTERNAL_PHY(23)
};
};
&switch0 {

View File

@ -92,13 +92,9 @@
&ethernet0 {
nvmem-cells = <&factory_macaddr>;
nvmem-cell-names = "mac-address";
};
mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -125,7 +121,6 @@
EXTERNAL_PHY(21)
EXTERNAL_PHY(22)
EXTERNAL_PHY(23)
};
};
&switch0 {

View File

@ -8,7 +8,7 @@
model = "Zyxel GS1900-16";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(16)
EXTERNAL_PHY(17)
EXTERNAL_PHY(18)

View File

@ -54,7 +54,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)

View File

@ -8,7 +8,7 @@
model = "Zyxel GS1900-24E";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)

View File

@ -12,7 +12,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)

View File

@ -54,7 +54,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)

View File

@ -50,7 +50,7 @@
status = "okay";
};
&mdio {
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)

View File

@ -10,13 +10,7 @@
model = "D-Link DGS-1210-52";
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
/* External phy RTL8218B #1 */
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
@ -82,7 +76,6 @@
EXTERNAL_SFP_PHY_FULL(49, 1)
EXTERNAL_SFP_PHY_FULL(50, 2)
EXTERNAL_SFP_PHY_FULL(51, 3)
};
};
&switch0 {

View File

@ -90,16 +90,13 @@
};
};
&ethernet0 {
mdio: mdio-bus {
&mdio_bus0 {
EXTERNAL_SFP_PHY_FULL(48, 0)
EXTERNAL_SFP_PHY_FULL(49, 1)
EXTERNAL_SFP_PHY_FULL(50, 2)
EXTERNAL_SFP_PHY_FULL(51, 3)
};
};
&switch0 {
ports {
SWITCH_PORT(48, 49, qsgmii)

View File

@ -80,13 +80,11 @@
};
&ethernet0 {
mdio: mdio-bus {
&mdio_bus0 {
EXTERNAL_SFP_PHY_FULL(48, 1)
EXTERNAL_SFP_PHY_FULL(49, 3)
EXTERNAL_SFP_PHY_FULL(50, 0)
EXTERNAL_SFP_PHY_FULL(51, 2)
};
};

View File

@ -24,13 +24,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -84,7 +78,6 @@
EXTERNAL_PHY(45)
EXTERNAL_PHY(46)
EXTERNAL_PHY(47)
};
};
&switch0 {

View File

@ -102,11 +102,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
// Switch doesn't come back properly after a reset so don't.
// reset-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
@ -173,7 +169,6 @@
/* RTL8393 Internal SerDes */
INTERNAL_PHY(48)
INTERNAL_PHY(49)
};
};
&switch0 {

View File

@ -242,12 +242,7 @@
};
};
&ethernet0 {
mdio-bus {
compatible = "realtek,rtl838x-mdio";
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
EXTERNAL_PHY(2)
@ -302,7 +297,6 @@
EXTERNAL_PHY(45)
EXTERNAL_PHY(46)
EXTERNAL_PHY(47)
};
};
&switch0 {

View File

@ -144,13 +144,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
/* External phy RTL8218B #1 */
EXTERNAL_PHY(0)
EXTERNAL_PHY(1)
@ -214,7 +208,6 @@
/* RTL8393 Internal SerDes */
INTERNAL_PHY_SDS(48, 12)
INTERNAL_PHY_SDS(49, 13)
};
};
&switch0 {

View File

@ -131,13 +131,9 @@
&ethernet0 {
nvmem-cells = <&macaddr_ubootenv_ethaddr 0>;
nvmem-cell-names = "mac-address";
};
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
/* External RTL8224 PHY */
phy0: ethernet-phy@0 {
reg = <0>;
@ -194,7 +190,6 @@
rtl9300,smi-address = <0 7>;
sds = < 3 >;
};
};
};
&switch0 {

View File

@ -35,7 +35,7 @@
};
};
&mdio {
&mdio_bus0 {
INTERNAL_PHY_SDS(26, 8)
INTERNAL_PHY_SDS(27, 9)
};

View File

@ -8,7 +8,7 @@
model = "Zyxel XGS1210-12 A1 Switch";
};
&mdio {
&mdio_bus0 {
phy24: ethernet-phy@24 {
reg = <24>;
compatible = "ethernet-phy-ieee802.3-c45";

View File

@ -146,13 +146,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
/* External RTL8218D PHY */
phy0: ethernet-phy@0 {
reg = <0>;
@ -200,7 +194,6 @@
INTERNAL_PHY_SDS(26, 8)
INTERNAL_PHY_SDS(27, 9)
};
};
&switch0 {

View File

@ -220,13 +220,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
/* External RTL8218D PHY */
phy0: ethernet-phy@0 {
reg = <0>;
@ -304,7 +298,6 @@
};
INTERNAL_PHY_SDS(27, 9)
};
};
&switch0 {

View File

@ -126,13 +126,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
phy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c45";
rtl9300,smi-address = <0 0>;
@ -188,7 +182,6 @@
reg = <27>;
sds = <9>;
};
};
};
&switch0 {

View File

@ -232,13 +232,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY_SDS(0, 2)
INTERNAL_PHY_SDS(8, 3)
INTERNAL_PHY_SDS(16, 4)
@ -247,7 +241,6 @@
INTERNAL_PHY_SDS(25, 7)
INTERNAL_PHY_SDS(26, 8)
INTERNAL_PHY_SDS(27, 9)
};
};
&switch0 {

View File

@ -221,13 +221,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY_SDS(0, 2)
INTERNAL_PHY_SDS(8, 3)
INTERNAL_PHY_SDS(16, 4)
@ -236,7 +230,6 @@
INTERNAL_PHY_SDS(25, 7)
INTERNAL_PHY_SDS(26, 8)
INTERNAL_PHY_SDS(27, 9)
};
};
&switch0 {

View File

@ -243,13 +243,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY_SDS(0, 2)
INTERNAL_PHY_SDS(8, 3)
INTERNAL_PHY_SDS(16, 4)
@ -258,7 +252,6 @@
INTERNAL_PHY_SDS(25, 7)
INTERNAL_PHY_SDS(26, 8)
INTERNAL_PHY_SDS(27, 9)
};
};
&switch0 {

View File

@ -240,13 +240,7 @@
};
};
&ethernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
regmap = <&ethernet0>;
#address-cells = <1>;
#size-cells = <0>;
&mdio_bus0 {
INTERNAL_PHY_SDS(0, 2)
INTERNAL_PHY_SDS(8, 3)
INTERNAL_PHY_SDS(16, 4)
@ -255,7 +249,6 @@
INTERNAL_PHY_SDS(25, 7)
INTERNAL_PHY_SDS(26, 8)
INTERNAL_PHY_SDS(27, 9)
};
};
&switch0 {

View File

@ -274,9 +274,9 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
int ret;
u32 pn;
np = of_find_compatible_node(NULL, NULL, "realtek,rtl838x-eth");
np = of_find_compatible_node(NULL, NULL, "realtek,otto-mdio");
if (!np) {
dev_err(priv->dev, "ethernet node not found");
dev_err(priv->dev, "mdio controller node not found");
return -ENODEV;
}

View File

@ -1397,7 +1397,7 @@ static int rtmdio_get_family(void)
static int rtmdio_probe(struct platform_device *pdev)
{
struct device_node *dn, *np, *mii_np;
struct device_node *dn, *mii_np;
struct device *dev = &pdev->dev;
struct rtmdio_bus_priv *priv;
struct mii_bus *bus;
@ -1407,11 +1407,7 @@ static int rtmdio_probe(struct platform_device *pdev)
family = rtmdio_get_family();
dev_info(dev, "probing RTL%04x family mdio bus\n", family);
np = of_find_compatible_node(NULL, NULL, "realtek,rtl838x-eth");
if (!np)
return -ENODEV;
mii_np = of_get_child_by_name(np, "mdio-bus");
mii_np = of_get_child_by_name(dev->of_node, "mdio-bus");
if (!mii_np)
return -ENODEV;