在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

電源管理入門:Thermal熱管理

yzcdx ? 來源:OS與AUTOSAR研究 ? 2023-11-29 10:09 ? 次閱讀

熱管理(Thermal Management)是什么?

熱管理指的是在電子設備或系統中通過各種方式控制其溫度來保證其正常工作延長壽命的過程。其中包括散熱設計、溫度監測、溫度控制等方面。熱管理的重要性越來越凸顯,尤其在高性能計算人工智能等領域的應用中更為重要。

管理之前要有策略之后要有控制操作

熱設計(Thermal Design)是指在產品設計階段為了滿足特定工作負載和環境條件等要求,采用合適的散熱方案和材料等措施,以達到良好的熱管理效果。其主要目的是確保產品在正常工作條件下溫度不超過設計范圍,避免由于過熱導致的性能下降、系統崩潰、壽命縮短等問題。

熱控(Thermal Control)是指在實際使用中采用各種措施控制電子設備或系統的溫度,以確保其工作在安全、穩定的溫度范圍內。主要包括基于溫度感應器的風扇旋轉控制、電壓和頻率的調整、動態散熱管理等技術。

熱管理、熱設計、熱控三者密不可分,熱設計是熱管理的前置條件,而熱控則是熱管理的具體實現。同時,三者也相互影響,優良的熱設計可以降低需要的熱控次數,有效延長產品壽命。熱控根據具體實際情況,需要根據實際情況進行決策和優化,以達到最佳熱管理效果。

1. Linux中Thermal框架

在 Linux 內核中,Thermal 特指一套關于溫控機制的驅動框架,其目的是為了防止 SoC 等硬件芯片因過熱而造成系統不穩定,甚至縮減芯片壽命。

320397da-8dda-11ee-939d-92fbcf53809c.png320ea332-8dda-11ee-939d-92fbcf53809c.png

Thermal sensor driver,SoC 內部 CPUGPU 的旁邊通常會有用于獲取它們溫度的傳感器,比如 tsadcTemperature Sensor ADC)。關于傳感器的更多細節我們在 sensor driver 章節再進行深入探討。獲取溫度的設備:在 Thermal 框架中被抽象為 Thermal Zone Device;

Thermal cooling device,降溫設備,比如風扇。這里有點特殊的是,CPU 和 GPU 不僅是發熱設備(即需要實施溫控策略的設備),也可以是降溫設備,當我們降低 CPU/GPU 的運行頻率的時候,它們就在充當降溫設備。降低產熱量即是在降溫。

Thermal governer,溫控策略,Linux 內核中的溫控策略要比空調控制精細得多,而且也提供了多種策略。

Thermal core,組織并管理上面三個組件,并通過 sysfs 和用戶空間交互。

32236718-8dda-11ee-939d-92fbcf53809c.png

代碼舉例:

Thermal sensor driver 代碼:
drivers/thermal/rockchip_thermal.c  /* tsadc驅動 */

Thermal cooling device 相關代碼:
drivers/thermal/devfreq_cooling.c
drivers/thermal/cpu_cooling.c

Thermal governor 相關代碼:
drivers/thermal/power_allocator.c    /* power allocator 溫控策略 */
drivers/thermal/step_wise.c              /* step wise 溫控策略 */
drivers/thermal/fair_share.c              /* fair share 溫控策略 */
drivers/thermal/user_space.c            /* userspace 溫控策略 */

Thermal core 相關代碼:
drivers/thermal/thermal_core.c
drivers/thermal/of_thermal.c

相關的節點:/sys/class/thermal
例如使用step_wise溫控策略:323d75b8-8dda-11ee-939d-92fbcf53809c.png

2. sensor driver相關

這部分一般需要自己開發,例如rockchip平臺上

struct rockchip_thermal_sensor {
struct rockchip_thermal_data *thermal;
struct thermal_zone_device *tzd;
int id;
};

struct rockchip_thermal_sensor:RK 平臺上該結構體代表了一個 tsadc;

struct rockchip_thermal_data:見下面的介紹;

