realtek: d-link: dgs-1210 remake of the device tree
authorDaniel Groth <flygarn12@gmail.com>
Fri, 12 Aug 2022 18:10:20 +0000 (20:10 +0200)
committerSander Vanheule <sander@svanheule.net>
Sat, 20 Aug 2022 07:02:44 +0000 (09:02 +0200)
I have collected the known information from the dts files we have.
After that I made a new device tree that should work for this whole D-Link
switch family.
This device tree is based on modules where you first select which SoC group
the device belongs to. Then you include the GPIO dtsi file depending on what
hardware your device has, see examples below.
This tree is also expandable for more hardware,
see the part 'Future expansion possibilities' further down.

-------------------------------------------------------------------------------
The device tree now looks like this:
                            ----------------
                            | rtl838x.dtsi |    // Note 1.
                            ----------------
                                    |
                                    |
                    ---------------------------------------
                    | rtl838x_d-link_dgs-1210_common.dtsi | // Note 2.
                    ---------------------------------------
                                |
                                |       --------------
                                |-------| device.dts |      // Note 3.
                                |       --------------
                                |
                -------------------------------------
                | rtl83xx_d-link_dgs-1210_gpio.dtsi |       // Note 4.
                -------------------------------------
                                |
                                |       --------------
                                |-------| device.dts |      // Note 5.
                                        --------------

Note 1; Included in rtl838x_d-link_dgs-1210_common.dtsi.

Note 2; SoC level information and memory mapping. Choose which one to include
in the device dts.

Note 3; At this point dgs-1210-16 will come out here.

Note 4; In this dtsi only common board hardware based on the rtl8231 is found.
No PoE based hardware in this dtsi.
In this dtsi there is no <#include> to above *_common.dtsi.

Note 5; Device dts with only rtl8231 based hardware without PoE will come out
here.

-------------------------------------------------------------------------------
How to set up in dts file:

The device dts will have one of these two <#include> alternatives.

This alternative includes only common features:
<#include "rtl838x_d-link_dgs-1210_common.dtsi">

This alternative includes common and the rtl8231 GPIO (no PoE) features:

<#include "rtl838x_d-link_dgs-1210_common.dtsi">
<#include "rtl83xx_d-link_dgs-1210_gpio.dtsi">

-------------------------------------------------------------------------------
Implementation:

Finally, I also implemented this new family device tree on the current
supported devices:
dgs-1210-10p
dgs-1210-16
dgs-1210-20
dgs-1210-28

The implementation for the dgs-1210-10p is different. I have removed the
information from the rtl8382_d-link_dgs-1210-10p.dts that is already present
in rtl838x_d-link_dgs-1210_common.dtsi.
Since the rest isn't officially probed in the device dts I do not want to
include the rtl83xx_d-link_dgs-1210_gpio.dtsi with dgs-1210-10p.dts.

Since I don't have these devices to test on I have built the original firmware
for each one of these devices before this change and saved the dtb file and
then compared the original dtb file with the dtb file built with this new
device tree.

-------------------------------------------------------------------------------
Future expansion possibilities:

In parallel with the rtl838x_d-link_dgs-1210_common.dtsi in the tree map
we can make a rtl839x_d-link_dgs-1210_common.dtsi to use the rtl839x.dtsi if
the need arises with more devices based on rtl839x soc.

When we have more PoE devices so the hardware map for these gets more clear
we can make a rtl83xx_d-link_dgs-1210_poe.dtsi below
the rtl83xx_d-link_dgs-1210_gpio.dtsi in the tree map.

I looked at the port and switch setup to see if it could be moved to the dtsi.
I decided not to touch this part now. The reason was that there isn't really
any meaningful way this could be shared between the devices.
The only thing in common over the family is the 8+2sfp ports on the
dgs-1210-10xx device.
And then there is the hot plug SFP and I2C ports that aren’t implemented
on any device. So maybe when we see the whole port map for the family
then maybe the ports can be moved to a *_common.dtsi but I don't think it is
the right moment for that now.

Signed-off-by: Daniel Groth <flygarn12@gmail.com>
[Capitalisation of abbreviations and 'D-Link']
Signed-off-by: Sander Vanheule <sander@svanheule.net>
target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-10p.dts
target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-16.dts
target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-20.dts
target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210-28.dts
target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi [deleted file]
target/linux/realtek/dts-5.10/rtl838x_d-link_dgs-1210_common.dtsi [new file with mode: 0644]
target/linux/realtek/dts-5.10/rtl83xx_d-link_dgs-1210_gpio.dtsi [new file with mode: 0644]

