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.
68 -------------------------------------------------------------------------
70 ======= ===========================================
71 `[0-*]` denotes any positive number starting from 0
72 `[1-*]` denotes any positive number starting from 1
76 ======= ===========================================
78 Read/write values may be read-only for some chips, depending on the
79 hardware implementation.
81 All entries (except name) are optional, and should only be created in a
82 given driver if the chip has the feature.
91 This should be a short, lowercase string, not containing
92 whitespace, dashes, or the wildcard character '*'.
93 This attribute represents the chip name. It is the only
95 I2C devices get this attribute created automatically.
100 The interval at which the chip will update readings.
105 Some devices have a variable update rate or interval.
106 This attribute can be used to change it to the desired value.
121 Voltage critical min value.
127 If voltage drops to or below this limit, the system may
128 take drastic action such as power down or reset. At the very
129 least, it should report a fault.
139 Voltage critical max value.
145 If voltage reaches or exceeds this limit, the system may
146 take drastic action such as power down or reset. At the very
147 least, it should report a fault.
156 Voltage measured on the chip pin.
158 Actual voltage depends on the scaling resistors on the
159 motherboard, as recommended in the chip datasheet.
161 This varies by chip and by motherboard.
162 Because of this variation, values are generally NOT scaled
163 by the chip driver, and must be done by the application.
164 However, some drivers (notably lm87 and via686a)
165 do scale, because of internal resistors built into a chip.
166 These drivers will output the actual voltage. Rule of
167 thumb: drivers should report the voltage values at the
178 Historical minimum voltage
185 Historical maximum voltage
191 `in[0-*]_reset_history`
192 Reset inX_lowest and inX_highest
197 Reset inX_lowest and inX_highest for all sensors
202 Suggested voltage channel label.
206 Should only be created if the driver has hints about what
207 this voltage channel is being used for, and user-space
208 doesn't. In all other cases, the label is provided by
214 Enable or disable the sensors.
216 When disabled the sensor read will return -ENODATA.
224 CPU core reference voltage.
233 Voltage Regulator Module version number.
235 RW (but changing it should no more be necessary)
237 Originally the VRM standard version multiplied by 10, but now
238 an arbitrary number, as not all standards have a version
241 Affects the way the driver calculates the CPU core reference
242 voltage from the vid pins.
244 Also see the Alarms section for status flags associated with voltages.
254 Unit: revolution/min (RPM)
261 Unit: revolution/min (RPM)
263 Only rarely supported by the hardware.
269 Unit: revolution/min (RPM)
276 Integer value in powers of two (1, 2, 4, 8, 16, 32, 64, 128).
280 Some chips only support values 1, 2, 4 and 8.
281 Note that this is actually an internal clock divisor, which
282 affects the measurable speed range, not the read value.
285 Number of tachometer pulses per fan revolution.
287 Integer value, typically between 1 and 4.
291 This value is a characteristic of the fan connected to the
292 device's input, so it has to be set in accordance with the fan
295 Should only be created if the chip has a register to configure
296 the number of pulses. In the absence of such a register (and
297 thus attribute) the value assumed by all devices is 2 pulses
303 Unit: revolution/min (RPM)
307 Only makes sense if the chip supports closed-loop fan speed
308 control based on the measured fan speed.
311 Suggested fan channel label.
315 Should only be created if the driver has hints about what
316 this fan channel is being used for, and user-space doesn't.
317 In all other cases, the label is provided by user-space.
322 Enable or disable the sensors.
324 When disabled the sensor read will return -ENODATA.
331 Also see the Alarms section for status flags associated with fans.
339 Pulse width modulation fan control.
341 Integer value in the range 0 to 255
348 Fan speed control method:
350 - 0: no fan speed control (i.e. fan at full speed)
351 - 1: manual fan speed control enabled (using `pwm[1-*]`)
352 - 2+: automatic fan speed control enabled
354 Check individual chip documentation files for automatic mode
360 - 0: DC mode (direct current)
361 - 1: PWM mode (pulse-width modulation)
366 Base PWM frequency in Hz.
368 Only possibly available when pwmN_mode is PWM, but not always
373 `pwm[1-*]_auto_channels_temp`
374 Select which temperature channels affect this PWM output in
377 Bitfield, 1 is temp1, 2 is temp2, 4 is temp3 etc...
378 Which values are possible depend on the chip used.
382 `pwm[1-*]_auto_point[1-*]_pwm` / `pwm[1-*]_auto_point[1-*]_temp` / `pwm[1-*]_auto_point[1-*]_temp_hyst`
383 Define the PWM vs temperature curve.
385 Number of trip points is chip-dependent. Use this for chips
386 which associate trip points to PWM output channels.
390 `temp[1-*]_auto_point[1-*]_pwm` / `temp[1-*]_auto_point[1-*]_temp` / `temp[1-*]_auto_point[1-*]_temp_hyst`
391 Define the PWM vs temperature curve.
393 Number of trip points is chip-dependent. Use this for chips
394 which associate trip points to temperature channels.
398 There is a third case where trip points are associated to both PWM output
399 channels and temperature channels: the PWM values are associated to PWM
400 output channels while the temperature values are associated to temperature
401 channels. In that case, the result is determined by the mapping between
402 temperature inputs and PWM outputs. When several temperature inputs are
403 mapped to a given PWM output, this leads to several candidate PWM values.
404 The actual result is up to the chip, but in general the highest candidate
405 value (fastest fan speed) wins.
413 Sensor type selection.
419 - 1: CPU embedded diode
426 Not all types are supported by all chips
429 Temperature max value.
431 Unit: millidegree Celsius (or millivolt, see below)
436 Temperature min value.
438 Unit: millidegree Celsius
443 Temperature hysteresis value for max limit.
445 Unit: millidegree Celsius
447 Must be reported as an absolute temperature, NOT a delta
453 Temperature hysteresis value for min limit.
454 Unit: millidegree Celsius
456 Must be reported as an absolute temperature, NOT a delta
462 Temperature input value.
464 Unit: millidegree Celsius
469 Temperature critical max value, typically greater than
470 corresponding temp_max values.
472 Unit: millidegree Celsius
476 `temp[1-*]_crit_hyst`
477 Temperature hysteresis value for critical limit.
479 Unit: millidegree Celsius
481 Must be reported as an absolute temperature, NOT a delta
482 from the critical value.
486 `temp[1-*]_emergency`
487 Temperature emergency max value, for chips supporting more than
488 two upper temperature limits. Must be equal or greater than
489 corresponding temp_crit values.
491 Unit: millidegree Celsius
495 `temp[1-*]_emergency_hyst`
496 Temperature hysteresis value for emergency limit.
498 Unit: millidegree Celsius
500 Must be reported as an absolute temperature, NOT a delta
501 from the emergency value.
506 Temperature critical min value, typically lower than
507 corresponding temp_min values.
509 Unit: millidegree Celsius
513 `temp[1-*]_lcrit_hyst`
514 Temperature hysteresis value for critical min limit.
516 Unit: millidegree Celsius
518 Must be reported as an absolute temperature, NOT a delta
519 from the critical min value.
524 Temperature offset which is added to the temperature reading
527 Unit: millidegree Celsius
532 Suggested temperature channel label.
536 Should only be created if the driver has hints about what
537 this temperature channel is being used for, and user-space
538 doesn't. In all other cases, the label is provided by
544 Historical minimum temperature
546 Unit: millidegree Celsius
551 Historical maximum temperature
553 Unit: millidegree Celsius
557 `temp[1-*]_reset_history`
558 Reset temp_lowest and temp_highest
563 Reset temp_lowest and temp_highest for all sensors
568 Enable or disable the sensors.
570 When disabled the sensor read will return -ENODATA.
577 Some chips measure temperature using external thermistors and an ADC, and
578 report the temperature measurement as a voltage. Converting this voltage
579 back to a temperature (or the other way around for limits) requires
580 mathematical functions not available in the kernel, so the conversion
581 must occur in user space. For these chips, all temp* files described
582 above should contain values expressed in millivolt instead of millidegree
583 Celsius. In other words, such temperature channels are handled as voltage
584 channels by the driver.
586 Also see the Alarms section for status flags associated with temperatures.
608 Current critical low value
615 Current critical high value.
636 Historical minimum current
643 Historical maximum current
647 `curr[1-*]_reset_history`
648 Reset currX_lowest and currX_highest
653 Reset currX_lowest and currX_highest for all sensors
658 Enable or disable the sensors.
660 When disabled the sensor read will return -ENODATA.
667 Also see the Alarms section for status flags associated with currents.
680 `power[1-*]_average_interval`
681 Power use averaging interval. A poll
682 notification is sent to this file if the
683 hardware changes the averaging interval.
689 `power[1-*]_average_interval_max`
690 Maximum power use averaging interval
696 `power[1-*]_average_interval_min`
697 Minimum power use averaging interval
703 `power[1-*]_average_highest`
704 Historical average maximum power use
710 `power[1-*]_average_lowest`
711 Historical average minimum power use
717 `power[1-*]_average_max`
718 A poll notification is sent to
719 `power[1-*]_average` when power use
720 rises above this value.
726 `power[1-*]_average_min`
727 A poll notification is sent to
728 `power[1-*]_average` when power use
729 sinks below this value.
736 Instantaneous power use
742 `power[1-*]_input_highest`
743 Historical maximum power use
749 `power[1-*]_input_lowest`
750 Historical minimum power use
756 `power[1-*]_reset_history`
757 Reset input_highest, input_lowest,
758 average_highest and average_lowest.
762 `power[1-*]_accuracy`
763 Accuracy of the power meter.
770 If power use rises above this limit, the
771 system should take action to reduce power use.
772 A poll notification is sent to this file if the
773 cap is changed by the hardware. The `*_cap`
774 files only appear if the cap is known to be
775 enforced by hardware.
781 `power[1-*]_cap_hyst`
782 Margin of hysteresis built around capping and
790 Maximum cap that can be set.
797 Minimum cap that can be set.
811 Critical maximum power.
813 If power rises to or above this limit, the
814 system is expected take drastic action to reduce
815 power consumption, such as a system shutdown or
816 a forced powerdown of some devices.
823 Enable or disable the sensors.
825 When disabled the sensor read will return
833 Also see the Alarms section for status flags associated with power readings.
840 Cumulative energy use
847 Enable or disable the sensors.
849 When disabled the sensor read will return
861 `humidity[1-*]_input`
864 Unit: milli-percent (per cent mille, pcm)
869 `humidity[1-*]_enable`
870 Enable or disable the sensors
872 When disabled the sensor read will return
884 Each channel or limit may have an associated alarm file, containing a
885 boolean value. 1 means than an alarm condition exists, 0 means no alarm.
887 Usually a given chip will either use channel-related alarms, or
888 limit-related alarms, not both. The driver should just reflect the hardware
891 +-------------------------------+-----------------------+
892 | **`in[0-*]_alarm`, | Channel alarm |
893 | `curr[1-*]_alarm`, | |
894 | `power[1-*]_alarm`, | - 0: no alarm |
895 | `fan[1-*]_alarm`, | - 1: alarm |
896 | `temp[1-*]_alarm`** | |
898 +-------------------------------+-----------------------+
902 +-------------------------------+-----------------------+
903 | **`in[0-*]_min_alarm`, | Limit alarm |
904 | `in[0-*]_max_alarm`, | |
905 | `in[0-*]_lcrit_alarm`, | - 0: no alarm |
906 | `in[0-*]_crit_alarm`, | - 1: alarm |
907 | `curr[1-*]_min_alarm`, | |
908 | `curr[1-*]_max_alarm`, | RO |
909 | `curr[1-*]_lcrit_alarm`, | |
910 | `curr[1-*]_crit_alarm`, | |
911 | `power[1-*]_cap_alarm`, | |
912 | `power[1-*]_max_alarm`, | |
913 | `power[1-*]_crit_alarm`, | |
914 | `fan[1-*]_min_alarm`, | |
915 | `fan[1-*]_max_alarm`, | |
916 | `temp[1-*]_min_alarm`, | |
917 | `temp[1-*]_max_alarm`, | |
918 | `temp[1-*]_lcrit_alarm`, | |
919 | `temp[1-*]_crit_alarm`, | |
920 | `temp[1-*]_emergency_alarm`** | |
921 +-------------------------------+-----------------------+
923 Each input channel may have an associated fault file. This can be used
924 to notify open diodes, unconnected fans etc. where the hardware
925 supports it. When this boolean has value 1, the measurement for that
926 channel should not be trusted.
928 `fan[1-*]_fault` / `temp[1-*]_fault`
929 Input fault condition
931 - 0: no fault occurred
936 Some chips also offer the possibility to get beeped when an alarm occurs:
946 `in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`,
954 In theory, a chip could provide per-limit beep masking, but no such chip
957 Old drivers provided a different, non-standard interface to alarms and
958 beeps. These interface files are deprecated, but will be kept around
959 for compatibility reasons:
966 Integer representation of one to four bytes.
968 A '1' bit means an alarm.
970 Chips should be programmed for 'comparator' mode so that
971 the alarm will 'come back' after you read the register
972 if it is still valid.
974 Generally a direct representation of a chip's internal
975 alarm registers; there is no standard for the position
976 of individual bits. For this reason, the use of this
977 interface file for new drivers is discouraged. Use
978 `individual *_alarm` and `*_fault` files instead.
979 Bits are defined in kernel/include/sensors.h.
983 Same format as 'alarms' with the same bit locations,
984 use discouraged for the same reason. Use individual
985 `*_beep` files instead.
993 `intrusion[0-*]_alarm`
994 Chassis intrusion detection
997 - 1: intrusion detected
1001 Contrary to regular alarm flags which clear themselves
1002 automatically when read, this one sticks until cleared by
1003 the user. This is done by writing 0 to the file. Writing
1004 other values is unsupported.
1006 `intrusion[0-*]_beep`
1007 Chassis intrusion beep
1014 ****************************
1015 Average sample configuration
1016 ****************************
1018 Devices allowing for reading {in,power,curr,temp}_average values may export
1019 attributes for controlling number of samples used to compute average.
1021 +--------------+---------------------------------------------------------------+
1022 | samples | Sets number of average samples for all types of measurements. |
1025 +--------------+---------------------------------------------------------------+
1026 | in_samples | Sets number of average samples for specific type of |
1027 | power_samples| measurements. |
1029 | temp_samples | Note that on some devices it won't be possible to set all of |
1030 | | them to different values so changing one might also change |
1034 +--------------+---------------------------------------------------------------+
1036 sysfs attribute writes interpretation
1037 -------------------------------------
1039 hwmon sysfs attributes always contain numbers, so the first thing to do is to
1040 convert the input to a number, there are 2 ways todo this depending whether
1041 the number can be negative or not::
1043 unsigned long u = simple_strtoul(buf, NULL, 10);
1044 long s = simple_strtol(buf, NULL, 10);
1046 With buf being the buffer with the user input being passed by the kernel.
1047 Notice that we do not use the second argument of strto[u]l, and thus cannot
1048 tell when 0 is returned, if this was really 0 or is caused by invalid input.
1049 This is done deliberately as checking this everywhere would add a lot of
1052 Notice that it is important to always store the converted value in an
1053 unsigned long or long, so that no wrap around can happen before any further
1056 After the input string is converted to an (unsigned) long, the value should be
1057 checked if its acceptable. Be careful with further conversions on the value
1058 before checking it for validity, as these conversions could still cause a wrap
1059 around before the check. For example do not multiply the result, and only
1060 add/subtract if it has been divided before the add/subtract.
1062 What to do if a value is found to be invalid, depends on the type of the
1063 sysfs attribute that is being set. If it is a continuous setting like a
1064 tempX_max or inX_max attribute, then the value should be clamped to its
1065 limits using clamp_val(value, min_limit, max_limit). If it is not continuous
1066 like for example a tempX_type, then when an invalid value is written,
1067 -EINVAL should be returned.
1069 Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees)::
1071 long v = simple_strtol(buf, NULL, 10) / 1000;
1072 v = clamp_val(v, -128, 127);
1073 /* write v to register */
1075 Example2, fan divider setting, valid values 2, 4 and 8::
1077 unsigned long v = simple_strtoul(buf, NULL, 10);
1080 case 2: v = 1; break;
1081 case 4: v = 2; break;
1082 case 8: v = 3; break;
1086 /* write v to register */