aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/hwmon/sysfs-interface
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/hwmon/sysfs-interface')
-rw-r--r--Documentation/hwmon/sysfs-interface131
1 files changed, 97 insertions, 34 deletions
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
index b3a9e1b9dbda..a17b692d2679 100644
--- a/Documentation/hwmon/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
@@ -67,6 +67,10 @@ between readings to be caught and alarmed. The exact definition of an
67alarm (for example, whether a threshold must be met or must be exceeded 67alarm (for example, whether a threshold must be met or must be exceeded
68to cause an alarm) is chip-dependent. 68to cause an alarm) is chip-dependent.
69 69
70When setting values of hwmon sysfs attributes, the string representation of
71the desired value must be written, note that strings which are not a number
72are interpreted as 0! For more on how written strings are interpreted see the
73"sysfs attribute writes interpretation" section at the end of this file.
70 74
71------------------------------------------------------------------------- 75-------------------------------------------------------------------------
72 76
@@ -78,8 +82,21 @@ RW read/write value
78Read/write values may be read-only for some chips, depending on the 82Read/write values may be read-only for some chips, depending on the
79hardware implementation. 83hardware implementation.
80 84
81All entries are optional, and should only be created in a given driver 85All entries (except name) are optional, and should only be created in a
82if the chip has the feature. 86given driver if the chip has the feature.
87
88
89********
90* Name *
91********
92
93name The chip name.
94 This should be a short, lowercase string, not containing
95 spaces nor dashes, representing the chip name. This is
96 the only mandatory attribute.
97 I2C devices get this attribute created automatically.
98 RO
99
83 100
84************ 101************
85* Voltages * 102* Voltages *
@@ -104,18 +121,17 @@ in[0-*]_input Voltage input value.
104 by the chip driver, and must be done by the application. 121 by the chip driver, and must be done by the application.
105 However, some drivers (notably lm87 and via686a) 122 However, some drivers (notably lm87 and via686a)
106 do scale, because of internal resistors built into a chip. 123 do scale, because of internal resistors built into a chip.
107 These drivers will output the actual voltage. 124 These drivers will output the actual voltage. Rule of
108 125 thumb: drivers should report the voltage values at the
109 Typical usage: 126 "pins" of the chip.
110 in0_* CPU #1 voltage (not scaled) 127
111 in1_* CPU #2 voltage (not scaled) 128in[0-*]_label Suggested voltage channel label.
112 in2_* 3.3V nominal (not scaled) 129 Text string
113 in3_* 5.0V nominal (scaled) 130 Should only be created if the driver has hints about what
114 in4_* 12.0V nominal (scaled) 131 this voltage channel is being used for, and user-space
115 in5_* -12.0V nominal (scaled) 132 doesn't. In all other cases, the label is provided by
116 in6_* -5.0V nominal (scaled) 133 user-space.
117 in7_* varies 134 RO
118 in8_* varies
119 135
120cpu[0-*]_vid CPU core reference voltage. 136cpu[0-*]_vid CPU core reference voltage.
121 Unit: millivolt 137 Unit: millivolt
@@ -159,6 +175,13 @@ fan[1-*]_target
159 Only makes sense if the chip supports closed-loop fan speed 175 Only makes sense if the chip supports closed-loop fan speed
160 control based on the measured fan speed. 176 control based on the measured fan speed.
161 177
178fan[1-*]_label Suggested fan channel label.
179 Text string
180 Should only be created if the driver has hints about what
181 this fan channel is being used for, and user-space doesn't.
182 In all other cases, the label is provided by user-space.
183 RO
184
162Also see the Alarms section for status flags associated with fans. 185Also see the Alarms section for status flags associated with fans.
163 186
164 187
@@ -219,12 +242,12 @@ temp[1-*]_auto_point[1-*]_temp_hyst
219**************** 242****************
220 243
221temp[1-*]_type Sensor type selection. 244temp[1-*]_type Sensor type selection.
222 Integers 1 to 6 or thermistor Beta value (typically 3435) 245 Integers 1 to 6
223 RW 246 RW
224 1: PII/Celeron Diode 247 1: PII/Celeron Diode
225 2: 3904 transistor 248 2: 3904 transistor
226 3: thermal diode 249 3: thermal diode
227 4: thermistor (default/unknown Beta) 250 4: thermistor
228 5: AMD AMDSI 251 5: AMD AMDSI
229 6: Intel PECI 252 6: Intel PECI
230 Not all types are supported by all chips 253 Not all types are supported by all chips
@@ -260,18 +283,19 @@ temp[1-*]_crit_hyst
260 from the critical value. 283 from the critical value.
261 RW 284 RW
262 285
263temp[1-4]_offset 286temp[1-*]_offset
264 Temperature offset which is added to the temperature reading 287 Temperature offset which is added to the temperature reading
265 by the chip. 288 by the chip.
266 Unit: millidegree Celsius 289 Unit: millidegree Celsius
267 Read/Write value. 290 Read/Write value.
268 291
269 If there are multiple temperature sensors, temp1_* is 292temp[1-*]_label Suggested temperature channel label.
270 generally the sensor inside the chip itself, 293 Text string
271 reported as "motherboard temperature". temp2_* to 294 Should only be created if the driver has hints about what
272 temp4_* are generally sensors external to the chip 295 this temperature channel is being used for, and user-space
273 itself, for example the thermal diode inside the CPU or 296 doesn't. In all other cases, the label is provided by
274 a thermistor nearby. 297 user-space.
298 RO
275 299
276Some chips measure temperature using external thermistors and an ADC, and 300Some chips measure temperature using external thermistors and an ADC, and
277report the temperature measurement as a voltage. Converting this voltage 301report the temperature measurement as a voltage. Converting this voltage
@@ -393,14 +417,53 @@ beep_mask Bitmask for beep.
393 RW 417 RW
394 418
395 419
396********* 420sysfs attribute writes interpretation
397* Other * 421-------------------------------------
398********* 422
399 423hwmon sysfs attributes always contain numbers, so the first thing to do is to
400eeprom Raw EEPROM data in binary form. 424convert the input to a number, there are 2 ways todo this depending whether
401 RO 425the number can be negative or not:
402 426unsigned long u = simple_strtoul(buf, NULL, 10);
403pec Enable or disable PEC (SMBus only) 427long s = simple_strtol(buf, NULL, 10);
404 0: disable 428
405 1: enable 429With buf being the buffer with the user input being passed by the kernel.
406 RW 430Notice that we do not use the second argument of strto[u]l, and thus cannot
431tell when 0 is returned, if this was really 0 or is caused by invalid input.
432This is done deliberately as checking this everywhere would add a lot of
433code to the kernel.
434
435Notice that it is important to always store the converted value in an
436unsigned long or long, so that no wrap around can happen before any further
437checking.
438
439After the input string is converted to an (unsigned) long, the value should be
440checked if its acceptable. Be careful with further conversions on the value
441before checking it for validity, as these conversions could still cause a wrap
442around before the check. For example do not multiply the result, and only
443add/subtract if it has been divided before the add/subtract.
444
445What to do if a value is found to be invalid, depends on the type of the
446sysfs attribute that is being set. If it is a continuous setting like a
447tempX_max or inX_max attribute, then the value should be clamped to its
448limits using SENSORS_LIMIT(value, min_limit, max_limit). If it is not
449continuous like for example a tempX_type, then when an invalid value is
450written, -EINVAL should be returned.
451
452Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees):
453
454 long v = simple_strtol(buf, NULL, 10) / 1000;
455 v = SENSORS_LIMIT(v, -128, 127);
456 /* write v to register */
457
458Example2, fan divider setting, valid values 2, 4 and 8:
459
460 unsigned long v = simple_strtoul(buf, NULL, 10);
461
462 switch (v) {
463 case 2: v = 1; break;
464 case 4: v = 2; break;
465 case 8: v = 3; break;
466 default:
467 return -EINVAL;
468 }
469 /* write v to register */