~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/driver-api/thermal/sysfs-api.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/driver-api/thermal/sysfs-api.rst (Version linux-6.12-rc7) and /Documentation/driver-api/thermal/sysfs-api.rst (Version linux-6.9.12)


  1 ===================================                 1 ===================================
  2 Generic Thermal Sysfs driver How To                 2 Generic Thermal Sysfs driver How To
  3 ===================================                 3 ===================================
  4                                                     4 
  5 Written by Sujith Thomas <sujith.thomas@intel.c      5 Written by Sujith Thomas <sujith.thomas@intel.com>, Zhang Rui <rui.zhang@intel.com>
  6                                                     6 
                                                   >>   7 Updated: 2 January 2008
                                                   >>   8 
  7 Copyright (c)  2008 Intel Corporation               9 Copyright (c)  2008 Intel Corporation
  8                                                    10 
  9                                                    11 
 10 0. Introduction                                    12 0. Introduction
 11 ===============                                    13 ===============
 12                                                    14 
 13 The generic thermal sysfs provides a set of in     15 The generic thermal sysfs provides a set of interfaces for thermal zone
 14 devices (sensors) and thermal cooling devices      16 devices (sensors) and thermal cooling devices (fan, processor...) to register
 15 with the thermal management solution and to be     17 with the thermal management solution and to be a part of it.
 16                                                    18 
 17 This how-to focuses on enabling new thermal zo     19 This how-to focuses on enabling new thermal zone and cooling devices to
 18 participate in thermal management.                 20 participate in thermal management.
 19 This solution is platform independent and any      21 This solution is platform independent and any type of thermal zone devices
 20 and cooling devices should be able to make use     22 and cooling devices should be able to make use of the infrastructure.
 21                                                    23 
 22 The main task of the thermal sysfs driver is t     24 The main task of the thermal sysfs driver is to expose thermal zone attributes
 23 as well as cooling device attributes to the us     25 as well as cooling device attributes to the user space.
 24 An intelligent thermal management application      26 An intelligent thermal management application can make decisions based on
 25 inputs from thermal zone attributes (the curre     27 inputs from thermal zone attributes (the current temperature and trip point
 26 temperature) and throttle appropriate devices.     28 temperature) and throttle appropriate devices.
 27                                                    29 
 28 - `[0-*]`       denotes any positive number st     30 - `[0-*]`       denotes any positive number starting from 0
 29 - `[1-*]`       denotes any positive number st     31 - `[1-*]`       denotes any positive number starting from 1
 30                                                    32 
 31 1. thermal sysfs driver interface functions        33 1. thermal sysfs driver interface functions
 32 ===========================================        34 ===========================================
 33                                                    35 
 34 1.1 thermal zone device interface                  36 1.1 thermal zone device interface
 35 ---------------------------------                  37 ---------------------------------
 36                                                    38 
 37     ::                                             39     ::
 38                                                    40 
 39         struct thermal_zone_device *           !!  41         struct thermal_zone_device
 40         thermal_zone_device_register_with_trip !!  42         *thermal_zone_device_register(char *type,
 41                                         const  !!  43                                       int trips, int mask, void *devdata,
 42                                         int nu !!  44                                       struct thermal_zone_device_ops *ops,
 43                                         const  !!  45                                       const struct thermal_zone_params *tzp,
 44                                         const  !!  46                                       int passive_delay, int polling_delay))
 45                                         unsign << 
 46                                         unsign << 
 47                                                    47 
 48     This interface function adds a new thermal !!  48     This interface function adds a new thermal zone device (sensor) to
 49     /sys/class/thermal folder as `thermal_zone     49     /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the
 50     thermal cooling devices registered to it a !!  50     thermal cooling devices registered at the same time.
 51                                                    51 
 52     type:                                          52     type:
 53         the thermal zone type.                     53         the thermal zone type.
 54     trips:                                         54     trips:
 55         the table of trip points for this ther !!  55         the total number of trip points this thermal zone supports.
                                                   >>  56     mask:
                                                   >>  57         Bit string: If 'n'th bit is set, then trip point 'n' is writable.
 56     devdata:                                       58     devdata:
 57         device private data                        59         device private data
 58     ops:                                           60     ops:
 59         thermal zone device call-backs.            61         thermal zone device call-backs.
 60                                                    62 
 61         .should_bind:                          !!  63         .bind:
 62                 check whether or not a given c !!  64                 bind the thermal zone device with a thermal cooling device.
 63                 a given trip point in this the !!  65         .unbind:
                                                   >>  66                 unbind the thermal zone device with a thermal cooling device.
 64         .get_temp:                                 67         .get_temp:
 65                 get the current temperature of     68                 get the current temperature of the thermal zone.
 66         .set_trips:                                69         .set_trips:
 67                 set the trip points window. Wh !!  70                     set the trip points window. Whenever the current temperature
 68                 is updated, the trip points im !!  71                     is updated, the trip points immediately below and above the
 69                 current temperature are found. !!  72                     current temperature are found.
 70         .change_mode:                          !!  73         .get_mode:
 71                 change the mode (enabled/disab !!  74                    get the current mode (enabled/disabled) of the thermal zone.
 72         .set_trip_temp:                        !!  75 
 73                 set the temperature of a given !!  76                         - "enabled" means the kernel thermal management is
 74         .get_crit_temp:                        !!  77                           enabled.
 75                 get the critical temperature f !!  78                         - "disabled" will prevent kernel thermal driver action
                                                   >>  79                           upon trip points so that user applications can take
                                                   >>  80                           charge of thermal management.
                                                   >>  81         .set_mode:
                                                   >>  82                 set the mode (enabled/disabled) of the thermal zone.
                                                   >>  83         .get_trip_type:
                                                   >>  84                 get the type of certain trip point.
                                                   >>  85         .get_trip_temp:
                                                   >>  86                         get the temperature above which the certain trip point
                                                   >>  87                         will be fired.
 76         .set_emul_temp:                            88         .set_emul_temp:
 77                 set the emulation temperature  !!  89                         set the emulation temperature which helps in debugging
 78                 different threshold temperatur !!  90                         different threshold temperature points.
 79         .get_trend:                            << 
 80                 get the trend of most recent z << 
 81         .hot:                                  << 
 82                 hot trip point crossing handle << 
 83         .critical:                             << 
 84                 critical trip point crossing h << 
 85     tzp:                                           91     tzp:
 86         thermal zone platform parameters.          92         thermal zone platform parameters.
 87     passive_delay:                                 93     passive_delay:
 88         number of milliseconds to wait between !!  94         number of milliseconds to wait between polls when
 89         cooling.                               !!  95         performing passive cooling.
 90     polling_delay:                                 96     polling_delay:
 91         number of milliseconds to wait between     97         number of milliseconds to wait between polls when checking
 92         whether trip points have been crossed      98         whether trip points have been crossed (0 for interrupt driven systems).
 93                                                    99 
 94     ::                                            100     ::
 95                                                   101 
 96         void thermal_zone_device_unregister(st    102         void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 97                                                   103 
 98     This interface function removes the therma    104     This interface function removes the thermal zone device.
 99     It deletes the corresponding entry from /s    105     It deletes the corresponding entry from /sys/class/thermal folder and
100     unbinds all the thermal cooling devices it    106     unbinds all the thermal cooling devices it uses.
101                                                   107 
102         ::                                        108         ::
103                                                   109 
104            struct thermal_zone_device             110            struct thermal_zone_device
105            *thermal_zone_of_sensor_register(st    111            *thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
106                                 void *data,       112                                 void *data,
107                                 const struct t    113                                 const struct thermal_zone_of_device_ops *ops)
108                                                   114 
109         This interface adds a new sensor to a     115         This interface adds a new sensor to a DT thermal zone.
110         This function will search the list of     116         This function will search the list of thermal zones described in
111         device tree and look for the zone that    117         device tree and look for the zone that refer to the sensor device
112         pointed by dev->of_node as temperature    118         pointed by dev->of_node as temperature providers. For the zone
113         pointing to the sensor node, the senso    119         pointing to the sensor node, the sensor will be added to the DT
114         thermal zone device.                      120         thermal zone device.
115                                                   121 
116         The parameters for this interface are:    122         The parameters for this interface are:
117                                                   123 
118         dev:                                      124         dev:
119                         Device node of sensor     125                         Device node of sensor containing valid node pointer in
120                         dev->of_node.             126                         dev->of_node.
121         sensor_id:                                127         sensor_id:
122                         a sensor identifier, i    128                         a sensor identifier, in case the sensor IP has more
123                         than one sensors          129                         than one sensors
124         data:                                     130         data:
125                         a private pointer (own    131                         a private pointer (owned by the caller) that will be
126                         passed back, when a te    132                         passed back, when a temperature reading is needed.
127         ops:                                      133         ops:
128                         `struct thermal_zone_o    134                         `struct thermal_zone_of_device_ops *`.
129                                                   135 
130                         ==============  ======    136                         ==============  =======================================
131                         get_temp        a poin    137                         get_temp        a pointer to a function that reads the
132                                         sensor    138                                         sensor temperature. This is mandatory
133                                         callba    139                                         callback provided by sensor driver.
134                         set_trips       a poin    140                         set_trips       a pointer to a function that sets a
135                                         temper    141                                         temperature window. When this window is
136                                         left t    142                                         left the driver must inform the thermal
137                                         core v    143                                         core via thermal_zone_device_update.
138                         get_trend       a poin    144                         get_trend       a pointer to a function that reads the
139                                         sensor    145                                         sensor temperature trend.
140                         set_emul_temp   a poin    146                         set_emul_temp   a pointer to a function that sets
141                                         sensor    147                                         sensor emulated temperature.
142                         ==============  ======    148                         ==============  =======================================
143                                                   149 
144         The thermal zone temperature is provid    150         The thermal zone temperature is provided by the get_temp() function
145         pointer of thermal_zone_of_device_ops.    151         pointer of thermal_zone_of_device_ops. When called, it will
146         have the private pointer @data back.      152         have the private pointer @data back.
147                                                   153 
148         It returns error pointer if fails othe    154         It returns error pointer if fails otherwise valid thermal zone device
149         handle. Caller should check the return    155         handle. Caller should check the return handle with IS_ERR() for finding
150         whether success or not.                   156         whether success or not.
151                                                   157 
152         ::                                        158         ::
153                                                   159 
154             void thermal_zone_of_sensor_unregi    160             void thermal_zone_of_sensor_unregister(struct device *dev,
155                                                   161                                                    struct thermal_zone_device *tzd)
156                                                   162 
157         This interface unregisters a sensor fr    163         This interface unregisters a sensor from a DT thermal zone which was
158         successfully added by interface therma    164         successfully added by interface thermal_zone_of_sensor_register().
159         This function removes the sensor callb    165         This function removes the sensor callbacks and private data from the
160         thermal zone device registered with th    166         thermal zone device registered with thermal_zone_of_sensor_register()
161         interface. It will also silent the zon    167         interface. It will also silent the zone by remove the .get_temp() and
162         get_trend() thermal zone device callba    168         get_trend() thermal zone device callbacks.
163                                                   169 
164         ::                                        170         ::
165                                                   171 
166           struct thermal_zone_device              172           struct thermal_zone_device
167           *devm_thermal_zone_of_sensor_registe    173           *devm_thermal_zone_of_sensor_register(struct device *dev,
168                                 int sensor_id,    174                                 int sensor_id,
169                                 void *data,       175                                 void *data,
170                                 const struct t    176                                 const struct thermal_zone_of_device_ops *ops)
171                                                   177 
172         This interface is resource managed ver    178         This interface is resource managed version of
173         thermal_zone_of_sensor_register().        179         thermal_zone_of_sensor_register().
174                                                   180 
175         All details of thermal_zone_of_sensor_    181         All details of thermal_zone_of_sensor_register() described in
176         section 1.1.3 is applicable here.         182         section 1.1.3 is applicable here.
177                                                   183 
178         The benefit of using this interface to    184         The benefit of using this interface to register sensor is that it
179         is not require to explicitly call ther    185         is not require to explicitly call thermal_zone_of_sensor_unregister()
180         in error path or during driver unbindi    186         in error path or during driver unbinding as this is done by driver
181         resource manager.                         187         resource manager.
182                                                   188 
183         ::                                        189         ::
184                                                   190 
185                 void devm_thermal_zone_of_sens    191                 void devm_thermal_zone_of_sensor_unregister(struct device *dev,
186                                                   192                                                 struct thermal_zone_device *tzd)
187                                                   193 
188         This interface is resource managed ver    194         This interface is resource managed version of
189         thermal_zone_of_sensor_unregister().      195         thermal_zone_of_sensor_unregister().
190         All details of thermal_zone_of_sensor_    196         All details of thermal_zone_of_sensor_unregister() described in
191         section 1.1.4 is applicable here.         197         section 1.1.4 is applicable here.
192         Normally this function will not need t    198         Normally this function will not need to be called and the resource
193         management code will ensure that the r    199         management code will ensure that the resource is freed.
194                                                   200 
195         ::                                        201         ::
196                                                   202 
197                 int thermal_zone_get_slope(str    203                 int thermal_zone_get_slope(struct thermal_zone_device *tz)
198                                                   204 
199         This interface is used to read the slo    205         This interface is used to read the slope attribute value
200         for the thermal zone device, which mig    206         for the thermal zone device, which might be useful for platform
201         drivers for temperature calculations.     207         drivers for temperature calculations.
202                                                   208 
203         ::                                        209         ::
204                                                   210 
205                 int thermal_zone_get_offset(st    211                 int thermal_zone_get_offset(struct thermal_zone_device *tz)
206                                                   212 
207         This interface is used to read the off    213         This interface is used to read the offset attribute value
208         for the thermal zone device, which mig    214         for the thermal zone device, which might be useful for platform
209         drivers for temperature calculations.     215         drivers for temperature calculations.
210                                                   216 
211 1.2 thermal cooling device interface              217 1.2 thermal cooling device interface
212 ------------------------------------              218 ------------------------------------
213                                                   219 
214                                                   220 
215     ::                                            221     ::
216                                                   222 
217         struct thermal_cooling_device             223         struct thermal_cooling_device
218         *thermal_cooling_device_register(char     224         *thermal_cooling_device_register(char *name,
219                         void *devdata, struct     225                         void *devdata, struct thermal_cooling_device_ops *)
220                                                   226 
221     This interface function adds a new thermal    227     This interface function adds a new thermal cooling device (fan/processor/...)
222     to /sys/class/thermal/ folder as `cooling_    228     to /sys/class/thermal/ folder as `cooling_device[0-*]`. It tries to bind itself
223     to all the thermal zone devices registered    229     to all the thermal zone devices registered at the same time.
224                                                   230 
225     name:                                         231     name:
226         the cooling device name.                  232         the cooling device name.
227     devdata:                                      233     devdata:
228         device private data.                      234         device private data.
229     ops:                                          235     ops:
230         thermal cooling devices call-backs.       236         thermal cooling devices call-backs.
231                                                   237 
232         .get_max_state:                           238         .get_max_state:
233                 get the Maximum throttle state    239                 get the Maximum throttle state of the cooling device.
234         .get_cur_state:                           240         .get_cur_state:
235                 get the Currently requested th    241                 get the Currently requested throttle state of the
236                 cooling device.                   242                 cooling device.
237         .set_cur_state:                           243         .set_cur_state:
238                 set the Current throttle state    244                 set the Current throttle state of the cooling device.
239                                                   245 
240     ::                                            246     ::
241                                                   247 
242         void thermal_cooling_device_unregister    248         void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
243                                                   249 
244     This interface function removes the therma    250     This interface function removes the thermal cooling device.
245     It deletes the corresponding entry from /s    251     It deletes the corresponding entry from /sys/class/thermal folder and
246     unbinds itself from all the thermal zone d    252     unbinds itself from all the thermal zone devices using it.
247                                                   253 
                                                   >> 254 1.3 interface for binding a thermal zone device with a thermal cooling device
                                                   >> 255 -----------------------------------------------------------------------------
                                                   >> 256 
                                                   >> 257     ::
                                                   >> 258 
                                                   >> 259         int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
                                                   >> 260                 int trip, struct thermal_cooling_device *cdev,
                                                   >> 261                 unsigned long upper, unsigned long lower, unsigned int weight);
                                                   >> 262 
                                                   >> 263     This interface function binds a thermal cooling device to a particular trip
                                                   >> 264     point of a thermal zone device.
                                                   >> 265 
                                                   >> 266     This function is usually called in the thermal zone device .bind callback.
                                                   >> 267 
                                                   >> 268     tz:
                                                   >> 269           the thermal zone device
                                                   >> 270     cdev:
                                                   >> 271           thermal cooling device
                                                   >> 272     trip:
                                                   >> 273           indicates which trip point in this thermal zone the cooling device
                                                   >> 274           is associated with.
                                                   >> 275     upper:
                                                   >> 276           the Maximum cooling state for this trip point.
                                                   >> 277           THERMAL_NO_LIMIT means no upper limit,
                                                   >> 278           and the cooling device can be in max_state.
                                                   >> 279     lower:
                                                   >> 280           the Minimum cooling state can be used for this trip point.
                                                   >> 281           THERMAL_NO_LIMIT means no lower limit,
                                                   >> 282           and the cooling device can be in cooling state 0.
                                                   >> 283     weight:
                                                   >> 284           the influence of this cooling device in this thermal
                                                   >> 285           zone.  See 1.4.1 below for more information.
                                                   >> 286 
                                                   >> 287     ::
                                                   >> 288 
                                                   >> 289         int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
                                                   >> 290                                 int trip, struct thermal_cooling_device *cdev);
                                                   >> 291 
                                                   >> 292     This interface function unbinds a thermal cooling device from a particular
                                                   >> 293     trip point of a thermal zone device. This function is usually called in
                                                   >> 294     the thermal zone device .unbind callback.
                                                   >> 295 
                                                   >> 296     tz:
                                                   >> 297         the thermal zone device
                                                   >> 298     cdev:
                                                   >> 299         thermal cooling device
                                                   >> 300     trip:
                                                   >> 301         indicates which trip point in this thermal zone the cooling device
                                                   >> 302         is associated with.
                                                   >> 303 
248 1.4 Thermal Zone Parameters                       304 1.4 Thermal Zone Parameters
249 ---------------------------                       305 ---------------------------
250                                                   306 
251     ::                                            307     ::
252                                                   308 
253         struct thermal_zone_params                309         struct thermal_zone_params
254                                                   310 
255     This structure defines the platform level     311     This structure defines the platform level parameters for a thermal zone.
256     This data, for each thermal zone should co    312     This data, for each thermal zone should come from the platform layer.
257     This is an optional feature where some pla    313     This is an optional feature where some platforms can choose not to
258     provide this data.                            314     provide this data.
259                                                   315 
260     .governor_name:                               316     .governor_name:
261                Name of the thermal governor us    317                Name of the thermal governor used for this zone
262     .no_hwmon:                                    318     .no_hwmon:
263                a boolean to indicate if the th    319                a boolean to indicate if the thermal to hwmon sysfs interface
264                is required. when no_hwmon == f    320                is required. when no_hwmon == false, a hwmon sysfs interface
265                will be created. when no_hwmon     321                will be created. when no_hwmon == true, nothing will be done.
266                In case the thermal_zone_params    322                In case the thermal_zone_params is NULL, the hwmon interface
267                will be created (for backward c    323                will be created (for backward compatibility).
268                                                   324 
269 2. sysfs attributes structure                     325 2. sysfs attributes structure
270 =============================                     326 =============================
271                                                   327 
272 ==      ================                          328 ==      ================
273 RO      read only value                           329 RO      read only value
274 WO      write only value                          330 WO      write only value
275 RW      read/write value                          331 RW      read/write value
276 ==      ================                          332 ==      ================
277                                                   333 
278 Thermal sysfs attributes will be represented u    334 Thermal sysfs attributes will be represented under /sys/class/thermal.
279 Hwmon sysfs I/F extension is also available un    335 Hwmon sysfs I/F extension is also available under /sys/class/hwmon
280 if hwmon is compiled in or built as a module.     336 if hwmon is compiled in or built as a module.
281                                                   337 
282 Thermal zone device sys I/F, created once it's    338 Thermal zone device sys I/F, created once it's registered::
283                                                   339 
284   /sys/class/thermal/thermal_zone[0-*]:           340   /sys/class/thermal/thermal_zone[0-*]:
285     |---type:                   Type of the th    341     |---type:                   Type of the thermal zone
286     |---temp:                   Current temper    342     |---temp:                   Current temperature
287     |---mode:                   Working mode o    343     |---mode:                   Working mode of the thermal zone
288     |---policy:                 Thermal govern    344     |---policy:                 Thermal governor used for this zone
289     |---available_policies:     Available ther    345     |---available_policies:     Available thermal governors for this zone
290     |---trip_point_[0-*]_temp:  Trip point tem    346     |---trip_point_[0-*]_temp:  Trip point temperature
291     |---trip_point_[0-*]_type:  Trip point typ    347     |---trip_point_[0-*]_type:  Trip point type
292     |---trip_point_[0-*]_hyst:  Hysteresis val    348     |---trip_point_[0-*]_hyst:  Hysteresis value for this trip point
293     |---emul_temp:              Emulated tempe    349     |---emul_temp:              Emulated temperature set node
294     |---sustainable_power:      Sustainable di    350     |---sustainable_power:      Sustainable dissipatable power
295     |---k_po:                   Proportional t    351     |---k_po:                   Proportional term during temperature overshoot
296     |---k_pu:                   Proportional t    352     |---k_pu:                   Proportional term during temperature undershoot
297     |---k_i:                    PID's integral    353     |---k_i:                    PID's integral term in the power allocator gov
298     |---k_d:                    PID's derivati    354     |---k_d:                    PID's derivative term in the power allocator
299     |---integral_cutoff:        Offset above w    355     |---integral_cutoff:        Offset above which errors are accumulated
300     |---slope:                  Slope constant    356     |---slope:                  Slope constant applied as linear extrapolation
301     |---offset:                 Offset constan    357     |---offset:                 Offset constant applied as linear extrapolation
302                                                   358 
303 Thermal cooling device sys I/F, created once i    359 Thermal cooling device sys I/F, created once it's registered::
304                                                   360 
305   /sys/class/thermal/cooling_device[0-*]:         361   /sys/class/thermal/cooling_device[0-*]:
306     |---type:                   Type of the co    362     |---type:                   Type of the cooling device(processor/fan/...)
307     |---max_state:              Maximum coolin    363     |---max_state:              Maximum cooling state of the cooling device
308     |---cur_state:              Current coolin    364     |---cur_state:              Current cooling state of the cooling device
309     |---stats:                  Directory cont    365     |---stats:                  Directory containing cooling device's statistics
310     |---stats/reset:            Writing any va    366     |---stats/reset:            Writing any value resets the statistics
311     |---stats/time_in_state_ms: Time (msec) sp    367     |---stats/time_in_state_ms: Time (msec) spent in various cooling states
312     |---stats/total_trans:      Total number o    368     |---stats/total_trans:      Total number of times cooling state is changed
313     |---stats/trans_table:      Cooling state     369     |---stats/trans_table:      Cooling state transition table
314                                                   370 
315                                                   371 
316 Then next two dynamic attributes are created/r    372 Then next two dynamic attributes are created/removed in pairs. They represent
317 the relationship between a thermal zone and it    373 the relationship between a thermal zone and its associated cooling device.
                                                   >> 374 They are created/removed for each successful execution of
                                                   >> 375 thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
318                                                   376 
319 ::                                                377 ::
320                                                   378 
321   /sys/class/thermal/thermal_zone[0-*]:           379   /sys/class/thermal/thermal_zone[0-*]:
322     |---cdev[0-*]:              [0-*]th coolin    380     |---cdev[0-*]:              [0-*]th cooling device in current thermal zone
323     |---cdev[0-*]_trip_point:   Trip point tha    381     |---cdev[0-*]_trip_point:   Trip point that cdev[0-*] is associated with
324     |---cdev[0-*]_weight:       Influence of t    382     |---cdev[0-*]_weight:       Influence of the cooling device in
325                                 this thermal z    383                                 this thermal zone
326                                                   384 
327 Besides the thermal zone device sysfs I/F and     385 Besides the thermal zone device sysfs I/F and cooling device sysfs I/F,
328 the generic thermal driver also creates a hwmo    386 the generic thermal driver also creates a hwmon sysfs I/F for each _type_
329 of thermal zone device. E.g. the generic therm    387 of thermal zone device. E.g. the generic thermal driver registers one hwmon
330 class device and build the associated hwmon sy    388 class device and build the associated hwmon sysfs I/F for all the registered
331 ACPI thermal zones.                               389 ACPI thermal zones.
332                                                   390 
333 Please read Documentation/ABI/testing/sysfs-cl    391 Please read Documentation/ABI/testing/sysfs-class-thermal for thermal
334 zone and cooling device attribute details.        392 zone and cooling device attribute details.
335                                                   393 
336 ::                                                394 ::
337                                                   395 
338   /sys/class/hwmon/hwmon[0-*]:                    396   /sys/class/hwmon/hwmon[0-*]:
339     |---name:                   The type of th    397     |---name:                   The type of the thermal zone devices
340     |---temp[1-*]_input:        The current te    398     |---temp[1-*]_input:        The current temperature of thermal zone [1-*]
341     |---temp[1-*]_critical:     The critical t    399     |---temp[1-*]_critical:     The critical trip point of thermal zone [1-*]
342                                                   400 
343 Please read Documentation/hwmon/sysfs-interfac    401 Please read Documentation/hwmon/sysfs-interface.rst for additional information.
344                                                   402 
345 3. A simple implementation                        403 3. A simple implementation
346 ==========================                        404 ==========================
347                                                   405 
348 ACPI thermal zone may support multiple trip po    406 ACPI thermal zone may support multiple trip points like critical, hot,
349 passive, active. If an ACPI thermal zone suppo    407 passive, active. If an ACPI thermal zone supports critical, passive,
350 active[0] and active[1] at the same time, it m    408 active[0] and active[1] at the same time, it may register itself as a
351 thermal_zone_device (thermal_zone1) with 4 tri    409 thermal_zone_device (thermal_zone1) with 4 trip points in all.
352 It has one processor and one fan, which are bo    410 It has one processor and one fan, which are both registered as
353 thermal_cooling_device. Both are considered to    411 thermal_cooling_device. Both are considered to have the same
354 effectiveness in cooling the thermal zone.        412 effectiveness in cooling the thermal zone.
355                                                   413 
356 If the processor is listed in _PSL method, and    414 If the processor is listed in _PSL method, and the fan is listed in _AL0
357 method, the sys I/F structure will be built li    415 method, the sys I/F structure will be built like this::
358                                                   416 
359  /sys/class/thermal:                              417  /sys/class/thermal:
360   |thermal_zone1:                                 418   |thermal_zone1:
361     |---type:                   acpitz            419     |---type:                   acpitz
362     |---temp:                   37000             420     |---temp:                   37000
363     |---mode:                   enabled           421     |---mode:                   enabled
364     |---policy:                 step_wise         422     |---policy:                 step_wise
365     |---available_policies:     step_wise fair    423     |---available_policies:     step_wise fair_share
366     |---trip_point_0_temp:      100000            424     |---trip_point_0_temp:      100000
367     |---trip_point_0_type:      critical          425     |---trip_point_0_type:      critical
368     |---trip_point_1_temp:      80000             426     |---trip_point_1_temp:      80000
369     |---trip_point_1_type:      passive           427     |---trip_point_1_type:      passive
370     |---trip_point_2_temp:      70000             428     |---trip_point_2_temp:      70000
371     |---trip_point_2_type:      active0           429     |---trip_point_2_type:      active0
372     |---trip_point_3_temp:      60000             430     |---trip_point_3_temp:      60000
373     |---trip_point_3_type:      active1           431     |---trip_point_3_type:      active1
374     |---cdev0:                  --->/sys/class    432     |---cdev0:                  --->/sys/class/thermal/cooling_device0
375     |---cdev0_trip_point:       1       /* cde    433     |---cdev0_trip_point:       1       /* cdev0 can be used for passive */
376     |---cdev0_weight:           1024              434     |---cdev0_weight:           1024
377     |---cdev1:                  --->/sys/class    435     |---cdev1:                  --->/sys/class/thermal/cooling_device3
378     |---cdev1_trip_point:       2       /* cde    436     |---cdev1_trip_point:       2       /* cdev1 can be used for active[0]*/
379     |---cdev1_weight:           1024              437     |---cdev1_weight:           1024
380                                                   438 
381   |cooling_device0:                               439   |cooling_device0:
382     |---type:                   Processor         440     |---type:                   Processor
383     |---max_state:              8                 441     |---max_state:              8
384     |---cur_state:              0                 442     |---cur_state:              0
385                                                   443 
386   |cooling_device3:                               444   |cooling_device3:
387     |---type:                   Fan               445     |---type:                   Fan
388     |---max_state:              2                 446     |---max_state:              2
389     |---cur_state:              0                 447     |---cur_state:              0
390                                                   448 
391  /sys/class/hwmon:                                449  /sys/class/hwmon:
392   |hwmon0:                                        450   |hwmon0:
393     |---name:                   acpitz            451     |---name:                   acpitz
394     |---temp1_input:            37000             452     |---temp1_input:            37000
395     |---temp1_crit:             100000            453     |---temp1_crit:             100000
396                                                   454 
397 4. Export Symbol APIs                             455 4. Export Symbol APIs
398 =====================                             456 =====================
399                                                   457 
400 4.1. get_tz_trend                                 458 4.1. get_tz_trend
401 -----------------                                 459 -----------------
402                                                   460 
403 This function returns the trend of a thermal z    461 This function returns the trend of a thermal zone, i.e the rate of change
404 of temperature of the thermal zone. Ideally, t    462 of temperature of the thermal zone. Ideally, the thermal sensor drivers
405 are supposed to implement the callback. If the    463 are supposed to implement the callback. If they don't, the thermal
406 framework calculated the trend by comparing th    464 framework calculated the trend by comparing the previous and the current
407 temperature values.                               465 temperature values.
408                                                   466 
409 4.2. thermal_cdev_update                       !! 467 4.2. get_thermal_instance
                                                   >> 468 -------------------------
                                                   >> 469 
                                                   >> 470 This function returns the thermal_instance corresponding to a given
                                                   >> 471 {thermal_zone, cooling_device, trip_point} combination. Returns NULL
                                                   >> 472 if such an instance does not exist.
                                                   >> 473 
                                                   >> 474 4.3. thermal_cdev_update
410 ------------------------                          475 ------------------------
411                                                   476 
412 This function serves as an arbitrator to set t    477 This function serves as an arbitrator to set the state of a cooling
413 device. It sets the cooling device to the deep    478 device. It sets the cooling device to the deepest cooling state if
414 possible.                                         479 possible.
415                                                   480 
416 5. thermal_emergency_poweroff                     481 5. thermal_emergency_poweroff
417 =============================                     482 =============================
418                                                   483 
419 On an event of critical trip temperature cross    484 On an event of critical trip temperature crossing the thermal framework
420 shuts down the system by calling hw_protection    485 shuts down the system by calling hw_protection_shutdown(). The
421 hw_protection_shutdown() first attempts to per    486 hw_protection_shutdown() first attempts to perform an orderly shutdown
422 but accepts a delay after which it proceeds do    487 but accepts a delay after which it proceeds doing a forced power-off
423 or as last resort an emergency_restart.           488 or as last resort an emergency_restart.
424                                                   489 
425 The delay should be carefully profiled so as t    490 The delay should be carefully profiled so as to give adequate time for
426 orderly poweroff.                                 491 orderly poweroff.
427                                                   492 
428 If the delay is set to 0 emergency poweroff wi    493 If the delay is set to 0 emergency poweroff will not be supported. So a
429 carefully profiled non-zero positive value is     494 carefully profiled non-zero positive value is a must for emergency
430 poweroff to be triggered.                         495 poweroff to be triggered.
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php