From: Anson Huang <Anson.Huang@nxp.com> To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, fabio.estevam@nxp.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, rui.zhang@intel.com, edubezval@gmail.com Cc: Linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 2/3] cpufreq: imx6q: add cpufreq cooling device based on device tree Date: Mon, 14 May 2018 16:09:18 +0800 [thread overview] Message-ID: <1526285359-17978-2-git-send-email-Anson.Huang@nxp.com> (raw) In-Reply-To: <1526285359-17978-1-git-send-email-Anson.Huang@nxp.com> Register the imx6q cpufreq driver as a cooling device based on the thermal device tree framework. When temperature exceeds the passive trip point, cpufreq driver will be used to throttle CPUs. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> --- drivers/cpufreq/imx6q-cpufreq.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 83cf631..27ce84d 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-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/of.h> @@ -50,6 +51,7 @@ static struct clk_bulk_data clks[] = { }; static struct device *cpu_dev; +struct thermal_cooling_device *cdev; static bool free_opp; static struct cpufreq_frequency_table *freq_table; static unsigned int max_freq; @@ -202,6 +204,11 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy) return ret; } +static void imx6q_cpufreq_ready(struct cpufreq_policy *policy) +{ + cdev = of_cpufreq_cooling_register(policy); +} + static struct cpufreq_driver imx6q_cpufreq_driver = { .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK, .verify = cpufreq_generic_frequency_table_verify, @@ -210,6 +217,7 @@ static struct cpufreq_driver imx6q_cpufreq_driver = { .init = imx6q_cpufreq_init, .name = "imx6q-cpufreq", .attr = cpufreq_generic_attr, + .ready = imx6q_cpufreq_ready, .suspend = cpufreq_generic_suspend, }; @@ -482,6 +490,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) static int imx6q_cpufreq_remove(struct platform_device *pdev) { + cpufreq_cooling_unregister(cdev); cpufreq_unregister_driver(&imx6q_cpufreq_driver); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); if (free_opp) -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Anson.Huang@nxp.com (Anson Huang) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] cpufreq: imx6q: add cpufreq cooling device based on device tree Date: Mon, 14 May 2018 16:09:18 +0800 [thread overview] Message-ID: <1526285359-17978-2-git-send-email-Anson.Huang@nxp.com> (raw) In-Reply-To: <1526285359-17978-1-git-send-email-Anson.Huang@nxp.com> Register the imx6q cpufreq driver as a cooling device based on the thermal device tree framework. When temperature exceeds the passive trip point, cpufreq driver will be used to throttle CPUs. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> --- drivers/cpufreq/imx6q-cpufreq.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 83cf631..27ce84d 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-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/of.h> @@ -50,6 +51,7 @@ static struct clk_bulk_data clks[] = { }; static struct device *cpu_dev; +struct thermal_cooling_device *cdev; static bool free_opp; static struct cpufreq_frequency_table *freq_table; static unsigned int max_freq; @@ -202,6 +204,11 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy) return ret; } +static void imx6q_cpufreq_ready(struct cpufreq_policy *policy) +{ + cdev = of_cpufreq_cooling_register(policy); +} + static struct cpufreq_driver imx6q_cpufreq_driver = { .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK, .verify = cpufreq_generic_frequency_table_verify, @@ -210,6 +217,7 @@ static struct cpufreq_driver imx6q_cpufreq_driver = { .init = imx6q_cpufreq_init, .name = "imx6q-cpufreq", .attr = cpufreq_generic_attr, + .ready = imx6q_cpufreq_ready, .suspend = cpufreq_generic_suspend, }; @@ -482,6 +490,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) static int imx6q_cpufreq_remove(struct platform_device *pdev) { + cpufreq_cooling_unregister(cdev); cpufreq_unregister_driver(&imx6q_cpufreq_driver); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); if (free_opp) -- 2.7.4
next prev parent reply other threads:[~2018-05-14 8:15 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-14 8:09 [PATCH 1/3] thermal: imx: remove cpufreq cooling registration Anson Huang 2018-05-14 8:09 ` Anson Huang 2018-05-14 8:09 ` Anson Huang [this message] 2018-05-14 8:09 ` [PATCH 2/3] cpufreq: imx6q: add cpufreq cooling device based on device tree Anson Huang 2018-05-14 8:09 ` [PATCH 3/3] ARM: dts: imx: add cooling-cells for cpufreq cooling device Anson Huang 2018-05-14 8:09 ` Anson Huang 2018-05-14 8:34 ` [PATCH 1/3] thermal: imx: remove cpufreq cooling registration Daniel Lezcano 2018-05-14 8:34 ` Daniel Lezcano 2018-05-14 8:37 ` Bastian Stender 2018-05-14 8:37 ` Bastian Stender 2018-05-14 9:10 ` Anson Huang 2018-05-14 9:10 ` Anson Huang 2018-05-14 9:18 ` Bastian Stender 2018-05-14 9:18 ` Bastian Stender
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1526285359-17978-2-git-send-email-Anson.Huang@nxp.com \ --to=anson.huang@nxp.com \ --cc=Linux-imx@nxp.com \ --cc=devicetree@vger.kernel.org \ --cc=edubezval@gmail.com \ --cc=fabio.estevam@nxp.com \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=rjw@rjwysocki.net \ --cc=robh+dt@kernel.org \ --cc=rui.zhang@intel.com \ --cc=s.hauer@pengutronix.de \ --cc=shawnguo@kernel.org \ --cc=viresh.kumar@linaro.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.