diff options
Diffstat (limited to 'include/linux/thermal.h')
-rw-r--r-- | include/linux/thermal.h | 134 |
1 files changed, 100 insertions, 34 deletions
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 91b34812cd84..fe82022478e7 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -29,6 +29,32 @@ | |||
29 | #include <linux/device.h> | 29 | #include <linux/device.h> |
30 | #include <linux/workqueue.h> | 30 | #include <linux/workqueue.h> |
31 | 31 | ||
32 | #define THERMAL_TRIPS_NONE -1 | ||
33 | #define THERMAL_MAX_TRIPS 12 | ||
34 | #define THERMAL_NAME_LENGTH 20 | ||
35 | |||
36 | /* No upper/lower limit requirement */ | ||
37 | #define THERMAL_NO_LIMIT -1UL | ||
38 | |||
39 | /* Unit conversion macros */ | ||
40 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ | ||
41 | ((long)t-2732+5)/10 : ((long)t-2732-5)/10) | ||
42 | #define CELSIUS_TO_KELVIN(t) ((t)*10+2732) | ||
43 | |||
44 | /* Adding event notification support elements */ | ||
45 | #define THERMAL_GENL_FAMILY_NAME "thermal_event" | ||
46 | #define THERMAL_GENL_VERSION 0x01 | ||
47 | #define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_group" | ||
48 | |||
49 | /* Default Thermal Governor */ | ||
50 | #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) | ||
51 | #define DEFAULT_THERMAL_GOVERNOR "step_wise" | ||
52 | #elif defined(CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE) | ||
53 | #define DEFAULT_THERMAL_GOVERNOR "fair_share" | ||
54 | #elif defined(CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE) | ||
55 | #define DEFAULT_THERMAL_GOVERNOR "user_space" | ||
56 | #endif | ||
57 | |||
32 | struct thermal_zone_device; | 58 | struct thermal_zone_device; |
33 | struct thermal_cooling_device; | 59 | struct thermal_cooling_device; |
34 | 60 | ||
@@ -50,6 +76,30 @@ enum thermal_trend { | |||
50 | THERMAL_TREND_DROPPING, /* temperature is dropping */ | 76 | THERMAL_TREND_DROPPING, /* temperature is dropping */ |
51 | }; | 77 | }; |
52 | 78 | ||
79 | /* Events supported by Thermal Netlink */ | ||
80 | enum events { | ||
81 | THERMAL_AUX0, | ||
82 | THERMAL_AUX1, | ||
83 | THERMAL_CRITICAL, | ||
84 | THERMAL_DEV_FAULT, | ||
85 | }; | ||
86 | |||
87 | /* attributes of thermal_genl_family */ | ||
88 | enum { | ||
89 | THERMAL_GENL_ATTR_UNSPEC, | ||
90 | THERMAL_GENL_ATTR_EVENT, | ||
91 | __THERMAL_GENL_ATTR_MAX, | ||
92 | }; | ||
93 | #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1) | ||
94 | |||
95 | /* commands supported by the thermal_genl_family */ | ||
96 | enum { | ||
97 | THERMAL_GENL_CMD_UNSPEC, | ||
98 | THERMAL_GENL_CMD_EVENT, | ||
99 | __THERMAL_GENL_CMD_MAX, | ||
100 | }; | ||
101 | #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1) | ||
102 | |||
53 | struct thermal_zone_device_ops { | 103 | struct thermal_zone_device_ops { |
54 | int (*bind) (struct thermal_zone_device *, | 104 | int (*bind) (struct thermal_zone_device *, |
55 | struct thermal_cooling_device *); | 105 | struct thermal_cooling_device *); |
@@ -83,11 +133,6 @@ struct thermal_cooling_device_ops { | |||
83 | int (*set_cur_state) (struct thermal_cooling_device *, unsigned long); | 133 | int (*set_cur_state) (struct thermal_cooling_device *, unsigned long); |
84 | }; | 134 | }; |
85 | 135 | ||
86 | #define THERMAL_NO_LIMIT -1UL /* no upper/lower limit requirement */ | ||
87 | |||
88 | #define THERMAL_TRIPS_NONE -1 | ||
89 | #define THERMAL_MAX_TRIPS 12 | ||
90 | #define THERMAL_NAME_LENGTH 20 | ||
91 | struct thermal_cooling_device { | 136 | struct thermal_cooling_device { |
92 | int id; | 137 | int id; |
93 | char type[THERMAL_NAME_LENGTH]; | 138 | char type[THERMAL_NAME_LENGTH]; |
@@ -100,10 +145,6 @@ struct thermal_cooling_device { | |||
100 | struct list_head node; | 145 | struct list_head node; |
101 | }; | 146 | }; |
102 | 147 | ||
103 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ | ||
104 | ((long)t-2732+5)/10 : ((long)t-2732-5)/10) | ||
105 | #define CELSIUS_TO_KELVIN(t) ((t)*10+2732) | ||
106 | |||
107 | struct thermal_attr { | 148 | struct thermal_attr { |
108 | struct device_attribute attr; | 149 | struct device_attribute attr; |
109 | char name[THERMAL_NAME_LENGTH]; | 150 | char name[THERMAL_NAME_LENGTH]; |
@@ -125,46 +166,61 @@ struct thermal_zone_device { | |||
125 | int passive; | 166 | int passive; |
126 | unsigned int forced_passive; | 167 | unsigned int forced_passive; |
127 | const struct thermal_zone_device_ops *ops; | 168 | const struct thermal_zone_device_ops *ops; |
169 | const struct thermal_zone_params *tzp; | ||
170 | struct thermal_governor *governor; | ||
128 | struct list_head thermal_instances; | 171 | struct list_head thermal_instances; |
129 | struct idr idr; | 172 | struct idr idr; |
130 | struct mutex lock; /* protect thermal_instances list */ | 173 | struct mutex lock; /* protect thermal_instances list */ |
131 | struct list_head node; | 174 | struct list_head node; |
132 | struct delayed_work poll_queue; | 175 | struct delayed_work poll_queue; |
133 | }; | 176 | }; |
134 | /* Adding event notification support elements */ | ||
135 | #define THERMAL_GENL_FAMILY_NAME "thermal_event" | ||
136 | #define THERMAL_GENL_VERSION 0x01 | ||
137 | #define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_group" | ||
138 | 177 | ||
139 | enum events { | 178 | /* Structure that holds thermal governor information */ |
140 | THERMAL_AUX0, | 179 | struct thermal_governor { |
141 | THERMAL_AUX1, | 180 | char name[THERMAL_NAME_LENGTH]; |
142 | THERMAL_CRITICAL, | 181 | int (*throttle)(struct thermal_zone_device *tz, int trip); |
143 | THERMAL_DEV_FAULT, | 182 | struct list_head governor_list; |
183 | struct module *owner; | ||
144 | }; | 184 | }; |
145 | 185 | ||
146 | struct thermal_genl_event { | 186 | /* Structure that holds binding parameters for a zone */ |
147 | u32 orig; | 187 | struct thermal_bind_params { |
148 | enum events event; | 188 | struct thermal_cooling_device *cdev; |
189 | |||
190 | /* | ||
191 | * This is a measure of 'how effectively these devices can | ||
192 | * cool 'this' thermal zone. The shall be determined by platform | ||
193 | * characterization. This is on a 'percentage' scale. | ||
194 | * See Documentation/thermal/sysfs-api.txt for more information. | ||
195 | */ | ||
196 | int weight; | ||
197 | |||
198 | /* | ||
199 | * This is a bit mask that gives the binding relation between this | ||
200 | * thermal zone and cdev, for a particular trip point. | ||
201 | * See Documentation/thermal/sysfs-api.txt for more information. | ||
202 | */ | ||
203 | int trip_mask; | ||
204 | int (*match) (struct thermal_zone_device *tz, | ||
205 | struct thermal_cooling_device *cdev); | ||
149 | }; | 206 | }; |
150 | /* attributes of thermal_genl_family */ | 207 | |
151 | enum { | 208 | /* Structure to define Thermal Zone parameters */ |
152 | THERMAL_GENL_ATTR_UNSPEC, | 209 | struct thermal_zone_params { |
153 | THERMAL_GENL_ATTR_EVENT, | 210 | char governor_name[THERMAL_NAME_LENGTH]; |
154 | __THERMAL_GENL_ATTR_MAX, | 211 | int num_tbps; /* Number of tbp entries */ |
212 | struct thermal_bind_params *tbp; | ||
155 | }; | 213 | }; |
156 | #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1) | ||
157 | 214 | ||
158 | /* commands supported by the thermal_genl_family */ | 215 | struct thermal_genl_event { |
159 | enum { | 216 | u32 orig; |
160 | THERMAL_GENL_CMD_UNSPEC, | 217 | enum events event; |
161 | THERMAL_GENL_CMD_EVENT, | ||
162 | __THERMAL_GENL_CMD_MAX, | ||
163 | }; | 218 | }; |
164 | #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1) | ||
165 | 219 | ||
220 | /* Function declarations */ | ||
166 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, | 221 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, |
167 | void *, const struct thermal_zone_device_ops *, int, int); | 222 | void *, const struct thermal_zone_device_ops *, |
223 | const struct thermal_zone_params *, int, int); | ||
168 | void thermal_zone_device_unregister(struct thermal_zone_device *); | 224 | void thermal_zone_device_unregister(struct thermal_zone_device *); |
169 | 225 | ||
170 | int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, | 226 | int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, |
@@ -173,10 +229,20 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, | |||
173 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, | 229 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, |
174 | struct thermal_cooling_device *); | 230 | struct thermal_cooling_device *); |
175 | void thermal_zone_device_update(struct thermal_zone_device *); | 231 | void thermal_zone_device_update(struct thermal_zone_device *); |
232 | |||
176 | struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, | 233 | struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, |
177 | const struct thermal_cooling_device_ops *); | 234 | const struct thermal_cooling_device_ops *); |
178 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); | 235 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); |
179 | 236 | ||
237 | int get_tz_trend(struct thermal_zone_device *, int); | ||
238 | struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, | ||
239 | struct thermal_cooling_device *, int); | ||
240 | void thermal_cdev_update(struct thermal_cooling_device *); | ||
241 | void notify_thermal_framework(struct thermal_zone_device *, int); | ||
242 | |||
243 | int thermal_register_governor(struct thermal_governor *); | ||
244 | void thermal_unregister_governor(struct thermal_governor *); | ||
245 | |||
180 | #ifdef CONFIG_NET | 246 | #ifdef CONFIG_NET |
181 | extern int thermal_generate_netlink_event(u32 orig, enum events event); | 247 | extern int thermal_generate_netlink_event(u32 orig, enum events event); |
182 | #else | 248 | #else |