* [PATCH] thermal: imx: use cpufreq cooling of registration method
@ 2017-11-03 16:42 Bastian Stender
2017-11-06 1:57 ` Eduardo Valentin
0 siblings, 1 reply; 3+ messages in thread
From: Bastian Stender @ 2017-11-03 16:42 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: linux-pm, Viresh Kumar, kernel, Bastian Stender
The of variant of cpufreq_cooling_register links the cooling device to
the device tree node provided.
This makes it possible to bind the cpufreq cooling device to a custom
thermal zone via a cooling-maps entry like:
cooling-maps {
map0 {
trip = <&board_alert>;
cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
};
};
Assuming a cpu node exists with label "cpu0" and #cooling-cells
property.
Signed-off-by: Bastian Stender <bst@pengutronix.de>
---
drivers/thermal/imx_thermal.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 4798b4b1fd77..de71cd3bb03a 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -473,6 +473,8 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
static int imx_thermal_probe(struct platform_device *pdev)
{
+ struct device_node *np;
+ struct device *cpu_dev;
struct imx_thermal_data *data;
struct regmap *map;
int measure_freq;
@@ -533,7 +535,19 @@ static int imx_thermal_probe(struct platform_device *pdev)
return -EPROBE_DEFER;
}
- data->cdev = cpufreq_cooling_register(data->policy);
+ cpu_dev = get_cpu_device(0);
+ if (!cpu_dev) {
+ pr_err("%s: failed to get cpu0 device\n", __func__);
+ return -ENODEV;
+ }
+
+ np = of_node_get(cpu_dev->of_node);
+ if (!np) {
+ dev_err(cpu_dev, "failed to find cpu0 node\n");
+ return -ENOENT;
+ }
+
+ data->cdev = of_cpufreq_cooling_register(np, data->policy);
if (IS_ERR(data->cdev)) {
ret = PTR_ERR(data->cdev);
dev_err(&pdev->dev,
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: imx: use cpufreq cooling of registration method
2017-11-03 16:42 [PATCH] thermal: imx: use cpufreq cooling of registration method Bastian Stender
@ 2017-11-06 1:57 ` Eduardo Valentin
2017-11-07 10:26 ` Bastian Stender
0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Valentin @ 2017-11-06 1:57 UTC (permalink / raw)
To: Bastian Stender; +Cc: Zhang Rui, linux-pm, Viresh Kumar, kernel
Hello Bastian,
On Fri, Nov 03, 2017 at 05:42:03PM +0100, Bastian Stender wrote:
> The of variant of cpufreq_cooling_register links the cooling device to
> the device tree node provided.
>
> This makes it possible to bind the cpufreq cooling device to a custom
> thermal zone via a cooling-maps entry like:
>
> cooling-maps {
> map0 {
> trip = <&board_alert>;
> cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> };
> };
>
> Assuming a cpu node exists with label "cpu0" and #cooling-cells
> property.
>
> Signed-off-by: Bastian Stender <bst@pengutronix.de>
> ---
> drivers/thermal/imx_thermal.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 4798b4b1fd77..de71cd3bb03a 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -473,6 +473,8 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
>
> static int imx_thermal_probe(struct platform_device *pdev)
> {
> + struct device_node *np;
> + struct device *cpu_dev;
> struct imx_thermal_data *data;
> struct regmap *map;
> int measure_freq;
> @@ -533,7 +535,19 @@ static int imx_thermal_probe(struct platform_device *pdev)
> return -EPROBE_DEFER;
> }
>
> - data->cdev = cpufreq_cooling_register(data->policy);
> + cpu_dev = get_cpu_device(0);
> + if (!cpu_dev) {
> + pr_err("%s: failed to get cpu0 device\n", __func__);
> + return -ENODEV;
> + }
> +
> + np = of_node_get(cpu_dev->of_node);
> + if (!np) {
> + dev_err(cpu_dev, "failed to find cpu0 node\n");
> + return -ENOENT;
> + }
> +
> + data->cdev = of_cpufreq_cooling_register(np, data->policy);
This would actually be better suited if added to IMX cpufreq driver
instead. Any reason to attempt to add to the thermal driver?
> if (IS_ERR(data->cdev)) {
> ret = PTR_ERR(data->cdev);
> dev_err(&pdev->dev,
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: imx: use cpufreq cooling of registration method
2017-11-06 1:57 ` Eduardo Valentin
@ 2017-11-07 10:26 ` Bastian Stender
0 siblings, 0 replies; 3+ messages in thread
From: Bastian Stender @ 2017-11-07 10:26 UTC (permalink / raw)
To: Eduardo Valentin; +Cc: Viresh Kumar, Zhang Rui, kernel, linux-pm
Hi Eduardo,
On 11/06/2017 02:57 AM, Eduardo Valentin wrote:
> On Fri, Nov 03, 2017 at 05:42:03PM +0100, Bastian Stender wrote:
>> The of variant of cpufreq_cooling_register links the cooling device to
>> the device tree node provided.
>>
>> This makes it possible to bind the cpufreq cooling device to a custom
>> thermal zone via a cooling-maps entry like:
>>
>> cooling-maps {
>> map0 {
>> trip = <&board_alert>;
>> cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> };
>> };
>>
>> Assuming a cpu node exists with label "cpu0" and #cooling-cells
>> property.
>>
>> Signed-off-by: Bastian Stender <bst@pengutronix.de>
>> ---
>> drivers/thermal/imx_thermal.c | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
>> index 4798b4b1fd77..de71cd3bb03a 100644
>> --- a/drivers/thermal/imx_thermal.c
>> +++ b/drivers/thermal/imx_thermal.c
>> @@ -473,6 +473,8 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
>>
>> static int imx_thermal_probe(struct platform_device *pdev)
>> {
>> + struct device_node *np;
>> + struct device *cpu_dev;
>> struct imx_thermal_data *data;
>> struct regmap *map;
>> int measure_freq;
>> @@ -533,7 +535,19 @@ static int imx_thermal_probe(struct platform_device *pdev)
>> return -EPROBE_DEFER;
>> }
>>
>> - data->cdev = cpufreq_cooling_register(data->policy);
>> + cpu_dev = get_cpu_device(0);
>> + if (!cpu_dev) {
>> + pr_err("%s: failed to get cpu0 device\n", __func__);
>> + return -ENODEV;
>> + }
>> +
>> + np = of_node_get(cpu_dev->of_node);
>> + if (!np) {
>> + dev_err(cpu_dev, "failed to find cpu0 node\n");
>> + return -ENOENT;
>> + }
>> +
>> + data->cdev = of_cpufreq_cooling_register(np, data->policy);
>
> This would actually be better suited if added to IMX cpufreq driver
> instead. Any reason to attempt to add to the thermal driver?
Yes, you are right. Leaving the cooling device in imx_thermal.c was just
the path of least resistance. I will have a look in moving the cooling
device to the IMX cpufreq driver.
Regards,
Bastian
--
Pengutronix e.K.
Industrial Linux Solutions
http://www.pengutronix.de/
Peiner Str. 6-8, 31137 Hildesheim, Germany
Amtsgericht Hildesheim, HRA 2686
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-07 10:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-03 16:42 [PATCH] thermal: imx: use cpufreq cooling of registration method Bastian Stender
2017-11-06 1:57 ` Eduardo Valentin
2017-11-07 10:26 ` Bastian Stender
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).