xref: /linux-6.15/include/linux/cpu_cooling.h (revision c75bec79)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  linux/include/linux/cpu_cooling.h
4  *
5  *  Copyright (C) 2012	Samsung Electronics Co., Ltd(http://www.samsung.com)
6  *  Copyright (C) 2012  Amit Daniel <[email protected]>
7  *
8  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9  *
10  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11  */
12 
13 #ifndef __CPU_COOLING_H__
14 #define __CPU_COOLING_H__
15 
16 #include <linux/of.h>
17 #include <linux/thermal.h>
18 #include <linux/cpumask.h>
19 
20 struct cpufreq_policy;
21 
22 #ifdef CONFIG_CPU_FREQ_THERMAL
23 /**
24  * cpufreq_cooling_register - function to create cpufreq cooling device.
25  * @policy: cpufreq policy.
26  */
27 struct thermal_cooling_device *
28 cpufreq_cooling_register(struct cpufreq_policy *policy);
29 
30 /**
31  * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
32  * @cdev: thermal cooling device pointer.
33  */
34 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
35 
36 /**
37  * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
38  * @policy: cpufreq policy.
39  */
40 struct thermal_cooling_device *
41 of_cpufreq_cooling_register(struct cpufreq_policy *policy);
42 
43 #else /* !CONFIG_CPU_FREQ_THERMAL */
44 static inline struct thermal_cooling_device *
45 cpufreq_cooling_register(struct cpufreq_policy *policy)
46 {
47 	return ERR_PTR(-ENOSYS);
48 }
49 
50 static inline
51 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
52 {
53 	return;
54 }
55 
56 static inline struct thermal_cooling_device *
57 of_cpufreq_cooling_register(struct cpufreq_policy *policy)
58 {
59 	return NULL;
60 }
61 #endif /* CONFIG_CPU_FREQ_THERMAL */
62 
63 struct cpuidle_driver;
64 
65 #ifdef CONFIG_CPU_IDLE_THERMAL
66 int cpuidle_cooling_register(struct cpuidle_driver *drv);
67 int cpuidle_of_cooling_register(struct device_node *np,
68 				struct cpuidle_driver *drv);
69 #else /* CONFIG_CPU_IDLE_THERMAL */
70 static inline int cpuidle_cooling_register(struct cpuidle_driver *drv)
71 {
72 	return 0;
73 }
74 static inline int cpuidle_of_cooling_register(struct device_node *np,
75 					      struct cpuidle_driver *drv)
76 {
77 	return 0;
78 }
79 #endif /* CONFIG_CPU_IDLE_THERMAL */
80 
81 #endif /* __CPU_COOLING_H__ */
82