rk3368 CPU动态调频与温度保护

Platform: RK3368

OS: Android 6.0

Kernel: 3.10.0


rk3368采用cpufreq进行CPU频率调节,但同时又做了过温保护和温度限制频率。

1. 过温保护

驱动位于kernel/drivers/thermal/rockchip_thermal.c
dts定义:

tsadc: tsadc@ff280000 {
                compatible = "rockchip,rk3368-tsadc";
                reg = <0x0 0xff280000 0x0 0x100>;
                interrupts = ;
                clocks = <&clk_tsadc>, <&clk_gates20 0>;
                rockchip,grf = <&grf>;
                rockchip,cru = <&cru>;
                rockchip,pmu = <&pmu>;
                clock-names = "tsadc", "apb_pclk";
                clock-frequency = <32000>;
                resets = <&reset RK3368_SRST_TSADC_P>;
                reset-names = "tsadc-apb";
                //pinctrl-names = "default";
                //pinctrl-0 = <&tsadc_int>;
                #thermal-sensor-cells = <1>;
                hw-shut-temp = <120000>;
                status = "disabled";
        };

可以看到当前hw-shut-temp = <120000>;也就是温度大于120度就会触发过温保护,强制关机。
查看当前CPU温度:

#cat /sys/rockchip_thermal/temp
2. CPU动态调频(DVFS)

Linux内部共有五种对频率的管理策略userspace,conservative,ondemand,powersave 和 performance.可以根据负载进行频率提升和降低。

查看支持的governors
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand userspace powersave interactive performance

DVFS的dts定义:

dvfs {
		vd_arm: vd_arm {
			regulator_name = "vdd_arm";
			suspend_volt = <1000>; //mV
			pd_core {
				clk_core_b_dvfs_table: clk_core_b {
					operating-points = <
						/* KHz    uV */
						312000 1200000
						504000 1200000
						816000 1200000
						1008000 1200000
						>;
					status = "okay";
					cluster = <0>;
					temp-limit-enable = <1>;
					target-temp = <80>;
					min_temp_limit = <216000>;
					normal-temp-limit = <
					/*delta-temp    delta-freq*/
						3	96000
						6	144000
						9	192000
						15	384000
						>;
					performance-temp-limit = <
						/*temp    freq*/
						100     816000
						>;
					lkg_adjust_volt_en = <1>;
					channel = <0>;
					tsadc-ch = <0>;
					def_table_lkg = <25>;
					min_adjust_freq = <216000>;
					lkg_adjust_volt_table = <
						/*lkg(mA)  volt(uV)*/
						0         25000
						>;
					pvtm_min_temp = <25>;
				};
				clk_core_l_dvfs_table: clk_core_l {
					operating-points = <
						/* KHz    uV */
						312000 1200000
						504000 1200000
						816000 1200000
						1008000 1200000
						>;
					status = "okay";
					cluster = <1>;
					temp-limit-enable = <1>;
					target-temp = <80>;
					min_temp_limit = <216000>;
					normal-temp-limit = <
					/*delta-temp    delta-freq*/
						3	96000
						6	144000
						9	192000
						15	384000
						>;
					performance-temp-limit = <
						/*temp    freq*/
						100     816000
						>;
					lkg_adjust_volt_en = <1>;
					channel = <0>;
					tsadc-ch = <0>;
					def_table_lkg = <25>;
					min_adjust_freq = <216000>;
					lkg_adjust_volt_table = <
						/*lkg(mA)  volt(uV)*/
						0         25000
						>;
					pvtm_min_temp = <25>;
				};
			};
		};

可以看到里面定义了大核和小核的两种限制模式,normal-temp-limit和performance-temp-limit。performance模式中,当温度高于80则频率限制在816000。而在normal模式中,则是每当温度上升delta-temp,则频率降低delta-freq,直到降到min_temp_limit为止。

实现代码位于:
arch/arm/mach-rockchip/dvfs.c
驱动初始化了一个工作队列dvfs_temp_limit_work_func,每隔HZ/10执行一次。主要任务是根据当前温度对temp_limit_rate进行修改。从而让dvfs_get_limit_rate返回的是限频的值。

系统默认为normal模式,在init.rc中写入的:

    # set temperature control policy as normal mode
    write /sys/module/rockchip_pm/parameters/policy 1

查看及修改当前电源策略:

# cat /sys/module/rockchip_pm/parameters/policy
# echo "1">/sys/module/rockchip_pm/parameters/policy

你可能感兴趣的:(android,linux,rockchip)