sysfs-interface.rst 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. Naming and data format standards for sysfs files
  2. ================================================
  3. The libsensors library offers an interface to the raw sensors data
  4. through the sysfs interface. Since lm-sensors 3.0.0, libsensors is
  5. completely chip-independent. It assumes that all the kernel drivers
  6. implement the standard sysfs interface described in this document.
  7. This makes adding or updating support for any given chip very easy, as
  8. libsensors, and applications using it, do not need to be modified.
  9. This is a major improvement compared to lm-sensors 2.
  10. Note that motherboards vary widely in the connections to sensor chips.
  11. There is no standard that ensures, for example, that the second
  12. temperature sensor is connected to the CPU, or that the second fan is on
  13. the CPU. Also, some values reported by the chips need some computation
  14. before they make full sense. For example, most chips can only measure
  15. voltages between 0 and +4V. Other voltages are scaled back into that
  16. range using external resistors. Since the values of these resistors
  17. can change from motherboard to motherboard, the conversions cannot be
  18. hard coded into the driver and have to be done in user space.
  19. For this reason, even if we aim at a chip-independent libsensors, it will
  20. still require a configuration file (e.g. /etc/sensors.conf) for proper
  21. values conversion, labeling of inputs and hiding of unused inputs.
  22. An alternative method that some programs use is to access the sysfs
  23. files directly. This document briefly describes the standards that the
  24. drivers follow, so that an application program can scan for entries and
  25. access this data in a simple and consistent way. That said, such programs
  26. will have to implement conversion, labeling and hiding of inputs. For
  27. this reason, it is still not recommended to bypass the library.
  28. Each chip gets its own directory in the sysfs /sys/devices tree. To
  29. find all sensor chips, it is easier to follow the device symlinks from
  30. `/sys/class/hwmon/hwmon*`.
  31. Up to lm-sensors 3.0.0, libsensors looks for hardware monitoring attributes
  32. in the "physical" device directory. Since lm-sensors 3.0.1, attributes found
  33. in the hwmon "class" device directory are also supported. Complex drivers
  34. (e.g. drivers for multifunction chips) may want to use this possibility to
  35. avoid namespace pollution. The only drawback will be that older versions of
  36. libsensors won't support the driver in question.
  37. All sysfs values are fixed point numbers.
  38. There is only one value per file, unlike the older /proc specification.
  39. The common scheme for files naming is: <type><number>_<item>. Usual
  40. types for sensor chips are "in" (voltage), "temp" (temperature) and
  41. "fan" (fan). Usual items are "input" (measured value), "max" (high
  42. threshold, "min" (low threshold). Numbering usually starts from 1,
  43. except for voltages which start from 0 (because most data sheets use
  44. this). A number is always used for elements that can be present more
  45. than once, even if there is a single element of the given type on the
  46. specific chip. Other files do not refer to a specific element, so
  47. they have a simple name, and no number.
  48. Alarms are direct indications read from the chips. The drivers do NOT
  49. make comparisons of readings to thresholds. This allows violations
  50. between readings to be caught and alarmed. The exact definition of an
  51. alarm (for example, whether a threshold must be met or must be exceeded
  52. to cause an alarm) is chip-dependent.
  53. When setting values of hwmon sysfs attributes, the string representation of
  54. the desired value must be written, note that strings which are not a number
  55. are interpreted as 0! For more on how written strings are interpreted see the
  56. "sysfs attribute writes interpretation" section at the end of this file.
  57. -------------------------------------------------------------------------
  58. ======= ===========================================
  59. `[0-*]` denotes any positive number starting from 0
  60. `[1-*]` denotes any positive number starting from 1
  61. RO read only value
  62. WO write only value
  63. RW read/write value
  64. ======= ===========================================
  65. Read/write values may be read-only for some chips, depending on the
  66. hardware implementation.
  67. All entries (except name) are optional, and should only be created in a
  68. given driver if the chip has the feature.
  69. *****************
  70. Global attributes
  71. *****************
  72. `name`
  73. The chip name.
  74. This should be a short, lowercase string, not containing
  75. whitespace, dashes, or the wildcard character '*'.
  76. This attribute represents the chip name. It is the only
  77. mandatory attribute.
  78. I2C devices get this attribute created automatically.
  79. RO
  80. `update_interval`
  81. The interval at which the chip will update readings.
  82. Unit: millisecond
  83. RW
  84. Some devices have a variable update rate or interval.
  85. This attribute can be used to change it to the desired value.
  86. ********
  87. Voltages
  88. ********
  89. `in[0-*]_min`
  90. Voltage min value.
  91. Unit: millivolt
  92. RW
  93. `in[0-*]_lcrit`
  94. Voltage critical min value.
  95. Unit: millivolt
  96. RW
  97. If voltage drops to or below this limit, the system may
  98. take drastic action such as power down or reset. At the very
  99. least, it should report a fault.
  100. `in[0-*]_max`
  101. Voltage max value.
  102. Unit: millivolt
  103. RW
  104. `in[0-*]_crit`
  105. Voltage critical max value.
  106. Unit: millivolt
  107. RW
  108. If voltage reaches or exceeds this limit, the system may
  109. take drastic action such as power down or reset. At the very
  110. least, it should report a fault.
  111. `in[0-*]_input`
  112. Voltage input value.
  113. Unit: millivolt
  114. RO
  115. Voltage measured on the chip pin.
  116. Actual voltage depends on the scaling resistors on the
  117. motherboard, as recommended in the chip datasheet.
  118. This varies by chip and by motherboard.
  119. Because of this variation, values are generally NOT scaled
  120. by the chip driver, and must be done by the application.
  121. However, some drivers (notably lm87 and via686a)
  122. do scale, because of internal resistors built into a chip.
  123. These drivers will output the actual voltage. Rule of
  124. thumb: drivers should report the voltage values at the
  125. "pins" of the chip.
  126. `in[0-*]_average`
  127. Average voltage
  128. Unit: millivolt
  129. RO
  130. `in[0-*]_lowest`
  131. Historical minimum voltage
  132. Unit: millivolt
  133. RO
  134. `in[0-*]_highest`
  135. Historical maximum voltage
  136. Unit: millivolt
  137. RO
  138. `in[0-*]_reset_history`
  139. Reset inX_lowest and inX_highest
  140. WO
  141. `in_reset_history`
  142. Reset inX_lowest and inX_highest for all sensors
  143. WO
  144. `in[0-*]_label`
  145. Suggested voltage channel label.
  146. Text string
  147. Should only be created if the driver has hints about what
  148. this voltage channel is being used for, and user-space
  149. doesn't. In all other cases, the label is provided by
  150. user-space.
  151. RO
  152. `in[0-*]_enable`
  153. Enable or disable the sensors.
  154. When disabled the sensor read will return -ENODATA.
  155. - 1: Enable
  156. - 0: Disable
  157. RW
  158. `cpu[0-*]_vid`
  159. CPU core reference voltage.
  160. Unit: millivolt
  161. RO
  162. Not always correct.
  163. `vrm`
  164. Voltage Regulator Module version number.
  165. RW (but changing it should no more be necessary)
  166. Originally the VRM standard version multiplied by 10, but now
  167. an arbitrary number, as not all standards have a version
  168. number.
  169. Affects the way the driver calculates the CPU core reference
  170. voltage from the vid pins.
  171. `in[0-*]_rated_min`
  172. Minimum rated voltage.
  173. Unit: millivolt
  174. RO
  175. `in[0-*]_rated_max`
  176. Maximum rated voltage.
  177. Unit: millivolt
  178. RO
  179. Also see the Alarms section for status flags associated with voltages.
  180. ****
  181. Fans
  182. ****
  183. `fan[1-*]_min`
  184. Fan minimum value
  185. Unit: revolution/min (RPM)
  186. RW
  187. `fan[1-*]_max`
  188. Fan maximum value
  189. Unit: revolution/min (RPM)
  190. Only rarely supported by the hardware.
  191. RW
  192. `fan[1-*]_input`
  193. Fan input value.
  194. Unit: revolution/min (RPM)
  195. RO
  196. `fan[1-*]_div`
  197. Fan divisor.
  198. Integer value in powers of two (1, 2, 4, 8, 16, 32, 64, 128).
  199. RW
  200. Some chips only support values 1, 2, 4 and 8.
  201. Note that this is actually an internal clock divisor, which
  202. affects the measurable speed range, not the read value.
  203. `fan[1-*]_pulses`
  204. Number of tachometer pulses per fan revolution.
  205. Integer value, typically between 1 and 4.
  206. RW
  207. This value is a characteristic of the fan connected to the
  208. device's input, so it has to be set in accordance with the fan
  209. model.
  210. Should only be created if the chip has a register to configure
  211. the number of pulses. In the absence of such a register (and
  212. thus attribute) the value assumed by all devices is 2 pulses
  213. per fan revolution.
  214. `fan[1-*]_target`
  215. Desired fan speed
  216. Unit: revolution/min (RPM)
  217. RW
  218. Only makes sense if the chip supports closed-loop fan speed
  219. control based on the measured fan speed.
  220. `fan[1-*]_label`
  221. Suggested fan channel label.
  222. Text string
  223. Should only be created if the driver has hints about what
  224. this fan channel is being used for, and user-space doesn't.
  225. In all other cases, the label is provided by user-space.
  226. RO
  227. `fan[1-*]_enable`
  228. Enable or disable the sensors.
  229. When disabled the sensor read will return -ENODATA.
  230. - 1: Enable
  231. - 0: Disable
  232. RW
  233. Also see the Alarms section for status flags associated with fans.
  234. ***
  235. PWM
  236. ***
  237. `pwm[1-*]`
  238. Pulse width modulation fan control.
  239. Integer value in the range 0 to 255
  240. RW
  241. 255 is max or 100%.
  242. `pwm[1-*]_enable`
  243. Fan speed control method:
  244. - 0: no fan speed control (i.e. fan at full speed)
  245. - 1: manual fan speed control enabled (using `pwm[1-*]`)
  246. - 2+: automatic fan speed control enabled
  247. Check individual chip documentation files for automatic mode
  248. details.
  249. RW
  250. `pwm[1-*]_mode`
  251. - 0: DC mode (direct current)
  252. - 1: PWM mode (pulse-width modulation)
  253. RW
  254. `pwm[1-*]_freq`
  255. Base PWM frequency in Hz.
  256. Only possibly available when pwmN_mode is PWM, but not always
  257. present even then.
  258. RW
  259. `pwm[1-*]_auto_channels_temp`
  260. Select which temperature channels affect this PWM output in
  261. auto mode.
  262. Bitfield, 1 is temp1, 2 is temp2, 4 is temp3 etc...
  263. Which values are possible depend on the chip used.
  264. RW
  265. `pwm[1-*]_auto_point[1-*]_pwm` / `pwm[1-*]_auto_point[1-*]_temp` / `pwm[1-*]_auto_point[1-*]_temp_hyst`
  266. Define the PWM vs temperature curve.
  267. Number of trip points is chip-dependent. Use this for chips
  268. which associate trip points to PWM output channels.
  269. RW
  270. `temp[1-*]_auto_point[1-*]_pwm` / `temp[1-*]_auto_point[1-*]_temp` / `temp[1-*]_auto_point[1-*]_temp_hyst`
  271. Define the PWM vs temperature curve.
  272. Number of trip points is chip-dependent. Use this for chips
  273. which associate trip points to temperature channels.
  274. RW
  275. There is a third case where trip points are associated to both PWM output
  276. channels and temperature channels: the PWM values are associated to PWM
  277. output channels while the temperature values are associated to temperature
  278. channels. In that case, the result is determined by the mapping between
  279. temperature inputs and PWM outputs. When several temperature inputs are
  280. mapped to a given PWM output, this leads to several candidate PWM values.
  281. The actual result is up to the chip, but in general the highest candidate
  282. value (fastest fan speed) wins.
  283. ************
  284. Temperatures
  285. ************
  286. `temp[1-*]_type`
  287. Sensor type selection.
  288. Integers 1 to 6
  289. RW
  290. - 1: CPU embedded diode
  291. - 2: 3904 transistor
  292. - 3: thermal diode
  293. - 4: thermistor
  294. - 5: AMD AMDSI
  295. - 6: Intel PECI
  296. Not all types are supported by all chips
  297. `temp[1-*]_max`
  298. Temperature max value.
  299. Unit: millidegree Celsius (or millivolt, see below)
  300. RW
  301. `temp[1-*]_min`
  302. Temperature min value.
  303. Unit: millidegree Celsius
  304. RW
  305. `temp[1-*]_max_hyst`
  306. Temperature hysteresis value for max limit.
  307. Unit: millidegree Celsius
  308. Must be reported as an absolute temperature, NOT a delta
  309. from the max value.
  310. RW
  311. `temp[1-*]_min_hyst`
  312. Temperature hysteresis value for min limit.
  313. Unit: millidegree Celsius
  314. Must be reported as an absolute temperature, NOT a delta
  315. from the min value.
  316. RW
  317. `temp[1-*]_input`
  318. Temperature input value.
  319. Unit: millidegree Celsius
  320. RO
  321. `temp[1-*]_crit`
  322. Temperature critical max value, typically greater than
  323. corresponding temp_max values.
  324. Unit: millidegree Celsius
  325. RW
  326. `temp[1-*]_crit_hyst`
  327. Temperature hysteresis value for critical limit.
  328. Unit: millidegree Celsius
  329. Must be reported as an absolute temperature, NOT a delta
  330. from the critical value.
  331. RW
  332. `temp[1-*]_emergency`
  333. Temperature emergency max value, for chips supporting more than
  334. two upper temperature limits. Must be equal or greater than
  335. corresponding temp_crit values.
  336. Unit: millidegree Celsius
  337. RW
  338. `temp[1-*]_emergency_hyst`
  339. Temperature hysteresis value for emergency limit.
  340. Unit: millidegree Celsius
  341. Must be reported as an absolute temperature, NOT a delta
  342. from the emergency value.
  343. RW
  344. `temp[1-*]_lcrit`
  345. Temperature critical min value, typically lower than
  346. corresponding temp_min values.
  347. Unit: millidegree Celsius
  348. RW
  349. `temp[1-*]_lcrit_hyst`
  350. Temperature hysteresis value for critical min limit.
  351. Unit: millidegree Celsius
  352. Must be reported as an absolute temperature, NOT a delta
  353. from the critical min value.
  354. RW
  355. `temp[1-*]_offset`
  356. Temperature offset which is added to the temperature reading
  357. by the chip.
  358. Unit: millidegree Celsius
  359. Read/Write value.
  360. `temp[1-*]_label`
  361. Suggested temperature channel label.
  362. Text string
  363. Should only be created if the driver has hints about what
  364. this temperature channel is being used for, and user-space
  365. doesn't. In all other cases, the label is provided by
  366. user-space.
  367. RO
  368. `temp[1-*]_lowest`
  369. Historical minimum temperature
  370. Unit: millidegree Celsius
  371. RO
  372. `temp[1-*]_highest`
  373. Historical maximum temperature
  374. Unit: millidegree Celsius
  375. RO
  376. `temp[1-*]_reset_history`
  377. Reset temp_lowest and temp_highest
  378. WO
  379. `temp_reset_history`
  380. Reset temp_lowest and temp_highest for all sensors
  381. WO
  382. `temp[1-*]_enable`
  383. Enable or disable the sensors.
  384. When disabled the sensor read will return -ENODATA.
  385. - 1: Enable
  386. - 0: Disable
  387. RW
  388. `temp[1-*]_rated_min`
  389. Minimum rated temperature.
  390. Unit: millidegree Celsius
  391. RO
  392. `temp[1-*]_rated_max`
  393. Maximum rated temperature.
  394. Unit: millidegree Celsius
  395. RO
  396. Some chips measure temperature using external thermistors and an ADC, and
  397. report the temperature measurement as a voltage. Converting this voltage
  398. back to a temperature (or the other way around for limits) requires
  399. mathematical functions not available in the kernel, so the conversion
  400. must occur in user space. For these chips, all temp* files described
  401. above should contain values expressed in millivolt instead of millidegree
  402. Celsius. In other words, such temperature channels are handled as voltage
  403. channels by the driver.
  404. Also see the Alarms section for status flags associated with temperatures.
  405. ********
  406. Currents
  407. ********
  408. `curr[1-*]_max`
  409. Current max value
  410. Unit: milliampere
  411. RW
  412. `curr[1-*]_min`
  413. Current min value.
  414. Unit: milliampere
  415. RW
  416. `curr[1-*]_lcrit`
  417. Current critical low value
  418. Unit: milliampere
  419. RW
  420. `curr[1-*]_crit`
  421. Current critical high value.
  422. Unit: milliampere
  423. RW
  424. `curr[1-*]_input`
  425. Current input value
  426. Unit: milliampere
  427. RO
  428. `curr[1-*]_average`
  429. Average current use
  430. Unit: milliampere
  431. RO
  432. `curr[1-*]_lowest`
  433. Historical minimum current
  434. Unit: milliampere
  435. RO
  436. `curr[1-*]_highest`
  437. Historical maximum current
  438. Unit: milliampere
  439. RO
  440. `curr[1-*]_reset_history`
  441. Reset currX_lowest and currX_highest
  442. WO
  443. `curr_reset_history`
  444. Reset currX_lowest and currX_highest for all sensors
  445. WO
  446. `curr[1-*]_enable`
  447. Enable or disable the sensors.
  448. When disabled the sensor read will return -ENODATA.
  449. - 1: Enable
  450. - 0: Disable
  451. RW
  452. `curr[1-*]_rated_min`
  453. Minimum rated current.
  454. Unit: milliampere
  455. RO
  456. `curr[1-*]_rated_max`
  457. Maximum rated current.
  458. Unit: milliampere
  459. RO
  460. Also see the Alarms section for status flags associated with currents.
  461. *****
  462. Power
  463. *****
  464. `power[1-*]_average`
  465. Average power use
  466. Unit: microWatt
  467. RO
  468. `power[1-*]_average_interval`
  469. Power use averaging interval. A poll
  470. notification is sent to this file if the
  471. hardware changes the averaging interval.
  472. Unit: milliseconds
  473. RW
  474. `power[1-*]_average_interval_max`
  475. Maximum power use averaging interval
  476. Unit: milliseconds
  477. RO
  478. `power[1-*]_average_interval_min`
  479. Minimum power use averaging interval
  480. Unit: milliseconds
  481. RO
  482. `power[1-*]_average_highest`
  483. Historical average maximum power use
  484. Unit: microWatt
  485. RO
  486. `power[1-*]_average_lowest`
  487. Historical average minimum power use
  488. Unit: microWatt
  489. RO
  490. `power[1-*]_average_max`
  491. A poll notification is sent to
  492. `power[1-*]_average` when power use
  493. rises above this value.
  494. Unit: microWatt
  495. RW
  496. `power[1-*]_average_min`
  497. A poll notification is sent to
  498. `power[1-*]_average` when power use
  499. sinks below this value.
  500. Unit: microWatt
  501. RW
  502. `power[1-*]_input`
  503. Instantaneous power use
  504. Unit: microWatt
  505. RO
  506. `power[1-*]_input_highest`
  507. Historical maximum power use
  508. Unit: microWatt
  509. RO
  510. `power[1-*]_input_lowest`
  511. Historical minimum power use
  512. Unit: microWatt
  513. RO
  514. `power[1-*]_reset_history`
  515. Reset input_highest, input_lowest,
  516. average_highest and average_lowest.
  517. WO
  518. `power[1-*]_accuracy`
  519. Accuracy of the power meter.
  520. Unit: Percent
  521. RO
  522. `power[1-*]_cap`
  523. If power use rises above this limit, the
  524. system should take action to reduce power use.
  525. A poll notification is sent to this file if the
  526. cap is changed by the hardware. The `*_cap`
  527. files only appear if the cap is known to be
  528. enforced by hardware.
  529. Unit: microWatt
  530. RW
  531. `power[1-*]_cap_hyst`
  532. Margin of hysteresis built around capping and
  533. notification.
  534. Unit: microWatt
  535. RW
  536. `power[1-*]_cap_max`
  537. Maximum cap that can be set.
  538. Unit: microWatt
  539. RO
  540. `power[1-*]_cap_min`
  541. Minimum cap that can be set.
  542. Unit: microWatt
  543. RO
  544. `power[1-*]_max`
  545. Maximum power.
  546. Unit: microWatt
  547. RW
  548. `power[1-*]_crit`
  549. Critical maximum power.
  550. If power rises to or above this limit, the
  551. system is expected take drastic action to reduce
  552. power consumption, such as a system shutdown or
  553. a forced powerdown of some devices.
  554. Unit: microWatt
  555. RW
  556. `power[1-*]_enable`
  557. Enable or disable the sensors.
  558. When disabled the sensor read will return
  559. -ENODATA.
  560. - 1: Enable
  561. - 0: Disable
  562. RW
  563. `power[1-*]_rated_min`
  564. Minimum rated power.
  565. Unit: microWatt
  566. RO
  567. `power[1-*]_rated_max`
  568. Maximum rated power.
  569. Unit: microWatt
  570. RO
  571. Also see the Alarms section for status flags associated with power readings.
  572. ******
  573. Energy
  574. ******
  575. `energy[1-*]_input`
  576. Cumulative energy use
  577. Unit: microJoule
  578. RO
  579. `energy[1-*]_enable`
  580. Enable or disable the sensors.
  581. When disabled the sensor read will return
  582. -ENODATA.
  583. - 1: Enable
  584. - 0: Disable
  585. RW
  586. ********
  587. Humidity
  588. ********
  589. `humidity[1-*]_input`
  590. Humidity
  591. Unit: milli-percent (per cent mille, pcm)
  592. RO
  593. `humidity[1-*]_enable`
  594. Enable or disable the sensors
  595. When disabled the sensor read will return
  596. -ENODATA.
  597. - 1: Enable
  598. - 0: Disable
  599. RW
  600. `humidity[1-*]_rated_min`
  601. Minimum rated humidity.
  602. Unit: milli-percent (per cent mille, pcm)
  603. RO
  604. `humidity[1-*]_rated_max`
  605. Maximum rated humidity.
  606. Unit: milli-percent (per cent mille, pcm)
  607. RO
  608. ******
  609. Alarms
  610. ******
  611. Each channel or limit may have an associated alarm file, containing a
  612. boolean value. 1 means than an alarm condition exists, 0 means no alarm.
  613. Usually a given chip will either use channel-related alarms, or
  614. limit-related alarms, not both. The driver should just reflect the hardware
  615. implementation.
  616. +-------------------------------+-----------------------+
  617. | **`in[0-*]_alarm`, | Channel alarm |
  618. | `curr[1-*]_alarm`, | |
  619. | `power[1-*]_alarm`, | - 0: no alarm |
  620. | `fan[1-*]_alarm`, | - 1: alarm |
  621. | `temp[1-*]_alarm`** | |
  622. | | RO |
  623. +-------------------------------+-----------------------+
  624. **OR**
  625. +-------------------------------+-----------------------+
  626. | **`in[0-*]_min_alarm`, | Limit alarm |
  627. | `in[0-*]_max_alarm`, | |
  628. | `in[0-*]_lcrit_alarm`, | - 0: no alarm |
  629. | `in[0-*]_crit_alarm`, | - 1: alarm |
  630. | `curr[1-*]_min_alarm`, | |
  631. | `curr[1-*]_max_alarm`, | RO |
  632. | `curr[1-*]_lcrit_alarm`, | |
  633. | `curr[1-*]_crit_alarm`, | |
  634. | `power[1-*]_cap_alarm`, | |
  635. | `power[1-*]_max_alarm`, | |
  636. | `power[1-*]_crit_alarm`, | |
  637. | `fan[1-*]_min_alarm`, | |
  638. | `fan[1-*]_max_alarm`, | |
  639. | `temp[1-*]_min_alarm`, | |
  640. | `temp[1-*]_max_alarm`, | |
  641. | `temp[1-*]_lcrit_alarm`, | |
  642. | `temp[1-*]_crit_alarm`, | |
  643. | `temp[1-*]_emergency_alarm`** | |
  644. +-------------------------------+-----------------------+
  645. Each input channel may have an associated fault file. This can be used
  646. to notify open diodes, unconnected fans etc. where the hardware
  647. supports it. When this boolean has value 1, the measurement for that
  648. channel should not be trusted.
  649. `fan[1-*]_fault` / `temp[1-*]_fault`
  650. Input fault condition
  651. - 0: no fault occurred
  652. - 1: fault condition
  653. RO
  654. Some chips also offer the possibility to get beeped when an alarm occurs:
  655. `beep_enable`
  656. Master beep enable
  657. - 0: no beeps
  658. - 1: beeps
  659. RW
  660. `in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`,
  661. Channel beep
  662. - 0: disable
  663. - 1: enable
  664. RW
  665. In theory, a chip could provide per-limit beep masking, but no such chip
  666. was seen so far.
  667. Old drivers provided a different, non-standard interface to alarms and
  668. beeps. These interface files are deprecated, but will be kept around
  669. for compatibility reasons:
  670. `alarms`
  671. Alarm bitmask.
  672. RO
  673. Integer representation of one to four bytes.
  674. A '1' bit means an alarm.
  675. Chips should be programmed for 'comparator' mode so that
  676. the alarm will 'come back' after you read the register
  677. if it is still valid.
  678. Generally a direct representation of a chip's internal
  679. alarm registers; there is no standard for the position
  680. of individual bits. For this reason, the use of this
  681. interface file for new drivers is discouraged. Use
  682. `individual *_alarm` and `*_fault` files instead.
  683. Bits are defined in kernel/include/sensors.h.
  684. `beep_mask`
  685. Bitmask for beep.
  686. Same format as 'alarms' with the same bit locations,
  687. use discouraged for the same reason. Use individual
  688. `*_beep` files instead.
  689. RW
  690. *******************
  691. Intrusion detection
  692. *******************
  693. `intrusion[0-*]_alarm`
  694. Chassis intrusion detection
  695. - 0: OK
  696. - 1: intrusion detected
  697. RW
  698. Contrary to regular alarm flags which clear themselves
  699. automatically when read, this one sticks until cleared by
  700. the user. This is done by writing 0 to the file. Writing
  701. other values is unsupported.
  702. `intrusion[0-*]_beep`
  703. Chassis intrusion beep
  704. 0: disable
  705. 1: enable
  706. RW
  707. ****************************
  708. Average sample configuration
  709. ****************************
  710. Devices allowing for reading {in,power,curr,temp}_average values may export
  711. attributes for controlling number of samples used to compute average.
  712. +--------------+---------------------------------------------------------------+
  713. | samples | Sets number of average samples for all types of measurements. |
  714. | | |
  715. | | RW |
  716. +--------------+---------------------------------------------------------------+
  717. | in_samples | Sets number of average samples for specific type of |
  718. | power_samples| measurements. |
  719. | curr_samples | |
  720. | temp_samples | Note that on some devices it won't be possible to set all of |
  721. | | them to different values so changing one might also change |
  722. | | some others. |
  723. | | |
  724. | | RW |
  725. +--------------+---------------------------------------------------------------+
  726. sysfs attribute writes interpretation
  727. -------------------------------------
  728. hwmon sysfs attributes always contain numbers, so the first thing to do is to
  729. convert the input to a number, there are 2 ways todo this depending whether
  730. the number can be negative or not::
  731. unsigned long u = simple_strtoul(buf, NULL, 10);
  732. long s = simple_strtol(buf, NULL, 10);
  733. With buf being the buffer with the user input being passed by the kernel.
  734. Notice that we do not use the second argument of strto[u]l, and thus cannot
  735. tell when 0 is returned, if this was really 0 or is caused by invalid input.
  736. This is done deliberately as checking this everywhere would add a lot of
  737. code to the kernel.
  738. Notice that it is important to always store the converted value in an
  739. unsigned long or long, so that no wrap around can happen before any further
  740. checking.
  741. After the input string is converted to an (unsigned) long, the value should be
  742. checked if its acceptable. Be careful with further conversions on the value
  743. before checking it for validity, as these conversions could still cause a wrap
  744. around before the check. For example do not multiply the result, and only
  745. add/subtract if it has been divided before the add/subtract.
  746. What to do if a value is found to be invalid, depends on the type of the
  747. sysfs attribute that is being set. If it is a continuous setting like a
  748. tempX_max or inX_max attribute, then the value should be clamped to its
  749. limits using clamp_val(value, min_limit, max_limit). If it is not continuous
  750. like for example a tempX_type, then when an invalid value is written,
  751. -EINVAL should be returned.
  752. Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees)::
  753. long v = simple_strtol(buf, NULL, 10) / 1000;
  754. v = clamp_val(v, -128, 127);
  755. /* write v to register */
  756. Example2, fan divider setting, valid values 2, 4 and 8::
  757. unsigned long v = simple_strtoul(buf, NULL, 10);
  758. switch (v) {
  759. case 2: v = 1; break;
  760. case 4: v = 2; break;
  761. case 8: v = 3; break;
  762. default:
  763. return -EINVAL;
  764. }
  765. /* write v to register */