[linux thermal] thermal device tree

thermal device tree

本文kernel版本:4.14
由于各个厂商在thermal governor和硬件上的差异(sensor的排布不同),thermal zone中的温度sensor、cooling devices的设备树配置也有所不同。kernel document总结了几种thermal zone设备树配置示例。

1、cpu thermal zone

thermal zone包含一个温度sensor和若干cooling devices的情况

#include <dt-bindings/thermal/thermal.h>

/*cpufreq cooling device-passive被动冷却*/
cpus {
	/*
	 * Here is an example of describing a cooling device for a DVFS
	 * capable CPU. The CPU node describes its four OPPs.
	 * The cooling states possible are 0..3, and they are
	 * used as OPP indexes. The minimum cooling state is 0, which means
	 * all four OPPs can be available to the system. The maximum
	 * cooling state is 3, which means only the lowest OPPs (198MHz@0.85V)
	 * can be available in the system.
	 */
    /*  */
	cpu0: cpu@0 {
		...
		operating-points = <
			/* kHz    uV */
			970000  1200000
			792000  1100000
			396000  950000
			198000  850000
		>;
		cooling-min-level = <0>;/* 说明四组OPPs都可用 */
		cooling-max-level = <3>;/* 说明OPPs中只有频率最低的那一组可用(198MHz@0.85V) */
		#cooling-cells = <2>; /* min followed by max */
	};
	...
};

/*风扇控制器-active主动冷却*/
/*一个通过i2c总线1控制的风扇设备fan0,地址0x48,有10个冷却等级*/
&i2c1 {
	...
	/*
	 * A simple fan controller which supports 10 speeds of operation
	 * (represented as 0-9).
	 */
	fan0: fan@0x48 {
		...
		cooling-min-level = <0>;
		cooling-max-level = <9>;/* 10 cooling states */
		#cooling-cells = <2>; /* min followed by max */
	};
};

/*温度传感器IC*/
/*ADC sensor(bandgap0),地址0x0000ED00,用来监视'cpu-thermal'的温度*/
ocp {
	...
	/*
	 * A simple IC with a single bandgap temperature sensor.
	 */
	bandgap0: bandgap@0x0000ED00 {
		...
		#thermal-sensor-cells = <0>;
	};
};

thermal-zones {
	cpu_thermal: cpu-thermal {
		polling-delay-passive = <250>; /* milliseconds */
		polling-delay = <1000>; /* milliseconds */

		thermal-sensors = <&bandgap0>;

		trips {
			cpu_alert0: cpu-alert0 {
				temperature = <90000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "active";
			};
			cpu_alert1: cpu-alert1 {
				temperature = <100000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			};
			cpu_crit: cpu-crit {
				temperature = <125000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "critical";
			};
		};

		cooling-maps {
			map0 {
				trip = <&cpu_alert0>;
				cooling-device = <&fan0 THERMAL_NO_LIMIT 4>;/* 温度超过cpu_alert0时,等级0-4 */
			};
			map1 {
				trip = <&cpu_alert1>;
				cooling-device = <&fan0 5 THERMAL_NO_LIMIT>;/* 温度超过cpu_alert1时,等级5-9 */ 
			};
			map2 {
				trip = <&cpu_alert1>;
				cooling-device =
				    <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;/* 所有冷却等级都可以用在cpu_alert1上,即温度在alert1-alert2之间,所有冷却等级可用 */
			};
		};
	};
};

2、IC with several internal sensors

每个sensor对应一个thermal zone的情况。
硬件排布上,这三个sensor分别放置在芯片中的不同位置,可以监视不同的热点温度。
bandgap0监视CPU thermal zone; bandgap1监视GPU thermal zone; bandgap2监视DSP thermal zone。
它们有各自的延时、trips和cooling maps。

#include <dt-bindings/thermal/thermal.h>

ocp {
	...
	/*
	 * A simple IC with several bandgap temperature sensors.
	 */
	bandgap0: bandgap@0x0000ED00 {
		...
		#thermal-sensor-cells = <1>;
	};
};

