aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/thermal/Kconfig1
-rw-r--r--drivers/thermal/cpu_cooling.c56
-rw-r--r--include/linux/cpu_cooling.h25
3 files changed, 76 insertions, 6 deletions
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index a150f8d53322..3feb5377fbf6 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -92,6 +92,7 @@ config THERMAL_GOV_USER_SPACE
92config CPU_THERMAL 92config CPU_THERMAL
93 bool "generic cpu cooling support" 93 bool "generic cpu cooling support"
94 depends on CPU_FREQ 94 depends on CPU_FREQ
95 depends on THERMAL_OF
95 help 96 help
96 This implements the generic cpu cooling mechanism through frequency 97 This implements the generic cpu cooling mechanism through frequency
97 reduction. An ACPI version of this already exists 98 reduction. An ACPI version of this already exists
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 02a46f23d14c..a6cb5531403f 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -417,18 +417,21 @@ static struct notifier_block thermal_cpufreq_notifier_block = {
417}; 417};
418 418
419/** 419/**
420 * cpufreq_cooling_register - function to create cpufreq cooling device. 420 * __cpufreq_cooling_register - helper function to create cpufreq cooling device
421 * @np: a valid struct device_node to the cooling device device tree node
421 * @clip_cpus: cpumask of cpus where the frequency constraints will happen. 422 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
422 * 423 *
423 * This interface function registers the cpufreq cooling device with the name 424 * This interface function registers the cpufreq cooling device with the name
424 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq 425 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
425 * cooling devices. 426 * cooling devices. It also gives the opportunity to link the cooling device
427 * with a device tree node, in order to bind it via the thermal DT code.
426 * 428 *
427 * Return: a valid struct thermal_cooling_device pointer on success, 429 * Return: a valid struct thermal_cooling_device pointer on success,
428 * on failure, it returns a corresponding ERR_PTR(). 430 * on failure, it returns a corresponding ERR_PTR().
429 */ 431 */
430struct thermal_cooling_device * 432static struct thermal_cooling_device *
431cpufreq_cooling_register(const struct cpumask *clip_cpus) 433__cpufreq_cooling_register(struct device_node *np,
434 const struct cpumask *clip_cpus)
432{ 435{
433 struct thermal_cooling_device *cool_dev; 436 struct thermal_cooling_device *cool_dev;
434 struct cpufreq_cooling_device *cpufreq_dev = NULL; 437 struct cpufreq_cooling_device *cpufreq_dev = NULL;
@@ -467,8 +470,8 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
467 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", 470 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
468 cpufreq_dev->id); 471 cpufreq_dev->id);
469 472
470 cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev, 473 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
471 &cpufreq_cooling_ops); 474 &cpufreq_cooling_ops);
472 if (IS_ERR(cool_dev)) { 475 if (IS_ERR(cool_dev)) {
473 release_idr(&cpufreq_idr, cpufreq_dev->id); 476 release_idr(&cpufreq_idr, cpufreq_dev->id);
474 kfree(cpufreq_dev); 477 kfree(cpufreq_dev);
@@ -488,9 +491,50 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
488 491
489 return cool_dev; 492 return cool_dev;
490} 493}
494
495/**
496 * cpufreq_cooling_register - function to create cpufreq cooling device.
497 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
498 *
499 * This interface function registers the cpufreq cooling device with the name
500 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
501 * cooling devices.
502 *
503 * Return: a valid struct thermal_cooling_device pointer on success,
504 * on failure, it returns a corresponding ERR_PTR().
505 */
506struct thermal_cooling_device *
507cpufreq_cooling_register(const struct cpumask *clip_cpus)
508{
509 return __cpufreq_cooling_register(NULL, clip_cpus);
510}
491EXPORT_SYMBOL_GPL(cpufreq_cooling_register); 511EXPORT_SYMBOL_GPL(cpufreq_cooling_register);
492 512
493/** 513/**
514 * of_cpufreq_cooling_register - function to create cpufreq cooling device.
515 * @np: a valid struct device_node to the cooling device device tree node
516 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
517 *
518 * This interface function registers the cpufreq cooling device with the name
519 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
520 * cooling devices. Using this API, the cpufreq cooling device will be
521 * linked to the device tree node provided.
522 *
523 * Return: a valid struct thermal_cooling_device pointer on success,
524 * on failure, it returns a corresponding ERR_PTR().
525 */
526struct thermal_cooling_device *
527of_cpufreq_cooling_register(struct device_node *np,
528 const struct cpumask *clip_cpus)
529{
530 if (!np)
531 return ERR_PTR(-EINVAL);
532
533 return __cpufreq_cooling_register(np, clip_cpus);
534}
535EXPORT_SYMBOL_GPL(of_cpufreq_cooling_register);
536
537/**
494 * cpufreq_cooling_unregister - function to remove cpufreq cooling device. 538 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
495 * @cdev: thermal cooling device pointer. 539 * @cdev: thermal cooling device pointer.
496 * 540 *
diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h
index a5d52eea8232..c303d383def1 100644
--- a/include/linux/cpu_cooling.h
+++ b/include/linux/cpu_cooling.h
@@ -24,6 +24,7 @@
24#ifndef __CPU_COOLING_H__ 24#ifndef __CPU_COOLING_H__
25#define __CPU_COOLING_H__ 25#define __CPU_COOLING_H__
26 26
27#include <linux/of.h>
27#include <linux/thermal.h> 28#include <linux/thermal.h>
28#include <linux/cpumask.h> 29#include <linux/cpumask.h>
29 30
@@ -36,6 +37,24 @@ struct thermal_cooling_device *
36cpufreq_cooling_register(const struct cpumask *clip_cpus); 37cpufreq_cooling_register(const struct cpumask *clip_cpus);
37 38
38/** 39/**
40 * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
41 * @np: a valid struct device_node to the cooling device device tree node.
42 * @clip_cpus: cpumask of cpus where the frequency constraints will happen
43 */
44#ifdef CONFIG_THERMAL_OF
45struct thermal_cooling_device *
46of_cpufreq_cooling_register(struct device_node *np,
47 const struct cpumask *clip_cpus);
48#else
49static inline struct thermal_cooling_device *
50of_cpufreq_cooling_register(struct device_node *np,
51 const struct cpumask *clip_cpus)
52{
53 return NULL;
54}
55#endif
56
57/**
39 * cpufreq_cooling_unregister - function to remove cpufreq cooling device. 58 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
40 * @cdev: thermal cooling device pointer. 59 * @cdev: thermal cooling device pointer.
41 */ 60 */
@@ -48,6 +67,12 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
48{ 67{
49 return NULL; 68 return NULL;
50} 69}
70static inline struct thermal_cooling_device *
71of_cpufreq_cooling_register(struct device_node *np,
72 const struct cpumask *clip_cpus)
73{
74 return NULL;
75}
51static inline 76static inline
52void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) 77void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
53{ 78{