162306a36Sopenharmony_ciNaming and data format standards for sysfs files
262306a36Sopenharmony_ci================================================
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciThe libsensors library offers an interface to the raw sensors data
562306a36Sopenharmony_cithrough the sysfs interface. Since lm-sensors 3.0.0, libsensors is
662306a36Sopenharmony_cicompletely chip-independent. It assumes that all the kernel drivers
762306a36Sopenharmony_ciimplement the standard sysfs interface described in this document.
862306a36Sopenharmony_ciThis makes adding or updating support for any given chip very easy, as
962306a36Sopenharmony_cilibsensors, and applications using it, do not need to be modified.
1062306a36Sopenharmony_ciThis is a major improvement compared to lm-sensors 2.
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciNote that motherboards vary widely in the connections to sensor chips.
1362306a36Sopenharmony_ciThere is no standard that ensures, for example, that the second
1462306a36Sopenharmony_citemperature sensor is connected to the CPU, or that the second fan is on
1562306a36Sopenharmony_cithe CPU. Also, some values reported by the chips need some computation
1662306a36Sopenharmony_cibefore they make full sense. For example, most chips can only measure
1762306a36Sopenharmony_civoltages between 0 and +4V. Other voltages are scaled back into that
1862306a36Sopenharmony_cirange using external resistors. Since the values of these resistors
1962306a36Sopenharmony_cican change from motherboard to motherboard, the conversions cannot be
2062306a36Sopenharmony_cihard coded into the driver and have to be done in user space.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciFor this reason, even if we aim at a chip-independent libsensors, it will
2362306a36Sopenharmony_cistill require a configuration file (e.g. /etc/sensors.conf) for proper
2462306a36Sopenharmony_civalues conversion, labeling of inputs and hiding of unused inputs.
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciAn alternative method that some programs use is to access the sysfs
2762306a36Sopenharmony_cifiles directly. This document briefly describes the standards that the
2862306a36Sopenharmony_cidrivers follow, so that an application program can scan for entries and
2962306a36Sopenharmony_ciaccess this data in a simple and consistent way. That said, such programs
3062306a36Sopenharmony_ciwill have to implement conversion, labeling and hiding of inputs. For
3162306a36Sopenharmony_cithis reason, it is still not recommended to bypass the library.
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciEach chip gets its own directory in the sysfs /sys/devices tree.  To
3462306a36Sopenharmony_cifind all sensor chips, it is easier to follow the device symlinks from
3562306a36Sopenharmony_ci`/sys/class/hwmon/hwmon*`.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciUp to lm-sensors 3.0.0, libsensors looks for hardware monitoring attributes
3862306a36Sopenharmony_ciin the "physical" device directory. Since lm-sensors 3.0.1, attributes found
3962306a36Sopenharmony_ciin the hwmon "class" device directory are also supported. Complex drivers
4062306a36Sopenharmony_ci(e.g. drivers for multifunction chips) may want to use this possibility to
4162306a36Sopenharmony_ciavoid namespace pollution. The only drawback will be that older versions of
4262306a36Sopenharmony_cilibsensors won't support the driver in question.
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciAll sysfs values are fixed point numbers.
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciThere is only one value per file, unlike the older /proc specification.
4762306a36Sopenharmony_ciThe common scheme for files naming is: <type><number>_<item>. Usual
4862306a36Sopenharmony_citypes for sensor chips are "in" (voltage), "temp" (temperature) and
4962306a36Sopenharmony_ci"fan" (fan). Usual items are "input" (measured value), "max" (high
5062306a36Sopenharmony_cithreshold, "min" (low threshold). Numbering usually starts from 1,
5162306a36Sopenharmony_ciexcept for voltages which start from 0 (because most data sheets use
5262306a36Sopenharmony_cithis). A number is always used for elements that can be present more
5362306a36Sopenharmony_cithan once, even if there is a single element of the given type on the
5462306a36Sopenharmony_cispecific chip. Other files do not refer to a specific element, so
5562306a36Sopenharmony_cithey have a simple name, and no number.
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciAlarms are direct indications read from the chips. The drivers do NOT
5862306a36Sopenharmony_cimake comparisons of readings to thresholds. This allows violations
5962306a36Sopenharmony_cibetween readings to be caught and alarmed. The exact definition of an
6062306a36Sopenharmony_cialarm (for example, whether a threshold must be met or must be exceeded
6162306a36Sopenharmony_cito cause an alarm) is chip-dependent.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciWhen setting values of hwmon sysfs attributes, the string representation of
6462306a36Sopenharmony_cithe desired value must be written, note that strings which are not a number
6562306a36Sopenharmony_ciare interpreted as 0! For more on how written strings are interpreted see the
6662306a36Sopenharmony_ci"sysfs attribute writes interpretation" section at the end of this file.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciAttribute access
6962306a36Sopenharmony_ci----------------
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciHardware monitoring sysfs attributes are displayed by unrestricted userspace
7262306a36Sopenharmony_ciapplications. For this reason, all standard ABI attributes shall be world
7362306a36Sopenharmony_cireadable. Writeable standard ABI attributes shall be writeable only for
7462306a36Sopenharmony_ciprivileged users.
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci-------------------------------------------------------------------------
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci======= ===========================================
7962306a36Sopenharmony_ci`[0-*]`	denotes any positive number starting from 0
8062306a36Sopenharmony_ci`[1-*]`	denotes any positive number starting from 1
8162306a36Sopenharmony_ciRO	read only value
8262306a36Sopenharmony_ciWO	write only value
8362306a36Sopenharmony_ciRW	read/write value
8462306a36Sopenharmony_ci======= ===========================================
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ciRead/write values may be read-only for some chips, depending on the
8762306a36Sopenharmony_cihardware implementation.
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciAll entries (except name) are optional, and should only be created in a
9062306a36Sopenharmony_cigiven driver if the chip has the feature.
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ciSee Documentation/ABI/testing/sysfs-class-hwmon for a complete description
9362306a36Sopenharmony_ciof the attributes.
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci*****************
9662306a36Sopenharmony_ciGlobal attributes
9762306a36Sopenharmony_ci*****************
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci`name`
10062306a36Sopenharmony_ci		The chip name.
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci`label`
10362306a36Sopenharmony_ci		A descriptive label that allows to uniquely identify a device
10462306a36Sopenharmony_ci		within the system.
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci`update_interval`
10762306a36Sopenharmony_ci		The interval at which the chip will update readings.
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci********
11162306a36Sopenharmony_ciVoltages
11262306a36Sopenharmony_ci********
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci`in[0-*]_min`
11562306a36Sopenharmony_ci		Voltage min value.
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci`in[0-*]_lcrit`
11862306a36Sopenharmony_ci		Voltage critical min value.
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci`in[0-*]_max`
12162306a36Sopenharmony_ci		Voltage max value.
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci`in[0-*]_crit`
12462306a36Sopenharmony_ci		Voltage critical max value.
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci`in[0-*]_input`
12762306a36Sopenharmony_ci		Voltage input value.
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci`in[0-*]_average`
13062306a36Sopenharmony_ci		Average voltage
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci`in[0-*]_lowest`
13362306a36Sopenharmony_ci		Historical minimum voltage
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci`in[0-*]_highest`
13662306a36Sopenharmony_ci		Historical maximum voltage
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci`in[0-*]_reset_history`
13962306a36Sopenharmony_ci		Reset inX_lowest and inX_highest
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci`in_reset_history`
14262306a36Sopenharmony_ci		Reset inX_lowest and inX_highest for all sensors
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci`in[0-*]_label`
14562306a36Sopenharmony_ci		Suggested voltage channel label.
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci`in[0-*]_enable`
14862306a36Sopenharmony_ci		Enable or disable the sensors.
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci`cpu[0-*]_vid`
15162306a36Sopenharmony_ci		CPU core reference voltage.
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci`vrm`
15462306a36Sopenharmony_ci		Voltage Regulator Module version number.
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci`in[0-*]_rated_min`
15762306a36Sopenharmony_ci		Minimum rated voltage.
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci`in[0-*]_rated_max`
16062306a36Sopenharmony_ci		Maximum rated voltage.
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ciAlso see the Alarms section for status flags associated with voltages.
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci****
16662306a36Sopenharmony_ciFans
16762306a36Sopenharmony_ci****
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci`fan[1-*]_min`
17062306a36Sopenharmony_ci		Fan minimum value
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci`fan[1-*]_max`
17362306a36Sopenharmony_ci		Fan maximum value
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci`fan[1-*]_input`
17662306a36Sopenharmony_ci		Fan input value.
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci`fan[1-*]_div`
17962306a36Sopenharmony_ci		Fan divisor.
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci`fan[1-*]_pulses`
18262306a36Sopenharmony_ci		Number of tachometer pulses per fan revolution.
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci`fan[1-*]_target`
18562306a36Sopenharmony_ci		Desired fan speed
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci`fan[1-*]_label`
18862306a36Sopenharmony_ci		Suggested fan channel label.
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci`fan[1-*]_enable`
19162306a36Sopenharmony_ci		Enable or disable the sensors.
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ciAlso see the Alarms section for status flags associated with fans.
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci***
19762306a36Sopenharmony_ciPWM
19862306a36Sopenharmony_ci***
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci`pwm[1-*]`
20162306a36Sopenharmony_ci		Pulse width modulation fan control.
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci`pwm[1-*]_enable`
20462306a36Sopenharmony_ci		Fan speed control method.
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci`pwm[1-*]_mode`
20762306a36Sopenharmony_ci		direct current or pulse-width modulation.
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci`pwm[1-*]_freq`
21062306a36Sopenharmony_ci		Base PWM frequency in Hz.
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci`pwm[1-*]_auto_channels_temp`
21362306a36Sopenharmony_ci		Select which temperature channels affect this PWM output in
21462306a36Sopenharmony_ci		auto mode.
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci`pwm[1-*]_auto_point[1-*]_pwm` / `pwm[1-*]_auto_point[1-*]_temp` / `pwm[1-*]_auto_point[1-*]_temp_hyst`
21762306a36Sopenharmony_ci		Define the PWM vs temperature curve.
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci`temp[1-*]_auto_point[1-*]_pwm` / `temp[1-*]_auto_point[1-*]_temp` / `temp[1-*]_auto_point[1-*]_temp_hyst`
22062306a36Sopenharmony_ci		Define the PWM vs temperature curve.
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ciThere is a third case where trip points are associated to both PWM output
22362306a36Sopenharmony_cichannels and temperature channels: the PWM values are associated to PWM
22462306a36Sopenharmony_cioutput channels while the temperature values are associated to temperature
22562306a36Sopenharmony_cichannels. In that case, the result is determined by the mapping between
22662306a36Sopenharmony_citemperature inputs and PWM outputs. When several temperature inputs are
22762306a36Sopenharmony_cimapped to a given PWM output, this leads to several candidate PWM values.
22862306a36Sopenharmony_ciThe actual result is up to the chip, but in general the highest candidate
22962306a36Sopenharmony_civalue (fastest fan speed) wins.
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci************
23362306a36Sopenharmony_ciTemperatures
23462306a36Sopenharmony_ci************
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci`temp[1-*]_type`
23762306a36Sopenharmony_ci		Sensor type selection.
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci`temp[1-*]_max`
24062306a36Sopenharmony_ci		Temperature max value.
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci`temp[1-*]_min`
24362306a36Sopenharmony_ci		Temperature min value.
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_ci`temp[1-*]_max_hyst`
24662306a36Sopenharmony_ci		Temperature hysteresis value for max limit.
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci`temp[1-*]_min_hyst`
24962306a36Sopenharmony_ci		Temperature hysteresis value for min limit.
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci`temp[1-*]_input`
25262306a36Sopenharmony_ci		Temperature input value.
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci`temp[1-*]_crit`
25562306a36Sopenharmony_ci		Temperature critical max value, typically greater than
25662306a36Sopenharmony_ci		corresponding temp_max values.
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci`temp[1-*]_crit_hyst`
25962306a36Sopenharmony_ci		Temperature hysteresis value for critical limit.
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci`temp[1-*]_emergency`
26262306a36Sopenharmony_ci		Temperature emergency max value, for chips supporting more than
26362306a36Sopenharmony_ci		two upper temperature limits.
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci`temp[1-*]_emergency_hyst`
26662306a36Sopenharmony_ci		Temperature hysteresis value for emergency limit.
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci`temp[1-*]_lcrit`
26962306a36Sopenharmony_ci		Temperature critical min value, typically lower than
27062306a36Sopenharmony_ci		corresponding temp_min values.
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci`temp[1-*]_lcrit_hyst`
27362306a36Sopenharmony_ci		Temperature hysteresis value for critical min limit.
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci`temp[1-*]_offset`
27662306a36Sopenharmony_ci		Temperature offset which is added to the temperature reading
27762306a36Sopenharmony_ci		by the chip.
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci`temp[1-*]_label`
28062306a36Sopenharmony_ci		Suggested temperature channel label.
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci`temp[1-*]_lowest`
28362306a36Sopenharmony_ci		Historical minimum temperature
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci`temp[1-*]_highest`
28662306a36Sopenharmony_ci		Historical maximum temperature
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci`temp[1-*]_reset_history`
28962306a36Sopenharmony_ci		Reset temp_lowest and temp_highest
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci`temp_reset_history`
29262306a36Sopenharmony_ci		Reset temp_lowest and temp_highest for all sensors
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci`temp[1-*]_enable`
29562306a36Sopenharmony_ci		Enable or disable the sensors.
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci`temp[1-*]_rated_min`
29862306a36Sopenharmony_ci		Minimum rated temperature.
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci`temp[1-*]_rated_max`
30162306a36Sopenharmony_ci		Maximum rated temperature.
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ciSome chips measure temperature using external thermistors and an ADC, and
30462306a36Sopenharmony_cireport the temperature measurement as a voltage. Converting this voltage
30562306a36Sopenharmony_ciback to a temperature (or the other way around for limits) requires
30662306a36Sopenharmony_cimathematical functions not available in the kernel, so the conversion
30762306a36Sopenharmony_cimust occur in user space. For these chips, all temp* files described
30862306a36Sopenharmony_ciabove should contain values expressed in millivolt instead of millidegree
30962306a36Sopenharmony_ciCelsius. In other words, such temperature channels are handled as voltage
31062306a36Sopenharmony_cichannels by the driver.
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ciAlso see the Alarms section for status flags associated with temperatures.
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ci********
31662306a36Sopenharmony_ciCurrents
31762306a36Sopenharmony_ci********
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci`curr[1-*]_max`
32062306a36Sopenharmony_ci		Current max value.
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci`curr[1-*]_min`
32362306a36Sopenharmony_ci		Current min value.
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci`curr[1-*]_lcrit`
32662306a36Sopenharmony_ci		Current critical low value
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci`curr[1-*]_crit`
32962306a36Sopenharmony_ci		Current critical high value.
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci`curr[1-*]_input`
33262306a36Sopenharmony_ci		Current input value.
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci`curr[1-*]_average`
33562306a36Sopenharmony_ci		Average current use.
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci`curr[1-*]_lowest`
33862306a36Sopenharmony_ci		Historical minimum current.
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_ci`curr[1-*]_highest`
34162306a36Sopenharmony_ci		Historical maximum current.
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ci`curr[1-*]_reset_history`
34462306a36Sopenharmony_ci		Reset currX_lowest and currX_highest
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci		WO
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci`curr_reset_history`
34962306a36Sopenharmony_ci		Reset currX_lowest and currX_highest for all sensors.
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci`curr[1-*]_enable`
35262306a36Sopenharmony_ci		Enable or disable the sensors.
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci`curr[1-*]_rated_min`
35562306a36Sopenharmony_ci		Minimum rated current.
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci`curr[1-*]_rated_max`
35862306a36Sopenharmony_ci		Maximum rated current.
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ciAlso see the Alarms section for status flags associated with currents.
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci*****
36362306a36Sopenharmony_ciPower
36462306a36Sopenharmony_ci*****
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci`power[1-*]_average`
36762306a36Sopenharmony_ci		Average power use.
36862306a36Sopenharmony_ci
36962306a36Sopenharmony_ci`power[1-*]_average_interval`
37062306a36Sopenharmony_ci		Power use averaging interval.
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ci`power[1-*]_average_interval_max`
37362306a36Sopenharmony_ci		Maximum power use averaging interval.
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_ci`power[1-*]_average_interval_min`
37662306a36Sopenharmony_ci		Minimum power use averaging interval.
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci`power[1-*]_average_highest`
37962306a36Sopenharmony_ci		Historical average maximum power use
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci`power[1-*]_average_lowest`
38262306a36Sopenharmony_ci		Historical average minimum power use
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci`power[1-*]_average_max`
38562306a36Sopenharmony_ci		A poll notification is sent to `power[1-*]_average` when
38662306a36Sopenharmony_ci		power use rises above this value.
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci`power[1-*]_average_min`
38962306a36Sopenharmony_ci		A poll notification is sent to `power[1-*]_average` when
39062306a36Sopenharmony_ci		power use sinks below this value.
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci`power[1-*]_input`
39362306a36Sopenharmony_ci		Instantaneous power use.
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci`power[1-*]_input_highest`
39662306a36Sopenharmony_ci		Historical maximum power use
39762306a36Sopenharmony_ci
39862306a36Sopenharmony_ci`power[1-*]_input_lowest`
39962306a36Sopenharmony_ci		Historical minimum power use.
40062306a36Sopenharmony_ci
40162306a36Sopenharmony_ci`power[1-*]_reset_history`
40262306a36Sopenharmony_ci		Reset input_highest, input_lowest, average_highest and
40362306a36Sopenharmony_ci		average_lowest.
40462306a36Sopenharmony_ci
40562306a36Sopenharmony_ci`power[1-*]_accuracy`
40662306a36Sopenharmony_ci		Accuracy of the power meter.
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci`power[1-*]_cap`
40962306a36Sopenharmony_ci		If power use rises above this limit, the
41062306a36Sopenharmony_ci		system should take action to reduce power use.
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ci`power[1-*]_cap_hyst`
41362306a36Sopenharmony_ci		Margin of hysteresis built around capping and notification.
41462306a36Sopenharmony_ci
41562306a36Sopenharmony_ci`power[1-*]_cap_max`
41662306a36Sopenharmony_ci		Maximum cap that can be set.
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci`power[1-*]_cap_min`
41962306a36Sopenharmony_ci		Minimum cap that can be set.
42062306a36Sopenharmony_ci
42162306a36Sopenharmony_ci`power[1-*]_max`
42262306a36Sopenharmony_ci		Maximum power.
42362306a36Sopenharmony_ci
42462306a36Sopenharmony_ci`power[1-*]_crit`
42562306a36Sopenharmony_ci				Critical maximum power.
42662306a36Sopenharmony_ci
42762306a36Sopenharmony_ci				If power rises to or above this limit, the
42862306a36Sopenharmony_ci				system is expected take drastic action to reduce
42962306a36Sopenharmony_ci				power consumption, such as a system shutdown or
43062306a36Sopenharmony_ci				a forced powerdown of some devices.
43162306a36Sopenharmony_ci
43262306a36Sopenharmony_ci				Unit: microWatt
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci				RW
43562306a36Sopenharmony_ci
43662306a36Sopenharmony_ci`power[1-*]_enable`
43762306a36Sopenharmony_ci				Enable or disable the sensors.
43862306a36Sopenharmony_ci
43962306a36Sopenharmony_ci				When disabled the sensor read will return
44062306a36Sopenharmony_ci				-ENODATA.
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci				- 1: Enable
44362306a36Sopenharmony_ci				- 0: Disable
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ci				RW
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_ci`power[1-*]_rated_min`
44862306a36Sopenharmony_ci				Minimum rated power.
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci				Unit: microWatt
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_ci				RO
45362306a36Sopenharmony_ci
45462306a36Sopenharmony_ci`power[1-*]_rated_max`
45562306a36Sopenharmony_ci				Maximum rated power.
45662306a36Sopenharmony_ci
45762306a36Sopenharmony_ci				Unit: microWatt
45862306a36Sopenharmony_ci
45962306a36Sopenharmony_ci				RO
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ciAlso see the Alarms section for status flags associated with power readings.
46262306a36Sopenharmony_ci
46362306a36Sopenharmony_ci******
46462306a36Sopenharmony_ciEnergy
46562306a36Sopenharmony_ci******
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ci`energy[1-*]_input`
46862306a36Sopenharmony_ci				Cumulative energy use
46962306a36Sopenharmony_ci
47062306a36Sopenharmony_ci				Unit: microJoule
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_ci				RO
47362306a36Sopenharmony_ci
47462306a36Sopenharmony_ci`energy[1-*]_enable`
47562306a36Sopenharmony_ci				Enable or disable the sensors.
47662306a36Sopenharmony_ci
47762306a36Sopenharmony_ci				When disabled the sensor read will return
47862306a36Sopenharmony_ci				-ENODATA.
47962306a36Sopenharmony_ci
48062306a36Sopenharmony_ci				- 1: Enable
48162306a36Sopenharmony_ci				- 0: Disable
48262306a36Sopenharmony_ci
48362306a36Sopenharmony_ci				RW
48462306a36Sopenharmony_ci
48562306a36Sopenharmony_ci********
48662306a36Sopenharmony_ciHumidity
48762306a36Sopenharmony_ci********
48862306a36Sopenharmony_ci
48962306a36Sopenharmony_ci`humidity[1-*]_input`
49062306a36Sopenharmony_ci		Humidity.
49162306a36Sopenharmony_ci
49262306a36Sopenharmony_ci`humidity[1-*]_enable`
49362306a36Sopenharmony_ci		Enable or disable the sensors.
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_ci`humidity[1-*]_rated_min`
49662306a36Sopenharmony_ci		Minimum rated humidity.
49762306a36Sopenharmony_ci
49862306a36Sopenharmony_ci`humidity[1-*]_rated_max`
49962306a36Sopenharmony_ci		Maximum rated humidity.
50062306a36Sopenharmony_ci
50162306a36Sopenharmony_ci******
50262306a36Sopenharmony_ciAlarms
50362306a36Sopenharmony_ci******
50462306a36Sopenharmony_ci
50562306a36Sopenharmony_ciEach channel or limit may have an associated alarm file, containing a
50662306a36Sopenharmony_ciboolean value. 1 means than an alarm condition exists, 0 means no alarm.
50762306a36Sopenharmony_ci
50862306a36Sopenharmony_ciUsually a given chip will either use channel-related alarms, or
50962306a36Sopenharmony_cilimit-related alarms, not both. The driver should just reflect the hardware
51062306a36Sopenharmony_ciimplementation.
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ci+-------------------------------+-----------------------+
51362306a36Sopenharmony_ci| **`in[0-*]_alarm`,		| Channel alarm		|
51462306a36Sopenharmony_ci| `curr[1-*]_alarm`,		|			|
51562306a36Sopenharmony_ci| `power[1-*]_alarm`,		|   - 0: no alarm	|
51662306a36Sopenharmony_ci| `fan[1-*]_alarm`,		|   - 1: alarm		|
51762306a36Sopenharmony_ci| `temp[1-*]_alarm`**		|			|
51862306a36Sopenharmony_ci|				|   RO			|
51962306a36Sopenharmony_ci+-------------------------------+-----------------------+
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci**OR**
52262306a36Sopenharmony_ci
52362306a36Sopenharmony_ci+-------------------------------+-----------------------+
52462306a36Sopenharmony_ci| **`in[0-*]_min_alarm`,	| Limit alarm		|
52562306a36Sopenharmony_ci| `in[0-*]_max_alarm`,		|			|
52662306a36Sopenharmony_ci| `in[0-*]_lcrit_alarm`,	|   - 0: no alarm	|
52762306a36Sopenharmony_ci| `in[0-*]_crit_alarm`,		|   - 1: alarm		|
52862306a36Sopenharmony_ci| `curr[1-*]_min_alarm`,	|			|
52962306a36Sopenharmony_ci| `curr[1-*]_max_alarm`,	| RO			|
53062306a36Sopenharmony_ci| `curr[1-*]_lcrit_alarm`,	|			|
53162306a36Sopenharmony_ci| `curr[1-*]_crit_alarm`,	|			|
53262306a36Sopenharmony_ci| `power[1-*]_cap_alarm`,	|			|
53362306a36Sopenharmony_ci| `power[1-*]_max_alarm`,	|			|
53462306a36Sopenharmony_ci| `power[1-*]_crit_alarm`,	|			|
53562306a36Sopenharmony_ci| `fan[1-*]_min_alarm`,		|			|
53662306a36Sopenharmony_ci| `fan[1-*]_max_alarm`,		|			|
53762306a36Sopenharmony_ci| `temp[1-*]_min_alarm`,	|			|
53862306a36Sopenharmony_ci| `temp[1-*]_max_alarm`,	|			|
53962306a36Sopenharmony_ci| `temp[1-*]_lcrit_alarm`,	|			|
54062306a36Sopenharmony_ci| `temp[1-*]_crit_alarm`,	|			|
54162306a36Sopenharmony_ci| `temp[1-*]_emergency_alarm`**	|			|
54262306a36Sopenharmony_ci+-------------------------------+-----------------------+
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_ciEach input channel may have an associated fault file. This can be used
54562306a36Sopenharmony_cito notify open diodes, unconnected fans etc. where the hardware
54662306a36Sopenharmony_cisupports it. When this boolean has value 1, the measurement for that
54762306a36Sopenharmony_cichannel should not be trusted.
54862306a36Sopenharmony_ci
54962306a36Sopenharmony_ci`fan[1-*]_fault` / `temp[1-*]_fault`
55062306a36Sopenharmony_ci		Input fault condition.
55162306a36Sopenharmony_ci
55262306a36Sopenharmony_ciSome chips also offer the possibility to get beeped when an alarm occurs:
55362306a36Sopenharmony_ci
55462306a36Sopenharmony_ci`beep_enable`
55562306a36Sopenharmony_ci		Master beep enable.
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_ci`in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`,
55862306a36Sopenharmony_ci		Channel beep.
55962306a36Sopenharmony_ci
56062306a36Sopenharmony_ciIn theory, a chip could provide per-limit beep masking, but no such chip
56162306a36Sopenharmony_ciwas seen so far.
56262306a36Sopenharmony_ci
56362306a36Sopenharmony_ciOld drivers provided a different, non-standard interface to alarms and
56462306a36Sopenharmony_cibeeps. These interface files are deprecated, but will be kept around
56562306a36Sopenharmony_cifor compatibility reasons:
56662306a36Sopenharmony_ci
56762306a36Sopenharmony_ci`alarms`
56862306a36Sopenharmony_ci		Alarm bitmask.
56962306a36Sopenharmony_ci
57062306a36Sopenharmony_ci`beep_mask`
57162306a36Sopenharmony_ci		Bitmask for beep.
57262306a36Sopenharmony_ci
57362306a36Sopenharmony_ci
57462306a36Sopenharmony_ci*******************
57562306a36Sopenharmony_ciIntrusion detection
57662306a36Sopenharmony_ci*******************
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_ci`intrusion[0-*]_alarm`
57962306a36Sopenharmony_ci		Chassis intrusion detection.
58062306a36Sopenharmony_ci
58162306a36Sopenharmony_ci`intrusion[0-*]_beep`
58262306a36Sopenharmony_ci		Chassis intrusion beep.
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_ci****************************
58562306a36Sopenharmony_ciAverage sample configuration
58662306a36Sopenharmony_ci****************************
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ciDevices allowing for reading {in,power,curr,temp}_average values may export
58962306a36Sopenharmony_ciattributes for controlling number of samples used to compute average.
59062306a36Sopenharmony_ci
59162306a36Sopenharmony_ci+--------------+---------------------------------------------------------------+
59262306a36Sopenharmony_ci| samples      | Sets number of average samples for all types of measurements. |
59362306a36Sopenharmony_ci|	       |							       |
59462306a36Sopenharmony_ci|	       | RW							       |
59562306a36Sopenharmony_ci+--------------+---------------------------------------------------------------+
59662306a36Sopenharmony_ci| in_samples   | Sets number of average samples for specific type of	       |
59762306a36Sopenharmony_ci| power_samples| measurements.						       |
59862306a36Sopenharmony_ci| curr_samples |							       |
59962306a36Sopenharmony_ci| temp_samples | Note that on some devices it won't be possible to set all of  |
60062306a36Sopenharmony_ci|	       | them to different values so changing one might also change    |
60162306a36Sopenharmony_ci|	       | some others.						       |
60262306a36Sopenharmony_ci|	       |							       |
60362306a36Sopenharmony_ci|	       | RW							       |
60462306a36Sopenharmony_ci+--------------+---------------------------------------------------------------+
60562306a36Sopenharmony_ci
60662306a36Sopenharmony_cisysfs attribute writes interpretation
60762306a36Sopenharmony_ci-------------------------------------
60862306a36Sopenharmony_ci
60962306a36Sopenharmony_cihwmon sysfs attributes always contain numbers, so the first thing to do is to
61062306a36Sopenharmony_ciconvert the input to a number, there are 2 ways todo this depending whether
61162306a36Sopenharmony_cithe number can be negative or not::
61262306a36Sopenharmony_ci
61362306a36Sopenharmony_ci	unsigned long u = simple_strtoul(buf, NULL, 10);
61462306a36Sopenharmony_ci	long s = simple_strtol(buf, NULL, 10);
61562306a36Sopenharmony_ci
61662306a36Sopenharmony_ciWith buf being the buffer with the user input being passed by the kernel.
61762306a36Sopenharmony_ciNotice that we do not use the second argument of strto[u]l, and thus cannot
61862306a36Sopenharmony_citell when 0 is returned, if this was really 0 or is caused by invalid input.
61962306a36Sopenharmony_ciThis is done deliberately as checking this everywhere would add a lot of
62062306a36Sopenharmony_cicode to the kernel.
62162306a36Sopenharmony_ci
62262306a36Sopenharmony_ciNotice that it is important to always store the converted value in an
62362306a36Sopenharmony_ciunsigned long or long, so that no wrap around can happen before any further
62462306a36Sopenharmony_cichecking.
62562306a36Sopenharmony_ci
62662306a36Sopenharmony_ciAfter the input string is converted to an (unsigned) long, the value should be
62762306a36Sopenharmony_cichecked if its acceptable. Be careful with further conversions on the value
62862306a36Sopenharmony_cibefore checking it for validity, as these conversions could still cause a wrap
62962306a36Sopenharmony_ciaround before the check. For example do not multiply the result, and only
63062306a36Sopenharmony_ciadd/subtract if it has been divided before the add/subtract.
63162306a36Sopenharmony_ci
63262306a36Sopenharmony_ciWhat to do if a value is found to be invalid, depends on the type of the
63362306a36Sopenharmony_cisysfs attribute that is being set. If it is a continuous setting like a
63462306a36Sopenharmony_citempX_max or inX_max attribute, then the value should be clamped to its
63562306a36Sopenharmony_cilimits using clamp_val(value, min_limit, max_limit). If it is not continuous
63662306a36Sopenharmony_cilike for example a tempX_type, then when an invalid value is written,
63762306a36Sopenharmony_ci-EINVAL should be returned.
63862306a36Sopenharmony_ci
63962306a36Sopenharmony_ciExample1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees)::
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci	long v = simple_strtol(buf, NULL, 10) / 1000;
64262306a36Sopenharmony_ci	v = clamp_val(v, -128, 127);
64362306a36Sopenharmony_ci	/* write v to register */
64462306a36Sopenharmony_ci
64562306a36Sopenharmony_ciExample2, fan divider setting, valid values 2, 4 and 8::
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_ci	unsigned long v = simple_strtoul(buf, NULL, 10);
64862306a36Sopenharmony_ci
64962306a36Sopenharmony_ci	switch (v) {
65062306a36Sopenharmony_ci	case 2: v = 1; break;
65162306a36Sopenharmony_ci	case 4: v = 2; break;
65262306a36Sopenharmony_ci	case 8: v = 3; break;
65362306a36Sopenharmony_ci	default:
65462306a36Sopenharmony_ci		return -EINVAL;
65562306a36Sopenharmony_ci	}
65662306a36Sopenharmony_ci	/* write v to register */
657