xref: /linux-6.15/include/linux/cpu_cooling.h (revision 3ebb62ff)
1 /*
2  *  linux/include/linux/cpu_cooling.h
3  *
4  *  Copyright (C) 2012	Samsung Electronics Co., Ltd(http://www.samsung.com)
5  *  Copyright (C) 2012  Amit Daniel <[email protected]>
6  *
7  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; version 2 of the License.
11  *
12  *  This program is distributed in the hope that it will be useful, but
13  *  WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License along
18  *  with this program; if not, write to the Free Software Foundation, Inc.,
19  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22  */
23 
24 #ifndef __CPU_COOLING_H__
25 #define __CPU_COOLING_H__
26 
27 #include <linux/of.h>
28 #include <linux/thermal.h>
29 #include <linux/cpumask.h>
30 
31 struct cpufreq_policy;
32 
33 typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
34 			    unsigned long voltage, u32 *power);
35 
36 #ifdef CONFIG_CPU_THERMAL
37 /**
38  * cpufreq_cooling_register - function to create cpufreq cooling device.
39  * @policy: cpufreq policy.
40  */
41 struct thermal_cooling_device *
42 cpufreq_cooling_register(struct cpufreq_policy *policy);
43 
44 /**
45  * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
46  * @cdev: thermal cooling device pointer.
47  */
48 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
49 
50 #else /* !CONFIG_CPU_THERMAL */
51 static inline struct thermal_cooling_device *
52 cpufreq_cooling_register(struct cpufreq_policy *policy)
53 {
54 	return ERR_PTR(-ENOSYS);
55 }
56 
57 static inline
58 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
59 {
60 	return;
61 }
62 #endif	/* CONFIG_CPU_THERMAL */
63 
64 #if defined(CONFIG_THERMAL_OF) && defined(CONFIG_CPU_THERMAL)
65 /**
66  * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
67  * @policy: cpufreq policy.
68  */
69 struct thermal_cooling_device *
70 of_cpufreq_cooling_register(struct cpufreq_policy *policy);
71 #else
72 static inline struct thermal_cooling_device *
73 of_cpufreq_cooling_register(struct cpufreq_policy *policy)
74 {
75 	return NULL;
76 }
77 #endif /* defined(CONFIG_THERMAL_OF) && defined(CONFIG_CPU_THERMAL) */
78 
79 #endif /* __CPU_COOLING_H__ */
80