struct thermal_zone_device:一個 tsadc 會和一個 thermal zone 綁定;

int id:該 tsadc 的編號,一般來說 RK 的 SoC 內部有兩個 tsadc;

struct rockchip_thermal_data:sensor driver 的私有數據,詳見注釋。RK 的 sensor driver 為了兼容他們家很多 SoC 的 tsadc,把差異性的東西抽出來。比如那些函數指針,由于寄存器地址的不一樣函數體的具體內容也會不一樣,如 RK3399 和 PX30 之間。再比如由于 SoC 制程不一樣,默認的關機溫度也可能不一樣。

3. governor

struct thermal_governor:用來描述一個 governor(即溫控策略) 信息。

內核目前有五種 governor

1、power_allocator:引? PID(?例-積分-微分)控制,根據當前溫度,動態給各 cooling device 分配 power,并將 power 轉換為頻率,從而達到根據溫度限制頻率的效果。

2、step_wise:根據當前溫度,cooling device 逐級降頻。

3、fair share:頻率檔位?較多的 cooling device 優先降頻。

4、bang bang:兩點溫度調節,可用于 cooling device 有風扇的場景。

5、userspace:用戶空間控制。

4. cooling device

嵌入式設備通過改變頻率電壓,來達到改變功耗的目的,cooling_device提供了獲取當前設備的溫控狀態以及設置等接口

325c0776-8dda-11ee-939d-92fbcf53809c.png

struct thermal_cooling_device {
int id;
char type[THERMAL_NAME_LENGTH];
struct device device;
struct device_node *np;
void *devdata;
const struct thermal_cooling_device_ops *ops;
bool updated; /* true if the cooling device does not need update */
struct mutex lock; /* protect thermal_instances list */
struct list_head thermal_instances;
struct list_head node;
};
 
 
struct thermal_cooling_device_ops {
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
int (*get_requested_power) (struct thermal_cooling_device *,
   struct thermal_zone_device *, u32 *);
int (*state2power) (struct thermal_cooling_device *,
   struct thermal_zone_device *, unsigned long, u32 *);
int (*power2state) (struct thermal_cooling_device *,
   struct thermal_zone_device *, u32, unsigned long *);

struct thermal_cooling_device:用來描述一個 cooling device(即降溫設備) 信息,并將函數操作集抽取出來。DTS中配置:

        bind1{
                contribution = <0>;
                trip = <&cpu_trip1>;
                cooling-device
                = <&cpu_budget_cooling 2 2>;
        };
        
