From 82ddc472d722d2d9befb1a1420055ababe7c0df1 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Sun, 31 May 2026 16:35:35 +0200 Subject: [PATCH] realtek: dts: convert to upstream switch notation There is currently a difference how upstream and downstream define the switch in the dts. Downstream holds the switch as a member node below a root switchcore parent. Upstream uses the switch as the parent. Upstream: ethernet-switch@1b000000 { mdio-controller@ca00 { }; ethernet { }; ethernet-ports { }; } Downstream: switchcore@1b000000 { ethernet-switch { ethernet-ports { }; }; mdio-controller@ca00 { }; ethernet { }; } Align downstream to upstream and merge the ethernet-switch into the parent node. For this to work adapt the port lookup in the MDIO and PCS driver. Remark! With this commit the boot process will give the spurious error message "rtl838x_eth 1b000000.ethernet-switch:ethernet eth0: Failed to create a device link to DSA switch 1b000000.ethernet-switch" This comes from the fact that the switch is the parent of the ethernet device. Thus a link back from ethernet device to the switch is no longer possible. Testing shows that the error is just cosmetic. Link: https://github.com/openwrt/openwrt/pull/23599 Signed-off-by: Markus Stockhausen --- target/linux/realtek/dts/rtl838x.dtsi | 14 ++++---------- target/linux/realtek/dts/rtl839x.dtsi | 14 ++++---------- target/linux/realtek/dts/rtl930x.dtsi | 14 ++++---------- target/linux/realtek/dts/rtl931x.dtsi | 16 +++++----------- .../drivers/net/mdio/mdio-realtek-otto.c | 9 ++------- .../files-6.18/drivers/net/pcs/pcs-rtl-otto.c | 9 ++------- 6 files changed, 21 insertions(+), 55 deletions(-) diff --git a/target/linux/realtek/dts/rtl838x.dtsi b/target/linux/realtek/dts/rtl838x.dtsi index 64e1e26e297..1ee9c46212f 100644 --- a/target/linux/realtek/dts/rtl838x.dtsi +++ b/target/linux/realtek/dts/rtl838x.dtsi @@ -199,9 +199,11 @@ }; }; - switchcore@1b000000 { - compatible = "syscon", "simple-mfd"; + switch0: ethernet-switch@1b000000 { + compatible = "realtek,rtl8380-switch", "realtek,otto-switch", "syscon", "simple-mfd"; reg = <0x1b000000 0x10000>; + interrupt-parent = <&intc>; + interrupts = <20 2>; #address-cells = <1>; #size-cells = <1>; @@ -280,14 +282,6 @@ compatible = "realtek,rtl8380-thermal"; #thermal-sensor-cells = <0>; }; - - switch0: ethernet-switch { - compatible = "realtek,rtl8380-switch", "realtek,otto-switch"; - status = "okay"; - - interrupt-parent = <&intc>; - interrupts = <20 2>; - }; }; pinmux@1b000144 { diff --git a/target/linux/realtek/dts/rtl839x.dtsi b/target/linux/realtek/dts/rtl839x.dtsi index 4ed1af9d053..0a31019dbff 100644 --- a/target/linux/realtek/dts/rtl839x.dtsi +++ b/target/linux/realtek/dts/rtl839x.dtsi @@ -207,9 +207,11 @@ }; - switchcore@1b000000 { - compatible = "syscon", "simple-mfd"; + switch0: ethernet-switch@1b000000 { + compatible = "realtek,rtl8392-switch", "realtek,otto-switch", "syscon", "simple-mfd"; reg = <0x1b000000 0x10000>; + interrupt-parent = <&intc>; + interrupts = <20 2>; #address-cells = <1>; #size-cells = <1>; @@ -325,14 +327,6 @@ compatible = "realtek,rtl8390-thermal"; #thermal-sensor-cells = <0>; }; - - switch0: ethernet-switch { - compatible = "realtek,rtl8392-switch", "realtek,otto-switch"; - status = "okay"; - - interrupt-parent = <&intc>; - interrupts = <20 2>; - }; }; pinmux@1b000004 { diff --git a/target/linux/realtek/dts/rtl930x.dtsi b/target/linux/realtek/dts/rtl930x.dtsi index 2e5d9eb6523..10507b1d389 100644 --- a/target/linux/realtek/dts/rtl930x.dtsi +++ b/target/linux/realtek/dts/rtl930x.dtsi @@ -167,9 +167,11 @@ }; - switchcore@1b000000 { - compatible = "syscon", "simple-mfd"; + switch0: ethernet-switch@1b000000 { + compatible = "realtek,rtl9301-switch", "realtek,otto-switch", "syscon", "simple-mfd"; reg = <0x1b000000 0x10000>; + interrupt-parent = <&intc>; + interrupts = <23 2>; #address-cells = <1>; #size-cells = <1>; @@ -304,14 +306,6 @@ compatible = "realtek,rtl9300-thermal"; #thermal-sensor-cells = <0>; }; - - switch0: ethernet-switch { - compatible = "realtek,rtl9301-switch", "realtek,otto-switch"; - status = "okay"; - - interrupt-parent = <&intc>; - interrupts = <23 2>; - }; }; pinmux@1b000200 { diff --git a/target/linux/realtek/dts/rtl931x.dtsi b/target/linux/realtek/dts/rtl931x.dtsi index 95448ae6fef..a26bfc6d554 100644 --- a/target/linux/realtek/dts/rtl931x.dtsi +++ b/target/linux/realtek/dts/rtl931x.dtsi @@ -194,9 +194,12 @@ }; }; - switchcore@1b000000 { - compatible = "syscon", "simple-mfd"; + switch0: ethernet-switch@1b000000 { + compatible = "realtek,rtl9311-switch", "realtek,otto-switch", "syscon", "simple-mfd"; reg = <0x1b000000 0x10000>; + interrupt-parent = <&gic>; + interrupts = ; + #interrupt-cells = <3>; #address-cells = <1>; #size-cells = <1>; @@ -339,15 +342,6 @@ #pcs-cells = <1>; }; }; - - switch0: ethernet-switch { - compatible = "realtek,rtl9311-switch", "realtek,otto-switch"; - status = "okay"; - - interrupt-parent = <&gic>; - #interrupt-cells = <3>; - interrupts = ; - }; }; pinmux@1b00103c { diff --git a/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c index 6888f86eba1..c4d425b7847 100644 --- a/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c +++ b/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c @@ -976,14 +976,9 @@ static int rtmd_map_ports(struct device *dev) struct rtmd_ctrl *ctrl = dev_get_drvdata(dev); int smi_bus, smi_addr, pn; - struct fwnode_handle *fw_parent __free(fwnode_handle) = fwnode_get_parent(fw_dev); - if (!fw_parent) - return -ENODEV; - - struct fwnode_handle *fw_switch __free(fwnode_handle) = - fwnode_get_named_child_node(fw_parent, "ethernet-switch"); + struct fwnode_handle *fw_switch __free(fwnode_handle) = fwnode_get_parent(fw_dev); if (!fw_switch) - return dev_err_probe(dev, -ENODEV, "%pfwP missing ethernet-switch\n", fw_parent); + return -ENODEV; struct fwnode_handle *fw_ports __free(fwnode_handle) = fwnode_get_named_child_node(fw_switch, "ethernet-ports"); diff --git a/target/linux/realtek/files-6.18/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.18/drivers/net/pcs/pcs-rtl-otto.c index ea1c445289f..b48d7900901 100644 --- a/target/linux/realtek/files-6.18/drivers/net/pcs/pcs-rtl-otto.c +++ b/target/linux/realtek/files-6.18/drivers/net/pcs/pcs-rtl-otto.c @@ -4247,14 +4247,9 @@ static struct rtpcs_serdes *rtpcs_find_serdes(struct rtpcs_ctrl *ctrl, static int rtpcs_map_links(struct device *dev, struct rtpcs_ctrl *ctrl) { struct fwnode_handle *fw_dev = dev_fwnode(dev); - struct fwnode_handle *fw_parent __free(fwnode_handle) = fwnode_get_parent(fw_dev); - if (!fw_parent) - return -ENODEV; - - struct fwnode_handle *fw_switch __free(fwnode_handle) = - fwnode_get_named_child_node(fw_parent, "ethernet-switch"); + struct fwnode_handle *fw_switch __free(fwnode_handle) = fwnode_get_parent(fw_dev); if (!fw_switch) - return dev_err_probe(dev, -ENODEV, "%pfwP missing ethernet-switch\n", fw_parent); + return -ENODEV; struct fwnode_handle *fw_ports __free(fwnode_handle) = fwnode_get_named_child_node(fw_switch, "ethernet-ports");