[RFC 2/4] realtek: hpe jg922a: move fans to hwmon

Evan Jobling evan.jobling at mslsc.com.au
Tue Oct 22 03:21:58 PDT 2024


Moving the fans to hwmon.
After rtl8231 init changes this also will fix
the default fan behaviour.

Update device compat to notify users that their fan
behaviour is about to change.

Signed-off-by: Evan Jobling <evan.jobling at mslsc.com.au>
---
 .../base-files/etc/board.d/03_gpio_switches     |  3 ---
 .../base-files/etc/board.d/05_compat-version    | 17 +++++++++++++++++
 .../dts/rtl8380_hpe_1920-8g-poe-180w.dts        | 17 +++++++++++++++++
 target/linux/realtek/image/rtl838x.mk           |  3 +++
 4 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 target/linux/realtek/base-files/etc/board.d/05_compat-version

diff --git a/target/linux/realtek/base-files/etc/board.d/03_gpio_switches b/target/linux/realtek/base-files/etc/board.d/03_gpio_switches
index 1e49d89c64..9c748396dd 100644
--- a/target/linux/realtek/base-files/etc/board.d/03_gpio_switches
+++ b/target/linux/realtek/base-files/etc/board.d/03_gpio_switches
@@ -6,9 +6,6 @@ board_config_update
 board=$(board_name)
 
 case "$board" in
-hpe,1920-8g-poe-180w)
-	ucidef_add_gpio_switch "fan_ctrl" "Fan control" "456" "0"
-	;;
 esac
 
 board_config_flush
diff --git a/target/linux/realtek/base-files/etc/board.d/05_compat-version b/target/linux/realtek/base-files/etc/board.d/05_compat-version
new file mode 100644
index 0000000000..6fd4283ca2
--- /dev/null
+++ b/target/linux/realtek/base-files/etc/board.d/05_compat-version
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+case "$(board_name)" in
+        hpe,1920-8g-poe-180w)
+                ucidef_set_compat_version "1.1"
+                ;;
+esac
+
+board_config_flush
+
+exit 0
+
diff --git a/target/linux/realtek/dts/rtl8380_hpe_1920-8g-poe-180w.dts b/target/linux/realtek/dts/rtl8380_hpe_1920-8g-poe-180w.dts
index 6398e6d034..2c72cba43f 100644
--- a/target/linux/realtek/dts/rtl8380_hpe_1920-8g-poe-180w.dts
+++ b/target/linux/realtek/dts/rtl8380_hpe_1920-8g-poe-180w.dts
@@ -5,6 +5,23 @@
 / {
 	compatible = "hpe,1920-8g-poe-180w", "realtek,rtl838x-soc";
 	model = "HPE 1920-8G-PoE+ 180W (JG922A)";
+
+	gpio_fan_array {
+		compatible = "gpio-fan";
+		target-rpm = <10000>;
+
+		gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
+		gpio-fan,speed-map =    <5000 0>,
+					<8200 1>;
+
+		alarm-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+		#cooling-cells = <2>;
+	};
+};
+
+//set initial GPIO state for fan  as it is reset by rtl8231 init.
+&gpio1 {
+	gpio-output-pin-state  =  <5 1>;
 };
 
 &uart1 {
diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk
index 01397af931..cea459c4c7 100644
--- a/target/linux/realtek/image/rtl838x.mk
+++ b/target/linux/realtek/image/rtl838x.mk
@@ -123,6 +123,9 @@ define Device/hpe_1920-8g-poe-180w
   SOC := rtl8380
   DEVICE_MODEL := 1920-8G-PoE+ 180W (JG922A)
   DEVICE_PACKAGES += realtek-poe
+  DEVICE_COMPAT_MESSAGE := \
+        Fan control switched to hwmon. Default fan behaviour fixed. Your fans will run at max speed unless configured otherwise.
+  DEVICE_COMPAT_VERSION := 1.1
   H3C_DEVICE_ID := 0x00010025
   SUPPORTED_DEVICES += hpe_1920-8g-poe
 endef
-- 
2.39.5




More information about the openwrt-devel mailing list