       cpu_budget_cooling:cpu_budget_cool{
            compatible = "allwinner,budget_cooling";
            device_type = "cpu_budget_cooling";
            #cooling-cells = <2>;
            status = "okay";
            state_cnt = <7>;
            cluster_num = <1>;
            state0 = <1800000 4>;
            state1 = <1512000 4>;
323d75b8-8dda-11ee-939d-92fbcf53809c.png

5. thermal zone

獲取溫度的設備:在 Thermal 框架中被抽象為 Thermal Zone Device;

struct thermal_zone_device {
int id;
char type[THERMAL_NAME_LENGTH];
struct device device;
struct thermal_attr *trip_temp_attrs;
struct thermal_attr *trip_type_attrs;
struct thermal_attr *trip_hyst_attrs;
void *devdata;
int trips;
unsigned long trips_disabled;/* bitmap for disabled trips */
int passive_delay;
int polling_delay;
int temperature;
int last_temperature;
int emul_temperature;
int passive;
unsigned int forced_passive;
atomic_t need_update;
struct thermal_zone_device_ops *ops;
struct thermal_zone_params *tzp;
struct thermal_governor *governor;
void *governor_data;
struct list_head thermal_instances;
struct idr idr;
struct mutex lock;
struct list_head node;
struct delayed_work poll_queue;
};
 
 
struct thermal_zone_device_ops {
int (*bind) (struct thermal_zone_device *,
     struct thermal_cooling_device *);
int (*unbind) (struct thermal_zone_device *,
       struct thermal_cooling_device *);
int (*get_temp) (struct thermal_zone_device *, int *);
int (*get_mode) (struct thermal_zone_device *,
 enum thermal_device_mode *);
int (*set_mode) (struct thermal_zone_device *,
enum thermal_device_mode);
int (*get_trip_type) (struct thermal_zone_device *, int,
enum thermal_trip_type *);
int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
int (*set_trip_temp) (struct thermal_zone_device *, int, int);// 設置溫度窗口
int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
int (*get_crit_temp) (struct thermal_zone_device *, int *);
int (*set_emul_temp) (struct thermal_zone_device *, int);
int (*get_trend) (struct thermal_zone_device *, int,
  enum thermal_trend *);
int (*notify) (struct thermal_zone_device *, int,
       enum thermal_trip_type);

struct thermal_zone_device:一個 thermal zone 是根據 dts 里的配置一步步解析并構建的,包含了很多信息,比如服務于該 thermal zone 的 tsadc,服務于該 thermal zone 的降溫設備,該 thermal zone 所用的 governor,以及 thermal 機制工作時所需的一些參數,等等。

通常,RK 平臺上 thermal zone 的 dts 配置格式如下。其它平臺應該和這個大同小異,因為都要基于 thermal core 來配置。

thermal_zones: thermal-zones {
/* 一個節點對應一個thermal zone,并包含溫控策略相關參數 */
soc_thermal: soc-thermal {
/* 溫度高于trip-point-0指定的值,每隔20ms獲取一次溫度 */
polling-delay-passive = <20>; /* milliseconds */
/* 溫度低于trip-point-0指定的值,每隔1000ms獲取一次溫度 */
polling-delay = <1000>; /* milliseconds */
/* 溫度等于trip-point-1指定的值時,系統分配給cooling device的能量 */
sustainable-power = <1000>; /* milliwatts */
/* 當前thermal zone通過tsadc0獲取溫度 */
thermal-sensors = <&tsadc 0>;
 
/* trips包含不同溫度閾值,不同的溫控策略,配置不一定相同 */
trips {
/*
 * 溫控閾值,超過該值溫控策略開始工作作,但不一定馬上限制頻率,
 * power小到一定程度才開始限制頻率
 */
threshold: trip-point-0 {
/* 超過70攝氏度,溫控策略開始工作,并且70度也是tsadc觸發中斷的一個閾值 */
temperature = <70000>; /* millicelsius */
/* 溫度低于temperature-hysteresis時觸發中斷,當前未實現,但框架要求必須填 */
hysteresis = <2000>; /* millicelsius */
type = "passive"; /* 表示超過該溫度值時,使用polling-delay-passive */
};
 
/* 溫控目標溫度,期望通過降頻使得芯片不超過該值 */
target: trip-point-1 {
/* 期望通過降頻使得芯片不超過85攝氏度,并且85度也是tsadc觸發中斷的一個閾值 */
temperature = <85000>; /* millicelsius */
/* 溫度低于temperature-hysteresis時觸發中斷,當前未實現,但框架要求必須填 */
hysteresis = <2000>; /* millicelsius */
type = "passive"; /* 表示超過該溫度值時,使用polling-delay-passive */
};
 
/* 過溫保護閾值,如果降頻后溫度仍然上升,那么超過該值后,讓系統重啟 */
soc_crit: soc-crit {
/* 超過115攝氏度重啟,并且115度也是tsadc觸發中斷的一個閾值 */
temperature = <115000>; /* millicelsius */
/* 溫度低于temperature-hysteresis時觸發中斷,當前未實現,但框架要求必須填 */
hysteresis = <2000>; /* millicelsius */
type = "critical"; /* 表示超過該溫度值時,重啟 */
};
};
 
/* cooling device配置節點,每個子節點代表一個cooling device */
cooling-maps {
map0 {
/*
 * 表示在target trip下,該cooling device才起作用,
 * 對于power allocater策略必須填target
 */
trip = <&target>;
/* A53做為cooloing device, THERMAL_NO_LIMIT不起作用,但必須填 */
cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
/* 計算功耗時乘以4096/1024倍,用于調整降頻順序和尺度 */
contribution = <4096>;
};
 
map1 {
/*
 * 表示在target trip下,該cooling device才起作用,
 * 對于power allocater策略必須填target
 */
trip = <&target>;
/* A72做為cooloing device, THERMAL_NO_LIMIT不起作用,但必須填 */
cooling-device = <&cpu_b0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
/* 計算功耗時乘以1024/1024倍,用于調整降頻順序和尺度 */
contribution = <1024>;
};
 
map2 {
/*
 * 表示在target trip下,該cooling device才起作用,
 * 對于power allocater策略必須填target
 */
trip = <&target>;
/* GPU做為cooloing device, THERMAL_NO_LIMIT不起作用,但必須填 */
cooling-device = <&gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
/* 計算功耗時乘以4096/1024倍,用于調整降頻順序和尺度 */
contribution = <4096>;
};
};
};
 
/* 一個節點對應一個thermal zone,并包含溫控策略相關參數,當前thermal zone只用于獲取溫度 */
gpu_thermal: gpu-thermal {
/* 包含溫控策略配置的情況下才起作用,框架要求必須填 */
polling-delay-passive = <100>; /* milliseconds */
/* 每隔1000ms獲取一次溫度 */
polling-delay = <1000>; /* milliseconds */
 
/* 當前thermal zone通過tsadc1獲取溫度 */
thermal-sensors = <&tsadc 1>;
};
};

在probe中完成注冊:

sensor->tz = thermal_zone_of_sensor_register(&pdev->dev,
        id, sensor, &combine_ops);

溫度獲取流程:

sunxi_combine_get_temp //sunxi_ths_combine.c
    -->ret = controller->ops->get_temp(controller,sensor_id, &temp);
sunxi_ths_get_temp  // sunxi_ths_core.c
    -->t = ths_driver_get_temp(ths_data, id);
ths_driver_reg_to_temp(reg_data, id, ths_data->ths_driver_version, ths_data->ths_coefficent->calcular_para); //sunxi_ths_driver.c

6. thermal core

在thermar core作為中樞注冊governor,注冊Thermal類,并且基于Device Tree注冊Thermal Zone;提供Thermal zone注冊函數,Cooling Device注冊函數,提供將Cooling設備綁定到Zone的函數,一個Thermal Zone可以有多個Cooling設備;同時還提供一個核心函數Thermal_zone_deviceupdate作為Thermal中斷處理函數和輪詢函數,輪詢時間會根據不同Trip Delay調節

329a1b6a-8dda-11ee-939d-92fbcf53809c.png

thermal輪詢流程:

在thermal core中通過不斷的輪詢來檢測溫度變化,如果溫度沒有達到crital則調用governor的throttle,通過governor的throttle決定下一次輪詢的時間;如果溫度為crital則走關機流程;

32a8156c-8dda-11ee-939d-92fbcf53809c.png

7. SoC硬件中設計

一般傳感器使用PVT模塊實現,PVTC中會包含多個temperature sensors、Voltage Monitor、Process Detectors PVT包含以下幾種傳感器:

Thermal Sensing(TS):熱傳感,精度高,集成方便。支持功率優化和可靠性

Distributed Thermal Sensing(DTS):分布式熱傳感。支持thermal mapping,高度精細的布放,低延時

Supply Monitoring(VM):供電監控,測量多個域的電源電壓、驗證配電網絡、實施靜態和動態IR壓降分析

Process Monitoring(PD):工藝監控,在大規模量產或者單個芯片生命周期,了解硅片速度變化(slow,fast,typical)。提供功率優化和老化監控

另外一種方式是使用單獨的thermal sensor,通過I2C slave接入MCU核心。CPU核心可以通過I2C讀取穩定,可以防止內部PVT損壞的影響。

后記:

電源管理相關的知識看似不多,但是詳細研究起來,根本研究不完。有時候要做一個件事情,不一定要追求完美,要確定好要做到的程度,比如公司里面調試某個功能,那么就必須研究透徹,但是相關的知識點自學,不需要實際動手調試,那就要了解框架即可,我們不可能什么活都干一遍,但是很多活不干一遍是不能體會其精髓的。確定好度很重要,防止陷入進去,同時防止走馬觀花沒有任何效果的形式主義。

電源管理系列剛開始都是作者參與調試的代碼,后來的就是擴展學習了,雖然不進行代碼調試,但是也力求把框架搞明白,做個記錄。以后或許那天要調試了再拿出來可以看看。

審核編輯:湯梓紅
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 電源管理
    +關注

    關注

    116

    文章

    6267

    瀏覽量

    145570
  • Linux
    +關注

    關注

    87

    文章

    11406

    瀏覽量

    212095
  • 熱管理
    +關注

    關注

    11

    文章

    465

    瀏覽量

    22163
  • 熱設計
    +關注

    關注

    11

    文章

    130

    瀏覽量

    26873

原文標題:電源管理入門-13Thermal 熱管理

文章出處:【微信號:OS與AUTOSAR研究,微信公眾號:OS與AUTOSAR研究】歡迎添加關注!文章轉載請注明出處。

收藏 人收藏

    評論

    相關推薦

    電源管理入門:驅動Runtime PM管理

    Runtime PM管理也就是設備驅動里面的電源管理,即設備驅動結構體里面的struct dev_pm_ops,只控制設備自己的電源。這樣可以在設備不需要工作的時候可以進入到低功耗狀態
    的頭像 發表于 11-29 10:13 ?3896次閱讀
    <b class='flag-5'>電源</b><b class='flag-5'>管理入門</b>:驅動Runtime PM<b class='flag-5'>管理</b>

    電源管理入門:Power Domain管理

    SoC中通常有很多IP,按邏輯可以把幾個相關功能的IP劃為一個電源域。一個電源域內的IP,通常按相同的方式由同一個硬件模塊PMIC供電,電壓一樣并且電源管理例如休眠喚醒一致。
    的頭像 發表于 11-29 10:16 ?4218次閱讀
    <b class='flag-5'>電源</b><b class='flag-5'>管理入門</b>:Power Domain<b class='flag-5'>管理</b>

    電源管理入門-芯片設計中的電源管理介紹

    SCP直接控制SoC的電源和時鐘,而AP通過硬件和軟件接口協同管理
    的頭像 發表于 12-06 09:16 ?3869次閱讀
    <b class='flag-5'>電源</b><b class='flag-5'>管理入門</b>-芯片設計中的<b class='flag-5'>電源</b><b class='flag-5'>管理</b>介紹

    電源管理入門:Hypervisor中的電源管理

    很多時候聽說Hypervisor,但是對底層軟件技術不了解的人感覺挺神秘。本篇文章簡單介紹下Hypervisor的基本概念,另外介紹下電源管理在Hypervisor之上多OS間怎么應用。
    的頭像 發表于 12-06 09:27 ?1841次閱讀
    <b class='flag-5'>電源</b><b class='flag-5'>管理入門</b>:Hypervisor中的<b class='flag-5'>電源</b><b class='flag-5'>管理</b>

    【dln團隊】DR-熱管理

    本帖最后由 wangjiamin2014 于 2015-1-8 11:43 編輯 項目名稱:DR-熱管理團隊名稱:dln團隊成員:董振宇、李雪、乜朝賢作品演示作品介紹為了減小溫度對電子設備壽命
    發表于 12-30 15:21

    功率MOSFET的高效熱管理

    功率MOSFET的高效熱管理
    發表于 02-03 21:16

    微波射頻設計的熱管理有什么影響?

    微波/射頻設計中正確的熱管理需從仔細選擇電子材料開始,而印刷電路板(PCB)又是這些材料中最重要的一種。在大功率、高頻率的電路(如功放)中,熱量可能在放大器中的有源器件周圍積聚起來。為了防止器件結點
    發表于 08-28 07:19

    PCB材料對熱管理有什么影響?

    微波/射頻設計中正確的熱管理需從仔細選擇電子材料開始,而印刷電路板(PCB)又是這些材料中最重要的一種。在大功率、高頻率的電路(如功放)中,熱量可能在放大器中的有源器件周圍積聚起來。為了防止器件結點
    發表于 08-29 06:25

    微型熱管理電源管理怎么解決散熱設計的難題?

    微型散熱管理熱管理電源管理產品能解決半導體行業、光電子行業、消費性行業、汽車行業、工業、醫療行業及國防/航空航天領域中新一代產品中的關鍵設計難題。而嵌入式熱電散熱器(eTEC)和溫
    發表于 03-10 08:06

    電動汽車熱管理系統和性能

    詳情見附件在內燃機車輛中,熱管理系統確保動力傳動系(發動機)、后處理(排氣系統)和空調調節系統的性能,在電動車和混合動力電動汽車中同樣重要,它還與安全和消除里程焦慮相關。熱管理系統(TMS
    發表于 04-23 16:36

    Mouser與Nextreme合作開發用于發電的電源熱管理及能源采集方案

    半導體與電子元器件業頂尖工程設計資源與全球分銷商Mouser Electronics,宣布與Nextreme Thermal Solutions展開合作,為客戶帶來新一代用于發電的電源熱管理及能源采集方案
    發表于 11-17 09:18 ?857次閱讀

    熱管理設計資源

    熱管理設計資源最大限度志提高電源轉換器性能。
    發表于 05-24 17:12 ?0次下載

    熱管理系統建模案例:模型工具、熱管理系統

    大家好,本系列文章的目標是幫助對整車熱管理建模感興趣的朋友更快的了解這個MATLAB 內置的純電車案例:Electric Vehicle Thermal Management (點擊“閱讀原文”,直達這個案例!)
    的頭像 發表于 04-04 16:16 ?2338次閱讀

    熱管理系統建模案例:各個回路的搭建

    大家好,本系列文章的目標是幫助對整車熱管理建模感興趣的朋友更快的了解這個 MATLAB 內置的純電車案例:Electric Vehicle Thermal Management。
    的頭像 發表于 04-13 10:11 ?2428次閱讀

    鴻蒙開發設備管理:ohos.thermal 熱管理

    該模塊提供熱管理相關的接口,包括熱檔位查詢及注冊回調等功能。
    的頭像 發表于 07-05 09:53 ?524次閱讀
    鴻蒙開發設備<b class='flag-5'>管理</b>:ohos.<b class='flag-5'>thermal</b> <b class='flag-5'>熱管理</b>
    主站蜘蛛池模板: 欧美色一级 | 亚洲电影在线 | 777色淫网站女女 | 俄罗斯aaaaa一级毛片 | 在线观看免费视频片 | 精彩视频一区二区三区 | 手机看片自拍自自拍日韩免费 | 激情婷婷六月 | 中文成人在线 | 国产在线视频不卡 | 手机在线看片福利盒子 | 高清不卡一区 | 人人射人人爽 | 777奇米影音| 伊人狠狠丁香婷婷综合色 | 全国男人的天堂网站 | 狠狠色成色综合网 | 天天舔夜夜操 | 尻逼久久| 久久久久久免费播放一级毛片 | 三级网站在线 | 一级一片一a一片 | 激情综合丁香 | 天天舔天天干天天操 | 嫩草影院入口一二三免费 | 一区二区影院 | freesex性欧美炮机喷潮 | 涩涩爱影院 | 亚洲一区二区三区中文字幕 | 中文字幕1区 | 国产精品爱啪在线线免费观看 | 国产三级日本三级美三级 | 一级待一黄aaa大片在线还看 | 国产精品任我爽爆在线播放6080 | 视频网站免费看 | 天天看天天爽 | 婷婷激情亚洲 | 狠狠色噜噜狠狠狠狠米奇7777 | 亚洲国产精品国产自在在线 | 五月综合激情网 | 久久久久综合中文字幕 |