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