全志平台他Tina系统linux4.9打开调频策略cpufreq后编译错误问题

2024-02-02 14:48:30 浏览数 (1)

【适用范围】

全志平台他Tina系统linux4.9,Tina3.0.1-Tina3.0.3,再往后的版本应该修复了这个问题,此处以R331为例

【问题现象】

选中CPU Power Management 下的 CPU Frequency scaling和改目录下的CPU驱动SUNXI CPUFreq support

编译时报错:

代码语言:javascript复制
drivers/built-in.o: In function `sunxi_cpufreq_set_vf':
/home/chenkunyao/workspace/tina2.0/atina/lichee/linux-4.9/drivers/cpufreq/sunxi-cpufreq.c:279: undefined reference to `arisc_dvfs_cfg_vf_table'
make[5]: *** [vmlinux] Error 1
make[5]: Leaving directory `/home/chenkunyao/workspace/tina2.0/atina/lichee/linux-4.9'
make[4]: *** [/home/chenkunyao/workspace/tina2.0/atina/out/bassoon-perf1/compile_dir/target/linux-bassoon-perf1/linux-4.9.56/.image] Error 2
make[4]: Leaving directory `/home/chenkunyao/workspace/tina2.0/atina/target/allwinner/bassoon-perf1'
make[3]: *** [install] Error 2
make[3]: Leaving directory `/home/chenkunyao/workspace/tina2.0/atina/target/allwinner'
make[2]: *** [target/allwinner/install] Error 2
make[2]: Leaving directory `/home/chenkunyao/workspace/tina2.0/atina'
make[1]: *** [/home/chenkunyao/workspace/tina2.0/atina/out/bassoon-perf1/staging_dir/target/stamp/.target_install] Error 2
make[1]: Leaving directory `/home/chenkunyao/workspace/tina2.0/atina'
make: *** [world] 错误 2
#### make failed to build some targets (14:35 (mm:ss)) ####

【问题原因】

没打patch,cpufreq接口没开

【解决方法】

linux4.9目录下打上patch:

代码语言:javascript复制
From XXXXXXXXXXXXXXXXX Mon Sep 17 00:00:00 2001
From: XXXXXXX@allwinnertech.com
Date: Thu, 30 Aug 2018 09:45:55  0800
Subject: [PATCH 89/92] sun8iw8p1: boobam_std: support dvfs

Change-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Signed-off-by: XXXXXX <XXXXXXX@allwinnertech.com>
---
 arch/arm/boot/dts/sun8iw8p1.dtsi | 74                                         
 drivers/cpufreq/sunxi-cpufreq.c  |  9   ---
 2 files changed, 79 insertions( ), 4 deletions(-)

diff --git a/arch/arm/boot/dts/sun8iw8p1.dtsi b/arch/arm/boot/dts/sun8iw8p1.dtsi
index fa53820..3e1a09a 100644
--- a/arch/arm/boot/dts/sun8iw8p1.dtsi
    b/arch/arm/boot/dts/sun8iw8p1.dtsi
@@ -37,6  37,7 @@
 	};
 
 	cpus {
 		enable-method = "allwinner,sun8iw8p1";
 		#address-cells = <1>;
 		#size-cells    = <0>;
 
@@ -44,10  45,83 @@
 			device_type = "cpu";
 			compatible  = "arm,cortex-a7";
 			reg         = <0x0>;
 			enable-method = "psci";
 			clocks = <&clk_pll_cpu>;
 			clock-latency = <2000000>;
 			clock-frequency = <1008000000>;
 			operating-points-v2 = <&cpu_opp_l_table0>;
 			/*cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0 &SYS_SLEEP_0>;*/
 		};
 	};
 
 
 	opp_dvfs_table:opp_dvfs_table {
 		cluster_num = <1>;
 		opp_table_count = <1>;
 
 		cpu_opp_l_table0: opp_l_table0 {
 			compatible = "allwinner,opp_l_table0";
 			opp_count = <8>;
 			opp-shared;
 
 			opp00 {
 				opp-hz = /bits/ 64 <60000000>;
 				opp-microvolt = <1040000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp01 {
 				opp-hz = /bits/ 64 <480000000>;
 				opp-microvolt = <1040000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp02 {
 				opp-hz = /bits/ 64 <648000000>;
 				opp-microvolt = <1040000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp03 {
 				opp-hz = /bits/ 64 <720000000>;
 				opp-microvolt = <1100000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp04 {
 				opp-hz = /bits/ 64 <816000000>;
 				opp-microvolt = <1100000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp05 {
 				opp-hz = /bits/ 64 <912000000>;
 				opp-microvolt = <1200000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp06 {
 				opp-hz = /bits/ 64 <1080000000>;
 				opp-microvolt = <1200000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 
 			opp07 {
 				opp-hz = /bits/ 64 <1200000000>;
 				opp-microvolt = <1320000>;
 				axi-bus-divide-ratio = <3>;
 				clock-latency-ns = <2000000>;
 			};
 		};
 	};
 
 	memory@40000000 {
 		device_type = "memory";
 		reg = <0x00000000 0x40000000 0x00000000 0x4000000>;  /*  64M*/
diff --git a/drivers/cpufreq/sunxi-cpufreq.c b/drivers/cpufreq/sunxi-cpufreq.c
index ff74e07..f0480a2 100644
--- a/drivers/cpufreq/sunxi-cpufreq.c
    b/drivers/cpufreq/sunxi-cpufreq.c
@@ -188,8  188,9 @@ static int sunxi_set_cpufreq_and_voltage(struct cpufreq_policy *policy,
 	struct device *cpu_dev;
 
 	cpu_dev = get_cpu_device(policy->cpu);
-
-
 #if defined(CONFIG_ARCH_SUN8IW8P1)
 	freq *= 1000;
 #endif
 	return dev_pm_opp_set_rate(cpu_dev, freq);
 }
 #endif
@@ -275,9  276,9 @@ static int sunxi_cpufreq_set_vf(struct cpufreq_frequency_table *table,
 	memcpy((void *)kvir, (void *)cpufreq_dvfs_table,
 			num * sizeof(struct cpufreq_frequency_table));
 	__dma_flush_area((void *)kvir, num * sizeof(struct cpufreq_frequency_table));
-
 #ifndef CONFIG_ARCH_SUN8IW8P1
 	arisc_dvfs_cfg_vf_table(0, num, virt_to_phys(kvir));
-
 #endif
 	kfree(kvir);
 	kvir = NULL;
 
-- 
1.9.1

make kernel_menuconfig下的配置如下:

选中CPU Power Management 下的 CPU Frequency scaling

选中几个需要的调频策略,如:

userspace 根据用户的选择调节

往下拉把 CPU驱动SUNXI CPUFreq support选上。

重新编译即可。

烧录后查看cpufreq节点:

cd /sys/devices/system/cpu/cpu0/cpufreq

查看当前cpu频率的办法

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

0 人点赞