mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-14 04:28:41 +04:00
Previously, fan control on D-Link DGS-1210-28P/MP switches was handled
by a user-space script (`fan_ctrl.sh`) triggered via cron every 5
minutes due to missing kernel sysfs writable attributes for PWM
frequency and hysteresis.
The `fan_ctrl.sh` contained a string-truncation comparison logic bug
(temp1_input was truncated while PSU_THRESH was not) that kept the fan
locked at a static 156 PWM (61%) rate regardless of temperature.
Also, since hwmon0 (cpu_thermal) appeared, it changed the order of hwmon
devices and broke fan_ctrl.sh PWM control, keeping it always stopped.
With commit 89ef8aaf3e ("kernel: backport lm63 enhancements"),
`pwm1_freq` and `pwm1_auto_point_temp_hyst` are now writable, enabling
full autonomous LUT hardware fan management on the LM63 chip.
Transition to autonomous hardware fan control:
- Configure LM63 Look-up Table (LUT) via `/etc/init.d/hwmon_fancontrol`
using the OEM register settings:
* PWM Frequency: ~7826 Hz (PFR divisor 23)
* Point 1: > 0°C -> PWM 28/46, 155/255 (~60.8% duty cycle)
* Point 2: > 51°C -> PWM 46/46, 255/255 (100% duty cycle)
* Points 3-8: > 127°C -> PWM 255/255 (chip defaults for unused points)
* Hysteresis: 3°C (3000 mC)
- Add `04_dlinkfan_migration` migration script to purge `fan_ctrl.sh` from
crontab during sysupgrade.
The LM63 PWM resolution depends on the PFR divisor setting (2 * PFR).
With PFR set to 23 (matching OEM ~7826 Hz), full scale is 46 (0x2e). The
sysfs interface maps 0-255 to 0-46, meaning the OEM defaults 28 (0x1c)
and 46 (0x2e) translate to sysfs values 155 (~60.8% duty cycle) and 255
(100% duty cycle). Those values match the old fan_ctrl.sh temperature range
and duty cycle.
Fixes: ab3f92e86481 ("realtek: add fan controller support to D-Link DGS-1210-28MP")
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24869
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>