cpufreq: qcom-hw: Add ready callback to register CPU cooling device

Add a ready callback, which will be called when a CPU policy is ready.
As a part of this callback, register the corresponding CPU cooling
device.

Change-Id: Ic12e0a8f7cd13fda583844454e3a0eb600a2cad3
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
This commit is contained in:
Ram Chandrasekar 2019-02-26 12:42:08 -07:00 • committed by Taniya Das
commit 6297328964

View file

@ -12,6 +12,7 @@
#include <linux/pm_opp.h>
#include <linux/energy_model.h>
#include <linux/sched.h>
#include <linux/cpu_cooling.h>
#define LUT_MAX_ENTRIES 40U
#define CORE_COUNT_VAL(val) (((val) & (GENMASK(18, 16))) >> 16)
@ -178,6 +179,35 @@ static struct freq_attr *qcom_cpufreq_hw_attr[] = {
NULL
};
static void qcom_cpufreq_ready(struct cpufreq_policy *policy)
{
static struct thermal_cooling_device *cdev[NR_CPUS];
struct device_node *np;
unsigned int cpu = policy->cpu;
if (cdev[cpu])
return;
np = of_cpu_device_node_get(cpu);
if (WARN_ON(!np))
return;
/*
* For now, just loading the cooling device;
* thermal DT code takes care of matching them.
*/
if (of_find_property(np, "#cooling-cells", NULL)) {
cdev[cpu] = of_cpufreq_cooling_register(policy);
if (IS_ERR(cdev[cpu])) {
pr_err("running cpufreq for CPU%d without cooling dev: %ld\n",
cpu, PTR_ERR(cdev[cpu]));
cdev[cpu] = NULL;
}
}
of_node_put(np);
}
static struct cpufreq_driver cpufreq_qcom_hw_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
@ -189,6 +219,7 @@ static struct cpufreq_driver cpufreq_qcom_hw_driver = {
.name = "qcom-cpufreq-hw",
.attr = qcom_cpufreq_hw_attr,
.boost_enabled = true,
.ready = qcom_cpufreq_ready,
};
static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev,