美文网首页
Linux内核dvfs之cpufreq配置

Linux内核dvfs之cpufreq配置

作者: 小田BSP | 来源:发表于2022-07-06 22:33 被阅读0次

    本文基于RockPi 4A单板Linux4.4 内核介绍OPP Table

    内核中将频率、电压的相关配置放在DTSI文件中,这些配置信息组成的节点被称为OPP Table(Operating Performance Points)

    定义文件:arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi,内容如下:

        cluster0_opp: opp-table0 {
            compatible = "operating-points-v2";
            opp-shared; 
    
            rockchip,temp-hysteresis = <5000>; ## 5摄氏度
            rockchip,low-temp = <0>;
            rockchip,low-temp-min-volt = <900000>; ## 0.9V
    
            nvmem-cells = <&cpul_leakage>;
            nvmem-cell-names = "cpu_leakage";
    
            rockchip,pvtm-voltage-sel = <
                0        143500   0
                143501   148500   1
                148501   152000   2
                152001   999999   3
            >;
            rockchip,pvtm-freq = <408000>;
            rockchip,pvtm-volt = <1000000>;
            rockchip,pvtm-ch = <0 0>;
            rockchip,pvtm-sample-time = <1000>;
            rockchip,pvtm-number = <10>;
            rockchip,pvtm-error = <1000>;
            rockchip,pvtm-ref-temp = <41>;
            rockchip,pvtm-temp-prop = <115 66>;
            rockchip,thermal-zone = "soc-thermal";
    
            opp-408000000 {
                opp-hz = /bits/ 64 <408000000>;
                opp-microvolt = <800000 800000 1200000>;
                opp-microvolt-L0 = <800000 800000 1200000>;
                opp-microvolt-L1 = <800000 800000 1200000>;
                opp-microvolt-L2 = <800000 800000 1200000>;
                opp-microvolt-L3 = <800000 800000 1200000>;
                clock-latency-ns = <40000>;
            };
            opp-600000000 {
                opp-hz = /bits/ 64 <600000000>;
                opp-microvolt = <800000 800000 1200000>;
                opp-microvolt-L0 = <800000 800000 1200000>;
                opp-microvolt-L1 = <800000 800000 1200000>;
                opp-microvolt-L2 = <800000 800000 1200000>;
                opp-microvolt-L3 = <800000 800000 1200000>;
                clock-latency-ns = <40000>;
            };
            opp-816000000 {
                opp-hz = /bits/ 64 <816000000>;
                opp-microvolt = <850000 850000 1200000>;
                opp-microvolt-L0 = <850000 850000 1200000>;
                opp-microvolt-L1 = <825000 825000 1200000>;
                opp-microvolt-L2 = <800000 800000 1200000>;
                opp-microvolt-L3 = <800000 800000 1200000>;
                clock-latency-ns = <40000>;
                opp-suspend;
            };
            opp-1008000000 {
                opp-hz = /bits/ 64 <1008000000>;
                opp-microvolt = <925000 925000 1200000>;
                opp-microvolt-L0 = <925000 925000 1200000>;
                opp-microvolt-L1 = <900000 900000 1200000>;
                opp-microvolt-L2 = <875000 875000 1200000>;
                opp-microvolt-L3 = <850000 850000 1200000>;
                clock-latency-ns = <40000>;
            };
            opp-1200000000 {
                opp-hz = /bits/ 64 <1200000000>;
                opp-microvolt = <1000000 1000000 1200000>;
                opp-microvolt-L0 = <1000000 1000000 1200000>;
                opp-microvolt-L1 = <975000 975000 1200000>;
                opp-microvolt-L2 = <950000 950000 1200000>;
                opp-microvolt-L3 = <925000 925000 1200000>;
                clock-latency-ns = <40000>;
            };
            opp-1416000000 {
                opp-hz = /bits/ 64 <1416000000>;
                opp-microvolt = <1125000 1125000 1200000>;
                opp-microvolt-L0 = <1125000 1125000 1200000>;
                opp-microvolt-L1 = <1100000 1100000 1200000>;
                opp-microvolt-L2 = <1075000 1075000 1200000>;
                opp-microvolt-L3 = <1050000 1050000 1200000>;
                clock-latency-ns = <40000>;
            };
        };
    

    上面节点中的相关属性含义如下:

    1、opp-shared:表示opp-table1是小核的各CPU共用。

    2、rockchip,temp-hysteresis:迟滞参数,防止频繁进入高温或低温,单位:毫摄氏度。

    3、rockchip,low-temp:低温阈值。小于该值时,进入低温,大于‘该值+迟滞参数’时,恢复常温。

    4、rockchip,low-temp-min-volt:低温下最低电压,单位:微伏。

    5、nvmem-cells:从eFUSE中读取相关信息值(小核漏电流)。

    6、rockchip,pvtm-voltage-sel:min-pvtm(单位KHz)、max-pvtm(单位KHz)和voltage-selector(用于匹配opp节点中opp-microvolt-L*属性的序列号)。例:pvtm值为:0 ~ 143500 使用opp-microvolt-L0,143501 ~ 148500使用opp-microvolt-L1

    7、rockchip,pvtm-freq:时钟频率(KHz),在获取pvtm的频率前,先设置CPU频率。

    8、rockchip,pvtm-volt:电压(微伏),在获取pvtm的频率前,先设置CPU电压。

    9、rockchip,pvtm-chPVTM通道,格式<通道号 sel的序号>

    10、rockchip,pvtm-sample-timePVTM采样时间,单位:毫秒。

    11、rockchip,pvtm-numberPVTM采样个数。

    12、rockchip,pvtm-error:允许采样数据之间的误差。

    13、rockchip,pvtm-ref-temp:参考温度。

    14、rockchip,pvtm-temp-propPVTM随温度变化的比例系数,格式<小于参考温度的比例系数 大于参考温度的比例系数>。

    15、rockchip,thermal-zone:获取温度的thermal-zone

    16、opp-microvolt-L*:电压(微伏),格式<target min max>

    17、clock-latency-ns:完成变频需要的时间,单位:纳秒。

    RK3399中,除了配置上述小核的opp table外,还设置了大核(cluster1_opp)、gpu(gpu_opp_table)等的相关值。查看命令如下:

    root@linaro-alip:/sys/kernel/debug/opp# ls
    cpu0  cpu1  cpu2  cpu3  cpu4  cpu5  opp_summary  platform-ff9a0000.gpu
    root@linaro-alip:/sys/kernel/debug/opp# cat opp_summary
     device                rate(Hz)    target(uV)    min(uV)    max(uV)
    -------------------------------------------------------------------
     platform-ff9a0000.gpu
                          200000000       800000      800000      800000
                          300000000       800000      800000      800000
                          400000000       825000      825000      825000
                          600000000       925000      925000      925000
                          800000000      1100000     1100000     1100000
     cpu4
                          408000000       800000      800000     1200000
                          600000000       800000      800000     1200000
                          816000000       825000      825000     1200000
                         1008000000       875000      875000     1200000
                         1200000000       950000      950000     1200000
                         1416000000      1025000     1025000     1200000
                         1608000000      1100000     1100000     1200000
                         1800000000      1200000     1200000     1200000
     cpu0
                          408000000       800000      800000     1200000
                          600000000       800000      800000     1200000
                          816000000       850000      850000     1200000
                         1008000000       925000      925000     1200000
                         1200000000      1000000     1000000     1200000
                         1416000000      1125000     1125000     1200000
    

    注:

    CPU PVTM(Process Voltage Temperature Monitor)是一个位于CPU附近,能反应出不同芯片之间性能差异的模块,受工艺,电压和温度 的影响。

    参考:

    Documentation/devicetree/bindings/cpufreq/cpufreq-rockchip.txt

    Documentation/devicetree/bindings/cpufreq/cpufreq-rockchip.txt

    相关文章

      网友评论

          本文标题:Linux内核dvfs之cpufreq配置

          本文链接:https://www.haomeiwen.com/subject/rgcubrtx.html