RK3399 Thermal (温度控制)
本文采用知識共享署名 4.0 國際許可協(xié)議進行許可,轉(zhuǎn)載時請注明原文鏈接,圖片在使用時請保留全部內(nèi)容,可適當縮放并在引用處附上圖片所在的文章鏈接。
- Thermal 是什么
- 配置?法
- Menuconfig配置
- Tsadc配置
- CPU & GPU配置
- Termal zone 配置
- ??態(tài)接口
- 常用設(shè)置
- 獲取當前溫度
- 關(guān)閉溫度控制功能
- 參考
Thermal 是什么
Thermal是內(nèi)核開發(fā)者定義的?套?持根據(jù)指定governor控制系統(tǒng)溫度,以防?芯?過熱的框架模型。Thermal framework由governor、core、cooling device、sensor driver組成,軟件架構(gòu)如下:
- Thermal governor:?于決定cooling device是否需要降頻,降到什么程度。?前Linux4.4內(nèi)核中包含了如下?種governor:
- power_allocator:引?PID(?例-積分-微分)控制,根據(jù)當前溫度,動態(tài)給各cooling device分配power,并將power轉(zhuǎn)換為頻率,從而達到根據(jù)溫度限制頻率的效果。
- step_wise :根據(jù)當前溫度,cooling device逐級降頻。
- fair share :頻率檔位?較多的cooling device優(yōu)先降頻。
- userspace:不限制頻率。
- Thermal core: 對thermal governors和thermal driver進?了封裝和抽象,并定義了清晰的接口。
- Thermal sensor driver:sensor驅(qū)動,?于獲取溫度,?如tsadc。
- Thermal cooling device:發(fā)熱源或者可以降溫的設(shè)備,?如CPU、GPU、DDR等。
配置?法
Menuconfig配置
<*> Generic Thermal sysfs driver --->--- Generic Thermal sysfs driver[*] APIs to parse thermal data out of device tree[*] Enable writable trip pointsDefault Thermal governor ( power_allocator ) ---> /* default thermal governor */[ ] Fair -share thermal governor[ ] Step_wise thermal governor /* step_wise governor */[ ] Bang Bang thermal governor[*] User_space thermal governor /* user_space governor */-*- Power allocator thermal governor /* power_allocator governor */[*] generic cpu cooling support /* cooling device */[ ] Generic clock cooling support[*] Generic device cooling support /* cooling device */[ ] Thermal emulation mode support< > Temperature sensor driver for Freescale i.MX SoCs<*> Rockchip thermal driver /* thermal sensor driver */< > rk_virtual thermal driver<*> rk3368 thermal driver legacy /* thermal sensor driver */通過“Default Thermal governor”配置項,可以選擇溫控策略,開發(fā)者可以根據(jù)實際產(chǎn)品需求進?修改。
Tsadc配置
Tsadc在溫控中作為thermal sensor,?于獲取溫度,通常需要在DTSI和DTS都做配置。
以RK3399為例,DTSI包括如下配置:
DTS的配置,主要?于選擇通過CRU復(fù)位還是GPIO復(fù)位,低電平復(fù)位還是?電平復(fù)位。需要特別注意的是如果配置成GPIO復(fù)位,硬件上需要否把tsadc輸出引腳連到PMIC的復(fù)位腳,否則只能配置成CRU復(fù)位。
&tsadc {rockchip ,hw -tshut -mode = <1>; /* tshut mode 0:CRU 1:GPIO */rockchip ,hw -tshut -polarity = <1>; /* tshut polarity 0:LOW 1:HIGH */status = "okay" ; };CPU & GPU配置
CPU在溫控中作為cooling device,節(jié)點中需要包含#cooling-cells、dynamic-power-coefficient屬性。
以RK3399為例:
GPU在溫控中作為cooling device,節(jié)點需要包含#cooling-cells屬性和power_model?節(jié)點。
以RK3399為例:
Termal zone 配置
Termal zone節(jié)點主要?于配置溫控策略相關(guān)的參數(shù)并?成對應(yīng)的??態(tài)接口。
以RK3399為例:
??態(tài)接口
??態(tài)接口在/sys/class/thermal/?錄下,具體內(nèi)容和DTSI中thermal zone節(jié)點的配置對應(yīng)。有的平臺thermalzone節(jié)點下只有?個?節(jié)點,對應(yīng)/sys/class/thermal/?錄下也只有thermal_zone0??錄;有的平臺有兩個?節(jié)點,對應(yīng)/sys/class/thermal/?錄下就會有thermal_zone0和thermal_zone1??錄。通過??態(tài)接口可以切換溫控策略,查看當前溫度等。
以RK3399為例?,/sys/class/thermal/thermal_zone0/?錄下包含如下常?的信息:
常用設(shè)置
獲取當前溫度
直接查看??態(tài)接口thermal_zone0或者thermal_zone1?錄下的temp節(jié)點即可。
以RK3399為例,獲取CPU溫度,在串口中輸?如下命令:
獲取GPU溫度,在串口中輸?如下命令:
cat /sys /class /thermal /thermal_zone1 /temp關(guān)閉溫度控制功能
?法?:menuconfig中默認溫控策略設(shè)置為user_space。
<*> Generic Thermal sysfs driver --->--- Generic Thermal sysfs driver[*] APIs to parse thermal data out of device tree[*] Enable writable trip pointsDefault Thermal governor ( user_space ) ---> /* power_allocator 改為user_space */?法?:開機后通過命令關(guān)溫控。
?先,把溫控策略切換到user_space,即把??態(tài)接口下的policy節(jié)點改成user_space;或者把mode設(shè)置成
disabled狀態(tài);然后,解除頻率限制,即將??態(tài)接口下的所有cdev的cur_state設(shè)置為0。
以RK3399為例,策略切換到user_space:
或者把mode設(shè)置成disabled狀態(tài):
echo disabled > /sys /class /thermal /thermal_zone0 /mode解除頻率限制:
/* 具體有多少個cdev ,根據(jù)實際情況修改 */ echo 0 > /sys /class /thermal /thermal_zone0 /cdev0 /cur_state echo 0 > /sys /class /thermal /thermal_zone0 /cdev1 /cur_state echo 0 > /sys /class /thermal /thermal_zone0 /cdev2 /cur_state參考
Thermal開發(fā)指南
總結(jié)
以上是生活随笔為你收集整理的RK3399 Thermal (温度控制)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VS2013各版本序列号
- 下一篇: VS2013好用的插件