diff options
Diffstat (limited to 'Documentation/hwmon/sysfs-interface')
-rw-r--r-- | Documentation/hwmon/sysfs-interface | 131 |
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 | |||
67 | alarm (for example, whether a threshold must be met or must be exceeded | 67 | alarm (for example, whether a threshold must be met or must be exceeded |
68 | to cause an alarm) is chip-dependent. | 68 | to cause an alarm) is chip-dependent. |
69 | 69 | ||
70 | When setting values of hwmon sysfs attributes, the string representation of | ||
71 | the desired value must be written, note that strings which are not a number | ||
72 | are 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 | |||
78 | Read/write values may be read-only for some chips, depending on the | 82 | Read/write values may be read-only for some chips, depending on the |
79 | hardware implementation. | 83 | hardware implementation. |
80 | 84 | ||
81 | All entries are optional, and should only be created in a given driver | 85 | All entries (except name) are optional, and should only be created in a |
82 | if the chip has the feature. | 86 | given driver if the chip has the feature. |
87 | |||
88 | |||
89 | ******** | ||
90 | * Name * | ||
91 | ******** | ||
92 | |||
93 | name 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) | 128 | in[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 | ||
120 | cpu[0-*]_vid CPU core reference voltage. | 136 | cpu[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 | ||
178 | fan[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 | |||
162 | Also see the Alarms section for status flags associated with fans. | 185 | Also 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 | ||
221 | temp[1-*]_type Sensor type selection. | 244 | temp[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 | ||
263 | temp[1-4]_offset | 286 | temp[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 | 292 | temp[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 | ||
276 | Some chips measure temperature using external thermistors and an ADC, and | 300 | Some chips measure temperature using external thermistors and an ADC, and |
277 | report the temperature measurement as a voltage. Converting this voltage | 301 | report 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 | ********* | 420 | sysfs attribute writes interpretation |
397 | * Other * | 421 | ------------------------------------- |
398 | ********* | 422 | |
399 | 423 | hwmon sysfs attributes always contain numbers, so the first thing to do is to | |
400 | eeprom Raw EEPROM data in binary form. | 424 | convert the input to a number, there are 2 ways todo this depending whether |
401 | RO | 425 | the number can be negative or not: |
402 | 426 | unsigned long u = simple_strtoul(buf, NULL, 10); | |
403 | pec Enable or disable PEC (SMBus only) | 427 | long s = simple_strtol(buf, NULL, 10); |
404 | 0: disable | 428 | |
405 | 1: enable | 429 | With buf being the buffer with the user input being passed by the kernel. |
406 | RW | 430 | Notice that we do not use the second argument of strto[u]l, and thus cannot |
431 | tell when 0 is returned, if this was really 0 or is caused by invalid input. | ||
432 | This is done deliberately as checking this everywhere would add a lot of | ||
433 | code to the kernel. | ||
434 | |||
435 | Notice that it is important to always store the converted value in an | ||
436 | unsigned long or long, so that no wrap around can happen before any further | ||
437 | checking. | ||
438 | |||
439 | After the input string is converted to an (unsigned) long, the value should be | ||
440 | checked if its acceptable. Be careful with further conversions on the value | ||
441 | before checking it for validity, as these conversions could still cause a wrap | ||
442 | around before the check. For example do not multiply the result, and only | ||
443 | add/subtract if it has been divided before the add/subtract. | ||
444 | |||
445 | What to do if a value is found to be invalid, depends on the type of the | ||
446 | sysfs attribute that is being set. If it is a continuous setting like a | ||
447 | tempX_max or inX_max attribute, then the value should be clamped to its | ||
448 | limits using SENSORS_LIMIT(value, min_limit, max_limit). If it is not | ||
449 | continuous like for example a tempX_type, then when an invalid value is | ||
450 | written, -EINVAL should be returned. | ||
451 | |||
452 | Example1, 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 | |||
458 | Example2, 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 */ | ||