]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: add support for Linksys LGS328MPCv2 23466/head
authorJan-Henrik Bruhn <git@jhbruhn.de>
Tue, 19 May 2026 22:30:36 +0000 (00:30 +0200)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Tue, 26 May 2026 14:10:07 +0000 (16:10 +0200)
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 <TFTP IP>: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 <IP>: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 <TFTP IP>: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 <git@jhbruhn.de>
Link: https://github.com/openwrt/openwrt/pull/23466
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
target/linux/realtek/base-files/etc/board.d/02_network
target/linux/realtek/base-files/etc/init.d/hwmon_fancontrol
target/linux/realtek/base-files/lib/upgrade/platform.sh
target/linux/realtek/dts/rtl9301_linksys_lgs328mpc-v2.dts [new file with mode: 0644]
target/linux/realtek/image/rtl930x_nand.mk

index f6ba62a08c2106f36693f1acbae084e0ed585f9e..847b3fc0b519e59106ae940340c63bb9e937c744 100644 (file)
@@ -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|\
index 19e070b7cbe694509efd4833f2f3ae1eb8448845..54c0e0e43ff96f053144c2b426c446c9bf876188 100755 (executable)
@@ -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
 }
index 549f96d70d2326a065249ce747cfef10c5caa09c..df128a825f0cd747fde7de2ffb5facb59a58a901 100644 (file)
@@ -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 (file)
index 0000000..7c66067
--- /dev/null
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later or MIT)
+/dts-v1/;
+
+#include "rtl9301_linksys_lgs328x_nand_common.dtsi"
+
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+       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 = <LED_COLOR_ID_GREEN>;
+                       gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_poe_max: led-poe-max {
+                       function = "poe-max";
+                       color = <LED_COLOR_ID_AMBER>;
+                       gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               led-mode {
+                       label = "led-mode";
+                       gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
+                       linux,code = <BTN_0>;
+                       debounce-interval = <60>;
+               };
+       };
+};
+
+&i2c_mst1 {
+       i2c1: i2c@1 {
+               reg = <1>;
+
+               lm63@4c {
+                       compatible = "national,lm63";
+                       reg = <0x4c>;
+                       #thermal-sensor-cells = <1>;
+               };
+       };
+};
index 784c3a72bddd95f5908bddcf6f59edbce09c5158..7c068c2600b45f6e5f24ca5983d4007e2049b521 100644 (file)
@@ -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