From 168e78013ba44eb2a677b36cbce1a1aba746c290 Mon Sep 17 00:00:00 2001 From: Dongjin Kim Date: Mon, 26 Aug 2019 15:08:00 +0900 Subject: [PATCH] ODROID-C4/N2: customize cpufreq/cooling for ODROID-N2 ODROID-N2 has two cpufreq clusters while ODROID-C4 has one. This patch is to manage the cpufreq for the different CPU cluster setup while a board is running instead of buildtime. Change-Id: I53d8208f5f53d0e83dbe08c9d24123e64cc1e24f Signed-off-by: Dongjin Kim --- drivers/thermal/cpu_cooling.c | 38 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 103a3c5015e7..7b0a0b5d7889 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -31,6 +31,10 @@ #include #include +#ifdef CONFIG_ARCH_MESON64_ODROID_COMMON +#include +#endif + #include /* @@ -295,17 +299,19 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, if (num_opps == 0) return -EINVAL; -#ifdef CONFIG_ARCH_MESON64_ODROIDN2 - pr_debug("[%s] num_opps %d cpufreq max_level %d\n", - __func__, num_opps, cpufreq_device->max_level); +#ifdef CONFIG_ARCH_MESON64_ODROID_COMMON + if (board_is_odroidn2()) { + pr_debug("[%s] num_opps %d cpufreq max_level %d\n", + __func__, num_opps, cpufreq_device->max_level); - if (cpufreq_device->max_level == 0) - return -EINVAL; + if (cpufreq_device->max_level == 0) + return -EINVAL; - if (num_opps < (cpufreq_device->max_level + 1)) - return -EINVAL; + if (num_opps < (cpufreq_device->max_level + 1)) + return -EINVAL; - num_opps = cpufreq_device->max_level + 1; + num_opps = cpufreq_device->max_level + 1; + } #endif power_table = kcalloc(num_opps, sizeof(*power_table), GFP_KERNEL); @@ -319,9 +325,18 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, freq++, i++) { u32 freq_mhz, voltage_mv; u64 power; -#ifdef CONFIG_ARCH_MESON64_ODROIDN2 - if (i >= num_opps) - break; + +#ifdef CONFIG_ARCH_MESON64_ODROID_COMMON + if (board_is_odroidn2()) { + if (i >= num_opps) + break; + } else { + if (i >= num_opps) { + rcu_read_unlock(); + ret = -EAGAIN; + goto free_power_table; + } + } #else if (i >= num_opps) { rcu_read_unlock(); @@ -329,6 +344,7 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, goto free_power_table; } #endif + freq_mhz = freq / 1000000; voltage_mv = dev_pm_opp_get_voltage(opp) / 1000;