From f21094809ca233d85d73efdc3b6ef05b2903140b Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy Date: Fri, 22 Nov 2024 01:29:06 +0300 Subject: [PATCH] mediatek: fix pwn fan settings for sinovoip bpi-r3 (v2) Popular bpi-r3 pwm fans like this one https://www.amazon.com/youyeetoo-Barebone-Fan-BPI-R3-Integrated/dp/B0CCCTY8PS will not work properly with current openwrt-23.05/24.10/upstream firmwares. Trying different pwm setting echo $value > /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1 I found: pwm1 value fan rotation speed cpu temperature notes ----------------------------------------------------------------- 0 maximal 31.5 Celsius too noisy 40 optimal 35.2 Celsius no noise hearable 95 minimal above 95 does not rotate 55.5 Celsius ----------------------------------------------------------------- At the moment we have following cooling levels: cooling-levels = <255 96 0>; for cpu-active-low, cpu-active-medium and cpu-active-high modes correspondingly. Thus only cpu-active-high and cpu-active-low are usable. I think this is wrong. This patch fixes cpu-active-medium settings for bpi-r3 board. PS: I know, the patch is not ideal as it can break pwm fan for some users. There are some peoples that use handmade cooling solutions, but: * discussed cooler is the only 'official' pwm cooler for bpi-r3 available on the market. * most peoples will use passive cooling available on the market or the discussed cooler. * the pwm-fan dts section was added before the official cooler appears on the market. Thus it should not be a lot of harm from this fix. This patch may not be enough, users may wants to tweak their thermal_zone0 trip points, thus tuning fan rotation speed depending on cpu temperature. That can be done by editing /etc/rc.local file like this: === /etc/rc.local === # Put your custom commands here that should be executed once # the system init finished. By default this file does nothing. # cpu temterature below 25 Celsius degrees, no rotation echo 25000 > /sys/class/thermal/thermal_zone0/trip_point_4_temp # cpu temperature in [25..32] Celsius degrees, normal rotation speed echo 32000 > /sys/class/thermal/thermal_zone0/trip_point_3_temp # cpu temperature above 50 Celsius degrees, max rotation speed echo 50000 > /sys/class/thermal/thermal_zone0/trip_point_2_temp exit 0 ===================== Changes v2: * put patch to a proper directory * updated patch description * tested with latest openwrt based on linux-6.6 Signed-off-by: Mikhail Kshevetskiy --- ...96-dts-mt7986a-bpi-r3-pwm-fan-cooling-levels.patch | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 target/linux/mediatek/patches-6.6/196-dts-mt7986a-bpi-r3-pwm-fan-cooling-levels.patch diff --git a/target/linux/mediatek/patches-6.6/196-dts-mt7986a-bpi-r3-pwm-fan-cooling-levels.patch b/target/linux/mediatek/patches-6.6/196-dts-mt7986a-bpi-r3-pwm-fan-cooling-levels.patch new file mode 100644 index 00000000000..267c654f350 --- /dev/null +++ b/target/linux/mediatek/patches-6.6/196-dts-mt7986a-bpi-r3-pwm-fan-cooling-levels.patch @@ -0,0 +1,11 @@ +--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +@@ -46,7 +46,7 @@ + compatible = "pwm-fan"; + #cooling-cells = <2>; + /* cooling level (0, 1, 2) - pwm inverted */ +- cooling-levels = <255 96 0>; ++ cooling-levels = <255 40 0>; + pwms = <&pwm 0 10000>; + status = "okay"; + };