From 8e724fc3b316968d426d5dc9ad312500619c3fd0 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Wed, 20 May 2026 00:30:36 +0200 Subject: [PATCH] realtek: add support for Linksys LGS328MPCv2 Hardware specification ---------------------- * RTL9301 SoC, 1 MIPS 34KEc core @ 800MHz * 512MB DRAM * 2MB NOR Flash * 128MB NAND Flash * 24 x 10/100/1000BASE-T ports with PoE+ * 4 x 10G SFP+ ports * Power LED, Fault LED, PoE Max LED, LAN Mode LED, PoE Mode LED * Reset button and LED Mode button on front panel * LM63 Fan Controller * UART (115200 8N1) via RJ45 * PSE: Nuvoton M0516LDE via I2C + 3x RTL8238B (not supported yet) Installation using serial interface ----------------------------------- 1. Press "a" "c" "p" during message "Enter correct key to stop autoboot" 2. Start network "rtk network on" 3. Load image "tftpboot :openwrt-realtek-rtl930x_nand-linksys_lgs328mpc-v2-initramfs-kernel.bin" 4. Boot image "bootm" 5. Switch to first bootpartition "fw_setsys bootpartition 0" 6. Download sysupgrade "scp :openwrt-realtek-rtl930x_nand-linksys_lgs328mpc-v2-squashfs-sysupgrade.bin /tmp/." 7. Install sysupgrade "sysupgrade /tmp/openwrt-realtek-rtl930x_nand-linksys_lgs328mpc-v2-squashfs-sysupgrade.bin" Installation using OEM webinterface ----------------------------------- This is not possible because the OpenWrt NAND Flash layout is different from the vendor layout. To be precise. Vendor uses: - 64 MB vendor UBI root_data - 32 MB vendor kernel+root 1 (~19 MB used) - 32 MB vendor kernel+root 2 (~19 MB used) OpenWrt uses: - 64 MB vendor UBI (not touched) - 10 MB OpenWrt kernel - 22 MB Openwrt mtd-concat UBI - 23 MB vendor kernel 2 (space reduced, vendor data unchanged) - 09 MB OpenWrt mtd-concat UBI Dual-boot with stock firmware using writable u-boot-env ------------------------------------------------------- From stock to OpenWrt / primary image 1 (CLI as admin): - > boot system image1 - > reboot From OpenWrt to stock / boot image 2: (shell as root) - # fw_setsys bootpartition 1 - # reboot Debrick using serial interface ------------------------------ 1. Press "a" "c" "p" during message "Enter correct key to stop autoboot" 2. Load vendor image with "upgrade runtime :LGS328xxxxx.imag" 3. switch to primary partition "setsys bootpartition 0" 4. safe config "savesys" MAC Address Source ------------------ The MAC address for this device is coming from the u-boot-env ethaddr cell. Further documentation --------------------- See https://openwrt.org/toh/linksys/lgs352c Signed-off-by: Jan-Henrik Bruhn Link: https://github.com/openwrt/openwrt/pull/23466 Signed-off-by: Jonas Jelonek --- .../realtek/base-files/etc/board.d/02_network | 1 + .../base-files/etc/init.d/hwmon_fancontrol | 43 ++++++++++++++++ .../base-files/lib/upgrade/platform.sh | 1 + .../dts/rtl9301_linksys_lgs328mpc-v2.dts | 51 +++++++++++++++++++ target/linux/realtek/image/rtl930x_nand.mk | 9 ++++ 5 files changed, 105 insertions(+) create mode 100644 target/linux/realtek/dts/rtl9301_linksys_lgs328mpc-v2.dts 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 f6ba62a08c2..847b3fc0b51 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -56,6 +56,7 @@ realtek_setup_macs() edgecore,ecs4100-12ph|\ linksys,lgs310c|\ linksys,lgs328c|\ + linksys,lgs328mpc-v2|\ linksys,lgs352c|\ netgear,gs108t-v3|\ netgear,gs110tpp-v1|\ diff --git a/target/linux/realtek/base-files/etc/init.d/hwmon_fancontrol b/target/linux/realtek/base-files/etc/init.d/hwmon_fancontrol index 19e070b7cbe..54c0e0e43ff 100755 --- a/target/linux/realtek/base-files/etc/init.d/hwmon_fancontrol +++ b/target/linux/realtek/base-files/etc/init.d/hwmon_fancontrol @@ -46,6 +46,46 @@ dlink_dgs_1250() { echo 57000 > "$path_temp_hwmon/temp1_max_hyst" } +linksys_lgs328mpc_v2() { + # The U-Boot of this device does not set up the LM63 fan controller for us, so we do it ourselves: + # Let LM63 steer high/low speed full automatically, vendor defaults are 40C low->high and 31C high->low. + # For this, reduce PMW frequency as otherwise the fan won't start at low speeds. + # Temperature point 1 is set to 1C and a hysteresis of 9C gives 1C - 9C = -8C - most likely always on. + # Temperature point 2 is set to 40C and a hysteresis of 9C gives 40C - 9C = 31C. + # Other points must be monotonic for the kernel to accept auto mode. + local path_to_hwmon="$(find /sys/bus/i2c/devices/0-004c/hwmon/ -type d -maxdepth 1 -mindepth 1 -name 'hwmon*')" + + [ -n "$path_to_hwmon" ] || return 0 + + # switch to manual mode, otherwise LUT is not writable + echo 1 > "$path_to_hwmon/pwm1_enable" + # Set PWM Frequency to 22Hz as otherwise the fan doesn't spin at low duty cycles. + echo 22 > "$path_to_hwmon/pwm1_freq" + + echo 1000 > "$path_to_hwmon/pwm1_auto_point1_temp" # 1°C + echo 128 > "$path_to_hwmon/pwm1_auto_point1_pwm" # 50% fan speed + echo 40000 > "$path_to_hwmon/pwm1_auto_point2_temp" # 40°C + echo 255 > "$path_to_hwmon/pwm1_auto_point2_pwm" # 100% fan speed + echo 41000 > "$path_to_hwmon/pwm1_auto_point3_temp" # monotonically increasing entries so the driver accepts this LUT + echo 255 > "$path_to_hwmon/pwm1_auto_point3_pwm" + echo 42000 > "$path_to_hwmon/pwm1_auto_point4_temp" + echo 255 > "$path_to_hwmon/pwm1_auto_point4_pwm" + echo 43000 > "$path_to_hwmon/pwm1_auto_point5_temp" + echo 255 > "$path_to_hwmon/pwm1_auto_point5_pwm" + echo 44000 > "$path_to_hwmon/pwm1_auto_point6_temp" + echo 255 > "$path_to_hwmon/pwm1_auto_point6_pwm" + echo 45000 > "$path_to_hwmon/pwm1_auto_point7_temp" + echo 255 > "$path_to_hwmon/pwm1_auto_point7_pwm" + echo 46000 > "$path_to_hwmon/pwm1_auto_point8_temp" + echo 255 > "$path_to_hwmon/pwm1_auto_point8_pwm" + + # set temperature hysteresis to 9K + echo 9000 > "$path_to_hwmon/pwm1_auto_point_temp_hyst" + + # switch to automatic, LUT driven mode + echo 2 > "$path_to_hwmon/pwm1_enable" +} + boot() { case $(board_name) in plasmacloud,esx28|\ @@ -55,5 +95,8 @@ boot() { d-link,dgs-1250-28x) dlink_dgs_1250 ;; + linksys,lgs328mpc-v2) + linksys_lgs328mpc_v2 + ;; esac } diff --git a/target/linux/realtek/base-files/lib/upgrade/platform.sh b/target/linux/realtek/base-files/lib/upgrade/platform.sh index 549f96d70d2..df128a825f0 100644 --- a/target/linux/realtek/base-files/lib/upgrade/platform.sh +++ b/target/linux/realtek/base-files/lib/upgrade/platform.sh @@ -41,6 +41,7 @@ platform_do_upgrade() { default_do_upgrade "$1" ;; linksys,lgs328c|\ + linksys,lgs328mpc-v2|\ linksys,lgs352c) nand_do_upgrade "$1" ;; diff --git a/target/linux/realtek/dts/rtl9301_linksys_lgs328mpc-v2.dts b/target/linux/realtek/dts/rtl9301_linksys_lgs328mpc-v2.dts new file mode 100644 index 00000000000..7c66067814a --- /dev/null +++ b/target/linux/realtek/dts/rtl9301_linksys_lgs328mpc-v2.dts @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later or MIT) +/dts-v1/; + +#include "rtl9301_linksys_lgs328x_nand_common.dtsi" + +#include +#include + +/ { + compatible = "linksys,lgs328mpc-v2", "realtek,rtl9301-soc"; + model = "Linksys LGS328MPC v2"; + + leds { + compatible = "gpio-leds"; + + led_poe_mode: led-poe-mode { + function = "poe-mode"; + color = ; + gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + }; + + led_poe_max: led-poe-max { + function = "poe-max"; + color = ; + gpios = <&gpio0 19 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + led-mode { + label = "led-mode"; + gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; +}; + +&i2c_mst1 { + i2c1: i2c@1 { + reg = <1>; + + lm63@4c { + compatible = "national,lm63"; + reg = <0x4c>; + #thermal-sensor-cells = <1>; + }; + }; +}; diff --git a/target/linux/realtek/image/rtl930x_nand.mk b/target/linux/realtek/image/rtl930x_nand.mk index 784c3a72bdd..7c068c2600b 100644 --- a/target/linux/realtek/image/rtl930x_nand.mk +++ b/target/linux/realtek/image/rtl930x_nand.mk @@ -28,3 +28,12 @@ define Device/linksys_lgs328c LINKSYS_MODEL := 60412040 endef TARGET_DEVICES += linksys_lgs328c + +define Device/linksys_lgs328mpc-v2 + $(Device/linksys_lgs328) + DEVICE_MODEL := LGS328MPC + DEVICE_VARIANT := v2 + DEVICE_PACKAGES += kmod-hwmon-lm63 + LINKSYS_MODEL := 60412060 +endef +TARGET_DEVICES += linksys_lgs328mpc-v2