qcom-cpufreq: Register cooling device in ready callback

Thermal cooling device has to be registered when the policy for a CPU is
ready. Cpufreq will get a callback when a cpufreq policy is ready and
register CPU cooling device as a part of this callback, so that the CPU
can be mitigated immediately if needed.

Ignore cpu cooling device registration when there is platform cooling
device available.

Change-Id: I7cfb8598aa8ead4091a617da3faddf86ff0fe6a8
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
[avilaj@codeaurora.org: Modify to support 4.19 API changes]
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
This commit is contained in:
Ram Chandrasekar
2017-12-06 12:22:24 -07:00
committed by Jonathan Avila
parent 96871e06b0
commit 6eebbaf2d7

View File

@@ -19,10 +19,13 @@
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/cpu_cooling.h>
#include <trace/events/power.h>
static DEFINE_MUTEX(l2bw_lock);
static struct thermal_cooling_device *cdev[NR_CPUS];
static struct clk *cpu_clk[NR_CPUS];
static struct clk *l2_clk;
static DEFINE_PER_CPU(struct cpufreq_frequency_table *, freq_table);
@@ -299,6 +302,41 @@ static struct freq_attr *msm_freq_attr[] = {
NULL,
};
static void msm_cpufreq_ready(struct cpufreq_policy *policy)
{
struct device_node *np, *lmh_node;
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)) {
lmh_node = of_parse_phandle(np, "qcom,lmh-dcvs", 0);
if (lmh_node) {
of_node_put(lmh_node);
goto ready_exit;
}
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;
}
}
ready_exit:
of_node_put(np);
}
static struct cpufreq_driver msm_cpufreq_driver = {
/* lps calculations are handled here. */
.flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS |
@@ -310,6 +348,7 @@ static struct cpufreq_driver msm_cpufreq_driver = {
.get = msm_cpufreq_get_freq,
.name = "msm",
.attr = msm_freq_attr,
.ready = msm_cpufreq_ready,
};
static struct cpufreq_frequency_table *cpufreq_parse_dt(struct device *dev,