How to Read and Control Fan Speed on AML-S905X-CC

PWM fans come with 4 wires:

  1. Ground
  2. Power (3.3V, 5V, 12V)
  3. Tachometer
  4. PWM speed control

Per the GPIO map, there is a convenient header 9J1:

  1. Ground
  2. GPIO (for tach)
  3. 5V

On the 40-pin header, there are 5 hardware PWMs we can use per our PWM guide. We do not want to waste CPU cycles to generate inaccurate PWM via software GPIO bitbanging.

We can hook these up to the fan via female to male jumper wires.

  • pwm-a - Pin 32
  • pwm-ao-a - Pin 11
  • pwm-ao-b-6 - Pin 12
  • pwm-ao-b-9 - Pin 13
  • pwm-e - Pin 33
  • pwm-f - Pin 35

To test with PWM A on pin 33:

sudo ldto enable pwm-a
sudo ldto enable pwm-a-fan

This will create a hwmon device in /sys/class/hwmon/.
The fan speed can be read from the file fan1_input in the hwmon device directory: cat fan1_input
The pwm level (0-255) can be set by the file pwm1 in the hwmon device directory. echo 0 | sudo tee pwm1

To make it permanent:

sudo ldto merge pwm-a
sudo ldto merge pwm-a-fan

From here, you can write userspace software in any language to implement control systems by reading fan1_input and writing to pwm1.

1 Like