~ [ 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.2.16)


  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 
                                                   >> 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:      Cooling 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    431 Please read Documentation/ABI/testing/sysfs-class-thermal for thermal
334 zone and cooling device attribute details.        432 zone and cooling device attribute details.
335                                                   433 
336 ::                                                434 ::
337                                                   435 
338   /sys/class/hwmon/hwmon[0-*]:                    436   /sys/class/hwmon/hwmon[0-*]:
339     |---name:                   The type of th    437     |---name:                   The type of the thermal zone devices
340     |---temp[1-*]_input:        The current te    438     |---temp[1-*]_input:        The current temperature of thermal zone [1-*]
341     |---temp[1-*]_critical:     The critical t    439     |---temp[1-*]_critical:     The critical trip point of thermal zone [1-*]
342                                                   440 
343 Please read Documentation/hwmon/sysfs-interfac    441 Please read Documentation/hwmon/sysfs-interface.rst for additional information.
344                                                   442 
345 3. A simple implementation                        443 3. A simple implementation
346 ==========================                        444 ==========================
347                                                   445 
348 ACPI thermal zone may support multiple trip po    446 ACPI thermal zone may support multiple trip points like critical, hot,
349 passive, active. If an ACPI thermal zone suppo    447 passive, active. If an ACPI thermal zone supports critical, passive,
350 active[0] and active[1] at the same time, it m    448 active[0] and active[1] at the same time, it may register itself as a
351 thermal_zone_device (thermal_zone1) with 4 tri    449 thermal_zone_device (thermal_zone1) with 4 trip points in all.
352 It has one processor and one fan, which are bo    450 It has one processor and one fan, which are both registered as
353 thermal_cooling_device. Both are considered to    451 thermal_cooling_device. Both are considered to have the same
354 effectiveness in cooling the thermal zone.        452 effectiveness in cooling the thermal zone.
355                                                   453 
356 If the processor is listed in _PSL method, and    454 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    455 method, the sys I/F structure will be built like this::
358                                                   456 
359  /sys/class/thermal:                              457  /sys/class/thermal:
360   |thermal_zone1:                                 458   |thermal_zone1:
361     |---type:                   acpitz            459     |---type:                   acpitz
362     |---temp:                   37000             460     |---temp:                   37000
363     |---mode:                   enabled           461     |---mode:                   enabled
364     |---policy:                 step_wise         462     |---policy:                 step_wise
365     |---available_policies:     step_wise fair    463     |---available_policies:     step_wise fair_share
366     |---trip_point_0_temp:      100000            464     |---trip_point_0_temp:      100000
367     |---trip_point_0_type:      critical          465     |---trip_point_0_type:      critical
368     |---trip_point_1_temp:      80000             466     |---trip_point_1_temp:      80000
369     |---trip_point_1_type:      passive           467     |---trip_point_1_type:      passive
370     |---trip_point_2_temp:      70000             468     |---trip_point_2_temp:      70000
371     |---trip_point_2_type:      active0           469     |---trip_point_2_type:      active0
372     |---trip_point_3_temp:      60000             470     |---trip_point_3_temp:      60000
373     |---trip_point_3_type:      active1           471     |---trip_point_3_type:      active1
374     |---cdev0:                  --->/sys/class    472     |---cdev0:                  --->/sys/class/thermal/cooling_device0
375     |---cdev0_trip_point:       1       /* cde    473     |---cdev0_trip_point:       1       /* cdev0 can be used for passive */
376     |---cdev0_weight:           1024              474     |---cdev0_weight:           1024
377     |---cdev1:                  --->/sys/class    475     |---cdev1:                  --->/sys/class/thermal/cooling_device3
378     |---cdev1_trip_point:       2       /* cde    476     |---cdev1_trip_point:       2       /* cdev1 can be used for active[0]*/
379     |---cdev1_weight:           1024              477     |---cdev1_weight:           1024
380                                                   478 
381   |cooling_device0:                               479   |cooling_device0:
382     |---type:                   Processor         480     |---type:                   Processor
383     |---max_state:              8                 481     |---max_state:              8
384     |---cur_state:              0                 482     |---cur_state:              0
385                                                   483 
386   |cooling_device3:                               484   |cooling_device3:
387     |---type:                   Fan               485     |---type:                   Fan
388     |---max_state:              2                 486     |---max_state:              2
389     |---cur_state:              0                 487     |---cur_state:              0
390                                                   488 
391  /sys/class/hwmon:                                489  /sys/class/hwmon:
392   |hwmon0:                                        490   |hwmon0:
393     |---name:                   acpitz            491     |---name:                   acpitz
394     |---temp1_input:            37000             492     |---temp1_input:            37000
395     |---temp1_crit:             100000            493     |---temp1_crit:             100000
396                                                   494 
397 4. Export Symbol APIs                             495 4. Export Symbol APIs
398 =====================                             496 =====================
399                                                   497 
400 4.1. get_tz_trend                                 498 4.1. get_tz_trend
401 -----------------                                 499 -----------------
402                                                   500 
403 This function returns the trend of a thermal z    501 This function returns the trend of a thermal zone, i.e the rate of change
404 of temperature of the thermal zone. Ideally, t    502 of temperature of the thermal zone. Ideally, the thermal sensor drivers
405 are supposed to implement the callback. If the    503 are supposed to implement the callback. If they don't, the thermal
406 framework calculated the trend by comparing th    504 framework calculated the trend by comparing the previous and the current
407 temperature values.                               505 temperature values.
408                                                   506 
409 4.2. thermal_cdev_update                       !! 507 4.2. get_thermal_instance
                                                   >> 508 -------------------------
                                                   >> 509 
                                                   >> 510 This function returns the thermal_instance corresponding to a given
                                                   >> 511 {thermal_zone, cooling_device, trip_point} combination. Returns NULL
                                                   >> 512 if such an instance does not exist.
                                                   >> 513 
                                                   >> 514 4.3. thermal_cdev_update
410 ------------------------                          515 ------------------------
411                                                   516 
412 This function serves as an arbitrator to set t    517 This function serves as an arbitrator to set the state of a cooling
413 device. It sets the cooling device to the deep    518 device. It sets the cooling device to the deepest cooling state if
414 possible.                                         519 possible.
415                                                   520 
416 5. thermal_emergency_poweroff                     521 5. thermal_emergency_poweroff
417 =============================                     522 =============================
418                                                   523 
419 On an event of critical trip temperature cross    524 On an event of critical trip temperature crossing the thermal framework
420 shuts down the system by calling hw_protection    525 shuts down the system by calling hw_protection_shutdown(). The
421 hw_protection_shutdown() first attempts to per    526 hw_protection_shutdown() first attempts to perform an orderly shutdown
422 but accepts a delay after which it proceeds do    527 but accepts a delay after which it proceeds doing a forced power-off
423 or as last resort an emergency_restart.           528 or as last resort an emergency_restart.
424                                                   529 
425 The delay should be carefully profiled so as t    530 The delay should be carefully profiled so as to give adequate time for
426 orderly poweroff.                                 531 orderly poweroff.
427                                                   532 
428 If the delay is set to 0 emergency poweroff wi    533 If the delay is set to 0 emergency poweroff will not be supported. So a
429 carefully profiled non-zero positive value is     534 carefully profiled non-zero positive value is a must for emergency
430 poweroff to be triggered.                         535 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