SPRACZ5 December 2021 DRA821U , DRA821U-Q1 , DRA829J , DRA829J-Q1 , DRA829V , DRA829V-Q1 , TDA4VM , TDA4VM-Q1
A simple Linux user space script that can be used to scale A72 frequency dynamically based on temperature polling. This requires additional Linux driver/DTS patches. For more information, go the E2E FAQ at this link: https://e2e.ti.com/support/processors/f/791/t/1060764.
#!/bin/bash
threshold=80000
safe=79000
interval=1
ht=false
devmem2 0x688040 w 0x80000001
while :
do
t0=`cat /sys/class/thermal/thermal_zone0/temp`
t1=`cat /sys/class/thermal/thermal_zone1/temp`
t2=`cat /sys/class/thermal/thermal_zone2/temp`
t3=`cat /sys/class/thermal/thermal_zone3/temp`
t4=`cat /sys/class/thermal/thermal_zone4/temp`
echo $t0 $t1 $t2 $t3 $t4
if [ $t0 -gt $threshold ] || [ $t1 -gt $threshold ] || [ $t2 -gt $threshold ] || [ $t3 -gt $threshold ] || [ $t4 -gt $threshold ];
then
if [ "$ht" = false ];
then
echo "on die sensor temperature is higher than $threshold so reducing frequency of A72 to 1GHz"
k3conf set clock 202 2 1000000000
ht=true
fi
else
if [ "$ht" = true ] && [ $t0 -lt $safe ] && [ $t1 -lt $safe ] && [ $t2 -lt $safe ] && [ $t3 -lt $safe ] && [ $t4 -lt $safe ];
then
echo "All are under safe temp so pushing back A72 frequency to 2GHz"
k3conf set clock 202 2 2000000000
ht=false
fi
fi
sleep $interval
done
Parameters:
Threshold and Safe temperatures are in milli-degree centigrade, they can be adjusted accordingly. The script checks whether or not any of the 5 thermal zones are above 80°C. It also check whether or not the condition holds, then reduces A72 frequency to 1 GHz as a thermal mitigation strategy and keeps it at 1GHz until the SoC cools below 79°C, after which it re-enables the 2GHz(Top frequency).
Other method one can employ is the VTM temperature alert feature demonstrated in the RTOS SDK, CSL folder:
pdk*/packages/ti/csl/example/vtm/vtm_pvt_sensor_temp_alert/vtm_sensor_temp_alert.c
This example demonstrates how to set thermal alerts. One can implement mitigation actions upon receipt of temperature alert interrupts.
For example: Change to A72 or other core's frequency using ti_sci calls.