diff options
author | Anson Huang <Anson.Huang@nxp.com> | 2017-07-28 10:30:35 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 8c74e11194ce5287f865adf2d6eaf3764c51f02c (patch) | |
tree | b3ad9ddae773f71a51eb5ebe902ca8cba3002d52 /drivers/cpufreq | |
parent | f21ef37d3292df6cc16c14825b925bffe19929e5 (diff) |
MLK-16093-3 cpufreq: imx8mq: add cooling device support
Add i.MX8MQ cooling device support, when temperature
exceeds passive threshold, cpu-freq will drop to lowest
set-point, and once temperature drops below passive
threshold, cpu-freq will restore.
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/imx8mq-cpufreq.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/cpufreq/imx8mq-cpufreq.c b/drivers/cpufreq/imx8mq-cpufreq.c index 1765b47b5f63..054e064fd7ac 100644 --- a/drivers/cpufreq/imx8mq-cpufreq.c +++ b/drivers/cpufreq/imx8mq-cpufreq.c @@ -9,6 +9,7 @@ #include <linux/clk.h> #include <linux/cpu.h> #include <linux/cpufreq.h> +#include <linux/cpu_cooling.h> #include <linux/err.h> #include <linux/module.h> #include <linux/slab.h> @@ -28,6 +29,7 @@ static struct clk *arm_a53_src_clk; static struct clk *arm_pll_clk; static struct clk *arm_pll_out_clk; static struct clk *sys1_pll_800m_clk; +struct thermal_cooling_device *cdev; static int imx8mq_set_target(struct cpufreq_policy *policy, unsigned int index) { @@ -68,6 +70,25 @@ static int imx8mq_set_target(struct cpufreq_policy *policy, unsigned int index) return ret; } +static void imx8mq_cpufreq_ready(struct cpufreq_policy *policy) +{ + struct device_node *np = of_get_cpu_node(policy->cpu, NULL); + + if (of_find_property(np, "#cooling-cells", NULL)) { + cdev = of_cpufreq_cooling_register(np, + policy->related_cpus); + + if (IS_ERR(cdev) && PTR_ERR(cdev) != -ENOSYS) { + pr_err("cpu%d is not running as cooling device: %ld\n", + policy->cpu, PTR_ERR(cdev)); + + cdev = NULL; + } + } + + of_node_put(np); +} + static int imx8mq_cpufreq_init(struct cpufreq_policy *policy) { int ret; @@ -92,6 +113,7 @@ static struct cpufreq_driver imx8mq_cpufreq_driver = { .get = cpufreq_generic_get, .init = imx8mq_cpufreq_init, .name = "imx8mq-cpufreq", + .ready = imx8mq_cpufreq_ready, .attr = cpufreq_generic_attr, #ifdef CONFIG_PM .suspend = cpufreq_generic_suspend, @@ -199,6 +221,7 @@ put_clk: static int imx8mq_cpufreq_remove(struct platform_device *pdev) { + cpufreq_cooling_unregister(cdev); cpufreq_unregister_driver(&imx8mq_cpufreq_driver); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); if (free_opp) |