18c2ecf20Sopenharmony_ciNaming and data format standards for sysfs files
28c2ecf20Sopenharmony_ci================================================
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciThe libsensors library offers an interface to the raw sensors data
58c2ecf20Sopenharmony_cithrough the sysfs interface. Since lm-sensors 3.0.0, libsensors is
68c2ecf20Sopenharmony_cicompletely chip-independent. It assumes that all the kernel drivers
78c2ecf20Sopenharmony_ciimplement the standard sysfs interface described in this document.
88c2ecf20Sopenharmony_ciThis makes adding or updating support for any given chip very easy, as
98c2ecf20Sopenharmony_cilibsensors, and applications using it, do not need to be modified.
108c2ecf20Sopenharmony_ciThis is a major improvement compared to lm-sensors 2.
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciNote that motherboards vary widely in the connections to sensor chips.
138c2ecf20Sopenharmony_ciThere is no standard that ensures, for example, that the second
148c2ecf20Sopenharmony_citemperature sensor is connected to the CPU, or that the second fan is on
158c2ecf20Sopenharmony_cithe CPU. Also, some values reported by the chips need some computation
168c2ecf20Sopenharmony_cibefore they make full sense. For example, most chips can only measure
178c2ecf20Sopenharmony_civoltages between 0 and +4V. Other voltages are scaled back into that
188c2ecf20Sopenharmony_cirange using external resistors. Since the values of these resistors
198c2ecf20Sopenharmony_cican change from motherboard to motherboard, the conversions cannot be
208c2ecf20Sopenharmony_cihard coded into the driver and have to be done in user space.
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciFor this reason, even if we aim at a chip-independent libsensors, it will
238c2ecf20Sopenharmony_cistill require a configuration file (e.g. /etc/sensors.conf) for proper
248c2ecf20Sopenharmony_civalues conversion, labeling of inputs and hiding of unused inputs.
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciAn alternative method that some programs use is to access the sysfs
278c2ecf20Sopenharmony_cifiles directly. This document briefly describes the standards that the
288c2ecf20Sopenharmony_cidrivers follow, so that an application program can scan for entries and
298c2ecf20Sopenharmony_ciaccess this data in a simple and consistent way. That said, such programs
308c2ecf20Sopenharmony_ciwill have to implement conversion, labeling and hiding of inputs. For
318c2ecf20Sopenharmony_cithis reason, it is still not recommended to bypass the library.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciEach chip gets its own directory in the sysfs /sys/devices tree.  To
348c2ecf20Sopenharmony_cifind all sensor chips, it is easier to follow the device symlinks from
358c2ecf20Sopenharmony_ci`/sys/class/hwmon/hwmon*`.
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciUp to lm-sensors 3.0.0, libsensors looks for hardware monitoring attributes
388c2ecf20Sopenharmony_ciin the "physical" device directory. Since lm-sensors 3.0.1, attributes found
398c2ecf20Sopenharmony_ciin the hwmon "class" device directory are also supported. Complex drivers
408c2ecf20Sopenharmony_ci(e.g. drivers for multifunction chips) may want to use this possibility to
418c2ecf20Sopenharmony_ciavoid namespace pollution. The only drawback will be that older versions of
428c2ecf20Sopenharmony_cilibsensors won't support the driver in question.
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ciAll sysfs values are fixed point numbers.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciThere is only one value per file, unlike the older /proc specification.
478c2ecf20Sopenharmony_ciThe common scheme for files naming is: <type><number>_<item>. Usual
488c2ecf20Sopenharmony_citypes for sensor chips are "in" (voltage), "temp" (temperature) and
498c2ecf20Sopenharmony_ci"fan" (fan). Usual items are "input" (measured value), "max" (high
508c2ecf20Sopenharmony_cithreshold, "min" (low threshold). Numbering usually starts from 1,
518c2ecf20Sopenharmony_ciexcept for voltages which start from 0 (because most data sheets use
528c2ecf20Sopenharmony_cithis). A number is always used for elements that can be present more
538c2ecf20Sopenharmony_cithan once, even if there is a single element of the given type on the
548c2ecf20Sopenharmony_cispecific chip. Other files do not refer to a specific element, so
558c2ecf20Sopenharmony_cithey have a simple name, and no number.
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ciAlarms are direct indications read from the chips. The drivers do NOT
588c2ecf20Sopenharmony_cimake comparisons of readings to thresholds. This allows violations
598c2ecf20Sopenharmony_cibetween readings to be caught and alarmed. The exact definition of an
608c2ecf20Sopenharmony_cialarm (for example, whether a threshold must be met or must be exceeded
618c2ecf20Sopenharmony_cito cause an alarm) is chip-dependent.
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ciWhen setting values of hwmon sysfs attributes, the string representation of
648c2ecf20Sopenharmony_cithe desired value must be written, note that strings which are not a number
658c2ecf20Sopenharmony_ciare interpreted as 0! For more on how written strings are interpreted see the
668c2ecf20Sopenharmony_ci"sysfs attribute writes interpretation" section at the end of this file.
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci-------------------------------------------------------------------------
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci======= ===========================================
718c2ecf20Sopenharmony_ci`[0-*]`	denotes any positive number starting from 0
728c2ecf20Sopenharmony_ci`[1-*]`	denotes any positive number starting from 1
738c2ecf20Sopenharmony_ciRO	read only value
748c2ecf20Sopenharmony_ciWO	write only value
758c2ecf20Sopenharmony_ciRW	read/write value
768c2ecf20Sopenharmony_ci======= ===========================================
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciRead/write values may be read-only for some chips, depending on the
798c2ecf20Sopenharmony_cihardware implementation.
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciAll entries (except name) are optional, and should only be created in a
828c2ecf20Sopenharmony_cigiven driver if the chip has the feature.
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci*****************
868c2ecf20Sopenharmony_ciGlobal attributes
878c2ecf20Sopenharmony_ci*****************
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci`name`
908c2ecf20Sopenharmony_ci		The chip name.
918c2ecf20Sopenharmony_ci		This should be a short, lowercase string, not containing
928c2ecf20Sopenharmony_ci		whitespace, dashes, or the wildcard character '*'.
938c2ecf20Sopenharmony_ci		This attribute represents the chip name. It is the only
948c2ecf20Sopenharmony_ci		mandatory attribute.
958c2ecf20Sopenharmony_ci		I2C devices get this attribute created automatically.
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci		RO
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci`update_interval`
1008c2ecf20Sopenharmony_ci		The interval at which the chip will update readings.
1018c2ecf20Sopenharmony_ci		Unit: millisecond
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci		RW
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci		Some devices have a variable update rate or interval.
1068c2ecf20Sopenharmony_ci		This attribute can be used to change it to the desired value.
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci********
1108c2ecf20Sopenharmony_ciVoltages
1118c2ecf20Sopenharmony_ci********
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci`in[0-*]_min`
1148c2ecf20Sopenharmony_ci		Voltage min value.
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci		Unit: millivolt
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci		RW
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci`in[0-*]_lcrit`
1218c2ecf20Sopenharmony_ci		Voltage critical min value.
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci		Unit: millivolt
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci		RW
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci		If voltage drops to or below this limit, the system may
1288c2ecf20Sopenharmony_ci		take drastic action such as power down or reset. At the very
1298c2ecf20Sopenharmony_ci		least, it should report a fault.
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci`in[0-*]_max`
1328c2ecf20Sopenharmony_ci		Voltage max value.
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci		Unit: millivolt
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci		RW
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci`in[0-*]_crit`
1398c2ecf20Sopenharmony_ci		Voltage critical max value.
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci		Unit: millivolt
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci		RW
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci		If voltage reaches or exceeds this limit, the system may
1468c2ecf20Sopenharmony_ci		take drastic action such as power down or reset. At the very
1478c2ecf20Sopenharmony_ci		least, it should report a fault.
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci`in[0-*]_input`
1508c2ecf20Sopenharmony_ci		Voltage input value.
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci		Unit: millivolt
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci		RO
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci		Voltage measured on the chip pin.
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci		Actual voltage depends on the scaling resistors on the
1598c2ecf20Sopenharmony_ci		motherboard, as recommended in the chip datasheet.
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci		This varies by chip and by motherboard.
1628c2ecf20Sopenharmony_ci		Because of this variation, values are generally NOT scaled
1638c2ecf20Sopenharmony_ci		by the chip driver, and must be done by the application.
1648c2ecf20Sopenharmony_ci		However, some drivers (notably lm87 and via686a)
1658c2ecf20Sopenharmony_ci		do scale, because of internal resistors built into a chip.
1668c2ecf20Sopenharmony_ci		These drivers will output the actual voltage. Rule of
1678c2ecf20Sopenharmony_ci		thumb: drivers should report the voltage values at the
1688c2ecf20Sopenharmony_ci		"pins" of the chip.
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci`in[0-*]_average`
1718c2ecf20Sopenharmony_ci		Average voltage
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci		Unit: millivolt
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci		RO
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci`in[0-*]_lowest`
1788c2ecf20Sopenharmony_ci		Historical minimum voltage
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci		Unit: millivolt
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci		RO
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci`in[0-*]_highest`
1858c2ecf20Sopenharmony_ci		Historical maximum voltage
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci		Unit: millivolt
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci		RO
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci`in[0-*]_reset_history`
1928c2ecf20Sopenharmony_ci		Reset inX_lowest and inX_highest
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci		WO
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci`in_reset_history`
1978c2ecf20Sopenharmony_ci		Reset inX_lowest and inX_highest for all sensors
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci		WO
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci`in[0-*]_label`
2028c2ecf20Sopenharmony_ci		Suggested voltage channel label.
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci		Text string
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci		Should only be created if the driver has hints about what
2078c2ecf20Sopenharmony_ci		this voltage channel is being used for, and user-space
2088c2ecf20Sopenharmony_ci		doesn't. In all other cases, the label is provided by
2098c2ecf20Sopenharmony_ci		user-space.
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci		RO
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci`in[0-*]_enable`
2148c2ecf20Sopenharmony_ci		Enable or disable the sensors.
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci		When disabled the sensor read will return -ENODATA.
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci		- 1: Enable
2198c2ecf20Sopenharmony_ci		- 0: Disable
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci		RW
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci`cpu[0-*]_vid`
2248c2ecf20Sopenharmony_ci		CPU core reference voltage.
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci		Unit: millivolt
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci		RO
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci		Not always correct.
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci`vrm`
2338c2ecf20Sopenharmony_ci		Voltage Regulator Module version number.
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci		RW (but changing it should no more be necessary)
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci		Originally the VRM standard version multiplied by 10, but now
2388c2ecf20Sopenharmony_ci		an arbitrary number, as not all standards have a version
2398c2ecf20Sopenharmony_ci		number.
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci		Affects the way the driver calculates the CPU core reference
2428c2ecf20Sopenharmony_ci		voltage from the vid pins.
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci`in[0-*]_rated_min`
2458c2ecf20Sopenharmony_ci		Minimum rated voltage.
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci		Unit: millivolt
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci		RO
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci`in[0-*]_rated_max`
2528c2ecf20Sopenharmony_ci		Maximum rated voltage.
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci		Unit: millivolt
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci		RO
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ciAlso see the Alarms section for status flags associated with voltages.
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci****
2628c2ecf20Sopenharmony_ciFans
2638c2ecf20Sopenharmony_ci****
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci`fan[1-*]_min`
2668c2ecf20Sopenharmony_ci		Fan minimum value
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci		Unit: revolution/min (RPM)
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci		RW
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci`fan[1-*]_max`
2738c2ecf20Sopenharmony_ci		Fan maximum value
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci		Unit: revolution/min (RPM)
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci		Only rarely supported by the hardware.
2788c2ecf20Sopenharmony_ci		RW
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci`fan[1-*]_input`
2818c2ecf20Sopenharmony_ci		Fan input value.
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci		Unit: revolution/min (RPM)
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci		RO
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci`fan[1-*]_div`
2888c2ecf20Sopenharmony_ci		Fan divisor.
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci		Integer value in powers of two (1, 2, 4, 8, 16, 32, 64, 128).
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci		RW
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci		Some chips only support values 1, 2, 4 and 8.
2958c2ecf20Sopenharmony_ci		Note that this is actually an internal clock divisor, which
2968c2ecf20Sopenharmony_ci		affects the measurable speed range, not the read value.
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci`fan[1-*]_pulses`
2998c2ecf20Sopenharmony_ci		Number of tachometer pulses per fan revolution.
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci		Integer value, typically between 1 and 4.
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci		RW
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci		This value is a characteristic of the fan connected to the
3068c2ecf20Sopenharmony_ci		device's input, so it has to be set in accordance with the fan
3078c2ecf20Sopenharmony_ci		model.
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci		Should only be created if the chip has a register to configure
3108c2ecf20Sopenharmony_ci		the number of pulses. In the absence of such a register (and
3118c2ecf20Sopenharmony_ci		thus attribute) the value assumed by all devices is 2 pulses
3128c2ecf20Sopenharmony_ci		per fan revolution.
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci`fan[1-*]_target`
3158c2ecf20Sopenharmony_ci		Desired fan speed
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci		Unit: revolution/min (RPM)
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci		RW
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci		Only makes sense if the chip supports closed-loop fan speed
3228c2ecf20Sopenharmony_ci		control based on the measured fan speed.
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci`fan[1-*]_label`
3258c2ecf20Sopenharmony_ci		Suggested fan channel label.
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci		Text string
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci		Should only be created if the driver has hints about what
3308c2ecf20Sopenharmony_ci		this fan channel is being used for, and user-space doesn't.
3318c2ecf20Sopenharmony_ci		In all other cases, the label is provided by user-space.
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci		RO
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci`fan[1-*]_enable`
3368c2ecf20Sopenharmony_ci		Enable or disable the sensors.
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci		When disabled the sensor read will return -ENODATA.
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci		- 1: Enable
3418c2ecf20Sopenharmony_ci		- 0: Disable
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci		RW
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ciAlso see the Alarms section for status flags associated with fans.
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci***
3498c2ecf20Sopenharmony_ciPWM
3508c2ecf20Sopenharmony_ci***
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci`pwm[1-*]`
3538c2ecf20Sopenharmony_ci		Pulse width modulation fan control.
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci		Integer value in the range 0 to 255
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci		RW
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci		255 is max or 100%.
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci`pwm[1-*]_enable`
3628c2ecf20Sopenharmony_ci		Fan speed control method:
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci		- 0: no fan speed control (i.e. fan at full speed)
3658c2ecf20Sopenharmony_ci		- 1: manual fan speed control enabled (using `pwm[1-*]`)
3668c2ecf20Sopenharmony_ci		- 2+: automatic fan speed control enabled
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci		Check individual chip documentation files for automatic mode
3698c2ecf20Sopenharmony_ci		details.
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci		RW
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci`pwm[1-*]_mode`
3748c2ecf20Sopenharmony_ci		- 0: DC mode (direct current)
3758c2ecf20Sopenharmony_ci		- 1: PWM mode (pulse-width modulation)
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci		RW
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci`pwm[1-*]_freq`
3808c2ecf20Sopenharmony_ci		Base PWM frequency in Hz.
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci		Only possibly available when pwmN_mode is PWM, but not always
3838c2ecf20Sopenharmony_ci		present even then.
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci		RW
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci`pwm[1-*]_auto_channels_temp`
3888c2ecf20Sopenharmony_ci		Select which temperature channels affect this PWM output in
3898c2ecf20Sopenharmony_ci		auto mode.
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci		Bitfield, 1 is temp1, 2 is temp2, 4 is temp3 etc...
3928c2ecf20Sopenharmony_ci		Which values are possible depend on the chip used.
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci		RW
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci`pwm[1-*]_auto_point[1-*]_pwm` / `pwm[1-*]_auto_point[1-*]_temp` / `pwm[1-*]_auto_point[1-*]_temp_hyst`
3978c2ecf20Sopenharmony_ci		Define the PWM vs temperature curve.
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci		Number of trip points is chip-dependent. Use this for chips
4008c2ecf20Sopenharmony_ci		which associate trip points to PWM output channels.
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci		RW
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci`temp[1-*]_auto_point[1-*]_pwm` / `temp[1-*]_auto_point[1-*]_temp` / `temp[1-*]_auto_point[1-*]_temp_hyst`
4058c2ecf20Sopenharmony_ci		Define the PWM vs temperature curve.
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci		Number of trip points is chip-dependent. Use this for chips
4088c2ecf20Sopenharmony_ci		which associate trip points to temperature channels.
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci		RW
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ciThere is a third case where trip points are associated to both PWM output
4138c2ecf20Sopenharmony_cichannels and temperature channels: the PWM values are associated to PWM
4148c2ecf20Sopenharmony_cioutput channels while the temperature values are associated to temperature
4158c2ecf20Sopenharmony_cichannels. In that case, the result is determined by the mapping between
4168c2ecf20Sopenharmony_citemperature inputs and PWM outputs. When several temperature inputs are
4178c2ecf20Sopenharmony_cimapped to a given PWM output, this leads to several candidate PWM values.
4188c2ecf20Sopenharmony_ciThe actual result is up to the chip, but in general the highest candidate
4198c2ecf20Sopenharmony_civalue (fastest fan speed) wins.
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci************
4238c2ecf20Sopenharmony_ciTemperatures
4248c2ecf20Sopenharmony_ci************
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci`temp[1-*]_type`
4278c2ecf20Sopenharmony_ci		Sensor type selection.
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci		Integers 1 to 6
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci		RW
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci		- 1: CPU embedded diode
4348c2ecf20Sopenharmony_ci		- 2: 3904 transistor
4358c2ecf20Sopenharmony_ci		- 3: thermal diode
4368c2ecf20Sopenharmony_ci		- 4: thermistor
4378c2ecf20Sopenharmony_ci		- 5: AMD AMDSI
4388c2ecf20Sopenharmony_ci		- 6: Intel PECI
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci		Not all types are supported by all chips
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci`temp[1-*]_max`
4438c2ecf20Sopenharmony_ci		Temperature max value.
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci		Unit: millidegree Celsius (or millivolt, see below)
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci		RW
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci`temp[1-*]_min`
4508c2ecf20Sopenharmony_ci		Temperature min value.
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci		RW
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci`temp[1-*]_max_hyst`
4578c2ecf20Sopenharmony_ci		Temperature hysteresis value for max limit.
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci		Must be reported as an absolute temperature, NOT a delta
4628c2ecf20Sopenharmony_ci		from the max value.
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci		RW
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci`temp[1-*]_min_hyst`
4678c2ecf20Sopenharmony_ci		Temperature hysteresis value for min limit.
4688c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci		Must be reported as an absolute temperature, NOT a delta
4718c2ecf20Sopenharmony_ci		from the min value.
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci		RW
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci`temp[1-*]_input`
4768c2ecf20Sopenharmony_ci	 Temperature input value.
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci		RO
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_ci`temp[1-*]_crit`
4838c2ecf20Sopenharmony_ci		Temperature critical max value, typically greater than
4848c2ecf20Sopenharmony_ci		corresponding temp_max values.
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci		RW
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ci`temp[1-*]_crit_hyst`
4918c2ecf20Sopenharmony_ci		Temperature hysteresis value for critical limit.
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci		Must be reported as an absolute temperature, NOT a delta
4968c2ecf20Sopenharmony_ci		from the critical value.
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ci		RW
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci`temp[1-*]_emergency`
5018c2ecf20Sopenharmony_ci		Temperature emergency max value, for chips supporting more than
5028c2ecf20Sopenharmony_ci		two upper temperature limits. Must be equal or greater than
5038c2ecf20Sopenharmony_ci		corresponding temp_crit values.
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci		RW
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci`temp[1-*]_emergency_hyst`
5108c2ecf20Sopenharmony_ci		Temperature hysteresis value for emergency limit.
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_ci		Must be reported as an absolute temperature, NOT a delta
5158c2ecf20Sopenharmony_ci		from the emergency value.
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci		RW
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci`temp[1-*]_lcrit`
5208c2ecf20Sopenharmony_ci		Temperature critical min value, typically lower than
5218c2ecf20Sopenharmony_ci		corresponding temp_min values.
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci		RW
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ci`temp[1-*]_lcrit_hyst`
5288c2ecf20Sopenharmony_ci		Temperature hysteresis value for critical min limit.
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci		Must be reported as an absolute temperature, NOT a delta
5338c2ecf20Sopenharmony_ci		from the critical min value.
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci		RW
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci`temp[1-*]_offset`
5388c2ecf20Sopenharmony_ci		Temperature offset which is added to the temperature reading
5398c2ecf20Sopenharmony_ci		by the chip.
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci		Read/Write value.
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci`temp[1-*]_label`
5468c2ecf20Sopenharmony_ci		Suggested temperature channel label.
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci		Text string
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ci		Should only be created if the driver has hints about what
5518c2ecf20Sopenharmony_ci		this temperature channel is being used for, and user-space
5528c2ecf20Sopenharmony_ci		doesn't. In all other cases, the label is provided by
5538c2ecf20Sopenharmony_ci		user-space.
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci		RO
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci`temp[1-*]_lowest`
5588c2ecf20Sopenharmony_ci		Historical minimum temperature
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci		RO
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci`temp[1-*]_highest`
5658c2ecf20Sopenharmony_ci		Historical maximum temperature
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci		RO
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci`temp[1-*]_reset_history`
5728c2ecf20Sopenharmony_ci		Reset temp_lowest and temp_highest
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci		WO
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci`temp_reset_history`
5778c2ecf20Sopenharmony_ci		Reset temp_lowest and temp_highest for all sensors
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci		WO
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci`temp[1-*]_enable`
5828c2ecf20Sopenharmony_ci		Enable or disable the sensors.
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci		When disabled the sensor read will return -ENODATA.
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci		- 1: Enable
5878c2ecf20Sopenharmony_ci		- 0: Disable
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci		RW
5908c2ecf20Sopenharmony_ci
5918c2ecf20Sopenharmony_ci`temp[1-*]_rated_min`
5928c2ecf20Sopenharmony_ci		Minimum rated temperature.
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci		RO
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci`temp[1-*]_rated_max`
5998c2ecf20Sopenharmony_ci		Maximum rated temperature.
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci		Unit: millidegree Celsius
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci		RO
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ciSome chips measure temperature using external thermistors and an ADC, and
6068c2ecf20Sopenharmony_cireport the temperature measurement as a voltage. Converting this voltage
6078c2ecf20Sopenharmony_ciback to a temperature (or the other way around for limits) requires
6088c2ecf20Sopenharmony_cimathematical functions not available in the kernel, so the conversion
6098c2ecf20Sopenharmony_cimust occur in user space. For these chips, all temp* files described
6108c2ecf20Sopenharmony_ciabove should contain values expressed in millivolt instead of millidegree
6118c2ecf20Sopenharmony_ciCelsius. In other words, such temperature channels are handled as voltage
6128c2ecf20Sopenharmony_cichannels by the driver.
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ciAlso see the Alarms section for status flags associated with temperatures.
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci********
6188c2ecf20Sopenharmony_ciCurrents
6198c2ecf20Sopenharmony_ci********
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci`curr[1-*]_max`
6228c2ecf20Sopenharmony_ci		Current max value
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci		Unit: milliampere
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci		RW
6278c2ecf20Sopenharmony_ci
6288c2ecf20Sopenharmony_ci`curr[1-*]_min`
6298c2ecf20Sopenharmony_ci		Current min value.
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci		Unit: milliampere
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_ci		RW
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci`curr[1-*]_lcrit`
6368c2ecf20Sopenharmony_ci		Current critical low value
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci		Unit: milliampere
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci		RW
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ci`curr[1-*]_crit`
6438c2ecf20Sopenharmony_ci		Current critical high value.
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_ci		Unit: milliampere
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci		RW
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci`curr[1-*]_input`
6508c2ecf20Sopenharmony_ci		Current input value
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci		Unit: milliampere
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci		RO
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci`curr[1-*]_average`
6578c2ecf20Sopenharmony_ci		Average current use
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_ci		Unit: milliampere
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci		RO
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci`curr[1-*]_lowest`
6648c2ecf20Sopenharmony_ci		Historical minimum current
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_ci		Unit: milliampere
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ci		RO
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci`curr[1-*]_highest`
6718c2ecf20Sopenharmony_ci		Historical maximum current
6728c2ecf20Sopenharmony_ci		Unit: milliampere
6738c2ecf20Sopenharmony_ci		RO
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci`curr[1-*]_reset_history`
6768c2ecf20Sopenharmony_ci		Reset currX_lowest and currX_highest
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_ci		WO
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci`curr_reset_history`
6818c2ecf20Sopenharmony_ci		Reset currX_lowest and currX_highest for all sensors
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci		WO
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci`curr[1-*]_enable`
6868c2ecf20Sopenharmony_ci		Enable or disable the sensors.
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_ci		When disabled the sensor read will return -ENODATA.
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci		- 1: Enable
6918c2ecf20Sopenharmony_ci		- 0: Disable
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci		RW
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_ci`curr[1-*]_rated_min`
6968c2ecf20Sopenharmony_ci		Minimum rated current.
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci		Unit: milliampere
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci		RO
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci`curr[1-*]_rated_max`
7038c2ecf20Sopenharmony_ci		Maximum rated current.
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci		Unit: milliampere
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ci		RO
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_ciAlso see the Alarms section for status flags associated with currents.
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ci*****
7128c2ecf20Sopenharmony_ciPower
7138c2ecf20Sopenharmony_ci*****
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci`power[1-*]_average`
7168c2ecf20Sopenharmony_ci				Average power use
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ci				Unit: microWatt
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci				RO
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_ci`power[1-*]_average_interval`
7238c2ecf20Sopenharmony_ci				Power use averaging interval.  A poll
7248c2ecf20Sopenharmony_ci				notification is sent to this file if the
7258c2ecf20Sopenharmony_ci				hardware changes the averaging interval.
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci				Unit: milliseconds
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_ci				RW
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci`power[1-*]_average_interval_max`
7328c2ecf20Sopenharmony_ci				Maximum power use averaging interval
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci				Unit: milliseconds
7358c2ecf20Sopenharmony_ci
7368c2ecf20Sopenharmony_ci				RO
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci`power[1-*]_average_interval_min`
7398c2ecf20Sopenharmony_ci				Minimum power use averaging interval
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci				Unit: milliseconds
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ci				RO
7448c2ecf20Sopenharmony_ci
7458c2ecf20Sopenharmony_ci`power[1-*]_average_highest`
7468c2ecf20Sopenharmony_ci				Historical average maximum power use
7478c2ecf20Sopenharmony_ci
7488c2ecf20Sopenharmony_ci				Unit: microWatt
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_ci				RO
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci`power[1-*]_average_lowest`
7538c2ecf20Sopenharmony_ci				Historical average minimum power use
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_ci				Unit: microWatt
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_ci				RO
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci`power[1-*]_average_max`
7608c2ecf20Sopenharmony_ci				A poll notification is sent to
7618c2ecf20Sopenharmony_ci				`power[1-*]_average` when power use
7628c2ecf20Sopenharmony_ci				rises above this value.
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci				Unit: microWatt
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci				RW
7678c2ecf20Sopenharmony_ci
7688c2ecf20Sopenharmony_ci`power[1-*]_average_min`
7698c2ecf20Sopenharmony_ci				A poll notification is sent to
7708c2ecf20Sopenharmony_ci				`power[1-*]_average` when power use
7718c2ecf20Sopenharmony_ci				sinks below this value.
7728c2ecf20Sopenharmony_ci
7738c2ecf20Sopenharmony_ci				Unit: microWatt
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ci				RW
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci`power[1-*]_input`
7788c2ecf20Sopenharmony_ci				Instantaneous power use
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_ci				Unit: microWatt
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci				RO
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci`power[1-*]_input_highest`
7858c2ecf20Sopenharmony_ci				Historical maximum power use
7868c2ecf20Sopenharmony_ci
7878c2ecf20Sopenharmony_ci				Unit: microWatt
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci				RO
7908c2ecf20Sopenharmony_ci
7918c2ecf20Sopenharmony_ci`power[1-*]_input_lowest`
7928c2ecf20Sopenharmony_ci				Historical minimum power use
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci				Unit: microWatt
7958c2ecf20Sopenharmony_ci
7968c2ecf20Sopenharmony_ci				RO
7978c2ecf20Sopenharmony_ci
7988c2ecf20Sopenharmony_ci`power[1-*]_reset_history`
7998c2ecf20Sopenharmony_ci				Reset input_highest, input_lowest,
8008c2ecf20Sopenharmony_ci				average_highest and average_lowest.
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_ci				WO
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ci`power[1-*]_accuracy`
8058c2ecf20Sopenharmony_ci				Accuracy of the power meter.
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ci				Unit: Percent
8088c2ecf20Sopenharmony_ci
8098c2ecf20Sopenharmony_ci				RO
8108c2ecf20Sopenharmony_ci
8118c2ecf20Sopenharmony_ci`power[1-*]_cap`
8128c2ecf20Sopenharmony_ci				If power use rises above this limit, the
8138c2ecf20Sopenharmony_ci				system should take action to reduce power use.
8148c2ecf20Sopenharmony_ci				A poll notification is sent to this file if the
8158c2ecf20Sopenharmony_ci				cap is changed by the hardware.  The `*_cap`
8168c2ecf20Sopenharmony_ci				files only appear if the cap is known to be
8178c2ecf20Sopenharmony_ci				enforced by hardware.
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci				Unit: microWatt
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_ci				RW
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci`power[1-*]_cap_hyst`
8248c2ecf20Sopenharmony_ci				Margin of hysteresis built around capping and
8258c2ecf20Sopenharmony_ci				notification.
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ci				Unit: microWatt
8288c2ecf20Sopenharmony_ci
8298c2ecf20Sopenharmony_ci				RW
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci`power[1-*]_cap_max`
8328c2ecf20Sopenharmony_ci				Maximum cap that can be set.
8338c2ecf20Sopenharmony_ci
8348c2ecf20Sopenharmony_ci				Unit: microWatt
8358c2ecf20Sopenharmony_ci
8368c2ecf20Sopenharmony_ci				RO
8378c2ecf20Sopenharmony_ci
8388c2ecf20Sopenharmony_ci`power[1-*]_cap_min`
8398c2ecf20Sopenharmony_ci				Minimum cap that can be set.
8408c2ecf20Sopenharmony_ci
8418c2ecf20Sopenharmony_ci				Unit: microWatt
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ci				RO
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_ci`power[1-*]_max`
8468c2ecf20Sopenharmony_ci				Maximum power.
8478c2ecf20Sopenharmony_ci
8488c2ecf20Sopenharmony_ci				Unit: microWatt
8498c2ecf20Sopenharmony_ci
8508c2ecf20Sopenharmony_ci				RW
8518c2ecf20Sopenharmony_ci
8528c2ecf20Sopenharmony_ci`power[1-*]_crit`
8538c2ecf20Sopenharmony_ci				Critical maximum power.
8548c2ecf20Sopenharmony_ci
8558c2ecf20Sopenharmony_ci				If power rises to or above this limit, the
8568c2ecf20Sopenharmony_ci				system is expected take drastic action to reduce
8578c2ecf20Sopenharmony_ci				power consumption, such as a system shutdown or
8588c2ecf20Sopenharmony_ci				a forced powerdown of some devices.
8598c2ecf20Sopenharmony_ci
8608c2ecf20Sopenharmony_ci				Unit: microWatt
8618c2ecf20Sopenharmony_ci
8628c2ecf20Sopenharmony_ci				RW
8638c2ecf20Sopenharmony_ci
8648c2ecf20Sopenharmony_ci`power[1-*]_enable`
8658c2ecf20Sopenharmony_ci				Enable or disable the sensors.
8668c2ecf20Sopenharmony_ci
8678c2ecf20Sopenharmony_ci				When disabled the sensor read will return
8688c2ecf20Sopenharmony_ci				-ENODATA.
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_ci				- 1: Enable
8718c2ecf20Sopenharmony_ci				- 0: Disable
8728c2ecf20Sopenharmony_ci
8738c2ecf20Sopenharmony_ci				RW
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci`power[1-*]_rated_min`
8768c2ecf20Sopenharmony_ci				Minimum rated power.
8778c2ecf20Sopenharmony_ci
8788c2ecf20Sopenharmony_ci				Unit: microWatt
8798c2ecf20Sopenharmony_ci
8808c2ecf20Sopenharmony_ci				RO
8818c2ecf20Sopenharmony_ci
8828c2ecf20Sopenharmony_ci`power[1-*]_rated_max`
8838c2ecf20Sopenharmony_ci				Maximum rated power.
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_ci				Unit: microWatt
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci				RO
8888c2ecf20Sopenharmony_ci
8898c2ecf20Sopenharmony_ciAlso see the Alarms section for status flags associated with power readings.
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci******
8928c2ecf20Sopenharmony_ciEnergy
8938c2ecf20Sopenharmony_ci******
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_ci`energy[1-*]_input`
8968c2ecf20Sopenharmony_ci				Cumulative energy use
8978c2ecf20Sopenharmony_ci
8988c2ecf20Sopenharmony_ci				Unit: microJoule
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_ci				RO
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_ci`energy[1-*]_enable`
9038c2ecf20Sopenharmony_ci				Enable or disable the sensors.
9048c2ecf20Sopenharmony_ci
9058c2ecf20Sopenharmony_ci				When disabled the sensor read will return
9068c2ecf20Sopenharmony_ci				-ENODATA.
9078c2ecf20Sopenharmony_ci
9088c2ecf20Sopenharmony_ci				- 1: Enable
9098c2ecf20Sopenharmony_ci				- 0: Disable
9108c2ecf20Sopenharmony_ci
9118c2ecf20Sopenharmony_ci				RW
9128c2ecf20Sopenharmony_ci
9138c2ecf20Sopenharmony_ci********
9148c2ecf20Sopenharmony_ciHumidity
9158c2ecf20Sopenharmony_ci********
9168c2ecf20Sopenharmony_ci
9178c2ecf20Sopenharmony_ci`humidity[1-*]_input`
9188c2ecf20Sopenharmony_ci				Humidity
9198c2ecf20Sopenharmony_ci
9208c2ecf20Sopenharmony_ci				Unit: milli-percent (per cent mille, pcm)
9218c2ecf20Sopenharmony_ci
9228c2ecf20Sopenharmony_ci				RO
9238c2ecf20Sopenharmony_ci
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ci`humidity[1-*]_enable`
9268c2ecf20Sopenharmony_ci				Enable or disable the sensors
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_ci				When disabled the sensor read will return
9298c2ecf20Sopenharmony_ci				-ENODATA.
9308c2ecf20Sopenharmony_ci
9318c2ecf20Sopenharmony_ci				- 1: Enable
9328c2ecf20Sopenharmony_ci				- 0: Disable
9338c2ecf20Sopenharmony_ci
9348c2ecf20Sopenharmony_ci				RW
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_ci`humidity[1-*]_rated_min`
9378c2ecf20Sopenharmony_ci				Minimum rated humidity.
9388c2ecf20Sopenharmony_ci
9398c2ecf20Sopenharmony_ci				Unit: milli-percent (per cent mille, pcm)
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_ci				RO
9428c2ecf20Sopenharmony_ci
9438c2ecf20Sopenharmony_ci`humidity[1-*]_rated_max`
9448c2ecf20Sopenharmony_ci				Maximum rated humidity.
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_ci				Unit: milli-percent (per cent mille, pcm)
9478c2ecf20Sopenharmony_ci
9488c2ecf20Sopenharmony_ci				RO
9498c2ecf20Sopenharmony_ci
9508c2ecf20Sopenharmony_ci******
9518c2ecf20Sopenharmony_ciAlarms
9528c2ecf20Sopenharmony_ci******
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_ciEach channel or limit may have an associated alarm file, containing a
9558c2ecf20Sopenharmony_ciboolean value. 1 means than an alarm condition exists, 0 means no alarm.
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_ciUsually a given chip will either use channel-related alarms, or
9588c2ecf20Sopenharmony_cilimit-related alarms, not both. The driver should just reflect the hardware
9598c2ecf20Sopenharmony_ciimplementation.
9608c2ecf20Sopenharmony_ci
9618c2ecf20Sopenharmony_ci+-------------------------------+-----------------------+
9628c2ecf20Sopenharmony_ci| **`in[0-*]_alarm`,		| Channel alarm		|
9638c2ecf20Sopenharmony_ci| `curr[1-*]_alarm`,		|			|
9648c2ecf20Sopenharmony_ci| `power[1-*]_alarm`,		|   - 0: no alarm	|
9658c2ecf20Sopenharmony_ci| `fan[1-*]_alarm`,		|   - 1: alarm		|
9668c2ecf20Sopenharmony_ci| `temp[1-*]_alarm`**		|			|
9678c2ecf20Sopenharmony_ci|				|   RO			|
9688c2ecf20Sopenharmony_ci+-------------------------------+-----------------------+
9698c2ecf20Sopenharmony_ci
9708c2ecf20Sopenharmony_ci**OR**
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci+-------------------------------+-----------------------+
9738c2ecf20Sopenharmony_ci| **`in[0-*]_min_alarm`,	| Limit alarm		|
9748c2ecf20Sopenharmony_ci| `in[0-*]_max_alarm`,		|			|
9758c2ecf20Sopenharmony_ci| `in[0-*]_lcrit_alarm`,	|   - 0: no alarm	|
9768c2ecf20Sopenharmony_ci| `in[0-*]_crit_alarm`,		|   - 1: alarm		|
9778c2ecf20Sopenharmony_ci| `curr[1-*]_min_alarm`,	|			|
9788c2ecf20Sopenharmony_ci| `curr[1-*]_max_alarm`,	| RO			|
9798c2ecf20Sopenharmony_ci| `curr[1-*]_lcrit_alarm`,	|			|
9808c2ecf20Sopenharmony_ci| `curr[1-*]_crit_alarm`,	|			|
9818c2ecf20Sopenharmony_ci| `power[1-*]_cap_alarm`,	|			|
9828c2ecf20Sopenharmony_ci| `power[1-*]_max_alarm`,	|			|
9838c2ecf20Sopenharmony_ci| `power[1-*]_crit_alarm`,	|			|
9848c2ecf20Sopenharmony_ci| `fan[1-*]_min_alarm`,		|			|
9858c2ecf20Sopenharmony_ci| `fan[1-*]_max_alarm`,		|			|
9868c2ecf20Sopenharmony_ci| `temp[1-*]_min_alarm`,	|			|
9878c2ecf20Sopenharmony_ci| `temp[1-*]_max_alarm`,	|			|
9888c2ecf20Sopenharmony_ci| `temp[1-*]_lcrit_alarm`,	|			|
9898c2ecf20Sopenharmony_ci| `temp[1-*]_crit_alarm`,	|			|
9908c2ecf20Sopenharmony_ci| `temp[1-*]_emergency_alarm`**	|			|
9918c2ecf20Sopenharmony_ci+-------------------------------+-----------------------+
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_ciEach input channel may have an associated fault file. This can be used
9948c2ecf20Sopenharmony_cito notify open diodes, unconnected fans etc. where the hardware
9958c2ecf20Sopenharmony_cisupports it. When this boolean has value 1, the measurement for that
9968c2ecf20Sopenharmony_cichannel should not be trusted.
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_ci`fan[1-*]_fault` / `temp[1-*]_fault`
9998c2ecf20Sopenharmony_ci		Input fault condition
10008c2ecf20Sopenharmony_ci
10018c2ecf20Sopenharmony_ci		- 0: no fault occurred
10028c2ecf20Sopenharmony_ci		- 1: fault condition
10038c2ecf20Sopenharmony_ci
10048c2ecf20Sopenharmony_ci		RO
10058c2ecf20Sopenharmony_ci
10068c2ecf20Sopenharmony_ciSome chips also offer the possibility to get beeped when an alarm occurs:
10078c2ecf20Sopenharmony_ci
10088c2ecf20Sopenharmony_ci`beep_enable`
10098c2ecf20Sopenharmony_ci		Master beep enable
10108c2ecf20Sopenharmony_ci
10118c2ecf20Sopenharmony_ci		- 0: no beeps
10128c2ecf20Sopenharmony_ci		- 1: beeps
10138c2ecf20Sopenharmony_ci
10148c2ecf20Sopenharmony_ci		RW
10158c2ecf20Sopenharmony_ci
10168c2ecf20Sopenharmony_ci`in[0-*]_beep`, `curr[1-*]_beep`, `fan[1-*]_beep`, `temp[1-*]_beep`,
10178c2ecf20Sopenharmony_ci		Channel beep
10188c2ecf20Sopenharmony_ci
10198c2ecf20Sopenharmony_ci		- 0: disable
10208c2ecf20Sopenharmony_ci		- 1: enable
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_ci		RW
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_ciIn theory, a chip could provide per-limit beep masking, but no such chip
10258c2ecf20Sopenharmony_ciwas seen so far.
10268c2ecf20Sopenharmony_ci
10278c2ecf20Sopenharmony_ciOld drivers provided a different, non-standard interface to alarms and
10288c2ecf20Sopenharmony_cibeeps. These interface files are deprecated, but will be kept around
10298c2ecf20Sopenharmony_cifor compatibility reasons:
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_ci`alarms`
10328c2ecf20Sopenharmony_ci		Alarm bitmask.
10338c2ecf20Sopenharmony_ci
10348c2ecf20Sopenharmony_ci		RO
10358c2ecf20Sopenharmony_ci
10368c2ecf20Sopenharmony_ci		Integer representation of one to four bytes.
10378c2ecf20Sopenharmony_ci
10388c2ecf20Sopenharmony_ci		A '1' bit means an alarm.
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_ci		Chips should be programmed for 'comparator' mode so that
10418c2ecf20Sopenharmony_ci		the alarm will 'come back' after you read the register
10428c2ecf20Sopenharmony_ci		if it is still valid.
10438c2ecf20Sopenharmony_ci
10448c2ecf20Sopenharmony_ci		Generally a direct representation of a chip's internal
10458c2ecf20Sopenharmony_ci		alarm registers; there is no standard for the position
10468c2ecf20Sopenharmony_ci		of individual bits. For this reason, the use of this
10478c2ecf20Sopenharmony_ci		interface file for new drivers is discouraged. Use
10488c2ecf20Sopenharmony_ci		`individual *_alarm` and `*_fault` files instead.
10498c2ecf20Sopenharmony_ci		Bits are defined in kernel/include/sensors.h.
10508c2ecf20Sopenharmony_ci
10518c2ecf20Sopenharmony_ci`beep_mask`
10528c2ecf20Sopenharmony_ci		Bitmask for beep.
10538c2ecf20Sopenharmony_ci		Same format as 'alarms' with the same bit locations,
10548c2ecf20Sopenharmony_ci		use discouraged for the same reason. Use individual
10558c2ecf20Sopenharmony_ci		`*_beep` files instead.
10568c2ecf20Sopenharmony_ci		RW
10578c2ecf20Sopenharmony_ci
10588c2ecf20Sopenharmony_ci
10598c2ecf20Sopenharmony_ci*******************
10608c2ecf20Sopenharmony_ciIntrusion detection
10618c2ecf20Sopenharmony_ci*******************
10628c2ecf20Sopenharmony_ci
10638c2ecf20Sopenharmony_ci`intrusion[0-*]_alarm`
10648c2ecf20Sopenharmony_ci		Chassis intrusion detection
10658c2ecf20Sopenharmony_ci
10668c2ecf20Sopenharmony_ci		- 0: OK
10678c2ecf20Sopenharmony_ci		- 1: intrusion detected
10688c2ecf20Sopenharmony_ci
10698c2ecf20Sopenharmony_ci		RW
10708c2ecf20Sopenharmony_ci
10718c2ecf20Sopenharmony_ci		Contrary to regular alarm flags which clear themselves
10728c2ecf20Sopenharmony_ci		automatically when read, this one sticks until cleared by
10738c2ecf20Sopenharmony_ci		the user. This is done by writing 0 to the file. Writing
10748c2ecf20Sopenharmony_ci		other values is unsupported.
10758c2ecf20Sopenharmony_ci
10768c2ecf20Sopenharmony_ci`intrusion[0-*]_beep`
10778c2ecf20Sopenharmony_ci		Chassis intrusion beep
10788c2ecf20Sopenharmony_ci
10798c2ecf20Sopenharmony_ci		0: disable
10808c2ecf20Sopenharmony_ci		1: enable
10818c2ecf20Sopenharmony_ci
10828c2ecf20Sopenharmony_ci		RW
10838c2ecf20Sopenharmony_ci
10848c2ecf20Sopenharmony_ci****************************
10858c2ecf20Sopenharmony_ciAverage sample configuration
10868c2ecf20Sopenharmony_ci****************************
10878c2ecf20Sopenharmony_ci
10888c2ecf20Sopenharmony_ciDevices allowing for reading {in,power,curr,temp}_average values may export
10898c2ecf20Sopenharmony_ciattributes for controlling number of samples used to compute average.
10908c2ecf20Sopenharmony_ci
10918c2ecf20Sopenharmony_ci+--------------+---------------------------------------------------------------+
10928c2ecf20Sopenharmony_ci| samples      | Sets number of average samples for all types of measurements. |
10938c2ecf20Sopenharmony_ci|	       |							       |
10948c2ecf20Sopenharmony_ci|	       | RW							       |
10958c2ecf20Sopenharmony_ci+--------------+---------------------------------------------------------------+
10968c2ecf20Sopenharmony_ci| in_samples   | Sets number of average samples for specific type of	       |
10978c2ecf20Sopenharmony_ci| power_samples| measurements.						       |
10988c2ecf20Sopenharmony_ci| curr_samples |							       |
10998c2ecf20Sopenharmony_ci| temp_samples | Note that on some devices it won't be possible to set all of  |
11008c2ecf20Sopenharmony_ci|	       | them to different values so changing one might also change    |
11018c2ecf20Sopenharmony_ci|	       | some others.						       |
11028c2ecf20Sopenharmony_ci|	       |							       |
11038c2ecf20Sopenharmony_ci|	       | RW							       |
11048c2ecf20Sopenharmony_ci+--------------+---------------------------------------------------------------+
11058c2ecf20Sopenharmony_ci
11068c2ecf20Sopenharmony_cisysfs attribute writes interpretation
11078c2ecf20Sopenharmony_ci-------------------------------------
11088c2ecf20Sopenharmony_ci
11098c2ecf20Sopenharmony_cihwmon sysfs attributes always contain numbers, so the first thing to do is to
11108c2ecf20Sopenharmony_ciconvert the input to a number, there are 2 ways todo this depending whether
11118c2ecf20Sopenharmony_cithe number can be negative or not::
11128c2ecf20Sopenharmony_ci
11138c2ecf20Sopenharmony_ci	unsigned long u = simple_strtoul(buf, NULL, 10);
11148c2ecf20Sopenharmony_ci	long s = simple_strtol(buf, NULL, 10);
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_ciWith buf being the buffer with the user input being passed by the kernel.
11178c2ecf20Sopenharmony_ciNotice that we do not use the second argument of strto[u]l, and thus cannot
11188c2ecf20Sopenharmony_citell when 0 is returned, if this was really 0 or is caused by invalid input.
11198c2ecf20Sopenharmony_ciThis is done deliberately as checking this everywhere would add a lot of
11208c2ecf20Sopenharmony_cicode to the kernel.
11218c2ecf20Sopenharmony_ci
11228c2ecf20Sopenharmony_ciNotice that it is important to always store the converted value in an
11238c2ecf20Sopenharmony_ciunsigned long or long, so that no wrap around can happen before any further
11248c2ecf20Sopenharmony_cichecking.
11258c2ecf20Sopenharmony_ci
11268c2ecf20Sopenharmony_ciAfter the input string is converted to an (unsigned) long, the value should be
11278c2ecf20Sopenharmony_cichecked if its acceptable. Be careful with further conversions on the value
11288c2ecf20Sopenharmony_cibefore checking it for validity, as these conversions could still cause a wrap
11298c2ecf20Sopenharmony_ciaround before the check. For example do not multiply the result, and only
11308c2ecf20Sopenharmony_ciadd/subtract if it has been divided before the add/subtract.
11318c2ecf20Sopenharmony_ci
11328c2ecf20Sopenharmony_ciWhat to do if a value is found to be invalid, depends on the type of the
11338c2ecf20Sopenharmony_cisysfs attribute that is being set. If it is a continuous setting like a
11348c2ecf20Sopenharmony_citempX_max or inX_max attribute, then the value should be clamped to its
11358c2ecf20Sopenharmony_cilimits using clamp_val(value, min_limit, max_limit). If it is not continuous
11368c2ecf20Sopenharmony_cilike for example a tempX_type, then when an invalid value is written,
11378c2ecf20Sopenharmony_ci-EINVAL should be returned.
11388c2ecf20Sopenharmony_ci
11398c2ecf20Sopenharmony_ciExample1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees)::
11408c2ecf20Sopenharmony_ci
11418c2ecf20Sopenharmony_ci	long v = simple_strtol(buf, NULL, 10) / 1000;
11428c2ecf20Sopenharmony_ci	v = clamp_val(v, -128, 127);
11438c2ecf20Sopenharmony_ci	/* write v to register */
11448c2ecf20Sopenharmony_ci
11458c2ecf20Sopenharmony_ciExample2, fan divider setting, valid values 2, 4 and 8::
11468c2ecf20Sopenharmony_ci
11478c2ecf20Sopenharmony_ci	unsigned long v = simple_strtoul(buf, NULL, 10);
11488c2ecf20Sopenharmony_ci
11498c2ecf20Sopenharmony_ci	switch (v) {
11508c2ecf20Sopenharmony_ci	case 2: v = 1; break;
11518c2ecf20Sopenharmony_ci	case 4: v = 2; break;
11528c2ecf20Sopenharmony_ci	case 8: v = 3; break;
11538c2ecf20Sopenharmony_ci	default:
11548c2ecf20Sopenharmony_ci		return -EINVAL;
11558c2ecf20Sopenharmony_ci	}
11568c2ecf20Sopenharmony_ci	/* write v to register */
1157