Imx8x internal temperature sensors

Hi, I have spent some time trying to come up with a Colibri imx8x cooling fan control. I planned to use the Linux kernel thermal subsystem specified completely in the device tree. Unfortunately I ended up with a user-space controlling script instead. Here is a list of things I stumbled on. Not sure which of them are real issues. I would like to get a second opinion on my findings and maybe provide information for someone trying to do something similar.

  • There are two sensors configured in the dts files
    • <&tsens IMX_SC_R_PMIC_0> in pmic-thermal0 in imx8qxp-colibri.dtsi
      • always stuck at 70000, that is most likely a BUG
    • <&tsens 355> in cpu-thermal0 which corresponds to IMX_SC_R_SYSTEM
  • None of the sensors can be used in multiple thermal zones. The second zone exists but trying to read the content of the /sys/class/thermal/thermal_zoneX/temp results in an error message “invalid argument”
  • The IMX_SC_R_SYSTEM sensor is handled by the kernel in imx_sc_thermal as mentioned here: iMX8(X): Temperature trip points / Linux Thermal Management
    • the driver blindly assumes two trip points in a given order which obscures its behavior from the dts point of view
    • the driver implements temperature trend retrieval imx_sc_thermal_get_trend which does not care about the temperature trend at all. It just checks a passive trip point returning either 0 or THERMAL_TREND_RAISE_FULL or THERMAL_TREND_DROP_FULL which confuses the default step_wise governor when additional trip points for active cooling are added.

Module: Colibri imx8x
Linux kernel: toradex_5.4-2.3.x-imx

Kind regards


Hi @marek.z, sorry for the delay answering this question. You can see here that for the IMX8X there are only two thermal zones defined, and only one of them brings up useful information.
Also, in the description of the thermal driver in the Linux Reference Manual, page 85 it states:

It defines two trip points: critical and passive. Cooling device will take actions to protect
the SoC according to the different trip points that SoC has reached:
• When reaching critical point, cooling device will shut down the system.
• When reaching passive point, cooling device will lower CPU frequency and notify
GPU/VPU to run at a lower frequency.
• When the temperature drops to 10 °C below passive point, cooling device will
release all the cooling actions.

As I understand it, these are the features of the imx thermal driver, and this one controls the DVFS passive cooling for the processor. If you want to control a fan using the same sensor, you could look into adding the fan controller phandle and then add a separate cooling-map inside the pmic-thermal0 zone of the device tree. The kernel documentation has an example on how to do that, and I think it could be worth a try:

As for the trends, I think you are right, the IMX thermal driver only returns RAISE_FULL and DROP_FULL and this could eliminate some intermediate steps in the cooling fan ramp.

Please let us know if you still have problems.
Rafael Beims