imx8mp: reading temperature in devicetree (trips, heat handling) is ignored

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx8mp: reading temperature in devicetree (trips, heat handling) is ignored

811 Views
s_arendt
Contributor III

imx8 can throttle speed or shut down if it is running above a certain temperature. This temperature should be adjustable in devicetree. But it isn't.

Found that the temperature setting in devicetree is ignored. In thermal_of.c (Kernel) it returns 0 (successful read temperature), but value doesn't match what is in deviceree (checked with dtc). While it reads a modified hystereses, it ignores the changes in temperature (in thermal_of.c).  Tested in Kernel 5.15 (LTS). While in imx8mp.dtsi there are settings of 85000 and 95000 it reads while booting in thermal_of.c (checked with printk) 95000 and 105000 - and I don't know from where!?!

Tested with mainline 5.15. LTS Kernel. Strange enough, if I rename temperature into temperature1 in both thermal_of.c and devicetree the values are correct!

0 Kudos
Reply
5 Replies

791 Views
s_arendt
Contributor III

Thanks for that hint.  I scanned code for this values 95000 and 105000, but couldn't found them - now I know why ;). But wait: imx_thermal.c isn't compiled in my system - just imx8mm_thermal.c ?!?

But there are entries for in devicetree, any reason why they are not used?
I first idea was -  this will be overwritten somehow. But I always thought that the _of files really ready from devicetree - see below:

 

static int thermal_of_populate_trip(struct device_node *np,
    struct thermal_trip *trip)
{
int prop;
int ret;
 
ret = of_property_read_u32(np, "temperature", &prop);

 

0 Kudos
Reply

789 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @s_arendt 

Sorry, i just search wrong file, the correct function should be imx8mp_tmu_get_temp, it read temperature from TMU TRITSR register, you can add printk here to verify the temperature.

devm_thermal_of_zone_register->thermal_of_zone_register->thermal_of_trips_init will read trips node in device tree.
0 Kudos
Reply

709 Views
s_arendt
Contributor III

I am sorry. It sounds logical that trip temp are derived in imx_init_temp_grade(), by -5 and -10K 

 

/*
* Set the critical trip point at 5 °C under max
* Set the passive trip point at 10 °C under max (changeable via sysfs)
*/
data->temp_critical = data->temp_max - (1000 * 5);
data->temp_passive = data->temp_max - (1000 * 10);

 

But the thing is, this imx_thermal.c is never ever compiled and therefore not part of my 5.15 kernel. But it seems that this is exactly how it works ?!? For imx8mp it is only this imx8mm_thermal.c  used, and call me blind - I don't find this section there.  I don't understand this.

0 Kudos
Reply

787 Views
s_arendt
Contributor III

Well, the TRITSR reads the actual temperature, right?
But I couldn't find the place where 95000 and 105000 are injected as trip temperatures in case of an imx8mp.  I couldn't found why and where the trip temperature from devicetree will be overruled. 

As mentioned I renamed in thermal_of_populate_trip() temperature to temperature1 in both devicetree and in thermal_of.c and i will be scanned properly. So it seems np already has been changed before.

Your first explanation sounds good but this file is not in use at all, as it is for imx6,7 only.

And I couldn't found in mainline 5.15: devm_thermal_of_zone_register->thermal_of_zone_register->thermal_of_trips_init ... is this only in NXP Kernels ?

I can workaround with some script to set the temperatures after boot, but as there are this entries in devicetree this looks dirty to me.

0 Kudos
Reply

796 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

The temperature information are read from ocotp/nvmem, you can refer imx_init_temp_grade in drivers/thermal/imx_thermal.c

Zhiming_Liu_0-1716792078409.png

 

0 Kudos
Reply