I am on a custom board using an i.MX6. I am using Yocto (Pyro) to build my kernel (4.14.16).

I am using the generic imx6qdl.dtsi device tree entry for PWM2 to drive the fan and it appears to work fine. The fan has a Tachometer input, which is connected to GPIO2_7. How do I read the fan speed? I have seen device tree blobs for cooling devices, but none of the examples seem to have a tachometer to monitor the fan's speed.

  • Have you checked /sys/class/hwmon/ (and /sys/class/pwm/)? I'm guessing yes, but just want to be sure there isn't an easy solution there. – derobert Mar 8 '19 at 20:53
  • I did. I could set the PWM for the fan from the /sys/class/pwm/ but there was no mechanism to read back the speed (just the PWM that i had set it to). All that I have in /sys/class/hwmon were temperature sensors. – Eskimoalva Mar 11 '19 at 12:23

I was unable to find a device tree solution, but found enough code snippets to make an application to read it. Basically I just set up an interrupt on the GPIO and used clock_gettime to measure the period between edges. It requires a lot of filtering, but I am only using it to make sure the fan is running so that is fine.

  • BTW, might be easier to count interrupts instead, and e.g., read your counter once per second (having your read thread sleep). Then you probably won't need filtering. – derobert Mar 11 '19 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.