~ [ 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-5.5.19)


  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 writeable.
 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 
                                                   >> 309         struct thermal_bind_params
                                                   >> 310 
                                                   >> 311     This structure defines the following parameters that are used to bind
                                                   >> 312     a zone with a cooling device for a particular trip point.
                                                   >> 313 
                                                   >> 314     .cdev:
                                                   >> 315              The cooling device pointer
                                                   >> 316     .weight:
                                                   >> 317              The 'influence' of a particular cooling device on this
                                                   >> 318              zone. This is relative to the rest of the cooling
                                                   >> 319              devices. For example, if all cooling devices have a
                                                   >> 320              weight of 1, then they all contribute the same. You can
                                                   >> 321              use percentages if you want, but it's not mandatory. A
                                                   >> 322              weight of 0 means that this cooling device doesn't
                                                   >> 323              contribute to the cooling of this zone unless all cooling
                                                   >> 324              devices have a weight of 0. If all weights are 0, then
                                                   >> 325              they all contribute the same.
                                                   >> 326     .trip_mask:
                                                   >> 327                This is a bit mask that gives the binding relation between
                                                   >> 328                this thermal zone and cdev, for a particular trip point.
                                                   >> 329                If nth bit is set, then the cdev and thermal zone are bound
                                                   >> 330                for trip point n.
                                                   >> 331     .binding_limits:
                                                   >> 332                      This is an array of cooling state limits. Must have
                                                   >> 333                      exactly 2 * thermal_zone.number_of_trip_points. It is an
                                                   >> 334                      array consisting of tuples <lower-state upper-state> of
                                                   >> 335                      state limits. Each trip will be associated with one state
                                                   >> 336                      limit tuple when binding. A NULL pointer means
                                                   >> 337                      <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips.
                                                   >> 338                      These limits are used when binding a cdev to a trip point.
                                                   >> 339     .match:
                                                   >> 340             This call back returns success(0) if the 'tz and cdev' need to
                                                   >> 341             be bound, as per platform data.
                                                   >> 342 
                                                   >> 343     ::
                                                   >> 344 
