Fan speed on upstream OpenWrt

Was this driver ever upstreamed?

https://ten64doc.traverse.com.au/hardware/fan-control/#fan-control-in-linux

I need to buckle down and learn the OpenWrt build system, but is the emc2301 easily added as a kernel package to the upstream tree?

I note I am on OpenWrt 23.05.2 r23630-842932a63d which is more out of date than I thought.

I tried, but there were various issues to work through, so it went down to the bottom of my priority list :frowning:

In kernel 6.1 and later there is an “emc2305” driver that was submitted by someone at Mellanox (NVIDIA).
(Around the same time I was working on re-writing and polishing my driver for upstream submission, but they got in ahead of me)

This driver does not have any device tree bindings which means it can’t be automatically linked to the thermal zone on the CPU.

At the time the device tree maintainers wanted someone to specify a fan binding definition so that every other fan control driver would not be re-inventing it. They are 100% correct, but it’s just a bit too much work for someone who isn’t working on Linux device drivers every day.

A fan dt-binding has finally been merged in recently so I might revisit it.

If you use mainline OpenWrt, you can compile our hwmon driver package with the SDK, using the instructions here.

Good to hear from you again Matt.

I definitely got tangled up trying to use the SDK, and then ran into the other kernel bug. I will retry once I can find the SDK that matches my current kernel.

I have added a note about the mainline emc2305 driver to the manual.

The bad news is that it automatically turns off the fans when it loads… eek!
I think this is because it uses a different method (PWM % rather than RPM, which is what we have always used), anyway, I will try and submit a patch to fix it. The other features will take more time to upstream.

As mentioned the mainline driver only works on a PWM % level. As a guide, 50% (128) is returning roughly 3000rpm.

If anyone does need to use it, make sure you set the fan speed immediately after loading the module:

# Turn fan to full speed
$ echo 255 > /sys/class/hwmon/hwmon4/pwm1
$ cat /sys/class/hwmon/hwmon4/fan1_input
5228

# Turn fan to "half" speed (~3000 RPM)
$ echo 128 > /sys/class/hwmon/hwmon4/pwm1
$ cat /sys/class/hwmon/hwmon4/fan1_input
3062