thermal-zones {
	cpu_thermal: cpu-thermal {
		polling-delay-passive = <250>; /* milliseconds */
		polling-delay = <1000>; /* milliseconds */

				/* sensor       ID */
		thermal-sensors = <&bandgap0     0>;

		trips {
			/* each zone within the SoC may have its own trips */
			cpu_alert: cpu-alert {
				temperature = <100000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			};
			cpu_crit: cpu-crit {
				temperature = <125000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "critical";
			};
		};

		cooling-maps {
			/* each zone within the SoC may have its own cooling */
			...
		};
	};

	gpu_thermal: gpu-thermal {
		polling-delay-passive = <120>; /* milliseconds */
		polling-delay = <1000>; /* milliseconds */

				/* sensor       ID */
		thermal-sensors = <&bandgap0     1>;

		trips {
			/* each zone within the SoC may have its own trips */
			gpu_alert: gpu-alert {
				temperature = <90000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			};
			gpu_crit: gpu-crit {
				temperature = <105000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "critical";
			};
		};

		cooling-maps {
			/* each zone within the SoC may have its own cooling */
			...
		};
	};

	dsp_thermal: dsp-thermal {
		polling-delay-passive = <50>; /* milliseconds */
		polling-delay = <1000>; /* milliseconds */

				/* sensor       ID */
		thermal-sensors = <&bandgap0     2>;

		trips {
			/* each zone within the SoC may have its own trips */
			dsp_alert: dsp-alert {
				temperature = <90000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			};
			dsp_crit: gpu-crit {
				temperature = <135000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "critical";
			};
		};

		cooling-maps {
			/* each zone within the SoC may have its own cooling */
			...
		};
	};
};

3、Several sensors within one single thermal zone

一个thermal zone对应多个sensor的情况。
假设这里有两个sensor,一个在cpu内部,一个在靠近cpu的位置。该thermal zone的温度变化由这两个sensor共同决定。

#include <dt-bindings/thermal/thermal.h>

&i2c1 {
	...
	/*
	 * A simple IC with a single temperature sensor.
	 */
	adc: sensor@0x49 {
		...
		#thermal-sensor-cells = <0>;
	};
};

ocp {
	...
	/*
	 * A simple IC with a single bandgap temperature sensor.
	 */
	bandgap0: bandgap@0x0000ED00 {
		...
		#thermal-sensor-cells = <0>;
	};
};

thermal-zones {
	cpu_thermal: cpu-thermal {
		polling-delay-passive = <250>; /* milliseconds */
		polling-delay = <1000>; /* milliseconds */

		thermal-sensors = <&bandgap0>,	/* cpu */
				  <&adc>;	/* pcb north */

		/* hotspot = 100 * bandgap - 120 * adc + 484 */
		coefficients =		<100	-120	484>;

		trips {
			...
		};

		cooling-maps {
			...
		};
	};
};

4、board thermal

一个thermal zone有多个sensor和cooling device的情况。
电池的thermal zone对应sensor adc_dummy4
board的thermal zone对应sensor adc_dummy0、1、2

#include <dt-bindings/thermal/thermal.h>

&i2c1 {
	...
	/*
	 * An IC with several temperature sensor.
	 */
	adc_dummy: sensor@0x50 {
		...
		#thermal-sensor-cells = <1>; /* sensor internal ID */
	};
};