253         struct thermal_zone_params                345         struct thermal_zone_params
254                                                   346 
255     This structure defines the platform level     347     This structure defines the platform level parameters for a thermal zone.
256     This data, for each thermal zone should co    348     This data, for each thermal zone should come from the platform layer.
257     This is an optional feature where some pla    349     This is an optional feature where some platforms can choose not to
258     provide this data.                            350     provide this data.
259                                                   351 
260     .governor_name:                               352     .governor_name:
261                Name of the thermal governor us    353                Name of the thermal governor used for this zone
262     .no_hwmon:                                    354     .no_hwmon:
263                a boolean to indicate if the th    355                a boolean to indicate if the thermal to hwmon sysfs interface
264                is required. when no_hwmon == f    356                is required. when no_hwmon == false, a hwmon sysfs interface
265                will be created. when no_hwmon     357                will be created. when no_hwmon == true, nothing will be done.
266                In case the thermal_zone_params    358                In case the thermal_zone_params is NULL, the hwmon interface
267                will be created (for backward c    359                will be created (for backward compatibility).
                                                   >> 360     .num_tbps:
                                                   >> 361                Number of thermal_bind_params entries for this zone
                                                   >> 362     .tbp:
                                                   >> 363                thermal_bind_params entries
268                                                   364 
269 2. sysfs attributes structure                     365 2. sysfs attributes structure
270 =============================                     366 =============================
271                                                   367 
272 ==      ================                          368 ==      ================
273 RO      read only value                           369 RO      read only value
274 WO      write only value                          370 WO      write only value
275 RW      read/write value                          371 RW      read/write value
276 ==      ================                          372 ==      ================
277                                                   373 
278 Thermal sysfs attributes will be represented u    374 Thermal sysfs attributes will be represented under /sys/class/thermal.
279 Hwmon sysfs I/F extension is also available un    375 Hwmon sysfs I/F extension is also available under /sys/class/hwmon
280 if hwmon is compiled in or built as a module.     376 if hwmon is compiled in or built as a module.
281                                                   377 
282 Thermal zone device sys I/F, created once it's    378 Thermal zone device sys I/F, created once it's registered::
283                                                   379 
284   /sys/class/thermal/thermal_zone[0-*]:           380   /sys/class/thermal/thermal_zone[0-*]:
285     |---type:                   Type of the th    381     |---type:                   Type of the thermal zone
286     |---temp:                   Current temper    382     |---temp:                   Current temperature
287     |---mode:                   Working mode o    383     |---mode:                   Working mode of the thermal zone
288     |---policy:                 Thermal govern    384     |---policy:                 Thermal governor used for this zone
289     |---available_policies:     Available ther    385     |---available_policies:     Available thermal governors for this zone
290     |---trip_point_[0-*]_temp:  Trip point tem    386     |---trip_point_[0-*]_temp:  Trip point temperature
291     |---trip_point_[0-*]_type:  Trip point typ    387     |---trip_point_[0-*]_type:  Trip point type
292     |---trip_point_[0-*]_hyst:  Hysteresis val    388     |---trip_point_[0-*]_hyst:  Hysteresis value for this trip point
293     |---emul_temp:              Emulated tempe    389     |---emul_temp:              Emulated temperature set node
294     |---sustainable_power:      Sustainable di    390     |---sustainable_power:      Sustainable dissipatable power
295     |---k_po:                   Proportional t    391     |---k_po:                   Proportional term during temperature overshoot
296     |---k_pu:                   Proportional t    392     |---k_pu:                   Proportional term during temperature undershoot
297     |---k_i:                    PID's integral    393     |---k_i:                    PID's integral term in the power allocator gov
298     |---k_d:                    PID's derivati    394     |---k_d:                    PID's derivative term in the power allocator
299     |---integral_cutoff:        Offset above w    395     |---integral_cutoff:        Offset above which errors are accumulated
300     |---slope:                  Slope constant    396     |---slope:                  Slope constant applied as linear extrapolation
301     |---offset:                 Offset constan    397     |---offset:                 Offset constant applied as linear extrapolation
302                                                   398 
303 Thermal cooling device sys I/F, created once i    399 Thermal cooling device sys I/F, created once it's registered::
304                                                   400 
305   /sys/class/thermal/cooling_device[0-*]:         401   /sys/class/thermal/cooling_device[0-*]:
306     |---type:                   Type of the co    402     |---type:                   Type of the cooling device(processor/fan/...)
307     |---max_state:              Maximum coolin    403     |---max_state:              Maximum cooling state of the cooling device
308     |---cur_state:              Current coolin    404     |---cur_state:              Current cooling state of the cooling device
309     |---stats:                  Directory cont    405     |---stats:                  Directory containing cooling device's statistics
310     |---stats/reset:            Writing any va    406     |---stats/reset:            Writing any value resets the statistics
311     |---stats/time_in_state_ms: Time (msec) sp    407     |---stats/time_in_state_ms: Time (msec) spent in various cooling states
312     |---stats/total_trans:      Total number o    408     |---stats/total_trans:      Total number of times cooling state is changed
313     |---stats/trans_table:      Cooling state  !! 409     |---stats/trans_table:      Cooing state transition table
314                                                   410 
315                                                   411 
316 Then next two dynamic attributes are created/r    412 Then next two dynamic attributes are created/removed in pairs. They represent
317 the relationship between a thermal zone and it    413 the relationship between a thermal zone and its associated cooling device.
                                                   >> 414 They are created/removed for each successful execution of
                                                   >> 415 thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
318                                                   416 
319 ::                                                417 ::
320                                                   418 
321   /sys/class/thermal/thermal_zone[0-*]:           419   /sys/class/thermal/thermal_zone[0-*]:
322     |---cdev[0-*]:              [0-*]th coolin    420     |---cdev[0-*]:              [0-*]th cooling device in current thermal zone
323     |---cdev[0-*]_trip_point:   Trip point tha    421     |---cdev[0-*]_trip_point:   Trip point that cdev[0-*] is associated with
324     |---cdev[0-*]_weight:       Influence of t    422     |---cdev[0-*]_weight:       Influence of the cooling device in
325                                 this thermal z    423                                 this thermal zone
326                                                   424 
327 Besides the thermal zone device sysfs I/F and     425 Besides the thermal zone device sysfs I/F and cooling device sysfs I/F,
328 the generic thermal driver also creates a hwmo    426 the generic thermal driver also creates a hwmon sysfs I/F for each _type_
329 of thermal zone device. E.g. the generic therm    427 of thermal zone device. E.g. the generic thermal driver registers one hwmon
330 class device and build the associated hwmon sy    428 class device and build the associated hwmon sysfs I/F for all the registered
331 ACPI thermal zones.                               429 ACPI thermal zones.
332                                                   430 
333 Please read Documentation/ABI/testing/sysfs-cl << 
334 zone and cooling device attribute details.     << 
335                                                << 
336 ::                                                431 ::
337                                                   432 
338   /sys/class/hwmon/hwmon[0-*]:                    433   /sys/class/hwmon/hwmon[0-*]:
339     |---name:                   The type of th    434     |---name:                   The type of the thermal zone devices
340     |---temp[1-*]_input:        The current te    435     |---temp[1-*]_input:        The current temperature of thermal zone [1-*]
341     |---temp[1-*]_critical:     The critical t    436     |---temp[1-*]_critical:     The critical trip point of thermal zone [1-*]
342                                                   437 
343 Please read Documentation/hwmon/sysfs-interfac    438 Please read Documentation/hwmon/sysfs-interface.rst for additional information.
344                                                   439 
                                                   >> 440 Thermal zone attributes
                                                   >> 441 -----------------------
                                                   >> 442 
                                                   >> 443 type
                                                   >> 444         Strings which represent the thermal zone type.
                                                   >> 445         This is given by thermal zone driver as part of registration.
                                                   >> 446         E.g: "acpitz" indicates it's an ACPI thermal device.
                                                   >> 447         In order to keep it consistent with hwmon sys attribute; this should
                                                   >> 448         be a short, lowercase string, not containing spaces nor dashes.
                                                   >> 449         RO, Required
                                                   >> 450 
                                                   >> 451 temp
                                                   >> 452         Current temperature as reported by thermal zone (sensor).
                                                   >> 453         Unit: millidegree Celsius
                                                   >> 454         RO, Required
                                                   >> 455 
                                                   >> 456 mode
                                                   >> 457         One of the predefined values in [enabled, disabled].
                                                   >> 458         This file gives information about the algorithm that is currently
                                                   >> 459         managing the thermal zone. It can be either default kernel based
                                                   >> 460         algorithm or user space application.
                                                   >> 461 
                                                   >> 462         enabled
                                                   >> 463                           enable Kernel Thermal management.
                                                   >> 464         disabled
                                                   >> 465                           Preventing kernel thermal zone driver actions upon
                                                   >> 466                           trip points so that user application can take full
                                                   >> 467                           charge of the thermal management.
                                                   >> 468 
                                                   >> 469         RW, Optional
                                                   >> 470 
                                                   >> 471 policy
                                                   >> 472         One of the various thermal governors used for a particular zone.
                                                   >> 473 
                                                   >> 474         RW, Required
                                                   >> 475 
                                                   >> 476 available_policies
                                                   >> 477         Available thermal governors which can be used for a particular zone.
                                                   >> 478 
                                                   >> 479         RO, Required
                                                   >> 480 
                                                   >> 481 `trip_point_[0-*]_temp`
                                                   >> 482         The temperature above which trip point will be fired.
                                                   >> 483 
                                                   >> 484         Unit: millidegree Celsius
                                                   >> 485 
                                                   >> 486         RO, Optional
                                                   >> 487 
                                                   >> 488 `trip_point_[0-*]_type`
                                                   >> 489         Strings which indicate the type of the trip point.
                                                   >> 490 
                                                   >> 491         E.g. it can be one of critical, hot, passive, `active[0-*]` for ACPI
                                                   >> 492         thermal zone.
                                                   >> 493 
                                                   >> 494         RO, Optional
                                                   >> 495 
                                                   >> 496 `trip_point_[0-*]_hyst`
                                                   >> 497         The hysteresis value for a trip point, represented as an integer
                                                   >> 498         Unit: Celsius
                                                   >> 499         RW, Optional
                                                   >> 500 
                                                   >> 501 `cdev[0-*]`
                                                   >> 502         Sysfs link to the thermal cooling device node where the sys I/F
                                                   >> 503         for cooling device throttling control represents.
                                                   >> 504 
                                                   >> 505         RO, Optional
                                                   >> 506 
                                                   >> 507 `cdev[0-*]_trip_point`
                                                   >> 508         The trip point in this thermal zone which `cdev[0-*]` is associated
                                                   >> 509         with; -1 means the cooling device is not associated with any trip
                                                   >> 510         point.
                                                   >> 511 
                                                   >> 512         RO, Optional
                                                   >> 513 
                                                   >> 514 `cdev[0-*]_weight`
                                                   >> 515         The influence of `cdev[0-*]` in this thermal zone. This value
                                                   >> 516         is relative to the rest of cooling devices in the thermal
                                                   >> 517         zone. For example, if a cooling device has a weight double
                                                   >> 518         than that of other, it's twice as effective in cooling the
                                                   >> 519         thermal zone.
                                                   >> 520 
                                                   >> 521         RW, Optional
                                                   >> 522 
                                                   >> 523 passive
                                                   >> 524         Attribute is only present for zones in which the passive cooling
                                                   >> 525         policy is not supported by native thermal driver. Default is zero
                                                   >> 526         and can be set to a temperature (in millidegrees) to enable a
                                                   >> 527         passive trip point for the zone. Activation is done by polling with
                                                   >> 528         an interval of 1 second.
                                                   >> 529 
                                                   >> 530         Unit: millidegrees Celsius
                                                   >> 531 
                                                   >> 532         Valid values: 0 (disabled) or greater than 1000
                                                   >> 533 
                                                   >> 534         RW, Optional
                                                   >> 535 
                                                   >> 536 emul_temp
                                                   >> 537         Interface to set the emulated temperature method in thermal zone
                                                   >> 538         (sensor). After setting this temperature, the thermal zone may pass
                                                   >> 539         this temperature to platform emulation function if registered or
                                                   >> 540         cache it locally. This is useful in debugging different temperature
                                                   >> 541         threshold and its associated cooling action. This is write only node
                                                   >> 542         and writing 0 on this node should disable emulation.
                                                   >> 543         Unit: millidegree Celsius
                                                   >> 544 
                                                   >> 545         WO, Optional
                                                   >> 546 
                                                   >> 547           WARNING:
                                                   >> 548             Be careful while enabling this option on production systems,
                                                   >> 549             because userland can easily disable the thermal policy by simply
                                                   >> 550             flooding this sysfs node with low temperature values.
                                                   >> 551 
                                                   >> 552 sustainable_power
                                                   >> 553         An estimate of the sustained power that can be dissipated by
                                                   >> 554         the thermal zone. Used by the power allocator governor. For
                                                   >> 555         more information see Documentation/driver-api/thermal/power_allocator.rst
                                                   >> 556 
                                                   >> 557         Unit: milliwatts
                                                   >> 558 
                                                   >> 559         RW, Optional
                                                   >> 560 
                                                   >> 561 k_po
                                                   >> 562         The proportional term of the power allocator governor's PID
                                                   >> 563         controller during temperature overshoot. Temperature overshoot
                                                   >> 564         is when the current temperature is above the "desired
                                                   >> 565         temperature" trip point. For more information see
                                                   >> 566         Documentation/driver-api/thermal/power_allocator.rst
                                                   >> 567 
                                                   >> 568         RW, Optional
                                                   >> 569 
                                                   >> 570 k_pu
                                                   >> 571         The proportional term of the power allocator governor's PID
                                                   >> 572         controller during temperature undershoot. Temperature undershoot
                                                   >> 573         is when the current temperature is below the "desired
                                                   >> 574         temperature" trip point. For more information see
                                                   >> 575         Documentation/driver-api/thermal/power_allocator.rst
                                                   >> 576 
                                                   >> 577         RW, Optional
                                                   >> 578 
                                                   >> 579 k_i
                                                   >> 580         The integral term of the power allocator governor's PID
                                                   >> 581         controller. This term allows the PID controller to compensate
                                                   >> 582         for long term drift. For more information see
                                                   >> 583         Documentation/driver-api/thermal/power_allocator.rst
                                                   >> 584 
                                                   >> 585         RW, Optional
                                                   >> 586 
                                                   >> 587 k_d
                                                   >> 588         The derivative term of the power allocator governor's PID
                                                   >> 589         controller. For more information see
                                                   >> 590         Documentation/driver-api/thermal/power_allocator.rst
                                                   >> 591 
                                                   >> 592         RW, Optional
                                                   >> 593 
                                                   >> 594 integral_cutoff
                                                   >> 595         Temperature offset from the desired temperature trip point
                                                   >> 596         above which the integral term of the power allocator
                                                   >> 597         governor's PID controller starts accumulating errors. For
                                                   >> 598         example, if integral_cutoff is 0, then the integral term only
                                                   >> 599         accumulates error when temperature is above the desired
                                                   >> 600         temperature trip point. For more information see
                                                   >> 601         Documentation/driver-api/thermal/power_allocator.rst
                                                   >> 602 
                                                   >> 603         Unit: millidegree Celsius
                                                   >> 604 
                                                   >> 605         RW, Optional
                                                   >> 606 
                                                   >> 607 slope
                                                   >> 608         The slope constant used in a linear extrapolation model
                                                   >> 609         to determine a hotspot temperature based off the sensor's
                                                   >> 610         raw readings. It is up to the device driver to determine
                                                   >> 611         the usage of these values.
                                                   >> 612 
                                                   >> 613         RW, Optional
                                                   >> 614 
                                                   >> 615 offset
                                                   >> 616         The offset constant used in a linear extrapolation model
                                                   >> 617         to determine a hotspot temperature based off the sensor's
                                                   >> 618         raw readings. It is up to the device driver to determine
                                                   >> 619         the usage of these values.
                                                   >> 620 
                                                   >> 621         RW, Optional
                                                   >> 622 
                                                   >> 623 Cooling device attributes
                                                   >> 624 -------------------------
                                                   >> 625 
                                                   >> 626 type
                                                   >> 627         String which represents the type of device, e.g:
                                                   >> 628 
                                                   >> 629         - for generic ACPI: should be "Fan", "Processor" or "LCD"
                                                   >> 630         - for memory controller device on intel_menlow platform:
                                                   >> 631           should be "Memory controller".
                                                   >> 632 
                                                   >> 633         RO, Required
                                                   >> 634 
                                                   >> 635 max_state
                                                   >> 636         The maximum permissible cooling state of this cooling device.
                                                   >> 637 
                                                   >> 638         RO, Required
                                                   >> 639 
                                                   >> 640 cur_state
                                                   >> 641         The current cooling state of this cooling device.
                                                   >> 642         The value can any integer numbers between 0 and max_state:
                                                   >> 643 
                                                   >> 644         - cur_state == 0 means no cooling
                                                   >> 645         - cur_state == max_state means the maximum cooling.
                                                   >> 646 
                                                   >> 647         RW, Required
                                                   >> 648 
                                                   >> 649 stats/reset
                                                   >> 650         Writing any value resets the cooling device's statistics.
                                                   >> 651         WO, Required
                                                   >> 652 
                                                   >> 653 stats/time_in_state_ms:
                                                   >> 654         The amount of time spent by the cooling device in various cooling
                                                   >> 655         states. The output will have "<state> <time>" pair in each line, which
                                                   >> 656         will mean this cooling device spent <time> msec of time at <state>.
                                                   >> 657         Output will have one line for each of the supported states.  usertime
                                                   >> 658         units here is 10mS (similar to other time exported in /proc).
                                                   >> 659         RO, Required
                                                   >> 660 
                                                   >> 661 
                                                   >> 662 stats/total_trans:
                                                   >> 663         A single positive value showing the total number of times the state of a
                                                   >> 664         cooling device is changed.
                                                   >> 665 
                                                   >> 666         RO, Required
                                                   >> 667 
                                                   >> 668 stats/trans_table:
                                                   >> 669         This gives fine grained information about all the cooling state
                                                   >> 670         transitions. The cat output here is a two dimensional matrix, where an
                                                   >> 671         entry <i,j> (row i, column j) represents the number of transitions from
                                                   >> 672         State_i to State_j. If the transition table is bigger than PAGE_SIZE,
                                                   >> 673         reading this will return an -EFBIG error.
                                                   >> 674         RO, Required
                                                   >> 675 
345 3. A simple implementation                        676 3. A simple implementation
346 ==========================                        677 ==========================
347                                                   678 
348 ACPI thermal zone may support multiple trip po    679 ACPI thermal zone may support multiple trip points like critical, hot,
349 passive, active. If an ACPI thermal zone suppo    680 passive, active. If an ACPI thermal zone supports critical, passive,
350 active[0] and active[1] at the same time, it m    681 active[0] and active[1] at the same time, it may register itself as a
351 thermal_zone_device (thermal_zone1) with 4 tri    682 thermal_zone_device (thermal_zone1) with 4 trip points in all.
352 It has one processor and one fan, which are bo    683 It has one processor and one fan, which are both registered as
353 thermal_cooling_device. Both are considered to    684 thermal_cooling_device. Both are considered to have the same
354 effectiveness in cooling the thermal zone.        685 effectiveness in cooling the thermal zone.
355                                                   686 
356 If the processor is listed in _PSL method, and    687 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    688 method, the sys I/F structure will be built like this::
358                                                   689 
359  /sys/class/thermal:                              690  /sys/class/thermal:
360   |thermal_zone1:                                 691   |thermal_zone1:
361     |---type:                   acpitz            692     |---type:                   acpitz
362     |---temp:                   37000             693     |---temp:                   37000
363     |---mode:                   enabled           694     |---mode:                   enabled
364     |---policy:                 step_wise         695     |---policy:                 step_wise
365     |---available_policies:     step_wise fair    696     |---available_policies:     step_wise fair_share
366     |---trip_point_0_temp:      100000            697     |---trip_point_0_temp:      100000
367     |---trip_point_0_type:      critical          698     |---trip_point_0_type:      critical
368     |---trip_point_1_temp:      80000             699     |---trip_point_1_temp:      80000
369     |---trip_point_1_type:      passive           700     |---trip_point_1_type:      passive
370     |---trip_point_2_temp:      70000             701     |---trip_point_2_temp:      70000
371     |---trip_point_2_type:      active0           702     |---trip_point_2_type:      active0
372     |---trip_point_3_temp:      60000             703     |---trip_point_3_temp:      60000
373     |---trip_point_3_type:      active1           704     |---trip_point_3_type:      active1
374     |---cdev0:                  --->/sys/class    705     |---cdev0:                  --->/sys/class/thermal/cooling_device0
375     |---cdev0_trip_point:       1       /* cde    706     |---cdev0_trip_point:       1       /* cdev0 can be used for passive */
376     |---cdev0_weight:           1024              707     |---cdev0_weight:           1024
377     |---cdev1:                  --->/sys/class    708     |---cdev1:                  --->/sys/class/thermal/cooling_device3
378     |---cdev1_trip_point:       2       /* cde    709     |---cdev1_trip_point:       2       /* cdev1 can be used for active[0]*/
379     |---cdev1_weight:           1024              710     |---cdev1_weight:           1024
380                                                   711 
381   |cooling_device0:                               712   |cooling_device0:
382     |---type:                   Processor         713     |---type:                   Processor
383     |---max_state:              8                 714     |---max_state:              8
384     |---cur_state:              0                 715     |---cur_state:              0
385                                                   716 
386   |cooling_device3:                               717   |cooling_device3:
387     |---type:                   Fan               718     |---type:                   Fan
388     |---max_state:              2                 719     |---max_state:              2
389     |---cur_state:              0                 720     |---cur_state:              0
390                                                   721 
391  /sys/class/hwmon:                                722  /sys/class/hwmon:
392   |hwmon0:                                        723   |hwmon0:
393     |---name:                   acpitz            724     |---name:                   acpitz
394     |---temp1_input:            37000             725     |---temp1_input:            37000
395     |---temp1_crit:             100000            726     |---temp1_crit:             100000
396                                                   727 
397 4. Export Symbol APIs                             728 4. Export Symbol APIs
398 =====================                             729 =====================
399                                                   730 
400 4.1. get_tz_trend                                 731 4.1. get_tz_trend
401 -----------------                                 732 -----------------
402                                                   733 
403 This function returns the trend of a thermal z    734 This function returns the trend of a thermal zone, i.e the rate of change
404 of temperature of the thermal zone. Ideally, t    735 of temperature of the thermal zone. Ideally, the thermal sensor drivers
405 are supposed to implement the callback. If the    736 are supposed to implement the callback. If they don't, the thermal
406 framework calculated the trend by comparing th    737 framework calculated the trend by comparing the previous and the current
407 temperature values.                               738 temperature values.
408                                                   739 
409 4.2. thermal_cdev_update                       !! 740 4.2. get_thermal_instance
                                                   >> 741 -------------------------
                                                   >> 742 
                                                   >> 743 This function returns the thermal_instance corresponding to a given
                                                   >> 744 {thermal_zone, cooling_device, trip_point} combination. Returns NULL
                                                   >> 745 if such an instance does not exist.
                                                   >> 746 
                                                   >> 747 4.3. thermal_notify_framework
                                                   >> 748 -----------------------------
                                                   >> 749 
                                                   >> 750 This function handles the trip events from sensor drivers. It starts
                                                   >> 751 throttling the cooling devices according to the policy configured.
                                                   >> 752 For CRITICAL and HOT trip points, this notifies the respective drivers,
                                                   >> 753 and does actual throttling for other trip points i.e ACTIVE and PASSIVE.
                                                   >> 754 The throttling policy is based on the configured platform data; if no
                                                   >> 755 platform data is provided, this uses the step_wise throttling policy.
                                                   >> 756 
                                                   >> 757 4.4. thermal_cdev_update
410 ------------------------                          758 ------------------------
411                                                   759 
412 This function serves as an arbitrator to set t    760 This function serves as an arbitrator to set the state of a cooling
413 device. It sets the cooling device to the deep    761 device. It sets the cooling device to the deepest cooling state if
414 possible.                                         762 possible.
415                                                   763 
416 5. thermal_emergency_poweroff                     764 5. thermal_emergency_poweroff
417 =============================                     765 =============================
418                                                   766 
419 On an event of critical trip temperature cross !! 767 On an event of critical trip temperature crossing. Thermal framework
420 shuts down the system by calling hw_protection !! 768 allows the system to shutdown gracefully by calling orderly_poweroff().
421 hw_protection_shutdown() first attempts to per !! 769 In the event of a failure of orderly_poweroff() to shut down the system
422 but accepts a delay after which it proceeds do !! 770 we are in danger of keeping the system alive at undesirably high
423 or as last resort an emergency_restart.        !! 771 temperatures. To mitigate this high risk scenario we program a work
                                                   >> 772 queue to fire after a pre-determined number of seconds to start
                                                   >> 773 an emergency shutdown of the device using the kernel_power_off()
                                                   >> 774 function. In case kernel_power_off() fails then finally
                                                   >> 775 emergency_restart() is called in the worst case.
424                                                   776 
425 The delay should be carefully profiled so as t    777 The delay should be carefully profiled so as to give adequate time for
426 orderly poweroff.                              !! 778 orderly_poweroff(). In case of failure of an orderly_poweroff() the
427                                                !! 779 emergency poweroff kicks in after the delay has elapsed and shuts down
428 If the delay is set to 0 emergency poweroff wi !! 780 the system.
429 carefully profiled non-zero positive value is  !! 781 
430 poweroff to be triggered.                      !! 782 If set to 0 emergency poweroff will not be supported. So a carefully
                                                   >> 783 profiled non-zero positive value is a must for emergerncy poweroff to be
                                                   >> 784 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