Commit 514e6d20147b86900f3302ef756af58890641b4d

Authored by Zhang Rui
1 parent a00e55f9c8

Thermal: update documentation for thermal_zone_device_register

Update kernel Documentation for thermal_zone_device_register.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Showing 1 changed file with 11 additions and 3 deletions Inline Diff

Documentation/thermal/sysfs-api.txt
1 Generic Thermal Sysfs driver How To 1 Generic Thermal Sysfs driver How To
2 =================================== 2 ===================================
3 3
4 Written by Sujith Thomas <sujith.thomas@intel.com>, Zhang Rui <rui.zhang@intel.com> 4 Written by Sujith Thomas <sujith.thomas@intel.com>, Zhang Rui <rui.zhang@intel.com>
5 5
6 Updated: 2 January 2008 6 Updated: 2 January 2008
7 7
8 Copyright (c) 2008 Intel Corporation 8 Copyright (c) 2008 Intel Corporation
9 9
10 10
11 0. Introduction 11 0. Introduction
12 12
13 The generic thermal sysfs provides a set of interfaces for thermal zone 13 The generic thermal sysfs provides a set of interfaces for thermal zone
14 devices (sensors) and thermal cooling devices (fan, processor...) to register 14 devices (sensors) and thermal cooling devices (fan, processor...) to register
15 with the thermal management solution and to be a part of it. 15 with the thermal management solution and to be a part of it.
16 16
17 This how-to focuses on enabling new thermal zone and cooling devices to 17 This how-to focuses on enabling new thermal zone and cooling devices to
18 participate in thermal management. 18 participate in thermal management.
19 This solution is platform independent and any type of thermal zone devices 19 This solution is platform independent and any type of thermal zone devices
20 and cooling devices should be able to make use of the infrastructure. 20 and cooling devices should be able to make use of the infrastructure.
21 21
22 The main task of the thermal sysfs driver is to expose thermal zone attributes 22 The main task of the thermal sysfs driver is to expose thermal zone attributes
23 as well as cooling device attributes to the user space. 23 as well as cooling device attributes to the user space.
24 An intelligent thermal management application can make decisions based on 24 An intelligent thermal management application can make decisions based on
25 inputs from thermal zone attributes (the current temperature and trip point 25 inputs from thermal zone attributes (the current temperature and trip point
26 temperature) and throttle appropriate devices. 26 temperature) and throttle appropriate devices.
27 27
28 [0-*] denotes any positive number starting from 0 28 [0-*] denotes any positive number starting from 0
29 [1-*] denotes any positive number starting from 1 29 [1-*] denotes any positive number starting from 1
30 30
31 1. thermal sysfs driver interface functions 31 1. thermal sysfs driver interface functions
32 32
33 1.1 thermal zone device interface 33 1.1 thermal zone device interface
34 1.1.1 struct thermal_zone_device *thermal_zone_device_register(char *name, 34 1.1.1 struct thermal_zone_device *thermal_zone_device_register(char *type,
35 int trips, int mask, void *devdata, 35 int trips, int mask, void *devdata,
36 struct thermal_zone_device_ops *ops) 36 struct thermal_zone_device_ops *ops,
37 const struct thermal_zone_params *tzp,
38 int passive_delay, int polling_delay))
37 39
38 This interface function adds a new thermal zone device (sensor) to 40 This interface function adds a new thermal zone device (sensor) to
39 /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the 41 /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
40 thermal cooling devices registered at the same time. 42 thermal cooling devices registered at the same time.
41 43
42 name: the thermal zone name. 44 type: the thermal zone type.
43 trips: the total number of trip points this thermal zone supports. 45 trips: the total number of trip points this thermal zone supports.
44 mask: Bit string: If 'n'th bit is set, then trip point 'n' is writeable. 46 mask: Bit string: If 'n'th bit is set, then trip point 'n' is writeable.
45 devdata: device private data 47 devdata: device private data
46 ops: thermal zone device call-backs. 48 ops: thermal zone device call-backs.
47 .bind: bind the thermal zone device with a thermal cooling device. 49 .bind: bind the thermal zone device with a thermal cooling device.
48 .unbind: unbind the thermal zone device with a thermal cooling device. 50 .unbind: unbind the thermal zone device with a thermal cooling device.
49 .get_temp: get the current temperature of the thermal zone. 51 .get_temp: get the current temperature of the thermal zone.
50 .get_mode: get the current mode (enabled/disabled) of the thermal zone. 52 .get_mode: get the current mode (enabled/disabled) of the thermal zone.
51 - "enabled" means the kernel thermal management is enabled. 53 - "enabled" means the kernel thermal management is enabled.
52 - "disabled" will prevent kernel thermal driver action upon trip points 54 - "disabled" will prevent kernel thermal driver action upon trip points
53 so that user applications can take charge of thermal management. 55 so that user applications can take charge of thermal management.
54 .set_mode: set the mode (enabled/disabled) of the thermal zone. 56 .set_mode: set the mode (enabled/disabled) of the thermal zone.
55 .get_trip_type: get the type of certain trip point. 57 .get_trip_type: get the type of certain trip point.
56 .get_trip_temp: get the temperature above which the certain trip point 58 .get_trip_temp: get the temperature above which the certain trip point
57 will be fired. 59 will be fired.
58 .set_emul_temp: set the emulation temperature which helps in debugging 60 .set_emul_temp: set the emulation temperature which helps in debugging
59 different threshold temperature points. 61 different threshold temperature points.
62 tzp: thermal zone platform parameters.
63 passive_delay: number of milliseconds to wait between polls when
64 performing passive cooling.
65 polling_delay: number of milliseconds to wait between polls when checking
66 whether trip points have been crossed (0 for interrupt driven systems).
67
60 68
61 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz) 69 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)
62 70
63 This interface function removes the thermal zone device. 71 This interface function removes the thermal zone device.
64 It deletes the corresponding entry form /sys/class/thermal folder and 72 It deletes the corresponding entry form /sys/class/thermal folder and
65 unbind all the thermal cooling devices it uses. 73 unbind all the thermal cooling devices it uses.
66 74
67 1.2 thermal cooling device interface 75 1.2 thermal cooling device interface
68 1.2.1 struct thermal_cooling_device *thermal_cooling_device_register(char *name, 76 1.2.1 struct thermal_cooling_device *thermal_cooling_device_register(char *name,
69 void *devdata, struct thermal_cooling_device_ops *) 77 void *devdata, struct thermal_cooling_device_ops *)
70 78
71 This interface function adds a new thermal cooling device (fan/processor/...) 79 This interface function adds a new thermal cooling device (fan/processor/...)
72 to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself 80 to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
73 to all the thermal zone devices register at the same time. 81 to all the thermal zone devices register at the same time.
74 name: the cooling device name. 82 name: the cooling device name.
75 devdata: device private data. 83 devdata: device private data.
76 ops: thermal cooling devices call-backs. 84 ops: thermal cooling devices call-backs.
77 .get_max_state: get the Maximum throttle state of the cooling device. 85 .get_max_state: get the Maximum throttle state of the cooling device.
78 .get_cur_state: get the Current throttle state of the cooling device. 86 .get_cur_state: get the Current throttle state of the cooling device.
79 .set_cur_state: set the Current throttle state of the cooling device. 87 .set_cur_state: set the Current throttle state of the cooling device.
80 88
81 1.2.2 void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) 89 1.2.2 void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
82 90
83 This interface function remove the thermal cooling device. 91 This interface function remove the thermal cooling device.
84 It deletes the corresponding entry form /sys/class/thermal folder and 92 It deletes the corresponding entry form /sys/class/thermal folder and
85 unbind itself from all the thermal zone devices using it. 93 unbind itself from all the thermal zone devices using it.
86 94
87 1.3 interface for binding a thermal zone device with a thermal cooling device 95 1.3 interface for binding a thermal zone device with a thermal cooling device
88 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, 96 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
89 int trip, struct thermal_cooling_device *cdev, 97 int trip, struct thermal_cooling_device *cdev,
90 unsigned long upper, unsigned long lower); 98 unsigned long upper, unsigned long lower);
91 99
92 This interface function bind a thermal cooling device to the certain trip 100 This interface function bind a thermal cooling device to the certain trip
93 point of a thermal zone device. 101 point of a thermal zone device.
94 This function is usually called in the thermal zone device .bind callback. 102 This function is usually called in the thermal zone device .bind callback.
95 tz: the thermal zone device 103 tz: the thermal zone device
96 cdev: thermal cooling device 104 cdev: thermal cooling device
97 trip: indicates which trip point the cooling devices is associated with 105 trip: indicates which trip point the cooling devices is associated with
98 in this thermal zone. 106 in this thermal zone.
99 upper:the Maximum cooling state for this trip point. 107 upper:the Maximum cooling state for this trip point.
100 THERMAL_NO_LIMIT means no upper limit, 108 THERMAL_NO_LIMIT means no upper limit,
101 and the cooling device can be in max_state. 109 and the cooling device can be in max_state.
102 lower:the Minimum cooling state can be used for this trip point. 110 lower:the Minimum cooling state can be used for this trip point.
103 THERMAL_NO_LIMIT means no lower limit, 111 THERMAL_NO_LIMIT means no lower limit,
104 and the cooling device can be in cooling state 0. 112 and the cooling device can be in cooling state 0.
105 113
106 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, 114 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
107 int trip, struct thermal_cooling_device *cdev); 115 int trip, struct thermal_cooling_device *cdev);
108 116
109 This interface function unbind a thermal cooling device from the certain 117 This interface function unbind a thermal cooling device from the certain
110 trip point of a thermal zone device. This function is usually called in 118 trip point of a thermal zone device. This function is usually called in
111 the thermal zone device .unbind callback. 119 the thermal zone device .unbind callback.
112 tz: the thermal zone device 120 tz: the thermal zone device
113 cdev: thermal cooling device 121 cdev: thermal cooling device
114 trip: indicates which trip point the cooling devices is associated with 122 trip: indicates which trip point the cooling devices is associated with
115 in this thermal zone. 123 in this thermal zone.
116 124
117 1.4 Thermal Zone Parameters 125 1.4 Thermal Zone Parameters
118 1.4.1 struct thermal_bind_params 126 1.4.1 struct thermal_bind_params
119 This structure defines the following parameters that are used to bind 127 This structure defines the following parameters that are used to bind
120 a zone with a cooling device for a particular trip point. 128 a zone with a cooling device for a particular trip point.
121 .cdev: The cooling device pointer 129 .cdev: The cooling device pointer
122 .weight: The 'influence' of a particular cooling device on this zone. 130 .weight: The 'influence' of a particular cooling device on this zone.
123 This is on a percentage scale. The sum of all these weights 131 This is on a percentage scale. The sum of all these weights
124 (for a particular zone) cannot exceed 100. 132 (for a particular zone) cannot exceed 100.
125 .trip_mask:This is a bit mask that gives the binding relation between 133 .trip_mask:This is a bit mask that gives the binding relation between
126 this thermal zone and cdev, for a particular trip point. 134 this thermal zone and cdev, for a particular trip point.
127 If nth bit is set, then the cdev and thermal zone are bound 135 If nth bit is set, then the cdev and thermal zone are bound
128 for trip point n. 136 for trip point n.
129 .match: This call back returns success(0) if the 'tz and cdev' need to 137 .match: This call back returns success(0) if the 'tz and cdev' need to
130 be bound, as per platform data. 138 be bound, as per platform data.
131 1.4.2 struct thermal_zone_params 139 1.4.2 struct thermal_zone_params
132 This structure defines the platform level parameters for a thermal zone. 140 This structure defines the platform level parameters for a thermal zone.
133 This data, for each thermal zone should come from the platform layer. 141 This data, for each thermal zone should come from the platform layer.
134 This is an optional feature where some platforms can choose not to 142 This is an optional feature where some platforms can choose not to
135 provide this data. 143 provide this data.
136 .governor_name: Name of the thermal governor used for this zone 144 .governor_name: Name of the thermal governor used for this zone
137 .num_tbps: Number of thermal_bind_params entries for this zone 145 .num_tbps: Number of thermal_bind_params entries for this zone
138 .tbp: thermal_bind_params entries 146 .tbp: thermal_bind_params entries
139 147
140 2. sysfs attributes structure 148 2. sysfs attributes structure
141 149
142 RO read only value 150 RO read only value
143 RW read/write value 151 RW read/write value
144 152
145 Thermal sysfs attributes will be represented under /sys/class/thermal. 153 Thermal sysfs attributes will be represented under /sys/class/thermal.
146 Hwmon sysfs I/F extension is also available under /sys/class/hwmon 154 Hwmon sysfs I/F extension is also available under /sys/class/hwmon
147 if hwmon is compiled in or built as a module. 155 if hwmon is compiled in or built as a module.
148 156
149 Thermal zone device sys I/F, created once it's registered: 157 Thermal zone device sys I/F, created once it's registered:
150 /sys/class/thermal/thermal_zone[0-*]: 158 /sys/class/thermal/thermal_zone[0-*]:
151 |---type: Type of the thermal zone 159 |---type: Type of the thermal zone
152 |---temp: Current temperature 160 |---temp: Current temperature
153 |---mode: Working mode of the thermal zone 161 |---mode: Working mode of the thermal zone
154 |---policy: Thermal governor used for this zone 162 |---policy: Thermal governor used for this zone
155 |---trip_point_[0-*]_temp: Trip point temperature 163 |---trip_point_[0-*]_temp: Trip point temperature
156 |---trip_point_[0-*]_type: Trip point type 164 |---trip_point_[0-*]_type: Trip point type
157 |---trip_point_[0-*]_hyst: Hysteresis value for this trip point 165 |---trip_point_[0-*]_hyst: Hysteresis value for this trip point
158 |---emul_temp: Emulated temperature set node 166 |---emul_temp: Emulated temperature set node
159 167
160 Thermal cooling device sys I/F, created once it's registered: 168 Thermal cooling device sys I/F, created once it's registered:
161 /sys/class/thermal/cooling_device[0-*]: 169 /sys/class/thermal/cooling_device[0-*]:
162 |---type: Type of the cooling device(processor/fan/...) 170 |---type: Type of the cooling device(processor/fan/...)
163 |---max_state: Maximum cooling state of the cooling device 171 |---max_state: Maximum cooling state of the cooling device
164 |---cur_state: Current cooling state of the cooling device 172 |---cur_state: Current cooling state of the cooling device
165 173
166 174
167 Then next two dynamic attributes are created/removed in pairs. They represent 175 Then next two dynamic attributes are created/removed in pairs. They represent
168 the relationship between a thermal zone and its associated cooling device. 176 the relationship between a thermal zone and its associated cooling device.
169 They are created/removed for each successful execution of 177 They are created/removed for each successful execution of
170 thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device. 178 thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
171 179
172 /sys/class/thermal/thermal_zone[0-*]: 180 /sys/class/thermal/thermal_zone[0-*]:
173 |---cdev[0-*]: [0-*]th cooling device in current thermal zone 181 |---cdev[0-*]: [0-*]th cooling device in current thermal zone
174 |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with 182 |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with
175 183
176 Besides the thermal zone device sysfs I/F and cooling device sysfs I/F, 184 Besides the thermal zone device sysfs I/F and cooling device sysfs I/F,
177 the generic thermal driver also creates a hwmon sysfs I/F for each _type_ 185 the generic thermal driver also creates a hwmon sysfs I/F for each _type_
178 of thermal zone device. E.g. the generic thermal driver registers one hwmon 186 of thermal zone device. E.g. the generic thermal driver registers one hwmon
179 class device and build the associated hwmon sysfs I/F for all the registered 187 class device and build the associated hwmon sysfs I/F for all the registered
180 ACPI thermal zones. 188 ACPI thermal zones.
181 189
182 /sys/class/hwmon/hwmon[0-*]: 190 /sys/class/hwmon/hwmon[0-*]:
183 |---name: The type of the thermal zone devices 191 |---name: The type of the thermal zone devices
184 |---temp[1-*]_input: The current temperature of thermal zone [1-*] 192 |---temp[1-*]_input: The current temperature of thermal zone [1-*]
185 |---temp[1-*]_critical: The critical trip point of thermal zone [1-*] 193 |---temp[1-*]_critical: The critical trip point of thermal zone [1-*]
186 194
187 Please read Documentation/hwmon/sysfs-interface for additional information. 195 Please read Documentation/hwmon/sysfs-interface for additional information.
188 196
189 *************************** 197 ***************************
190 * Thermal zone attributes * 198 * Thermal zone attributes *
191 *************************** 199 ***************************
192 200
193 type 201 type
194 Strings which represent the thermal zone type. 202 Strings which represent the thermal zone type.
195 This is given by thermal zone driver as part of registration. 203 This is given by thermal zone driver as part of registration.
196 E.g: "acpitz" indicates it's an ACPI thermal device. 204 E.g: "acpitz" indicates it's an ACPI thermal device.
197 In order to keep it consistent with hwmon sys attribute; this should 205 In order to keep it consistent with hwmon sys attribute; this should
198 be a short, lowercase string, not containing spaces nor dashes. 206 be a short, lowercase string, not containing spaces nor dashes.
199 RO, Required 207 RO, Required
200 208
201 temp 209 temp
202 Current temperature as reported by thermal zone (sensor). 210 Current temperature as reported by thermal zone (sensor).
203 Unit: millidegree Celsius 211 Unit: millidegree Celsius
204 RO, Required 212 RO, Required
205 213
206 mode 214 mode
207 One of the predefined values in [enabled, disabled]. 215 One of the predefined values in [enabled, disabled].
208 This file gives information about the algorithm that is currently 216 This file gives information about the algorithm that is currently
209 managing the thermal zone. It can be either default kernel based 217 managing the thermal zone. It can be either default kernel based
210 algorithm or user space application. 218 algorithm or user space application.
211 enabled = enable Kernel Thermal management. 219 enabled = enable Kernel Thermal management.
212 disabled = Preventing kernel thermal zone driver actions upon 220 disabled = Preventing kernel thermal zone driver actions upon
213 trip points so that user application can take full 221 trip points so that user application can take full
214 charge of the thermal management. 222 charge of the thermal management.
215 RW, Optional 223 RW, Optional
216 224
217 policy 225 policy
218 One of the various thermal governors used for a particular zone. 226 One of the various thermal governors used for a particular zone.
219 RW, Required 227 RW, Required
220 228
221 trip_point_[0-*]_temp 229 trip_point_[0-*]_temp
222 The temperature above which trip point will be fired. 230 The temperature above which trip point will be fired.
223 Unit: millidegree Celsius 231 Unit: millidegree Celsius
224 RO, Optional 232 RO, Optional
225 233
226 trip_point_[0-*]_type 234 trip_point_[0-*]_type
227 Strings which indicate the type of the trip point. 235 Strings which indicate the type of the trip point.
228 E.g. it can be one of critical, hot, passive, active[0-*] for ACPI 236 E.g. it can be one of critical, hot, passive, active[0-*] for ACPI
229 thermal zone. 237 thermal zone.
230 RO, Optional 238 RO, Optional
231 239
232 trip_point_[0-*]_hyst 240 trip_point_[0-*]_hyst
233 The hysteresis value for a trip point, represented as an integer 241 The hysteresis value for a trip point, represented as an integer
234 Unit: Celsius 242 Unit: Celsius
235 RW, Optional 243 RW, Optional
236 244
237 cdev[0-*] 245 cdev[0-*]
238 Sysfs link to the thermal cooling device node where the sys I/F 246 Sysfs link to the thermal cooling device node where the sys I/F
239 for cooling device throttling control represents. 247 for cooling device throttling control represents.
240 RO, Optional 248 RO, Optional
241 249
242 cdev[0-*]_trip_point 250 cdev[0-*]_trip_point
243 The trip point with which cdev[0-*] is associated in this thermal 251 The trip point with which cdev[0-*] is associated in this thermal
244 zone; -1 means the cooling device is not associated with any trip 252 zone; -1 means the cooling device is not associated with any trip
245 point. 253 point.
246 RO, Optional 254 RO, Optional
247 255
248 passive 256 passive
249 Attribute is only present for zones in which the passive cooling 257 Attribute is only present for zones in which the passive cooling
250 policy is not supported by native thermal driver. Default is zero 258 policy is not supported by native thermal driver. Default is zero
251 and can be set to a temperature (in millidegrees) to enable a 259 and can be set to a temperature (in millidegrees) to enable a
252 passive trip point for the zone. Activation is done by polling with 260 passive trip point for the zone. Activation is done by polling with
253 an interval of 1 second. 261 an interval of 1 second.
254 Unit: millidegrees Celsius 262 Unit: millidegrees Celsius
255 Valid values: 0 (disabled) or greater than 1000 263 Valid values: 0 (disabled) or greater than 1000
256 RW, Optional 264 RW, Optional
257 265
258 emul_temp 266 emul_temp
259 Interface to set the emulated temperature method in thermal zone 267 Interface to set the emulated temperature method in thermal zone
260 (sensor). After setting this temperature, the thermal zone may pass 268 (sensor). After setting this temperature, the thermal zone may pass
261 this temperature to platform emulation function if registered or 269 this temperature to platform emulation function if registered or
262 cache it locally. This is useful in debugging different temperature 270 cache it locally. This is useful in debugging different temperature
263 threshold and its associated cooling action. This is write only node 271 threshold and its associated cooling action. This is write only node
264 and writing 0 on this node should disable emulation. 272 and writing 0 on this node should disable emulation.
265 Unit: millidegree Celsius 273 Unit: millidegree Celsius
266 WO, Optional 274 WO, Optional
267 275
268 WARNING: Be careful while enabling this option on production systems, 276 WARNING: Be careful while enabling this option on production systems,
269 because userland can easily disable the thermal policy by simply 277 because userland can easily disable the thermal policy by simply
270 flooding this sysfs node with low temperature values. 278 flooding this sysfs node with low temperature values.
271 279
272 ***************************** 280 *****************************
273 * Cooling device attributes * 281 * Cooling device attributes *
274 ***************************** 282 *****************************
275 283
276 type 284 type
277 String which represents the type of device, e.g: 285 String which represents the type of device, e.g:
278 - for generic ACPI: should be "Fan", "Processor" or "LCD" 286 - for generic ACPI: should be "Fan", "Processor" or "LCD"
279 - for memory controller device on intel_menlow platform: 287 - for memory controller device on intel_menlow platform:
280 should be "Memory controller". 288 should be "Memory controller".
281 RO, Required 289 RO, Required
282 290
283 max_state 291 max_state
284 The maximum permissible cooling state of this cooling device. 292 The maximum permissible cooling state of this cooling device.
285 RO, Required 293 RO, Required
286 294
287 cur_state 295 cur_state
288 The current cooling state of this cooling device. 296 The current cooling state of this cooling device.
289 The value can any integer numbers between 0 and max_state: 297 The value can any integer numbers between 0 and max_state:
290 - cur_state == 0 means no cooling 298 - cur_state == 0 means no cooling
291 - cur_state == max_state means the maximum cooling. 299 - cur_state == max_state means the maximum cooling.
292 RW, Required 300 RW, Required
293 301
294 3. A simple implementation 302 3. A simple implementation
295 303
296 ACPI thermal zone may support multiple trip points like critical, hot, 304 ACPI thermal zone may support multiple trip points like critical, hot,
297 passive, active. If an ACPI thermal zone supports critical, passive, 305 passive, active. If an ACPI thermal zone supports critical, passive,
298 active[0] and active[1] at the same time, it may register itself as a 306 active[0] and active[1] at the same time, it may register itself as a
299 thermal_zone_device (thermal_zone1) with 4 trip points in all. 307 thermal_zone_device (thermal_zone1) with 4 trip points in all.
300 It has one processor and one fan, which are both registered as 308 It has one processor and one fan, which are both registered as
301 thermal_cooling_device. 309 thermal_cooling_device.
302 310
303 If the processor is listed in _PSL method, and the fan is listed in _AL0 311 If the processor is listed in _PSL method, and the fan is listed in _AL0
304 method, the sys I/F structure will be built like this: 312 method, the sys I/F structure will be built like this:
305 313
306 /sys/class/thermal: 314 /sys/class/thermal:
307 315
308 |thermal_zone1: 316 |thermal_zone1:
309 |---type: acpitz 317 |---type: acpitz
310 |---temp: 37000 318 |---temp: 37000
311 |---mode: enabled 319 |---mode: enabled
312 |---policy: step_wise 320 |---policy: step_wise
313 |---trip_point_0_temp: 100000 321 |---trip_point_0_temp: 100000
314 |---trip_point_0_type: critical 322 |---trip_point_0_type: critical
315 |---trip_point_1_temp: 80000 323 |---trip_point_1_temp: 80000
316 |---trip_point_1_type: passive 324 |---trip_point_1_type: passive
317 |---trip_point_2_temp: 70000 325 |---trip_point_2_temp: 70000
318 |---trip_point_2_type: active0 326 |---trip_point_2_type: active0
319 |---trip_point_3_temp: 60000 327 |---trip_point_3_temp: 60000
320 |---trip_point_3_type: active1 328 |---trip_point_3_type: active1
321 |---cdev0: --->/sys/class/thermal/cooling_device0 329 |---cdev0: --->/sys/class/thermal/cooling_device0
322 |---cdev0_trip_point: 1 /* cdev0 can be used for passive */ 330 |---cdev0_trip_point: 1 /* cdev0 can be used for passive */
323 |---cdev1: --->/sys/class/thermal/cooling_device3 331 |---cdev1: --->/sys/class/thermal/cooling_device3
324 |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/ 332 |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/
325 333
326 |cooling_device0: 334 |cooling_device0:
327 |---type: Processor 335 |---type: Processor
328 |---max_state: 8 336 |---max_state: 8
329 |---cur_state: 0 337 |---cur_state: 0
330 338
331 |cooling_device3: 339 |cooling_device3:
332 |---type: Fan 340 |---type: Fan
333 |---max_state: 2 341 |---max_state: 2
334 |---cur_state: 0 342 |---cur_state: 0
335 343
336 /sys/class/hwmon: 344 /sys/class/hwmon:
337 345
338 |hwmon0: 346 |hwmon0:
339 |---name: acpitz 347 |---name: acpitz
340 |---temp1_input: 37000 348 |---temp1_input: 37000
341 |---temp1_crit: 100000 349 |---temp1_crit: 100000
342 350
343 4. Event Notification 351 4. Event Notification
344 352
345 The framework includes a simple notification mechanism, in the form of a 353 The framework includes a simple notification mechanism, in the form of a
346 netlink event. Netlink socket initialization is done during the _init_ 354 netlink event. Netlink socket initialization is done during the _init_
347 of the framework. Drivers which intend to use the notification mechanism 355 of the framework. Drivers which intend to use the notification mechanism
348 just need to call thermal_generate_netlink_event() with two arguments viz 356 just need to call thermal_generate_netlink_event() with two arguments viz
349 (originator, event). The originator is a pointer to struct thermal_zone_device 357 (originator, event). The originator is a pointer to struct thermal_zone_device
350 from where the event has been originated. An integer which represents the 358 from where the event has been originated. An integer which represents the
351 thermal zone device will be used in the message to identify the zone. The 359 thermal zone device will be used in the message to identify the zone. The
352 event will be one of:{THERMAL_AUX0, THERMAL_AUX1, THERMAL_CRITICAL, 360 event will be one of:{THERMAL_AUX0, THERMAL_AUX1, THERMAL_CRITICAL,
353 THERMAL_DEV_FAULT}. Notification can be sent when the current temperature 361 THERMAL_DEV_FAULT}. Notification can be sent when the current temperature
354 crosses any of the configured thresholds. 362 crosses any of the configured thresholds.
355 363
356 5. Export Symbol APIs: 364 5. Export Symbol APIs:
357 365
358 5.1: get_tz_trend: 366 5.1: get_tz_trend:
359 This function returns the trend of a thermal zone, i.e the rate of change 367 This function returns the trend of a thermal zone, i.e the rate of change
360 of temperature of the thermal zone. Ideally, the thermal sensor drivers 368 of temperature of the thermal zone. Ideally, the thermal sensor drivers
361 are supposed to implement the callback. If they don't, the thermal 369 are supposed to implement the callback. If they don't, the thermal
362 framework calculated the trend by comparing the previous and the current 370 framework calculated the trend by comparing the previous and the current
363 temperature values. 371 temperature values.
364 372
365 5.2:get_thermal_instance: 373 5.2:get_thermal_instance:
366 This function returns the thermal_instance corresponding to a given 374 This function returns the thermal_instance corresponding to a given
367 {thermal_zone, cooling_device, trip_point} combination. Returns NULL 375 {thermal_zone, cooling_device, trip_point} combination. Returns NULL
368 if such an instance does not exist. 376 if such an instance does not exist.
369 377
370 5.3:thermal_notify_framework: 378 5.3:thermal_notify_framework:
371 This function handles the trip events from sensor drivers. It starts 379 This function handles the trip events from sensor drivers. It starts
372 throttling the cooling devices according to the policy configured. 380 throttling the cooling devices according to the policy configured.
373 For CRITICAL and HOT trip points, this notifies the respective drivers, 381 For CRITICAL and HOT trip points, this notifies the respective drivers,
374 and does actual throttling for other trip points i.e ACTIVE and PASSIVE. 382 and does actual throttling for other trip points i.e ACTIVE and PASSIVE.
375 The throttling policy is based on the configured platform data; if no 383 The throttling policy is based on the configured platform data; if no
376 platform data is provided, this uses the step_wise throttling policy. 384 platform data is provided, this uses the step_wise throttling policy.
377 385
378 5.4:thermal_cdev_update: 386 5.4:thermal_cdev_update:
379 This function serves as an arbitrator to set the state of a cooling 387 This function serves as an arbitrator to set the state of a cooling
380 device. It sets the cooling device to the deepest cooling state if 388 device. It sets the cooling device to the deepest cooling state if
381 possible. 389 possible.
382 390