Commit | Line | Data |
---|---|---|
1da177e4 | 1 | Naming and data format standards for sysfs files |
b04f2f7d | 2 | ================================================ |
1da177e4 LT |
3 | |
4 | The libsensors library offers an interface to the raw sensors data | |
125ff808 JD |
5 | through the sysfs interface. Since lm-sensors 3.0.0, libsensors is |
6 | completely chip-independent. It assumes that all the kernel drivers | |
7 | implement the standard sysfs interface described in this document. | |
8 | This makes adding or updating support for any given chip very easy, as | |
9 | libsensors, and applications using it, do not need to be modified. | |
10 | This is a major improvement compared to lm-sensors 2. | |
1da177e4 LT |
11 | |
12 | Note that motherboards vary widely in the connections to sensor chips. | |
13 | There is no standard that ensures, for example, that the second | |
14 | temperature sensor is connected to the CPU, or that the second fan is on | |
15 | the CPU. Also, some values reported by the chips need some computation | |
16 | before they make full sense. For example, most chips can only measure | |
17 | voltages between 0 and +4V. Other voltages are scaled back into that | |
18 | range using external resistors. Since the values of these resistors | |
19 | can change from motherboard to motherboard, the conversions cannot be | |
20 | hard coded into the driver and have to be done in user space. | |
21 | ||
740e06a8 | 22 | For this reason, even if we aim at a chip-independent libsensors, it will |
1da177e4 LT |
23 | still require a configuration file (e.g. /etc/sensors.conf) for proper |
24 | values conversion, labeling of inputs and hiding of unused inputs. | |
25 | ||
26 | An alternative method that some programs use is to access the sysfs | |
27 | files directly. This document briefly describes the standards that the | |
28 | drivers follow, so that an application program can scan for entries and | |
29 | access this data in a simple and consistent way. That said, such programs | |
30 | will have to implement conversion, labeling and hiding of inputs. For | |
31 | this reason, it is still not recommended to bypass the library. | |
32 | ||
1da177e4 | 33 | Each chip gets its own directory in the sysfs /sys/devices tree. To |
740e06a8 | 34 | find all sensor chips, it is easier to follow the device symlinks from |
b04f2f7d | 35 | `/sys/class/hwmon/hwmon*`. |
1da177e4 | 36 | |
125ff808 JD |
37 | Up to lm-sensors 3.0.0, libsensors looks for hardware monitoring attributes |
38 | in the "physical" device directory. Since lm-sensors 3.0.1, attributes found | |
39 | in the hwmon "class" device directory are also supported. Complex drivers | |
40 | (e.g. drivers for multifunction chips) may want to use this possibility to | |
41 | avoid namespace pollution. The only drawback will be that older versions of | |
42 | libsensors won't support the driver in question. | |
43 | ||
740e06a8 | 44 | All sysfs values are fixed point numbers. |
1da177e4 LT |
45 | |
46 | There is only one value per file, unlike the older /proc specification. | |
47 | The common scheme for files naming is: <type><number>_<item>. Usual | |
48 | types for sensor chips are "in" (voltage), "temp" (temperature) and | |
49 | "fan" (fan). Usual items are "input" (measured value), "max" (high | |
50 | threshold, "min" (low threshold). Numbering usually starts from 1, | |
51 | except for voltages which start from 0 (because most data sheets use | |
52 | this). A number is always used for elements that can be present more | |
53 | than once, even if there is a single element of the given type on the | |
54 | specific chip. Other files do not refer to a specific element, so | |
55 | they have a simple name, and no number. | |
56 | ||
57 | Alarms are direct indications read from the chips. The drivers do NOT | |
58 | make comparisons of readings to thresholds. This allows violations | |
59 | between readings to be caught and alarmed. The exact definition of an | |
60 | alarm (for example, whether a threshold must be met or must be exceeded | |
61 | to cause an alarm) is chip-dependent. | |
62 | ||
2ed42633 HG |
63 | When setting values of hwmon sysfs attributes, the string representation of |
64 | the desired value must be written, note that strings which are not a number | |
65 | are interpreted as 0! For more on how written strings are interpreted see the | |
66 | "sysfs attribute writes interpretation" section at the end of this file. | |
1da177e4 | 67 | |
e1576396 GR |
68 | Attribute access |
69 | ---------------- | |
70 | ||
71 | Hardware monitoring sysfs attributes are displayed by unrestricted userspace | |
72 | applications. For this reason, all standard ABI attributes shall be world | |
73 | readable. Writeable standard ABI attributes shall be writeable only for | |
74 | privileged users. | |
75 | ||
1da177e4 LT |
76 | ------------------------------------------------------------------------- |
77 | ||
b04f2f7d MCC |
78 | ======= =========================================== |
79 | `[0-*]` denotes any positive number starting from 0 | |
80 | `[1-*]` denotes any positive number starting from 1 | |
057bc350 | 81 | RO read only value |
cd4e96c5 | 82 | WO write only value |
057bc350 | 83 | RW read/write value |
b04f2f7d | 84 | ======= =========================================== |
057bc350 RM |
85 | |
86 | Read/write values may be read-only for some chips, depending on the | |
87 | hardware implementation. | |
88 | ||
176544dc JD |
89 | All entries (except name) are optional, and should only be created in a |
90 | given driver if the chip has the feature. | |
91 | ||
036d6a4e MCC |
92 | See Documentation/ABI/testing/sysfs-class-hwmon for a complete description |
93 | of the attributes. | |
176544dc | 94 | |
b04f2f7d MCC |
95 | ***************** |
96 | Global attributes | |
97 | ***************** | |
176544dc | 98 | |
b04f2f7d MCC |
99 | `name` |
100 | The chip name. | |
176544dc | 101 | |
32b9a19a PC |
102 | `label` |
103 | A descriptive label that allows to uniquely identify a device | |
104 | within the system. | |
105 | ||
b04f2f7d MCC |
106 | `update_interval` |
107 | The interval at which the chip will update readings. | |
d2b847d4 | 108 | |
740e06a8 | 109 | |
b04f2f7d MCC |
110 | ******** |
111 | Voltages | |
112 | ******** | |
113 | ||
114 | `in[0-*]_min` | |
115 | Voltage min value. | |
1da177e4 | 116 | |
b04f2f7d MCC |
117 | `in[0-*]_lcrit` |
118 | Voltage critical min value. | |
119 | ||
b04f2f7d MCC |
120 | `in[0-*]_max` |
121 | Voltage max value. | |
122 | ||
b04f2f7d MCC |
123 | `in[0-*]_crit` |
124 | Voltage critical max value. | |
125 | ||
b04f2f7d MCC |
126 | `in[0-*]_input` |
127 | Voltage input value. | |
128 | ||
b04f2f7d | 129 | `in[0-*]_average` |
0084e9fa | 130 | Average voltage |
b04f2f7d | 131 | |
b04f2f7d | 132 | `in[0-*]_lowest` |
0084e9fa | 133 | Historical minimum voltage |
b04f2f7d | 134 | |
b04f2f7d | 135 | `in[0-*]_highest` |
0084e9fa | 136 | Historical maximum voltage |
b04f2f7d | 137 | |
b04f2f7d | 138 | `in[0-*]_reset_history` |
0084e9fa | 139 | Reset inX_lowest and inX_highest |
b04f2f7d | 140 | |
b04f2f7d | 141 | `in_reset_history` |
0084e9fa | 142 | Reset inX_lowest and inX_highest for all sensors |
b04f2f7d | 143 | |
b04f2f7d MCC |
144 | `in[0-*]_label` |
145 | Suggested voltage channel label. | |
146 | ||
b04f2f7d | 147 | `in[0-*]_enable` |
fb41a710 | 148 | Enable or disable the sensors. |
b04f2f7d | 149 | |
b04f2f7d MCC |
150 | `cpu[0-*]_vid` |
151 | CPU core reference voltage. | |
152 | ||
b04f2f7d MCC |
153 | `vrm` |
154 | Voltage Regulator Module version number. | |
155 | ||
e8e61235 ZL |
156 | `in[0-*]_rated_min` |
157 | Minimum rated voltage. | |
158 | ||
e8e61235 ZL |
159 | `in[0-*]_rated_max` |
160 | Maximum rated voltage. | |
161 | ||
057bc350 RM |
162 | Also see the Alarms section for status flags associated with voltages. |
163 | ||
1da177e4 | 164 | |
b04f2f7d MCC |
165 | **** |
166 | Fans | |
167 | **** | |
168 | ||
169 | `fan[1-*]_min` | |
170 | Fan minimum value | |
1da177e4 | 171 | |
b04f2f7d MCC |
172 | `fan[1-*]_max` |
173 | Fan maximum value | |
174 | ||
b04f2f7d MCC |
175 | `fan[1-*]_input` |
176 | Fan input value. | |
177 | ||
b04f2f7d MCC |
178 | `fan[1-*]_div` |
179 | Fan divisor. | |
180 | ||
b04f2f7d MCC |
181 | `fan[1-*]_pulses` |
182 | Number of tachometer pulses per fan revolution. | |
183 | ||
b04f2f7d | 184 | `fan[1-*]_target` |
2dbc514a | 185 | Desired fan speed |
b04f2f7d | 186 | |
b04f2f7d MCC |
187 | `fan[1-*]_label` |
188 | Suggested fan channel label. | |
189 | ||
b04f2f7d | 190 | `fan[1-*]_enable` |
fb41a710 | 191 | Enable or disable the sensors. |
b04f2f7d | 192 | |
057bc350 RM |
193 | Also see the Alarms section for status flags associated with fans. |
194 | ||
195 | ||
b04f2f7d MCC |
196 | *** |
197 | PWM | |
198 | *** | |
199 | ||
200 | `pwm[1-*]` | |
201 | Pulse width modulation fan control. | |
1da177e4 | 202 | |
b04f2f7d | 203 | `pwm[1-*]_enable` |
9fadbda6 | 204 | Fan speed control method. |
b04f2f7d | 205 | |
b04f2f7d | 206 | `pwm[1-*]_mode` |
036d6a4e | 207 | direct current or pulse-width modulation. |
f8d0c19a | 208 | |
b04f2f7d MCC |
209 | `pwm[1-*]_freq` |
210 | Base PWM frequency in Hz. | |
211 | ||
b04f2f7d | 212 | `pwm[1-*]_auto_channels_temp` |
1da177e4 | 213 | Select which temperature channels affect this PWM output in |
b04f2f7d MCC |
214 | auto mode. |
215 | ||
b04f2f7d MCC |
216 | `pwm[1-*]_auto_point[1-*]_pwm` / `pwm[1-*]_auto_point[1-*]_temp` / `pwm[1-*]_auto_point[1-*]_temp_hyst` |
217 | Define the PWM vs temperature curve. | |
218 | ||
b04f2f7d MCC |
219 | `temp[1-*]_auto_point[1-*]_pwm` / `temp[1-*]_auto_point[1-*]_temp` / `temp[1-*]_auto_point[1-*]_temp_hyst` |
220 | Define the PWM vs temperature curve. | |
221 | ||
f7290e24 JD |
222 | There is a third case where trip points are associated to both PWM output |
223 | channels and temperature channels: the PWM values are associated to PWM | |
224 | output channels while the temperature values are associated to temperature | |
225 | channels. In that case, the result is determined by the mapping between | |
226 | temperature inputs and PWM outputs. When several temperature inputs are | |
227 | mapped to a given PWM output, this leads to several candidate PWM values. | |
228 | The actual result is up to the chip, but in general the highest candidate | |
229 | value (fastest fan speed) wins. | |
230 | ||
1da177e4 | 231 | |
b04f2f7d MCC |
232 | ************ |
233 | Temperatures | |
234 | ************ | |
235 | ||
236 | `temp[1-*]_type` | |
237 | Sensor type selection. | |
1da177e4 | 238 | |
b04f2f7d MCC |
239 | `temp[1-*]_max` |
240 | Temperature max value. | |
241 | ||
b04f2f7d MCC |
242 | `temp[1-*]_min` |
243 | Temperature min value. | |
244 | ||
b04f2f7d | 245 | `temp[1-*]_max_hyst` |
1da177e4 | 246 | Temperature hysteresis value for max limit. |
b04f2f7d | 247 | |
b04f2f7d | 248 | `temp[1-*]_min_hyst` |
01325145 | 249 | Temperature hysteresis value for min limit. |
01325145 | 250 | |
b04f2f7d | 251 | `temp[1-*]_input` |
036d6a4e | 252 | Temperature input value. |
1da177e4 | 253 | |
b04f2f7d MCC |
254 | `temp[1-*]_crit` |
255 | Temperature critical max value, typically greater than | |
1da177e4 | 256 | corresponding temp_max values. |
b04f2f7d | 257 | |
b04f2f7d | 258 | `temp[1-*]_crit_hyst` |
1da177e4 | 259 | Temperature hysteresis value for critical limit. |
b04f2f7d | 260 | |
b04f2f7d | 261 | `temp[1-*]_emergency` |
28e7438f | 262 | Temperature emergency max value, for chips supporting more than |
036d6a4e | 263 | two upper temperature limits. |
28e7438f | 264 | |
b04f2f7d | 265 | `temp[1-*]_emergency_hyst` |
28e7438f | 266 | Temperature hysteresis value for emergency limit. |
b04f2f7d | 267 | |
b04f2f7d MCC |
268 | `temp[1-*]_lcrit` |
269 | Temperature critical min value, typically lower than | |
f46fc8cd | 270 | corresponding temp_min values. |
b04f2f7d | 271 | |
b04f2f7d | 272 | `temp[1-*]_lcrit_hyst` |
01325145 | 273 | Temperature hysteresis value for critical min limit. |
b04f2f7d | 274 | |
b04f2f7d | 275 | `temp[1-*]_offset` |
59ac8367 HR |
276 | Temperature offset which is added to the temperature reading |
277 | by the chip. | |
b04f2f7d | 278 | |
b04f2f7d MCC |
279 | `temp[1-*]_label` |
280 | Suggested temperature channel label. | |
281 | ||
b04f2f7d | 282 | `temp[1-*]_lowest` |
cd4e96c5 | 283 | Historical minimum temperature |
b04f2f7d | 284 | |
b04f2f7d | 285 | `temp[1-*]_highest` |
cd4e96c5 | 286 | Historical maximum temperature |
b04f2f7d | 287 | |
b04f2f7d | 288 | `temp[1-*]_reset_history` |
cd4e96c5 | 289 | Reset temp_lowest and temp_highest |
b04f2f7d | 290 | |
b04f2f7d | 291 | `temp_reset_history` |
cd4e96c5 | 292 | Reset temp_lowest and temp_highest for all sensors |
b04f2f7d | 293 | |
b04f2f7d | 294 | `temp[1-*]_enable` |
fb41a710 | 295 | Enable or disable the sensors. |
b04f2f7d | 296 | |
e8e61235 ZL |
297 | `temp[1-*]_rated_min` |
298 | Minimum rated temperature. | |
299 | ||
e8e61235 ZL |
300 | `temp[1-*]_rated_max` |
301 | Maximum rated temperature. | |
302 | ||
740e06a8 JD |
303 | Some chips measure temperature using external thermistors and an ADC, and |
304 | report the temperature measurement as a voltage. Converting this voltage | |
305 | back to a temperature (or the other way around for limits) requires | |
306 | mathematical functions not available in the kernel, so the conversion | |
307 | must occur in user space. For these chips, all temp* files described | |
308 | above should contain values expressed in millivolt instead of millidegree | |
309 | Celsius. In other words, such temperature channels are handled as voltage | |
310 | channels by the driver. | |
311 | ||
057bc350 RM |
312 | Also see the Alarms section for status flags associated with temperatures. |
313 | ||
1da177e4 | 314 | |
b04f2f7d MCC |
315 | ******** |
316 | Currents | |
317 | ******** | |
318 | ||
319 | `curr[1-*]_max` | |
036d6a4e | 320 | Current max value. |
1da177e4 | 321 | |
b04f2f7d MCC |
322 | `curr[1-*]_min` |
323 | Current min value. | |
324 | ||
b04f2f7d MCC |
325 | `curr[1-*]_lcrit` |
326 | Current critical low value | |
327 | ||
b04f2f7d MCC |
328 | `curr[1-*]_crit` |
329 | Current critical high value. | |
330 | ||
b04f2f7d | 331 | `curr[1-*]_input` |
036d6a4e | 332 | Current input value. |
1da177e4 | 333 | |
b04f2f7d | 334 | `curr[1-*]_average` |
036d6a4e | 335 | Average current use. |
0084e9fa | 336 | |
b04f2f7d | 337 | `curr[1-*]_lowest` |
036d6a4e | 338 | Historical minimum current. |
0084e9fa | 339 | |
b04f2f7d | 340 | `curr[1-*]_highest` |
036d6a4e | 341 | Historical maximum current. |
0084e9fa | 342 | |
b04f2f7d | 343 | `curr[1-*]_reset_history` |
0084e9fa | 344 | Reset currX_lowest and currX_highest |
b04f2f7d | 345 | |
0084e9fa GR |
346 | WO |
347 | ||
b04f2f7d | 348 | `curr_reset_history` |
036d6a4e | 349 | Reset currX_lowest and currX_highest for all sensors. |
0084e9fa | 350 | |
b04f2f7d | 351 | `curr[1-*]_enable` |
fb41a710 | 352 | Enable or disable the sensors. |
b04f2f7d | 353 | |
e8e61235 ZL |
354 | `curr[1-*]_rated_min` |
355 | Minimum rated current. | |
356 | ||
e8e61235 ZL |
357 | `curr[1-*]_rated_max` |
358 | Maximum rated current. | |
359 | ||
581693b5 GR |
360 | Also see the Alarms section for status flags associated with currents. |
361 | ||
b04f2f7d MCC |
362 | ***** |
363 | Power | |
364 | ***** | |
365 | ||
366 | `power[1-*]_average` | |
036d6a4e | 367 | Average power use. |
38fb56a2 | 368 | |
b04f2f7d | 369 | `power[1-*]_average_interval` |
036d6a4e | 370 | Power use averaging interval. |
ddedc658 | 371 | |
b04f2f7d | 372 | `power[1-*]_average_interval_max` |
036d6a4e | 373 | Maximum power use averaging interval. |
115a57c5 | 374 | |
b04f2f7d | 375 | `power[1-*]_average_interval_min` |
036d6a4e | 376 | Minimum power use averaging interval. |
115a57c5 | 377 | |
b04f2f7d | 378 | `power[1-*]_average_highest` |
036d6a4e | 379 | Historical average maximum power use |
38fb56a2 | 380 | |
b04f2f7d | 381 | `power[1-*]_average_lowest` |
036d6a4e | 382 | Historical average minimum power use |
38fb56a2 | 383 | |
b04f2f7d | 384 | `power[1-*]_average_max` |
036d6a4e MCC |
385 | A poll notification is sent to `power[1-*]_average` when |
386 | power use rises above this value. | |
115a57c5 | 387 | |
b04f2f7d | 388 | `power[1-*]_average_min` |
036d6a4e MCC |
389 | A poll notification is sent to `power[1-*]_average` when |
390 | power use sinks below this value. | |
115a57c5 | 391 | |
b04f2f7d | 392 | `power[1-*]_input` |
036d6a4e | 393 | Instantaneous power use. |
38fb56a2 | 394 | |
b04f2f7d | 395 | `power[1-*]_input_highest` |
036d6a4e | 396 | Historical maximum power use |
38fb56a2 | 397 | |
b04f2f7d | 398 | `power[1-*]_input_lowest` |
036d6a4e | 399 | Historical minimum power use. |
38fb56a2 | 400 | |
b04f2f7d | 401 | `power[1-*]_reset_history` |
036d6a4e MCC |
402 | Reset input_highest, input_lowest, average_highest and |
403 | average_lowest. | |
1da177e4 | 404 | |
b04f2f7d | 405 | `power[1-*]_accuracy` |
036d6a4e | 406 | Accuracy of the power meter. |
115a57c5 | 407 | |
b04f2f7d | 408 | `power[1-*]_cap` |
036d6a4e MCC |
409 | If power use rises above this limit, the |
410 | system should take action to reduce power use. | |
115a57c5 | 411 | |
b04f2f7d | 412 | `power[1-*]_cap_hyst` |
036d6a4e | 413 | Margin of hysteresis built around capping and notification. |
115a57c5 | 414 | |
b04f2f7d | 415 | `power[1-*]_cap_max` |
036d6a4e | 416 | Maximum cap that can be set. |
115a57c5 | 417 | |
b04f2f7d | 418 | `power[1-*]_cap_min` |
036d6a4e | 419 | Minimum cap that can be set. |
115a57c5 | 420 | |
b04f2f7d | 421 | `power[1-*]_max` |
036d6a4e | 422 | Maximum power. |
581693b5 | 423 | |
b04f2f7d MCC |
424 | `power[1-*]_crit` |
425 | Critical maximum power. | |
426 | ||
581693b5 GR |
427 | If power rises to or above this limit, the |
428 | system is expected take drastic action to reduce | |
429 | power consumption, such as a system shutdown or | |
430 | a forced powerdown of some devices. | |
b04f2f7d | 431 | |
581693b5 | 432 | Unit: microWatt |
b04f2f7d | 433 | |
581693b5 GR |
434 | RW |
435 | ||
b04f2f7d MCC |
436 | `power[1-*]_enable` |
437 | Enable or disable the sensors. | |
438 | ||
fb41a710 SB |
439 | When disabled the sensor read will return |
440 | -ENODATA. | |
b04f2f7d MCC |
441 | |
442 | - 1: Enable | |
443 | - 0: Disable | |
444 | ||
fb41a710 SB |
445 | RW |
446 | ||
e8e61235 ZL |
447 | `power[1-*]_rated_min` |
448 | Minimum rated power. | |
449 | ||
450 | Unit: microWatt | |
451 | ||
452 | RO | |
453 | ||
454 | `power[1-*]_rated_max` | |
455 | Maximum rated power. | |
456 | ||
457 | Unit: microWatt | |
458 | ||
459 | RO | |
460 | ||
581693b5 GR |
461 | Also see the Alarms section for status flags associated with power readings. |
462 | ||
b04f2f7d MCC |
463 | ****** |
464 | Energy | |
465 | ****** | |
466 | ||
467 | `energy[1-*]_input` | |
468 | Cumulative energy use | |
ddedc658 | 469 | |
ddedc658 | 470 | Unit: microJoule |
b04f2f7d | 471 | |
ddedc658 DW |
472 | RO |
473 | ||
b04f2f7d MCC |
474 | `energy[1-*]_enable` |
475 | Enable or disable the sensors. | |
476 | ||
fb41a710 SB |
477 | When disabled the sensor read will return |
478 | -ENODATA. | |
b04f2f7d MCC |
479 | |
480 | - 1: Enable | |
481 | - 0: Disable | |
482 | ||
fb41a710 | 483 | RW |
ec199209 | 484 | |
b04f2f7d MCC |
485 | ******** |
486 | Humidity | |
487 | ******** | |
488 | ||
489 | `humidity[1-*]_input` | |
036d6a4e | 490 | Humidity. |
c6c2c163 | 491 | |
b04f2f7d | 492 | `humidity[1-*]_enable` |
036d6a4e | 493 | Enable or disable the sensors. |
fb41a710 | 494 | |
e8e61235 | 495 | `humidity[1-*]_rated_min` |
036d6a4e | 496 | Minimum rated humidity. |
e8e61235 ZL |
497 | |
498 | `humidity[1-*]_rated_max` | |
036d6a4e | 499 | Maximum rated humidity. |
e8e61235 | 500 | |
b04f2f7d MCC |
501 | ****** |
502 | Alarms | |
503 | ****** | |
400b48ec JD |
504 | |
505 | Each channel or limit may have an associated alarm file, containing a | |
506 | boolean value. 1 means than an alarm condition exists, 0 means no alarm. | |
507 | ||
508 | Usually a given chip will either use channel-related alarms, or | |
509 | limit-related alarms, not both. The driver should just reflect the hardware | |
510 | implementation. | |
511 | ||
b04f2f7d MCC |
512 | +-------------------------------+-----------------------+ |
513 | | **`in[0-*]_alarm`, | Channel alarm | | |
514 | | `curr[1-*]_alarm`, | | | |
515 | | `power[1-*]_alarm`, | - 0: no alarm | | |
516 | | `fan[1-*]_alarm`, | - 1: alarm | | |
517 | | `temp[1-*]_alarm`** | | | |
518 | | | RO | | |
519 | +-------------------------------+-----------------------+ | |
520 | ||
521 | **OR** | |
522 | ||
523 | +-------------------------------+-----------------------+ | |
524 | | **`in[0-*]_min_alarm`, | Limit alarm | | |
525 | | `in[0-*]_max_alarm`, | | | |
526 | | `in[0-*]_lcrit_alarm`, | - 0: no alarm | | |
527 | | `in[0-*]_crit_alarm`, | - 1: alarm | | |
528 | | `curr[1-*]_min_alarm`, | | | |
529 | | `curr[1-*]_max_alarm`, | RO | | |
530 | | `curr[1-*]_lcrit_alarm`, | | | |
531 | | `curr[1-*]_crit_alarm`, | | | |
532 | | `power[1-*]_cap_alarm`, | | | |
533 | | `power[1-*]_max_alarm`, | | | |
534 | | `power[1-*]_crit_alarm`, | | | |
535 | | `fan[1-*]_min_alarm`, | | | |
536 | | `fan[1-*]_max_alarm`, | | | |
537 | | `temp[1-*]_min_alarm`, | | | |
538 | | `temp[1-*]_max_alarm`, | | | |
539 | | `temp[1-*]_lcrit_alarm`, | | | |
540 | | `temp[1-*]_crit_alarm`, | | | |
541 | | `temp[1-*]_emergency_alarm`** | | | |
542 | +-------------------------------+-----------------------+ | |
400b48ec JD |
543 | |
544 | Each input channel may have an associated fault file. This can be used | |
545 | to notify open diodes, unconnected fans etc. where the hardware | |
546 | supports it. When this boolean has value 1, the measurement for that | |
547 | channel should not be trusted. | |
548 | ||
b04f2f7d | 549 | `fan[1-*]_fault` / `temp[1-*]_fault` |
036d6a4e | 550 | Input fault condition. |
400b48ec JD |
551 | |
552 | Some chips also offer the possibility to get beeped when an alarm occurs: | |
553 | ||
b04f2f7d | 554 | `beep_enable` |
036d6a4e | 555 | Master beep enable. |
400b48ec | 556 | |
b04f2f7d | 557 | `in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`, |
036d6a4e | 558 | Channel beep. |
400b48ec JD |
559 | |
560 | In theory, a chip could provide per-limit beep masking, but no such chip | |
561 | was seen so far. | |
562 | ||
563 | Old drivers provided a different, non-standard interface to alarms and | |
564 | beeps. These interface files are deprecated, but will be kept around | |
565 | for compatibility reasons: | |
1da177e4 | 566 | |
b04f2f7d MCC |
567 | `alarms` |
568 | Alarm bitmask. | |
569 | ||
b04f2f7d MCC |
570 | `beep_mask` |
571 | Bitmask for beep. | |
2ed42633 HG |
572 | |
573 | ||
b04f2f7d MCC |
574 | ******************* |
575 | Intrusion detection | |
576 | ******************* | |
ec199209 | 577 | |
b04f2f7d | 578 | `intrusion[0-*]_alarm` |
036d6a4e | 579 | Chassis intrusion detection. |
ec199209 | 580 | |
b04f2f7d | 581 | `intrusion[0-*]_beep` |
036d6a4e | 582 | Chassis intrusion beep. |
ec199209 | 583 | |
b04f2f7d MCC |
584 | **************************** |
585 | Average sample configuration | |
586 | **************************** | |
bfe033a0 AKNPW |
587 | |
588 | Devices allowing for reading {in,power,curr,temp}_average values may export | |
589 | attributes for controlling number of samples used to compute average. | |
590 | ||
b04f2f7d MCC |
591 | +--------------+---------------------------------------------------------------+ |
592 | | samples | Sets number of average samples for all types of measurements. | | |
593 | | | | | |
594 | | | RW | | |
595 | +--------------+---------------------------------------------------------------+ | |
596 | | in_samples | Sets number of average samples for specific type of | | |
597 | | power_samples| measurements. | | |
598 | | curr_samples | | | |
599 | | temp_samples | Note that on some devices it won't be possible to set all of | | |
600 | | | them to different values so changing one might also change | | |
601 | | | some others. | | |
602 | | | | | |
603 | | | RW | | |
604 | +--------------+---------------------------------------------------------------+ | |
ec199209 | 605 | |
2ed42633 HG |
606 | sysfs attribute writes interpretation |
607 | ------------------------------------- | |
608 | ||
609 | hwmon sysfs attributes always contain numbers, so the first thing to do is to | |
610 | convert the input to a number, there are 2 ways todo this depending whether | |
b04f2f7d MCC |
611 | the number can be negative or not:: |
612 | ||
613 | unsigned long u = simple_strtoul(buf, NULL, 10); | |
614 | long s = simple_strtol(buf, NULL, 10); | |
2ed42633 HG |
615 | |
616 | With buf being the buffer with the user input being passed by the kernel. | |
617 | Notice that we do not use the second argument of strto[u]l, and thus cannot | |
618 | tell when 0 is returned, if this was really 0 or is caused by invalid input. | |
619 | This is done deliberately as checking this everywhere would add a lot of | |
620 | code to the kernel. | |
621 | ||
622 | Notice that it is important to always store the converted value in an | |
623 | unsigned long or long, so that no wrap around can happen before any further | |
624 | checking. | |
625 | ||
626 | After the input string is converted to an (unsigned) long, the value should be | |
627 | checked if its acceptable. Be careful with further conversions on the value | |
628 | before checking it for validity, as these conversions could still cause a wrap | |
629 | around before the check. For example do not multiply the result, and only | |
630 | add/subtract if it has been divided before the add/subtract. | |
631 | ||
632 | What to do if a value is found to be invalid, depends on the type of the | |
633 | sysfs attribute that is being set. If it is a continuous setting like a | |
634 | tempX_max or inX_max attribute, then the value should be clamped to its | |
c25fb816 GR |
635 | limits using clamp_val(value, min_limit, max_limit). If it is not continuous |
636 | like for example a tempX_type, then when an invalid value is written, | |
637 | -EINVAL should be returned. | |
2ed42633 | 638 | |
b04f2f7d | 639 | Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees):: |
5fbea518 JD |
640 | |
641 | long v = simple_strtol(buf, NULL, 10) / 1000; | |
c25fb816 | 642 | v = clamp_val(v, -128, 127); |
5fbea518 | 643 | /* write v to register */ |
2ed42633 | 644 | |
b04f2f7d | 645 | Example2, fan divider setting, valid values 2, 4 and 8:: |
5fbea518 JD |
646 | |
647 | unsigned long v = simple_strtoul(buf, NULL, 10); | |
648 | ||
649 | switch (v) { | |
650 | case 2: v = 1; break; | |
651 | case 4: v = 2; break; | |
652 | case 8: v = 3; break; | |
653 | default: | |
654 | return -EINVAL; | |
655 | } | |
656 | /* write v to register */ |