thermal-zones {
	batt-thermal {
		polling-delay-passive = <500>; /* milliseconds */
		polling-delay = <2500>; /* milliseconds */

				/* sensor       ID */
		thermal-sensors = <&adc_dummy     4>;

		trips {
			...
		};

		cooling-maps {
			...
		};
	};

	board_thermal: board-thermal {
		polling-delay-passive = <1000>; /* milliseconds */
		polling-delay = <2500>; /* milliseconds */

				/* sensor       ID */
		thermal-sensors = <&adc_dummy     0>, /* pcb top edge */
				  <&adc_dummy     1>, /* lcd */
				  <&adc_dummy     2>; /* back cover */
		/*
         * 三个sensor的线性对应关系:
		 * An array of coefficients describing the sensor
		 * linear relation. E.g.:
		 * z = c1*x1 + c2*x2 + c3*x3
		 */
		coefficients =		<1200	-345	890>;

		sustainable-power = <2500>;

		trips {
			/* Trips are based on resulting linear equation */
			cpu_trip: cpu-trip {
				temperature = <60000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			};
			gpu_trip: gpu-trip {
				temperature = <55000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			}
			lcd_trip: lcp-trip {
				temperature = <53000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "passive";
			};
			crit_trip: crit-trip {
				temperature = <68000>; /* millicelsius */
				hysteresis = <2000>; /* millicelsius */
				type = "critical";
			};
		};

		cooling-maps {
			map0 {
				trip = <&cpu_trip>;
				cooling-device = <&cpu0 0 2>;
				contribution = <55>;
			};
			map1 {
				trip = <&gpu_trip>;
				cooling-device = <&gpu0 0 2>;
				contribution = <20>;
			};
			map2 {
				trip = <&lcd_trip>;
				cooling-device = <&lcd0 5 10>;
				contribution = <15>;
			};
		};
	};
};

参考链接:https://elixir.bootlin.com/linux/v4.14.262/source/Documentation/devicetree/bindings/thermal/thermal.txt

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Linux thermal是一个用于管理系统温度的子系统。它可以监测系统的温度,并根据需要调整风扇转速或者降低CPU频率等措施来控制温度。这个子系统可以通过/sys/class/thermal目录下的文件进行配置和控制。在Linux系统中,thermal子系统是非常重要的,它可以保证系统的稳定性和可靠性。 ### 回答2: Linux thermal(温度)是Linux内核中的一个子系统,用于监测和管理硬件设备的温度。在计算机系统中,温度是一个非常重要的参数,因为过高的温度可能会导致硬件故障、性能下降甚至损坏。 Linux thermal子系统通过不同的方式来获取硬件的温度信息。例如,它可以通过传感器来读取处理器、显卡、硬盘等设备的温度数据。这些传感器通常嵌入在硬件设备中,并通过总线接口(如I2C)与计算机系统连接。 一旦获取到硬件设备的温度数据,Linux thermal子系统会根据预先设置的策略来采取相应的措施。例如,它可以通过调整风扇转速来降低设备的温度。它还可以通过降低处理器频率来减少能量消耗和温度。 此外,Linux thermal子系统还提供了用户空间接口,允许用户查询和控制温度相关的信息。用户可以使用命令行工具或编写脚本来监控和调整硬件设备的温度状态。 总之,Linux thermalLinux内核中的一个重要子系统,用于监控和管理硬件设备的温度。它通过传感器获取温度数据,并根据预先设置的策略来调整硬件设备的工作状态,以保持温度在可接受的范围内。这对于确保计算机系统的性能和可靠性非常重要。 ### 回答3: Linux thermalLinux 热管理系统)是Linux操作系统中的一个功能,旨在监测和管理计算机硬件的温度,在温度升高时采取适当的措施来保护硬件免受损坏。 Linux thermal通过硬件传感器监测计算机中各个部件(如处理器、图形卡、内存等)的温度。传感器可以是来自硬件设备的内置传感器,也可以是外部插件设备的传感器。通过读取这些传感器的数据,Linux thermal能够实时监测温度的变化。 当温度超过设定的安全阈值时,Linux thermal会采取相应的措施来降低硬件的温度。这些措施可以包括调整风扇的转速,降低电压供应,甚至通过暂停或降低某些任务的运行来减少硬件的功耗。 在服务器和桌面计算机等大型计算设备上,Linux thermal的作用非常重要。过高的温度会导致硬件故障、损坏甚至灾难性的停机。通过及时监测温度并进行热管理,Linux系统可以保护硬件的完整性和可靠性。 除了保护硬件免受损坏外,Linux thermal还可以提高计算机的性能和能效。通过优化温度控制,可以避免出现过度降温的情况,提高硬件的工作效率并减少能源消耗。 总之,Linux thermalLinux操作系统中用于监测和管理计算机硬件温度的功能,它通过读取传感器数据并采取适当的措施来保护硬件,提高性能和能效。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值