realtek: d-link: add support for dgs-1210-28p-f
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>
Wed, 10 Jul 2024 23:20:06 +0000 (20:20 -0300)
committerSander Vanheule <sander@svanheule.net>
Tue, 24 Sep 2024 18:59:50 +0000 (20:59 +0200)
General hardware info:
----------------------

D-Link DGS-1210-28P rev. F1 is a switch with 24 ethernet ports and 4
combo ports, all ports Gbit capable. It is based on a RTL8382 SoC
@500MHz, DRAM 128MB and 32MB flash. 24 ethernet ports are 802.3af/at PoE
capable with a total PoE power budget of 193W.

Power over Ethernet:
--------------------

The PSE hardware consists of three BCM59121 PSE chips, serving 8 ports
each. They are controlled by a Nuvoton MCU.  In order to enable PoE, the
realtek-poe package is required. It is installed by default, but
currently it requires the manual editing of /etc/config/poe. Keep in
mind that the port number assignment does not match on this switch,
alway 8 ports are in reversed order: 8-1, 16-9 and 24-17.

LEDs and Buttons:
-----------------

On stock firmware, the mode button is supposed to switch the LED
indicators of all port LEDs between Link Activity and PoE status. The
currently selected mode is visualized using the respective LEDs. PoE Max
indicates that the maximum PoE budget has been reached.  Since there is
currently no support for this behavior, these LEDs and the mode button
can be used independently.

Serial connection:
------------------
The UART for the SoC (115200 8N1) is available via unpopulated standard
0.1" pin header marked J6. Pin1 is marked with arrow and square.

Pin 1: Vcc 3.3V
Pin 2: Tx
Pin 3: Rx
Pin 4: Gnd

OEM installation from Web Interface:
------------------------------------

    1. Make sure you are booting using OEM in image 2 slot. If not,
       switch to
        image2 using the menus
        System > Firmware Information > Boot from image2
        Tools > reboot
    2. Upload image in vendor firmware via Tools > Backup / Upgrade
        Firmware > image1
    3. Toggle startup image via System > Firmware Information > Boot
       from
        image1
    4. Tools > reboot

Other installation methods not tested, but since the device shares the
board with the DGS-1210-28, the following should work:

Boot initramfs image from U-Boot:
---------------------------------

    1. Press Escape key during `Hit Esc key to stop autoboot` prompt
    2. Press CTRL+C keys to get into real U-Boot prompt
    3. Init network with `rtk network on` command
    4. Load image with `tftpboot 0x8f000000
        openwrt-rtl838x-generic-d-link_dgs-1210-28p-f-initramfs-kernel.bin`
        command
    5. Boot the image with `bootm` command

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/15938
Signed-off-by: Sander Vanheule <sander@svanheule.net>
target/linux/realtek/base-files/etc/board.d/02_network
target/linux/realtek/base-files/etc/uci-defaults/04_dlinkfan
target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28mp-f.dts
target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28p-f.dts [new file with mode: 0644]
target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28p_common.dtsi [new file with mode: 0644]
target/linux/realtek/image/rtl838x.mk

index e856ad7479ac676ca8bb088eec973c57fbc18f02..5073dbcc31e90b81f0a4672bcb9b9221d9379084 100644 (file)
@@ -82,6 +82,10 @@ d-link,dgs-1210-28mp-f)
        ucidef_set_poe 370 "lan8 lan7 lan6 lan5 lan4 lan3 lan2 lan1 lan16 lan15 lan14 lan13 lan12 lan11 lan10 lan9 lan24 lan23
                        lan22 lan21 lan20 lan19 lan18 lan17"
        ;;
+d-link,dgs-1210-28p-f)
+       ucidef_set_poe 193 "lan8 lan7 lan6 lan5 lan4 lan3 lan2 lan1 lan16 lan15 lan14 lan13 lan12 lan11 lan10 lan9 lan24 lan23
+                       lan22 lan21 lan20 lan19 lan18 lan17"
+       ;;
 engenius,ews2910p)
        ucidef_set_poe 60 "$(filter_port_list "$lan_list" "lan9 lan10")"
        ;;
index 1a5fd3606f24c81f1522d221734fc7cd030e8ee2..17cc6494388f25bdb8a9b60a137c3961199bb538 100644 (file)
@@ -7,7 +7,7 @@
 board=$(board_name)
 
 case "$board" in
-d-link,dgs-1210-28mp-f)
+d-link,dgs-1210-28p-f|d-link,dgs-1210-28mp-f)
        # Enable fan control
        FAN_CTRL='/sys/class/hwmon/hwmon0'
        echo 1 > "$FAN_PATH/pwm1_enable"
index 4c20a4ae6e2aa6e54e1ca507a9f3b5aba2418db8..4aa6498b03e93a600a4193afc962e7ef4db3b965 100644 (file)
@@ -5,53 +5,10 @@
 #include "rtl83xx_d-link_dgs-1210_gpio.dtsi"
 #include "rtl83xx_d-link_dgs-1210_gpio_sfp.dtsi"
 #include "rtl8382_d-link_dgs-1210-28_common.dtsi"
