1 Naming and data format standards for sysfs files
2 ================================================
4 The libsensors library offers an interface to the raw sensors data
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.
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.
22 For this reason, even if we aim at a chip-independent libsensors, it will
23 still require a configuration file (e.g. /etc/sensors.conf) for proper
24 values conversion, labeling of inputs and hiding of unused inputs.
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.
33 Each chip gets its own directory in the sysfs /sys/devices tree. To
34 find all sensor chips, it is easier to follow the device symlinks from
35 `/sys/class/hwmon/hwmon*`.
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.
44 All sysfs values are fixed point numbers.
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.
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.
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.
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
76 -------------------------------------------------------------------------
78 ======= ===========================================
79 `[0-*]` denotes any positive number starting from 0
80 `[1-*]` denotes any positive number starting from 1
84 ======= ===========================================
86 Read/write values may be read-only for some chips, depending on the
87 hardware implementation.
89 All entries (except name) are optional, and should only be created in a
90 given driver if the chip has the feature.
92 See Documentation/ABI/testing/sysfs-class-hwmon for a complete description
103 A descriptive label that allows to uniquely identify a device
107 The interval at which the chip will update readings.
118 Voltage critical min value.
124 Voltage critical max value.
133 Historical minimum voltage
136 Historical maximum voltage
138 `in[0-*]_reset_history`
139 Reset inX_lowest and inX_highest
142 Reset inX_lowest and inX_highest for all sensors
145 Suggested voltage channel label.
148 Enable or disable the sensors.
151 CPU core reference voltage.
154 Voltage Regulator Module version number.
157 Minimum rated voltage.
160 Maximum rated voltage.
162 Also see the Alarms section for status flags associated with voltages.
182 Number of tachometer pulses per fan revolution.
188 Suggested fan channel label.
191 Enable or disable the sensors.
193 Also see the Alarms section for status flags associated with fans.
201 Pulse width modulation fan control.
204 Fan speed control method.
207 direct current or pulse-width modulation.
210 Base PWM frequency in Hz.
212 `pwm[1-*]_auto_channels_temp`
213 Select which temperature channels affect this PWM output in
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.
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.
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.
237 Sensor type selection.
240 Temperature max value.
243 Temperature min value.
246 Temperature hysteresis value for max limit.
249 Temperature hysteresis value for min limit.
252 Temperature input value.
255 Temperature critical max value, typically greater than
256 corresponding temp_max values.
258 `temp[1-*]_crit_hyst`
259 Temperature hysteresis value for critical limit.
261 `temp[1-*]_emergency`
262 Temperature emergency max value, for chips supporting more than
263 two upper temperature limits.
265 `temp[1-*]_emergency_hyst`
266 Temperature hysteresis value for emergency limit.
269 Temperature critical min value, typically lower than
270 corresponding temp_min values.
272 `temp[1-*]_lcrit_hyst`
273 Temperature hysteresis value for critical min limit.
276 Temperature offset which is added to the temperature reading
280 Suggested temperature channel label.
283 Historical minimum temperature
286 Historical maximum temperature
288 `temp[1-*]_reset_history`
289 Reset temp_lowest and temp_highest
292 Reset temp_lowest and temp_highest for all sensors
295 Enable or disable the sensors.
297 `temp[1-*]_rated_min`
298 Minimum rated temperature.
300 `temp[1-*]_rated_max`
301 Maximum rated temperature.
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.
312 Also see the Alarms section for status flags associated with temperatures.
326 Current critical low value
329 Current critical high value.
338 Historical minimum current.
341 Historical maximum current.
343 `curr[1-*]_reset_history`
344 Reset currX_lowest and currX_highest
349 Reset currX_lowest and currX_highest for all sensors.
352 Enable or disable the sensors.
354 `curr[1-*]_rated_min`
355 Minimum rated current.
357 `curr[1-*]_rated_max`
358 Maximum rated current.
360 Also see the Alarms section for status flags associated with currents.
369 `power[1-*]_average_interval`
370 Power use averaging interval.
372 `power[1-*]_average_interval_max`
373 Maximum power use averaging interval.
375 `power[1-*]_average_interval_min`
376 Minimum power use averaging interval.
378 `power[1-*]_average_highest`
379 Historical average maximum power use
381 `power[1-*]_average_lowest`
382 Historical average minimum power use
384 `power[1-*]_average_max`
385 A poll notification is sent to `power[1-*]_average` when
386 power use rises above this value.
388 `power[1-*]_average_min`
389 A poll notification is sent to `power[1-*]_average` when
390 power use sinks below this value.
393 Instantaneous power use.
395 `power[1-*]_input_highest`
396 Historical maximum power use
398 `power[1-*]_input_lowest`
399 Historical minimum power use.
401 `power[1-*]_reset_history`
402 Reset input_highest, input_lowest, average_highest and
405 `power[1-*]_accuracy`
406 Accuracy of the power meter.
409 If power use rises above this limit, the
410 system should take action to reduce power use.
412 `power[1-*]_cap_hyst`
413 Margin of hysteresis built around capping and notification.
416 Maximum cap that can be set.
419 Minimum cap that can be set.
425 Critical maximum power.
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.
437 Enable or disable the sensors.
439 When disabled the sensor read will return
447 `power[1-*]_rated_min`
454 `power[1-*]_rated_max`
461 Also see the Alarms section for status flags associated with power readings.
468 Cumulative energy use
475 Enable or disable the sensors.
477 When disabled the sensor read will return
489 `humidity[1-*]_input`
492 `humidity[1-*]_enable`
493 Enable or disable the sensors.
495 `humidity[1-*]_rated_min`
496 Minimum rated humidity.
498 `humidity[1-*]_rated_max`
499 Maximum rated humidity.
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.
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
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`** | |
519 +-------------------------------+-----------------------+
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 +-------------------------------+-----------------------+
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.
549 `fan[1-*]_fault` / `temp[1-*]_fault`
550 Input fault condition.
552 Some chips also offer the possibility to get beeped when an alarm occurs:
557 `in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`,
560 In theory, a chip could provide per-limit beep masking, but no such chip
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:
578 `intrusion[0-*]_alarm`
579 Chassis intrusion detection.
581 `intrusion[0-*]_beep`
582 Chassis intrusion beep.
584 ****************************
585 Average sample configuration
586 ****************************
588 Devices allowing for reading {in,power,curr,temp}_average values may export
589 attributes for controlling number of samples used to compute average.
591 +--------------+---------------------------------------------------------------+
592 | samples | Sets number of average samples for all types of measurements. |
595 +--------------+---------------------------------------------------------------+
596 | in_samples | Sets number of average samples for specific type of |
597 | power_samples| measurements. |
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 |
604 +--------------+---------------------------------------------------------------+
606 sysfs attribute writes interpretation
607 -------------------------------------
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
611 the number can be negative or not::
613 unsigned long u = simple_strtoul(buf, NULL, 10);
614 long s = simple_strtol(buf, NULL, 10);
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
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
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.
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
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.
639 Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees)::
641 long v = simple_strtol(buf, NULL, 10) / 1000;
642 v = clamp_val(v, -128, 127);
643 /* write v to register */
645 Example2, fan divider setting, valid values 2, 4 and 8::
647 unsigned long v = simple_strtoul(buf, NULL, 10);
650 case 2: v = 1; break;
651 case 4: v = 2; break;
652 case 8: v = 3; break;
656 /* write v to register */