Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d12acda0 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qcom-cpufreq: Register cooling device in ready callback"

parents 65fe963d b18b809f
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -27,10 +27,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);
@@ -308,6 +311,52 @@ 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 = 0;

	if (cdev[policy->cpu])
		return;

	np = of_cpu_device_node_get(policy->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;
		}

		for_each_cpu(cpu, policy->related_cpus) {
			cpumask_t cpu_mask  = CPU_MASK_NONE;

			of_node_put(np);
			np = of_cpu_device_node_get(cpu);
			if (WARN_ON(!np))
				return;

			cpumask_set_cpu(cpu, &cpu_mask);
			cdev[cpu] = of_cpufreq_cooling_register(np, &cpu_mask);
			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 | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
@@ -318,6 +367,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,