CPUIDLE 能让cpu 在空间时进入低功耗模式,达到节省功耗的目的。
2.2 相关术语介绍
表2-1: 术语介绍
术语 | 说明 |
Sunxi | 指Allwinner 的一系列SOC 硬件平台。 |
CPUIDLE | 让cpu 进入低功耗状态的一种方法 |
2.3 模块配置介绍
2.3.1
Device tree 配置说明
设备树中存在的是该类
芯片所有平台的模块配置, 设备树文件的路径为:
kernel/linux-4.9/arch(RISCV 平台为riscv)/arm64(32 位平台为arm)/boot/dts/sunxi/CHIP.dtsi(CHIP为研发代号,如sun50iw10p1 等)。
• cpu 节点
- cpu0: cpu@0 {
- device_type = "cpu";
- compatible = "arm,cortex-a53","arm,ARMv8";
- reg = <0x0 0x0>;
- enable-method = "psci";
- clocks = <&clk_pll_cpu>;
- clock-latency = <2000000>;
- clock-frequency = <1320000000>;
- dynamic-power-coefficient = <190>;
- operating-points-v2 = <&cpu_opp_l_table>;
- cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; //引用定义好的idle的状态
- #cooling-cells = <2>;
- };
- cpu@1 {
- device_type = "cpu";
- compatible = "arm,cortex-a53","arm,armv8";
- reg = <0x0 0x1>;
- enable-method = "psci";
- clocks = <&clk_pll_cpu>;
- clock-frequency = <1320000000>;
- operating-points-v2 = <&cpu_opp_l_table>;
- cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; //引用定义好的idle的状态
- #cooling-cells = <2>;
- };
复制代码
• psci 节点:
- psci {
- compatible = "arm,psci-1.0";
- method = "smc";
- }
- cpuidle的实现需要通过psci,如果没有定义psci节点,cpuidle功能就无法实现。
复制代码
• idle-states 节点
- idle-states {
- entry-method = "arm,psci"; //说明通过psci方式进入退出cpuidle
- CPU_SLEEP_0: cpu-sleep-0 {
- compatible = "arm,idle-state"; //匹配psci-idle或arm-idle驱动
- arm,psci-suspend-param = <0x0010000>; //PSCI传递参数,存储了power_state信息,
- 对cpuidle来说,bit24用于区分哪种掉电方式
- entry-latency-us = <46>; //进入该cpuidle状态的时间,
- 由软件进入时间和硬件进入时间组成
- exit-latency-us = <59>; //退出该cpuidle状态的时间,
- 由软件退出时间和硬件退出时间组成
- min-residency-us = <3570>; //在该cpuidle状态的最小驻留时间,
- 一旦小于时间idle反而会增加功耗
- local-timer-stop; //指示在进入cpuidle时,
- 是否需要关闭本地的timer
- };
- CLUSTER_SLEEP_0: cluster-sleep-0 {
- compatible = "arm,idle-state";
- arm,psci-suspend-param = <0x1010000>;
- entry-latency-us = <47>;
- exit-latency-us = <74>;
- min-residency-us = <5000>;
- local-timer-stop;
- }
- }
复制代码• timer 节点
- timer@3009000 {
- compatible = "allwinner,sun4i-a10-timer";
- /*
- * FIXME: After using sunxi timer driver, the number
- * of CPU entering idle becomes less?
- * "allwinner,sunxi-timer";
- */
- reg = <0x0 0x03009000 0x0 0x90>;
- interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
- clocks = <&dcxo24M>;
- };
- cpu进入idle后需要不定期通过tick进行唤醒,但是如果在idle-state节点中定义了local-timer-stop属性就会导致cpu本地的timer被关闭,出现没有外部中断来临就无法退出中断的情况,这种情况下就需要将一个timer变为broadcast-timer,用来一段时间后让cpu退出idle状态。SUNXI平台使用timer(部分soc平台中叫soc_timer)来作为broadcast-timer,所以使用cpuidle功能需要配置timer节点并加载timer驱动。
复制代码2.3.2 board.dts 配置说明
board.dts 用于保存每一个板级平台的设备信息(如demo 板,perf1 板等),里面的配置信息会覆盖上面的Device Tree 默认配置信息。
cpuidle 模块在board.dts 中无用户可用配置。
2.3.3 sysconfig 配置说明
cpuidle 模块在sysconfig 中无用户可用配置。