2 hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring
4 This file declares helper functions for the sysfs class "hwmon",
5 for use by sensors drivers.
7 Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
17 #include <linux/bitops.h>
20 struct attribute_group
;
22 enum hwmon_sensor_types
{
31 enum hwmon_chip_attributes
{
32 hwmon_chip_temp_reset_history
,
33 hwmon_chip_in_reset_history
,
34 hwmon_chip_curr_reset_history
,
35 hwmon_chip_register_tz
,
36 hwmon_chip_update_interval
,
40 #define HWMON_C_TEMP_RESET_HISTORY BIT(hwmon_chip_temp_reset_history)
41 #define HWMON_C_IN_RESET_HISTORY BIT(hwmon_chip_in_reset_history)
42 #define HWMON_C_CURR_RESET_HISTORY BIT(hwmon_chip_curr_reset_history)
43 #define HWMON_C_REGISTER_TZ BIT(hwmon_chip_register_tz)
44 #define HWMON_C_UPDATE_INTERVAL BIT(hwmon_chip_update_interval)
45 #define HWMON_C_ALARMS BIT(hwmon_chip_alarms)
47 enum hwmon_temp_attributes
{
51 hwmon_temp_lcrit_hyst
,
59 hwmon_temp_emergency_hyst
,
61 hwmon_temp_lcrit_alarm
,
64 hwmon_temp_crit_alarm
,
65 hwmon_temp_emergency_alarm
,
71 hwmon_temp_reset_history
,
74 #define HWMON_T_INPUT BIT(hwmon_temp_input)
75 #define HWMON_T_TYPE BIT(hwmon_temp_type)
76 #define HWMON_T_LCRIT BIT(hwmon_temp_lcrit)
77 #define HWMON_T_LCRIT_HYST BIT(hwmon_temp_lcrit_hyst)
78 #define HWMON_T_MIN BIT(hwmon_temp_min)
79 #define HWMON_T_MIN_HYST BIT(hwmon_temp_min_hyst)
80 #define HWMON_T_MAX BIT(hwmon_temp_max)
81 #define HWMON_T_MAX_HYST BIT(hwmon_temp_max_hyst)
82 #define HWMON_T_CRIT BIT(hwmon_temp_crit)
83 #define HWMON_T_CRIT_HYST BIT(hwmon_temp_crit_hyst)
84 #define HWMON_T_EMERGENCY BIT(hwmon_temp_emergency)
85 #define HWMON_T_EMERGENCY_HYST BIT(hwmon_temp_emergency_hyst)
86 #define HWMON_T_MIN_ALARM BIT(hwmon_temp_min_alarm)
87 #define HWMON_T_MAX_ALARM BIT(hwmon_temp_max_alarm)
88 #define HWMON_T_CRIT_ALARM BIT(hwmon_temp_crit_alarm)
89 #define HWMON_T_EMERGENCY_ALARM BIT(hwmon_temp_emergency_alarm)
90 #define HWMON_T_FAULT BIT(hwmon_temp_fault)
91 #define HWMON_T_OFFSET BIT(hwmon_temp_offset)
92 #define HWMON_T_LABEL BIT(hwmon_temp_label)
93 #define HWMON_T_LOWEST BIT(hwmon_temp_lowest)
94 #define HWMON_T_HIGHEST BIT(hwmon_temp_highest)
95 #define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history)
97 enum hwmon_in_attributes
{
106 hwmon_in_reset_history
,
111 hwmon_in_lcrit_alarm
,
115 #define HWMON_I_INPUT BIT(hwmon_in_input)
116 #define HWMON_I_MIN BIT(hwmon_in_min)
117 #define HWMON_I_MAX BIT(hwmon_in_max)
118 #define HWMON_I_LCRIT BIT(hwmon_in_lcrit)
119 #define HWMON_I_CRIT BIT(hwmon_in_crit)
120 #define HWMON_I_AVERAGE BIT(hwmon_in_average)
121 #define HWMON_I_LOWEST BIT(hwmon_in_lowest)
122 #define HWMON_I_HIGHEST BIT(hwmon_in_highest)
123 #define HWMON_I_RESET_HISTORY BIT(hwmon_in_reset_history)
124 #define HWMON_I_LABEL BIT(hwmon_in_label)
125 #define HWMON_I_ALARM BIT(hwmon_in_alarm)
126 #define HWMON_I_MIN_ALARM BIT(hwmon_in_min_alarm)
127 #define HWMON_I_MAX_ALARM BIT(hwmon_in_max_alarm)
128 #define HWMON_I_LCRIT_ALARM BIT(hwmon_in_lcrit_alarm)
129 #define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm)
131 enum hwmon_curr_attributes
{
140 hwmon_curr_reset_history
,
143 hwmon_curr_min_alarm
,
144 hwmon_curr_max_alarm
,
145 hwmon_curr_lcrit_alarm
,
146 hwmon_curr_crit_alarm
,
149 #define HWMON_C_INPUT BIT(hwmon_curr_input)
150 #define HWMON_C_MIN BIT(hwmon_curr_min)
151 #define HWMON_C_MAX BIT(hwmon_curr_max)
152 #define HWMON_C_LCRIT BIT(hwmon_curr_lcrit)
153 #define HWMON_C_CRIT BIT(hwmon_curr_crit)
154 #define HWMON_C_AVERAGE BIT(hwmon_curr_average)
155 #define HWMON_C_LOWEST BIT(hwmon_curr_lowest)
156 #define HWMON_C_HIGHEST BIT(hwmon_curr_highest)
157 #define HWMON_C_RESET_HISTORY BIT(hwmon_curr_reset_history)
158 #define HWMON_C_LABEL BIT(hwmon_curr_label)
159 #define HWMON_C_ALARM BIT(hwmon_curr_alarm)
160 #define HWMON_C_MIN_ALARM BIT(hwmon_curr_min_alarm)
161 #define HWMON_C_MAX_ALARM BIT(hwmon_curr_max_alarm)
162 #define HWMON_C_LCRIT_ALARM BIT(hwmon_curr_lcrit_alarm)
163 #define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm)
166 * struct hwmon_ops - hwmon device operations
167 * @is_visible: Callback to return attribute visibility. Mandatory.
169 * @const void *drvdata:
170 * Pointer to driver-private data structure passed
171 * as argument to hwmon_device_register_with_info().
173 * @attr: Sensor attribute
176 * The function returns the file permissions.
177 * If the return value is 0, no attribute will be created.
178 * @read: Read callback. Optional. If not provided, attributes
179 * will not be readable.
181 * @dev: Pointer to hardware monitoring device
183 * @attr: Sensor attribute
186 * @val: Pointer to returned value
187 * The function returns 0 on success or a negative error number.
188 * @write: Write callback. Optional. If not provided, attributes
189 * will not be writable.
191 * @dev: Pointer to hardware monitoring device
193 * @attr: Sensor attribute
196 * @val: Value to write
197 * The function returns 0 on success or a negative error number.
200 umode_t (*is_visible
)(const void *drvdata
, enum hwmon_sensor_types type
,
201 u32 attr
, int channel
);
202 int (*read
)(struct device
*dev
, enum hwmon_sensor_types type
,
203 u32 attr
, int channel
, long *val
);
204 int (*write
)(struct device
*dev
, enum hwmon_sensor_types type
,
205 u32 attr
, int channel
, long val
);
209 * Channel information
210 * @type: Channel type.
211 * @config: Pointer to NULL-terminated list of channel parameters.
212 * Use for per-channel attributes.
214 struct hwmon_channel_info
{
215 enum hwmon_sensor_types type
;
221 * @ops: Pointer to hwmon operations.
222 * @info: Null-terminated list of channel information.
224 struct hwmon_chip_info
{
225 const struct hwmon_ops
*ops
;
226 const struct hwmon_channel_info
**info
;
229 struct device
*hwmon_device_register(struct device
*dev
);
231 hwmon_device_register_with_groups(struct device
*dev
, const char *name
,
233 const struct attribute_group
**groups
);
235 devm_hwmon_device_register_with_groups(struct device
*dev
, const char *name
,
237 const struct attribute_group
**groups
);
239 hwmon_device_register_with_info(struct device
*dev
,
240 const char *name
, void *drvdata
,
241 const struct hwmon_chip_info
*info
,
242 const struct attribute_group
**groups
);
244 devm_hwmon_device_register_with_info(struct device
*dev
,
245 const char *name
, void *drvdata
,
246 const struct hwmon_chip_info
*info
,
247 const struct attribute_group
**groups
);
249 void hwmon_device_unregister(struct device
*dev
);
250 void devm_hwmon_device_unregister(struct device
*dev
);