index 3321887c9a5b13cff154659126f7ce60362a6751..e57197d55c825966833869640241f54d7d542124 100644 (file)
@@ -1,38 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "rtl838x.dtsi"
-
-#include <dt-bindings/input/input.h>
-#include <dt-bindings/gpio/gpio.h>
+#include "rtl838x_d-link_dgs-1210_common.dtsi"
 
 / {
        compatible = "d-link,dgs-1210-10p", "realtek,rtl838x-soc";
        model = "D-Link DGS-1210-10P";
 
-       aliases {
-               led-boot = &led_power;
-               led-failsafe = &led_power;
-               led-running = &led_power;
-               led-upgrade = &led_power;
-       };
-
-       memory@0 {
-               device_type = "memory";
-               reg = <0x0 0x8000000>;
-       };
-
-       leds {
-               pinctrl-names = "default";
-               pinctrl-0 = <&pinmux_disable_sys_led>;
-               compatible = "gpio-leds";
-
-               led_power: power {
-                       // GPIO 0 seems to provide power to the leds
-                       label = "green:power";
-                       gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
-               };
-       };
-
        keys {
                compatible = "gpio-keys-polled";
                poll-interval = <20>;
        };
 };
 
-
-&spi0 {
-       status = "okay";
-       flash@0 {
-               compatible = "jedec,spi-nor";
-               reg = <0>;
-               spi-max-frequency = <10000000>;
-
-               partitions {
-                       compatible = "fixed-partitions";
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-
-                       partition@0 {
-                               label = "u-boot";
-                               reg = <0x00000000 0x80000>;
-                               read-only;
-                       };
-                       partition@80000 {
-                               label = "u-boot-env";
-                               reg = <0x00080000 0x40000>;
-                               read-only;
-                       };
-                       partition@c0000 {
-                               label = "u-boot-env2";
-                               reg = <0x000c0000 0x40000>;
-                       };
-                       partition@280000 {
-                               label = "firmware";
-                               compatible = "denx,uimage";
-                               reg = <0x00100000 0xd80000>;
-                       };
-                       partition@be80000 {
-                               label = "kernel2";
-                               reg = <0x00e80000 0x180000>;
-                       };
-                       partition@1000000 {
-                               label = "sysinfo";
-                               reg = <0x01000000 0x40000>;
-                       };
-                       partition@1040000 {
-                               label = "rootfs2";
-                               reg = <0x01040000 0xc00000>;
-                       };
-                       partition@1c40000 {
-                               label = "jffs2";
-                               reg = <0x01c40000 0x3c0000>;
-                       };
-               };
-       };
-};
-
 &uart1 {
        status = "okay";
 };