+#include "rtl8382_d-link_dgs-1210-28p_common.dtsi"
 
 / {
        compatible = "d-link,dgs-1210-28mp-f", "realtek,rtl8382-soc", "realtek,rtl838x-soc";
        model = "D-Link DGS-1210-28MP F";
 
-       /* LM63 */
-       i2c-gpio-4 {
-               compatible = "i2c-gpio";
-               sda-gpios = <&gpio1 32 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
-               scl-gpios = <&gpio1 31 GPIO_ACTIVE_HIGH>;
-               i2c-gpio,delay-us = <2>;
-               i2c-gpio,scl-open-drain; /* should be replaced by i2c-gpio,scl-has-no-pullup in kernel 6.6 */
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               lm63@4c {
-                       compatible = "national,lm63";
-                       reg = <0x4c>;
-               };
-       };
-};
-
-&leds {
-       link_act {
-               label = "green:link_act";
-               gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
-       };
-
-       poe {
-               label = "green:poe";
-               gpios = <&gpio1 29 GPIO_ACTIVE_LOW>;
-       };
-
-       poe_max {
-               label = "yellow:poe_max";
-               gpios = <&gpio1 27 GPIO_ACTIVE_LOW>;
-       };
-};
-
-&keys {
-       mode {
-               label = "mode";
-               gpios = <&gpio1 30 GPIO_ACTIVE_LOW>;
-               linux,code = <BTN_0>;
-       };
-};
-
-&uart1 {
-       status = "okay";
 };
diff --git a/target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28p-f.dts b/target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28p-f.dts
new file mode 100644 (file)
index 0000000..6cb8db8
--- /dev/null
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "rtl838x.dtsi"
+#include "rtl83xx_d-link_dgs-1210_common.dtsi"
+#include "rtl83xx_d-link_dgs-1210_gpio.dtsi"
+#include "rtl83xx_d-link_dgs-1210_gpio_sfp.dtsi"
+#include "rtl8382_d-link_dgs-1210-28_common.dtsi"
+#include "rtl8382_d-link_dgs-1210-28p_common.dtsi"
+
+/ {
+       compatible = "d-link,dgs-1210-28p-f", "realtek,rtl8382-soc", "realtek,rtl838x-soc";
+       model = "D-Link DGS-1210-28P F";
+};
diff --git a/target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28p_common.dtsi b/target/linux/realtek/dts/rtl8382_d-link_dgs-1210-28p_common.dtsi
new file mode 100644 (file)
index 0000000..8aaa637
--- /dev/null
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/ {
+       /* LM63 */
+       i2c-gpio-4 {
+               compatible = "i2c-gpio";
+               sda-gpios = <&gpio1 32 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+               scl-gpios = <&gpio1 31 GPIO_ACTIVE_HIGH>;
+               i2c-gpio,delay-us = <2>;
+               i2c-gpio,scl-open-drain; /* should be replaced by i2c-gpio,scl-has-no-pullup in kernel 6.6 */
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               lm63@4c {
+                       compatible = "national,lm63";
+                       reg = <0x4c>;
+               };
+       };
+};
+
+&leds {
+       link_act {
+               label = "green:link_act";
+               gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
+       };
+
+       poe {
+               label = "green:poe";
+               gpios = <&gpio1 29 GPIO_ACTIVE_LOW>;
+       };
+
+       poe_max {
+               label = "yellow:poe_max";
+               gpios = <&gpio1 27 GPIO_ACTIVE_LOW>;
+       };
+};
+
+&keys {
+       mode {
+               label = "mode";
+               gpios = <&gpio1 30 GPIO_ACTIVE_LOW>;
+               linux,code = <BTN_0>;
+       };
+};
+
+&uart1 {
+       status = "okay";
+};
index c44e3a74f7ecca7de4d81670c9e5a620aa627d20..c8e1c481ec928004cc45821aad5d761463b3929a 100644 (file)
@@ -75,6 +75,15 @@ define Device/d-link_dgs-1210-28mp-f
 endef
 TARGET_DEVICES += d-link_dgs-1210-28mp-f
 
+define Device/d-link_dgs-1210-28p-f
+  $(Device/d-link_dgs-1210)
+  SOC := rtl8382
+  DEVICE_MODEL := DGS-1210-28P
+  DEVICE_VARIANT := F
+  DEVICE_PACKAGES += realtek-poe kmod-hwmon-lm63
+endef
+TARGET_DEVICES += d-link_dgs-1210-28p-f
+
 # The "IMG-" uImage name allows flashing the iniramfs from the vendor Web UI.
 # Avoided for sysupgrade, as the vendor FW would do an incomplete flash.
 define Device/engenius_ews2910p