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 | |
b04f2f7d MCC |
102 | `update_interval` |
103 | The interval at which the chip will update readings. | |
d2b847d4 | 104 | |
740e06a8 | 105 | |
b04f2f7d MCC |
106 | ******** |
107 | Voltages | |
108 | ******** | |
109 | ||
110 | `in[0-*]_min` | |
111 | Voltage min value. | |
1da177e4 | 112 | |
b04f2f7d MCC |
113 | `in[0-*]_lcrit` |
114 | Voltage critical min value. | |
115 | ||
b04f2f7d MCC |
116 | `in[0-*]_max` |
117 | Voltage max value. | |
118 | ||
b04f2f7d MCC |
119 | `in[0-*]_crit` |
120 | Voltage critical max value. | |
121 | ||
b04f2f7d MCC |
122 | `in[0-*]_input` |
123 | Voltage input value. | |
124 | ||
b04f2f7d | 125 | `in[0-*]_average` |
0084e9fa | 126 | Average voltage |
b04f2f7d | 127 | |
b04f2f7d | 128 | `in[0-*]_lowest` |
0084e9fa | 129 | Historical minimum voltage |
b04f2f7d | 130 | |
b04f2f7d | 131 | `in[0-*]_highest` |
0084e9fa | 132 | Historical maximum voltage |
b04f2f7d | 133 | |
b04f2f7d | 134 | `in[0-*]_reset_history` |
0084e9fa | 135 | Reset inX_lowest and inX_highest |
b04f2f7d | 136 | |
b04f2f7d | 137 | `in_reset_history` |
0084e9fa | 138 | Reset inX_lowest and inX_highest for all sensors |
b04f2f7d | 139 | |
b04f2f7d MCC |
140 | `in[0-*]_label` |
141 | Suggested voltage channel label. | |
142 | ||
b04f2f7d | 143 | `in[0-*]_enable` |
fb41a710 | 144 | Enable or disable the sensors. |
b04f2f7d | 145 | |
b04f2f7d MCC |
146 | `cpu[0-*]_vid` |
147 | CPU core reference voltage. | |
148 | ||
b04f2f7d MCC |
149 | `vrm` |
150 | Voltage Regulator Module version number. | |
151 | ||
e8e61235 ZL |
152 | `in[0-*]_rated_min` |
153 | Minimum rated voltage. | |
154 | ||
e8e61235 ZL |
155 | `in[0-*]_rated_max` |
156 | Maximum rated voltage. | |
157 | ||
057bc350 RM |
158 | Also see the Alarms section for status flags associated with voltages. |
159 | ||
1da177e4 | 160 | |
b04f2f7d MCC |
161 | **** |
162 | Fans | |
163 | **** | |
164 | ||
165 | `fan[1-*]_min` | |
166 | Fan minimum value | |
1da177e4 | 167 | |
b04f2f7d MCC |
168 | `fan[1-*]_max` |
169 | Fan maximum value | |
170 | ||
b04f2f7d MCC |
171 | `fan[1-*]_input` |
172 | Fan input value. | |
173 | ||
b04f2f7d MCC |
174 | `fan[1-*]_div` |
175 | Fan divisor. | |
176 | ||
b04f2f7d MCC |
177 | `fan[1-*]_pulses` |
178 | Number of tachometer pulses per fan revolution. | |
179 | ||
b04f2f7d | 180 | `fan[1-*]_target` |
2dbc514a | 181 | Desired fan speed |
b04f2f7d | 182 | |
b04f2f7d MCC |
183 | `fan[1-*]_label` |
184 | Suggested fan channel label. | |
185 | ||
b04f2f7d | 186 | `fan[1-*]_enable` |
fb41a710 | 187 | Enable or disable the sensors. |
b04f2f7d | 188 | |
057bc350 RM |
189 | Also see the Alarms section for status flags associated with fans. |
190 | ||
191 | ||
b04f2f7d MCC |
192 | *** |
193 | PWM | |
194 | *** | |
195 | ||
196 | `pwm[1-*]` | |
197 | Pulse width modulation fan control. | |
1da177e4 | 198 | |
b04f2f7d | 199 | `pwm[1-*]_enable` |
875f25d5 | 200 | Fan speed control method: |
b04f2f7d | 201 | |
b04f2f7d | 202 | `pwm[1-*]_mode` |
036d6a4e | 203 | direct current or pulse-width modulation. |
f8d0c19a | 204 | |
b04f2f7d MCC |
205 | `pwm[1-*]_freq` |
206 | Base PWM frequency in Hz. | |
207 | ||
b04f2f7d | 208 | `pwm[1-*]_auto_channels_temp` |
1da177e4 | 209 | Select which temperature channels affect this PWM output in |
b04f2f7d MCC |
210 | auto mode. |
211 | ||
b04f2f7d MCC |
212 | `pwm[1-*]_auto_point[1-*]_pwm` / `pwm[1-*]_auto_point[1-*]_temp` / `pwm[1-*]_auto_point[1-*]_temp_hyst` |
213 | Define the PWM vs temperature curve. | |
214 | ||
b04f2f7d MCC |
215 | `temp[1-*]_auto_point[1-*]_pwm` / `temp[1-*]_auto_point[1-*]_temp` / `temp[1-*]_auto_point[1-*]_temp_hyst` |
216 | Define the PWM vs temperature curve. | |
217 | ||
f7290e24 JD |
218 | There is a third case where trip points are associated to both PWM output |
219 | channels and temperature channels: the PWM values are associated to PWM | |
220 | output channels while the temperature values are associated to temperature | |
221 | channels. In that case, the result is determined by the mapping between | |
222 | temperature inputs and PWM outputs. When several temperature inputs are | |
223 | mapped to a given PWM output, this leads to several candidate PWM values. | |
224 | The actual result is up to the chip, but in general the highest candidate | |
225 | value (fastest fan speed) wins. | |
226 | ||
1da177e4 | 227 | |
b04f2f7d MCC |
228 | ************ |
229 | Temperatures | |
230 | ************ | |
231 | ||
232 | `temp[1-*]_type` | |
233 | Sensor type selection. | |
1da177e4 | 234 | |
b04f2f7d MCC |
235 | `temp[1-*]_max` |
236 | Temperature max value. | |
237 | ||
b04f2f7d MCC |
238 | `temp[1-*]_min` |
239 | Temperature min value. | |
240 | ||
b04f2f7d | 241 | `temp[1-*]_max_hyst` |
1da177e4 | 242 | Temperature hysteresis value for max limit. |
b04f2f7d | 243 | |
b04f2f7d | 244 | `temp[1-*]_min_hyst` |
01325145 | 245 | Temperature hysteresis value for min limit. |
01325145 | 246 | |
b04f2f7d | 247 | `temp[1-*]_input` |
036d6a4e | 248 | Temperature input value. |
1da177e4 | 249 | |
b04f2f7d MCC |
250 | `temp[1-*]_crit` |
251 | Temperature critical max value, typically greater than | |
1da177e4 | 252 | corresponding temp_max values. |
b04f2f7d | 253 | |
b04f2f7d | 254 | `temp[1-*]_crit_hyst` |
1da177e4 | 255 | Temperature hysteresis value for critical limit. |
b04f2f7d | 256 | |
b04f2f7d | 257 | `temp[1-*]_emergency` |
28e7438f | 258 | Temperature emergency max value, for chips supporting more than |
036d6a4e | 259 | two upper temperature limits. |
28e7438f | 260 | |
b04f2f7d | 261 | `temp[1-*]_emergency_hyst` |
28e7438f | 262 | Temperature hysteresis value for emergency limit. |
b04f2f7d | 263 | |
b04f2f7d MCC |
264 | `temp[1-*]_lcrit` |
265 | Temperature critical min value, typically lower than | |
f46fc8cd | 266 | corresponding temp_min values. |
b04f2f7d | 267 | |
b04f2f7d | 268 | `temp[1-*]_lcrit_hyst` |
01325145 | 269 | Temperature hysteresis value for critical min limit. |
b04f2f7d | 270 | |
b04f2f7d | 271 | `temp[1-*]_offset` |
59ac8367 HR |
272 | Temperature offset which is added to the temperature reading |
273 | by the chip. | |
b04f2f7d | 274 | |
b04f2f7d MCC |
275 | `temp[1-*]_label` |
276 | Suggested temperature channel label. | |
277 | ||
b04f2f7d | 278 | `temp[1-*]_lowest` |
cd4e96c5 | 279 | Historical minimum temperature |
b04f2f7d | 280 | |
b04f2f7d | 281 | `temp[1-*]_highest` |
cd4e96c5 | 282 | Historical maximum temperature |
b04f2f7d | 283 | |
b04f2f7d | 284 | `temp[1-*]_reset_history` |
cd4e96c5 | 285 | Reset temp_lowest and temp_highest |
b04f2f7d | 286 | |
b04f2f7d | 287 | `temp_reset_history` |
cd4e96c5 | 288 | Reset temp_lowest and temp_highest for all sensors |
b04f2f7d | 289 | |
b04f2f7d | 290 | `temp[1-*]_enable` |
fb41a710 | 291 | Enable or disable the sensors. |
b04f2f7d | 292 | |
e8e61235 ZL |
293 | `temp[1-*]_rated_min` |
294 | Minimum rated temperature. | |
295 | ||
e8e61235 ZL |
296 | `temp[1-*]_rated_max` |
297 | Maximum rated temperature. | |
298 | ||
740e06a8 JD |
299 | Some chips measure temperature using external thermistors and an ADC, and |
300 | report the temperature measurement as a voltage. Converting this voltage | |
301 | back to a temperature (or the other way around for limits) requires | |
302 | mathematical functions not available in the kernel, so the conversion | |
303 | must occur in user space. For these chips, all temp* files described | |
304 | above should contain values expressed in millivolt instead of millidegree | |
305 | Celsius. In other words, such temperature channels are handled as voltage | |
306 | channels by the driver. | |
307 | ||
057bc350 RM |
308 | Also see the Alarms section for status flags associated with temperatures. |
309 | ||
1da177e4 | 310 | |
b04f2f7d MCC |
311 | ******** |
312 | Currents | |
313 | ******** | |
314 | ||
315 | `curr[1-*]_max` | |
036d6a4e | 316 | Current max value. |
1da177e4 | 317 | |
b04f2f7d MCC |
318 | `curr[1-*]_min` |
319 | Current min value. | |
320 | ||
b04f2f7d MCC |
321 | `curr[1-*]_lcrit` |
322 | Current critical low value | |
323 | ||
b04f2f7d MCC |
324 | `curr[1-*]_crit` |
325 | Current critical high value. | |
326 | ||
b04f2f7d | 327 | `curr[1-*]_input` |
036d6a4e | 328 | Current input value. |
1da177e4 | 329 | |
b04f2f7d | 330 | `curr[1-*]_average` |
036d6a4e | 331 | Average current use. |
0084e9fa | 332 | |
b04f2f7d | 333 | `curr[1-*]_lowest` |
036d6a4e | 334 | Historical minimum current. |
0084e9fa | 335 | |
b04f2f7d | 336 | `curr[1-*]_highest` |
036d6a4e | 337 | Historical maximum current. |
0084e9fa | 338 | |
b04f2f7d | 339 | `curr[1-*]_reset_history` |
0084e9fa | 340 | Reset currX_lowest and currX_highest |
b04f2f7d | 341 | |
0084e9fa GR |
342 | WO |
343 | ||
b04f2f7d | 344 | `curr_reset_history` |
036d6a4e | 345 | Reset currX_lowest and currX_highest for all sensors. |
0084e9fa | 346 | |
b04f2f7d | 347 | `curr[1-*]_enable` |
fb41a710 | 348 | Enable or disable the sensors. |
b04f2f7d | 349 | |
e8e61235 ZL |
350 | `curr[1-*]_rated_min` |
351 | Minimum rated current. | |
352 | ||
e8e61235 ZL |
353 | `curr[1-*]_rated_max` |
354 | Maximum rated current. | |
355 | ||
581693b5 GR |
356 | Also see the Alarms section for status flags associated with currents. |
357 | ||
b04f2f7d MCC |
358 | ***** |
359 | Power | |
360 | ***** | |
361 | ||
362 | `power[1-*]_average` | |
036d6a4e | 363 | Average power use. |
38fb56a2 | 364 | |
b04f2f7d | 365 | `power[1-*]_average_interval` |
036d6a4e | 366 | Power use averaging interval. |
ddedc658 | 367 | |
b04f2f7d | 368 | `power[1-*]_average_interval_max` |
036d6a4e | 369 | Maximum power use averaging interval. |
115a57c5 | 370 | |
b04f2f7d | 371 | `power[1-*]_average_interval_min` |
036d6a4e | 372 | Minimum power use averaging interval. |
115a57c5 | 373 | |
b04f2f7d | 374 | `power[1-*]_average_highest` |
036d6a4e | 375 | Historical average maximum power use |
38fb56a2 | 376 | |
b04f2f7d | 377 | `power[1-*]_average_lowest` |
036d6a4e | 378 | Historical average minimum power use |
38fb56a2 | 379 | |
b04f2f7d | 380 | `power[1-*]_average_max` |
036d6a4e MCC |
381 | A poll notification is sent to `power[1-*]_average` when |
382 | power use rises above this value. | |
115a57c5 | 383 | |
b04f2f7d | 384 | `power[1-*]_average_min` |
036d6a4e MCC |
385 | A poll notification is sent to `power[1-*]_average` when |
386 | power use sinks below this value. | |
115a57c5 | 387 | |
b04f2f7d | 388 | `power[1-*]_input` |
036d6a4e | 389 | Instantaneous power use. |
38fb56a2 | 390 | |
b04f2f7d | 391 | `power[1-*]_input_highest` |
036d6a4e | 392 | Historical maximum power use |
38fb56a2 | 393 | |
b04f2f7d | 394 | `power[1-*]_input_lowest` |
036d6a4e | 395 | Historical minimum power use. |
38fb56a2 | 396 | |
b04f2f7d | 397 | `power[1-*]_reset_history` |
036d6a4e MCC |
398 | Reset input_highest, input_lowest, average_highest and |
399 | average_lowest. | |
1da177e4 | 400 | |
b04f2f7d | 401 | `power[1-*]_accuracy` |
036d6a4e | 402 | Accuracy of the power meter. |
115a57c5 | 403 | |
b04f2f7d | 404 | `power[1-*]_cap` |
036d6a4e MCC |
405 | If power use rises above this limit, the |
406 | system should take action to reduce power use. | |
115a57c5 | 407 | |
b04f2f7d | 408 | `power[1-*]_cap_hyst` |
036d6a4e | 409 | Margin of hysteresis built around capping and notification. |
115a57c5 | 410 | |
b04f2f7d | 411 | `power[1-*]_cap_max` |
036d6a4e | 412 | Maximum cap that can be set. |
115a57c5 | 413 | |
b04f2f7d | 414 | `power[1-*]_cap_min` |
036d6a4e | 415 | Minimum cap that can be set. |
115a57c5 | 416 | |
b04f2f7d | 417 | `power[1-*]_max` |
036d6a4e | 418 | Maximum power. |
581693b5 | 419 | |
b04f2f7d MCC |
420 | `power[1-*]_crit` |
421 | Critical maximum power. | |
422 | ||
581693b5 GR |
423 | If power rises to or above this limit, the |
424 | system is expected take drastic action to reduce | |
425 | power consumption, such as a system shutdown or | |
426 | a forced powerdown of some devices. | |
b04f2f7d | 427 | |
581693b5 | 428 | Unit: microWatt |
b04f2f7d | 429 | |
581693b5 GR |
430 | RW |
431 | ||
b04f2f7d MCC |
432 | `power[1-*]_enable` |
433 | Enable or disable the sensors. | |
434 | ||
fb41a710 SB |
435 | When disabled the sensor read will return |
436 | -ENODATA. | |
b04f2f7d MCC |
437 | |
438 | - 1: Enable | |
439 | - 0: Disable | |
440 | ||
fb41a710 SB |
441 | RW |
442 | ||
e8e61235 ZL |
443 | `power[1-*]_rated_min` |
444 | Minimum rated power. | |
445 | ||
446 | Unit: microWatt | |
447 | ||
448 | RO | |
449 | ||
450 | `power[1-*]_rated_max` | |
451 | Maximum rated power. | |
452 | ||
453 | Unit: microWatt | |
454 | ||
455 | RO | |
456 | ||
581693b5 GR |
457 | Also see the Alarms section for status flags associated with power readings. |
458 | ||
b04f2f7d MCC |
459 | ****** |
460 | Energy | |
461 | ****** | |
462 | ||
463 | `energy[1-*]_input` | |
464 | Cumulative energy use | |
ddedc658 | 465 | |
ddedc658 | 466 | Unit: microJoule |
b04f2f7d | 467 | |
ddedc658 DW |
468 | RO |
469 | ||
b04f2f7d MCC |
470 | `energy[1-*]_enable` |
471 | Enable or disable the sensors. | |
472 | ||
fb41a710 SB |
473 | When disabled the sensor read will return |
474 | -ENODATA. | |
b04f2f7d MCC |
475 | |
476 | - 1: Enable | |
477 | - 0: Disable | |
478 | ||
fb41a710 | 479 | RW |
ec199209 | 480 | |
b04f2f7d MCC |
481 | ******** |
482 | Humidity | |
483 | ******** | |
484 | ||
485 | `humidity[1-*]_input` | |
036d6a4e | 486 | Humidity. |
c6c2c163 | 487 | |
b04f2f7d | 488 | `humidity[1-*]_enable` |
036d6a4e | 489 | Enable or disable the sensors. |
fb41a710 | 490 | |
e8e61235 | 491 | `humidity[1-*]_rated_min` |
036d6a4e | 492 | Minimum rated humidity. |
e8e61235 ZL |
493 | |
494 | `humidity[1-*]_rated_max` | |
036d6a4e | 495 | Maximum rated humidity. |
e8e61235 | 496 | |
b04f2f7d MCC |
497 | ****** |
498 | Alarms | |
499 | ****** | |
400b48ec JD |
500 | |
501 | Each channel or limit may have an associated alarm file, containing a | |
502 | boolean value. 1 means than an alarm condition exists, 0 means no alarm. | |
503 | ||
504 | Usually a given chip will either use channel-related alarms, or | |
505 | limit-related alarms, not both. The driver should just reflect the hardware | |
506 | implementation. | |
507 | ||
b04f2f7d MCC |
508 | +-------------------------------+-----------------------+ |
509 | | **`in[0-*]_alarm`, | Channel alarm | | |
510 | | `curr[1-*]_alarm`, | | | |
511 | | `power[1-*]_alarm`, | - 0: no alarm | | |
512 | | `fan[1-*]_alarm`, | - 1: alarm | | |
513 | | `temp[1-*]_alarm`** | | | |
514 | | | RO | | |
515 | +-------------------------------+-----------------------+ | |
516 | ||
517 | **OR** | |
518 | ||
519 | +-------------------------------+-----------------------+ | |
520 | | **`in[0-*]_min_alarm`, | Limit alarm | | |
521 | | `in[0-*]_max_alarm`, | | | |
522 | | `in[0-*]_lcrit_alarm`, | - 0: no alarm | | |
523 | | `in[0-*]_crit_alarm`, | - 1: alarm | | |
524 | | `curr[1-*]_min_alarm`, | | | |
525 | | `curr[1-*]_max_alarm`, | RO | | |
526 | | `curr[1-*]_lcrit_alarm`, | | | |
527 | | `curr[1-*]_crit_alarm`, | | | |
528 | | `power[1-*]_cap_alarm`, | | | |
529 | | `power[1-*]_max_alarm`, | | | |
530 | | `power[1-*]_crit_alarm`, | | | |
531 | | `fan[1-*]_min_alarm`, | | | |
532 | | `fan[1-*]_max_alarm`, | | | |
533 | | `temp[1-*]_min_alarm`, | | | |
534 | | `temp[1-*]_max_alarm`, | | | |
535 | | `temp[1-*]_lcrit_alarm`, | | | |
536 | | `temp[1-*]_crit_alarm`, | | | |
537 | | `temp[1-*]_emergency_alarm`** | | | |
538 | +-------------------------------+-----------------------+ | |
400b48ec JD |
539 | |
540 | Each input channel may have an associated fault file. This can be used | |
541 | to notify open diodes, unconnected fans etc. where the hardware | |
542 | supports it. When this boolean has value 1, the measurement for that | |
543 | channel should not be trusted. | |
544 | ||
b04f2f7d | 545 | `fan[1-*]_fault` / `temp[1-*]_fault` |
036d6a4e | 546 | Input fault condition. |
400b48ec JD |
547 | |
548 | Some chips also offer the possibility to get beeped when an alarm occurs: | |
549 | ||
b04f2f7d | 550 | `beep_enable` |
036d6a4e | 551 | Master beep enable. |
400b48ec | 552 | |
b04f2f7d | 553 | `in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`, |
036d6a4e | 554 | Channel beep. |
400b48ec JD |
555 | |
556 | In theory, a chip could provide per-limit beep masking, but no such chip | |
557 | was seen so far. | |
558 | ||
559 | Old drivers provided a different, non-standard interface to alarms and | |
560 | beeps. These interface files are deprecated, but will be kept around | |
561 | for compatibility reasons: | |
1da177e4 | 562 | |
b04f2f7d MCC |
563 | `alarms` |
564 | Alarm bitmask. | |
565 | ||
b04f2f7d MCC |
566 | `beep_mask` |
567 | Bitmask for beep. | |
2ed42633 HG |
568 | |
569 | ||
b04f2f7d MCC |
570 | ******************* |
571 | Intrusion detection | |
572 | ******************* | |
ec199209 | 573 | |
b04f2f7d | 574 | `intrusion[0-*]_alarm` |
036d6a4e | 575 | Chassis intrusion detection. |
ec199209 | 576 | |
b04f2f7d | 577 | `intrusion[0-*]_beep` |
036d6a4e | 578 | Chassis intrusion beep. |
ec199209 | 579 | |
b04f2f7d MCC |
580 | **************************** |
581 | Average sample configuration | |
582 | **************************** | |
bfe033a0 AKNPW |
583 | |
584 | Devices allowing for reading {in,power,curr,temp}_average values may export | |
585 | attributes for controlling number of samples used to compute average. | |
586 | ||
b04f2f7d MCC |
587 | +--------------+---------------------------------------------------------------+ |
588 | | samples | Sets number of average samples for all types of measurements. | | |
589 | | | | | |
590 | | | RW | | |
591 | +--------------+---------------------------------------------------------------+ | |
592 | | in_samples | Sets number of average samples for specific type of | | |
593 | | power_samples| measurements. | | |
594 | | curr_samples | | | |
595 | | temp_samples | Note that on some devices it won't be possible to set all of | | |
596 | | | them to different values so changing one might also change | | |
597 | | | some others. | | |
598 | | | | | |
599 | | | RW | | |
600 | +--------------+---------------------------------------------------------------+ | |
ec199209 | 601 | |
2ed42633 HG |
602 | sysfs attribute writes interpretation |
603 | ------------------------------------- | |
604 | ||
605 | hwmon sysfs attributes always contain numbers, so the first thing to do is to | |
606 | convert the input to a number, there are 2 ways todo this depending whether | |
b04f2f7d MCC |
607 | the number can be negative or not:: |
608 | ||
609 | unsigned long u = simple_strtoul(buf, NULL, 10); | |
610 | long s = simple_strtol(buf, NULL, 10); | |
2ed42633 HG |
611 | |
612 | With buf being the buffer with the user input being passed by the kernel. | |
613 | Notice that we do not use the second argument of strto[u]l, and thus cannot | |
614 | tell when 0 is returned, if this was really 0 or is caused by invalid input. | |
615 | This is done deliberately as checking this everywhere would add a lot of | |
616 | code to the kernel. | |
617 | ||
618 | Notice that it is important to always store the converted value in an | |
619 | unsigned long or long, so that no wrap around can happen before any further | |
620 | checking. | |
621 | ||
622 | After the input string is converted to an (unsigned) long, the value should be | |
623 | checked if its acceptable. Be careful with further conversions on the value | |
624 | before checking it for validity, as these conversions could still cause a wrap | |
625 | around before the check. For example do not multiply the result, and only | |
626 | add/subtract if it has been divided before the add/subtract. | |
627 | ||
628 | What to do if a value is found to be invalid, depends on the type of the | |
629 | sysfs attribute that is being set. If it is a continuous setting like a | |
630 | tempX_max or inX_max attribute, then the value should be clamped to its | |
c25fb816 GR |
631 | limits using clamp_val(value, min_limit, max_limit). If it is not continuous |
632 | like for example a tempX_type, then when an invalid value is written, | |
633 | -EINVAL should be returned. | |
2ed42633 | 634 | |
b04f2f7d | 635 | Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees):: |
5fbea518 JD |
636 | |
637 | long v = simple_strtol(buf, NULL, 10) / 1000; | |
c25fb816 | 638 | v = clamp_val(v, -128, 127); |
5fbea518 | 639 | /* write v to register */ |
2ed42633 | 640 | |
b04f2f7d | 641 | Example2, fan divider setting, valid values 2, 4 and 8:: |
5fbea518 JD |
642 | |
643 | unsigned long v = simple_strtoul(buf, NULL, 10); | |
644 | ||
645 | switch (v) { | |
646 | case 2: v = 1; break; | |
647 | case 4: v = 2; break; | |
648 | case 8: v = 3; break; | |
649 | default: | |
650 | return -EINVAL; | |
651 | } | |
652 | /* write v to register */ |