index ac51185ed034589d5757026d70e8cc347ebf5fb5..28c64c2ab4f43e0774928100f862eba09eb17fcb 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "rtl8382_d-link_dgs-1210.dtsi"
+#include "rtl838x_d-link_dgs-1210_common.dtsi"
 
 / {
        compatible = "d-link,dgs-1210-16", "realtek,rtl838x-soc";
index cd495bc343df88c5bca4cf6f77c4fa6b2fa1d020..f96f08db29e95f043a149ae77388ecd5eac02f83 100644 (file)
@@ -1,34 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "rtl8382_d-link_dgs-1210.dtsi"
+#include "rtl838x_d-link_dgs-1210_common.dtsi"
+#include "rtl83xx_d-link_dgs-1210_gpio.dtsi"
 
 / {
        compatible = "d-link,dgs-1210-20", "realtek,rtl838x-soc";
        model = "D-Link DGS-1210-20";
-
-       gpio-restart {
-               compatible = "gpio-restart";
-               gpios = <&gpio1 34 GPIO_ACTIVE_LOW>;
-               open-source;
-       };
-
-       keys {
-               compatible = "gpio-keys-polled";
-               poll-interval = <20>;
-
-               reset {
-                       label = "reset";
-                       gpios = <&gpio1 33 GPIO_ACTIVE_LOW>;
-                       linux,code = <KEY_RESTART>;
-               };
-       };
-
-       gpio1: rtl8231-gpio {
-               compatible = "realtek,rtl8231-gpio";
-               #gpio-cells = <2>;
-               gpio-controller;
-               indirect-access-bus-id = <0>;
-       };
 };
 
 &ethernet0 {
index a73e19e16f05bd5f4e80f4f2363947b1180f3715..a4a450cc09160f56526f67a3fd53a8f8fe1402ef 100644 (file)
@@ -1,34 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "rtl8382_d-link_dgs-1210.dtsi"
+#include "rtl838x_d-link_dgs-1210_common.dtsi"
+#include "rtl83xx_d-link_dgs-1210_gpio.dtsi"
 
 / {
        compatible = "d-link,dgs-1210-28", "realtek,rtl838x-soc";
        model = "D-Link DGS-1210-28";
-
-       gpio-restart {
-               compatible = "gpio-restart";
-               gpios = <&gpio1 34 GPIO_ACTIVE_LOW>;
-               open-source;
-       };
-
-       keys {
-               compatible = "gpio-keys-polled";
-               poll-interval = <20>;
-
-               reset {
-                       label = "reset";
-                       gpios = <&gpio1 33 GPIO_ACTIVE_LOW>;
-                       linux,code = <KEY_RESTART>;
-               };
-       };
-
-       gpio1: rtl8231-gpio {
-               compatible = "realtek,rtl8231-gpio";
-               #gpio-cells = <2>;
-               gpio-controller;
-               indirect-access-bus-id = <0>;
-       };
 };
 
 &ethernet0 {
diff --git a/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi b/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi
deleted file mode 100644 (file)
index 565ba45..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-
-#include "rtl838x.dtsi"
-
-#include <dt-bindings/input/input.h>
-#include <dt-bindings/gpio/gpio.h>
-
-/ {
-       aliases {
-               led-boot = &led_power;
-               led-failsafe = &led_power;
-               led-running = &led_power;
-               led-upgrade = &led_power;
-       };
-
-       memory@0 {
-               device_type = "memory";
-               reg = <0x0 0x8000000>;
-       };
-
-       leds {
-               pinctrl-names = "default";
-               pinctrl-0 = <&pinmux_disable_sys_led>;
-
-               compatible = "gpio-leds";
-
-               led_power: power {
-                       label = "green:power";
-                       gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
-               };
-       };
-};
-
-&gpio0 {
-       indirect-access-bus-id = <0>;
-};
-
-&spi0 {
-       status = "okay";
-       flash@0 {
-               compatible = "jedec,spi-nor";
-               reg = <0>;
-               spi-max-frequency = <10000000>;
-
-               partitions {
-                       compatible = "fixed-partitions";
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-
-                       partition@0 {
-                               label = "u-boot";
-                               reg = <0x00000000 0x80000>;
-                               read-only;
-                       };
-                       partition@80000 {
-                               label = "u-boot-env";
-                               reg = <0x00080000 0x40000>;
-                       };
-                       partition@c0000 {
-                               label = "board-name";
-                               reg = <0x000c0000 0x40000>;
-                       };
-                       partition@280000 {
-                               label = "firmware";
-                               compatible = "denx,uimage";
-                               reg = <0x00100000 0xd80000>;
-                       };
-                       partition@be80000 {
-                               label = "kernel2";
-                               reg = <0x00e80000 0x180000>;
-                       };
-                       partition@1000000 {
-                               label = "sysinfo";
-                               reg = <0x01000000 0x40000>;
-                       };
-                       partition@1040000 {
-                               label = "rootfs2";
-                               reg = <0x01040000 0xc00000>;
-                       };
-                       partition@1c40000 {
-                               label = "jffs2";
-                               reg = <0x01c40000 0x3c0000>;
-                       };
-               };
-       };
-};
diff --git a/target/linux/realtek/dts-5.10/rtl838x_d-link_dgs-1210_common.dtsi b/target/linux/realtek/dts-5.10/rtl838x_d-link_dgs-1210_common.dtsi
new file mode 100644 (file)
index 0000000..c1deff4
--- /dev/null
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "rtl838x.dtsi"
+
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       memory@0 {
+               device_type = "memory";
+               reg = <0x0 0x8000000>;
+       };
+
+       leds: leds {
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinmux_disable_sys_led>;
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "green:power";
+                       gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+&gpio0 {
+       indirect-access-bus-id = <0>;
+};
+
+&spi0 {
+       status = "okay";
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x00000000 0x80000>;
+                               read-only;
+                       };
+                       partition@80000 {
+                               label = "u-boot-env";
+                               reg = <0x00080000 0x40000>;
+                       };
+                       partition@c0000 {
+                               label = "board-name";
+                               reg = <0x000c0000 0x40000>;
+                       };
+                       partition@280000 {
+                               label = "firmware";
+                               compatible = "denx,uimage";
+                               reg = <0x00100000 0xd80000>;
+                       };
+                       partition@be80000 {
+                               label = "kernel2";
+                               reg = <0x00e80000 0x180000>;
+                       };
+                       partition@1000000 {
+                               label = "sysinfo";
+                               reg = <0x01000000 0x40000>;
+                       };
+                       partition@1040000 {
+                               label = "rootfs2";
+                               reg = <0x01040000 0xc00000>;
+                       };
+                       partition@1c40000 {
+                               label = "jffs2";
+                               reg = <0x01c40000 0x3c0000>;
+                       };
+               };
+       };
+};
diff --git a/target/linux/realtek/dts-5.10/rtl83xx_d-link_dgs-1210_gpio.dtsi b/target/linux/realtek/dts-5.10/rtl83xx_d-link_dgs-1210_gpio.dtsi
new file mode 100644 (file)
index 0000000..b1477aa
--- /dev/null
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/ {
+       gpio-restart {
+               compatible = "gpio-restart";
+               gpios = <&gpio1 34 GPIO_ACTIVE_LOW>;
+               open-source;
+       };
+
+       keys: keys {
+               compatible = "gpio-keys-polled";
+               poll-interval = <20>;
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio1 33 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+       };
+
+       gpio1: rtl8231-gpio {
+               compatible = "realtek,rtl8231-gpio";
+               #gpio-cells = <2>;
+               gpio-controller;
+               indirect-access-bus-id = <0>;
+       };
+};