Control speed of fan

The FAN_EN transistor is connected to GPIO3_A0/MAC_TXD2/SPI4_RXD_d.
It’s not a hardware PWM pin, so no hardware speed control.

Workarounds:

  1. Software PWM.
    Do it from the kernel, expose it as software pwm so a real fancontrol program can pick it up.
    Won’t be too heavy – we can lower the frequency to 50Hz or even 10Hz.
    Technically, the current fan control script is a 85.7% PWM at 0.028Hz

  2. Use the 40pin GPIO connector to loopback a real PWM pin to pull the leveler.

  3. Use the GPIO connector from the keyboard to loopback a real PWM pin. Stupidly amusing.

1 Like

I got it working.

Proof of pwm fan ramping up:

Patches uploaded here:

To test fan speed control:

#!/bin/bash
cd /sys/class/pwm/pwmchip0
echo 0 > export
cd pwm0
# 50_000_000ns, 50ms period
echo 50000000 > period
# enable it...
echo 1 > enable
# ramp it...
for i in {20000000,30000000,35000000,40000000,42000000,44000000,46000000,47000000,48000000,49000000,50000000}
do
  echo $i
  echo $i > duty_cycle
  read a
done

Yet pwmconfig doesn’t detect it :joy:
Once we figure it out we can have fancontrol taking over (maybe more advanced fan control? the last steps in the ramps are rather exponential).

PWM-enabled fan control daemon:

Weekend project done in the first night :sunglasses:
Strangely satisfying.

2 Likes

I saw that you did a lot of work adding depreciated pwm-gpio codes.
I would like to know why you didn’t use gpio_fan module?

Also as you have added fan node then why not add thermal trip in dts itself so no need for a python based daemon.

I will give some time to this approach and see if I can get fan to work on kernel level instead of user level.

Thanks for the patches I was looking for the gpio pin used for fan on off.

Some Update :

Because I want pwm_fan instead for speed control, so the first thing to do is to make the system believe there’s an extra pwm.

Nice job on gpio fan, maybe these two can be plugged together?

1 Like

Does the fan have more than 1 speed?

How it’s pwn fan different unless it have multiple speeds?

Yes it does. It’s pwm, so you can have any speed between 0rpm and 6000rpm.