Commit | Line | Data |
---|---|---|
02361418 ADK |
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 <amit.kachhap@linaro.org> | |
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 | ||
39d99cff | 27 | #include <linux/of.h> |
02361418 | 28 | #include <linux/thermal.h> |
198f38f7 | 29 | #include <linux/cpumask.h> |
02361418 | 30 | |
c36cf071 JM |
31 | typedef int (*get_static_t)(cpumask_t *cpumask, int interval, |
32 | unsigned long voltage, u32 *power); | |
33 | ||
bbf7fc88 | 34 | #ifdef CONFIG_CPU_THERMAL |
02361418 ADK |
35 | /** |
36 | * cpufreq_cooling_register - function to create cpufreq cooling device. | |
37 | * @clip_cpus: cpumask of cpus where the frequency constraints will happen | |
38 | */ | |
d44ada51 EV |
39 | struct thermal_cooling_device * |
40 | cpufreq_cooling_register(const struct cpumask *clip_cpus); | |
02361418 | 41 | |
c36cf071 JM |
42 | struct thermal_cooling_device * |
43 | cpufreq_power_cooling_register(const struct cpumask *clip_cpus, | |
44 | u32 capacitance, get_static_t plat_static_func); | |
45 | ||
39d99cff EV |
46 | /** |
47 | * of_cpufreq_cooling_register - create cpufreq cooling device based on DT. | |
48 | * @np: a valid struct device_node to the cooling device device tree node. | |
49 | * @clip_cpus: cpumask of cpus where the frequency constraints will happen | |
50 | */ | |
51 | #ifdef CONFIG_THERMAL_OF | |
52 | struct thermal_cooling_device * | |
53 | of_cpufreq_cooling_register(struct device_node *np, | |
54 | const struct cpumask *clip_cpus); | |
c36cf071 JM |
55 | |
56 | struct thermal_cooling_device * | |
57 | of_cpufreq_power_cooling_register(struct device_node *np, | |
58 | const struct cpumask *clip_cpus, | |
59 | u32 capacitance, | |
60 | get_static_t plat_static_func); | |
39d99cff EV |
61 | #else |
62 | static inline struct thermal_cooling_device * | |
63 | of_cpufreq_cooling_register(struct device_node *np, | |
64 | const struct cpumask *clip_cpus) | |
65 | { | |
503ccc3f | 66 | return ERR_PTR(-ENOSYS); |
39d99cff | 67 | } |
c36cf071 JM |
68 | |
69 | static inline struct thermal_cooling_device * | |
70 | of_cpufreq_power_cooling_register(struct device_node *np, | |
71 | const struct cpumask *clip_cpus, | |
72 | u32 capacitance, | |
73 | get_static_t plat_static_func) | |
74 | { | |
75 | return NULL; | |
76 | } | |
39d99cff EV |
77 | #endif |
78 | ||
02361418 ADK |
79 | /** |
80 | * cpufreq_cooling_unregister - function to remove cpufreq cooling device. | |
81 | * @cdev: thermal cooling device pointer. | |
82 | */ | |
83 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); | |
57df8106 | 84 | |
e8d39240 | 85 | unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq); |
02361418 | 86 | #else /* !CONFIG_CPU_THERMAL */ |
d44ada51 EV |
87 | static inline struct thermal_cooling_device * |
88 | cpufreq_cooling_register(const struct cpumask *clip_cpus) | |
02361418 | 89 | { |
503ccc3f | 90 | return ERR_PTR(-ENOSYS); |
02361418 | 91 | } |
c36cf071 JM |
92 | static inline struct thermal_cooling_device * |
93 | cpufreq_power_cooling_register(const struct cpumask *clip_cpus, | |
94 | u32 capacitance, get_static_t plat_static_func) | |
95 | { | |
96 | return NULL; | |
97 | } | |
98 | ||
39d99cff EV |
99 | static inline struct thermal_cooling_device * |
100 | of_cpufreq_cooling_register(struct device_node *np, | |
101 | const struct cpumask *clip_cpus) | |
102 | { | |
503ccc3f | 103 | return ERR_PTR(-ENOSYS); |
39d99cff | 104 | } |
c36cf071 JM |
105 | |
106 | static inline struct thermal_cooling_device * | |
107 | of_cpufreq_power_cooling_register(struct device_node *np, | |
108 | const struct cpumask *clip_cpus, | |
109 | u32 capacitance, | |
110 | get_static_t plat_static_func) | |
111 | { | |
112 | return NULL; | |
113 | } | |
114 | ||
d44ada51 EV |
115 | static inline |
116 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) | |
02361418 ADK |
117 | { |
118 | return; | |
119 | } | |
d44ada51 | 120 | static inline |
e8d39240 | 121 | unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) |
57df8106 ZR |
122 | { |
123 | return THERMAL_CSTATE_INVALID; | |
124 | } | |
02361418 ADK |
125 | #endif /* CONFIG_CPU_THERMAL */ |
126 | ||
127 | #endif /* __CPU_COOLING_H__ */ |