From 01e2184c49c52ac5169207cd9fabf662f50b56b8 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sat, 20 Aug 2022 13:49:52 -0500 Subject: [PATCH] realtek: add support for TP-Link SG2210P Add support for the TP-Link SG2210P switch. This is an RTL8380 based switch with eight RJ-45 ports with 802.3af PoE, and two SFP ports. This device shares the same board with the SG2008P and SG2008. To model this, declare all the capabilities in the sg2xxx dtsi, and disable unpopulated on the lower end models. Specifications: --------------- - SoC: Realtek RTL8380M - Flash: 32 MiB SPI flash (Vendor varies) - RAM: 256 MiB (Vendor varies) - Ethernet: 8x 10/100/1000 Mbps with PoE (all ports) 2x SFP ports - Buttons: 1x "Reset" button on front panel - Power: 53.5V DC barrel jack - UART: 1x serial header, unpopulated - PoE: 2x TI TPS23861 I2C PoE controller Works: ------ - (8) RJ-45 ethernet ports - (2) SFP ports (with caveats) - Switch functions - System LED Not yet enabled: ---------------- - Power-over-Ethernet (driver works, but doesn't enable "auto" mode) - PoE LEDs Enabling SFP ports: ------------------- The SFP port control lines are hardwired, except for tx-disable. These lines are controller by the RTL8231 in shift register mode. There is no driver support for this yet. However, to enable the lasers on SFP1 and SFP2 respectively: echo 0x0510ff00 > /sys/kernel/debug/rtl838x/led/led_p_en_ctrl echo 0x140 > /sys/kernel/debug/rtl838x/led/led_sw_p_ctrl.26 echo 0x140 > /sys/kernel/debug/rtl838x/led/led_sw_p_ctrl.24 Install via serial console/tftp: -------------------------------- The footprints R27 (0201) and R28 (0402) are not populated. To enable serial console, 50 ohm resistors should be soldered -- any value from 0 ohm to 50 ohm will work. R27 can be replaced by a solder bridge. The u-boot firmware drops to a TP-Link specific "BOOTUTIL" shell at 38400 baud. There is no known way to exit out of this shell, and no way to do anything useful. Ideally, one would trick the bootloader into flashing the sysupgrade image first. However, if the image exceeds 6MiB in size, it will not work. The sysupgrade image can also be flashed. To install OpenWrt: Prepare a tftp server with: 1. server address: 192.168.0.146 2. the image as: "uImage.img" Power on device, and stop boot by pressing any key. Once the shell is active: 1. Ground out the CLK (pin 16) of the ROM (U7) 2. Select option "3. Start" 3. Bootloader notes that "The kernel has been damaged!" 4. Release CLK as sson as bootloader thinks image is corrupted. 5. Bootloader enters automatic recovery -- details printed on console 6. Watch as the bootloader flashes and boots OpenWrt. Signed-off-by: Alexandru Gagniuc [OpenWrt capitalisation in commit message] Signed-off-by: Sander Vanheule --- package/boot/uboot-envtools/files/realtek | 1 + .../realtek/base-files/etc/board.d/02_network | 1 + .../base-files/lib/upgrade/platform.sh | 3 ++- .../dts-5.10/rtl8380_tplink_sg2008p-v1.dts | 20 +++++++++++++++++++ .../dts-5.10/rtl8380_tplink_sg2210p-v3.dts | 16 +++++++++++++++ .../dts-5.10/rtl8380_tplink_sg2xxx.dtsi | 14 ++++++++++++- target/linux/realtek/image/rtl838x.mk | 11 ++++++++++ 7 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts diff --git a/package/boot/uboot-envtools/files/realtek b/package/boot/uboot-envtools/files/realtek index 22568afd12..f191503876 100644 --- a/package/boot/uboot-envtools/files/realtek +++ b/package/boot/uboot-envtools/files/realtek @@ -30,6 +30,7 @@ zyxel,gs1900-24hp-v2) ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000" ;; tplink,sg2008p-v1|\ +tplink,sg2210p-v3|\ tplink,sg2452p-v4) idx="$(find_mtd_index u-boot-env)" [ -n "$idx" ] && \ diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index aacbef77b4..1dea2ad5a6 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -40,6 +40,7 @@ hpe,1920-24g) lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1))) ;; tplink,sg2008p-v1|\ +tplink,sg2210p-v3|\ tplink,sg2452p-v4) label_mac=$(get_mac_label) lan_mac="$label_mac" diff --git a/target/linux/realtek/base-files/lib/upgrade/platform.sh b/target/linux/realtek/base-files/lib/upgrade/platform.sh index b39b332063..6faded74b5 100644 --- a/target/linux/realtek/base-files/lib/upgrade/platform.sh +++ b/target/linux/realtek/base-files/lib/upgrade/platform.sh @@ -27,7 +27,8 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in - tplink,sg2008p-v1) + tplink,sg2008p-v1|\ + tplink,sg2210p-v3) tplink_sg2xxx_fix_mtdparts default_do_upgrade "$1" ;; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts index 0fef52984c..bf43e412b1 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts @@ -6,3 +6,23 @@ compatible = "tplink,sg2008p-v1", "realtek,rtl838x-soc"; model = "TP-Link SG2008P v1"; }; + +&tps23861_20 { + status = "disabled"; +}; + +&phy24 { + status = "disabled"; +}; + +&phy26 { + status = "disabled"; +}; + +&port24 { + status = "disabled"; +}; + +&port26 { + status = "disabled"; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts new file mode 100644 index 0000000000..4b0022c388 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "rtl8380_tplink_sg2xxx.dtsi" + +/ { + compatible = "tplink,sg2210p-v3", "realtek,rtl838x-soc"; + model = "TP-Link SG2210P v3"; +}; + +&port24 { + label = "lan-sfp2"; +}; + +&port26 { + label = "lan-sfp1"; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi index 8eb309d8a8..e727a9405a 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi @@ -51,7 +51,13 @@ #address-cells = <1>; #size-cells = <0>; - tps23861@28 { + tps23861_20: tps23861@20 { + compatible = "ti,tps23861"; + reg = <0x20>; + shunt-resistor-micro-ohms = <255000>; + }; + + tps23861_28: tps23861@28 { compatible = "ti,tps23861"; reg = <0x28>; shunt-resistor-micro-ohms = <255000>; @@ -140,6 +146,9 @@ INTERNAL_PHY(13) INTERNAL_PHY(14) INTERNAL_PHY(15) + + INTERNAL_PHY(24) + INTERNAL_PHY(26) }; }; @@ -157,6 +166,9 @@ SWITCH_PORT(9, 7, internal) SWITCH_PORT(8, 8, internal) + SWITCH_SFP_PORT(24, 9, 1000base-x) + SWITCH_SFP_PORT(26, 10, 1000base-x) + port@28 { ethernet = <ðernet0>; reg = <28>; diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk index 3e27576bda..36b19b3cbb 100644 --- a/target/linux/realtek/image/rtl838x.mk +++ b/target/linux/realtek/image/rtl838x.mk @@ -188,6 +188,17 @@ define Device/tplink_sg2008p-v1 endef TARGET_DEVICES += tplink_sg2008p-v1 +define Device/tplink_sg2210p-v3 + SOC := rtl8380 + KERNEL_SIZE := 6m + IMAGE_SIZE := 26m + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := SG2210P + DEVICE_VARIANT := v3 + DEVICE_PACKAGES := kmod-hwmon-tps23861 +endef +TARGET_DEVICES += tplink_sg2210p-v3 + define Device/zyxel_gs1900 SOC := rtl8380 IMAGE_SIZE := 6976k -- 2.30.2