net/mlx5: Fix version printout in case of health issue
[linux-2.6-block.git] / include / linux / hwmon.h
CommitLineData
1236441f
MH
1/*
2 hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring
3
4 This file declares helper functions for the sysfs class "hwmon",
5 for use by sensors drivers.
6
7 Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
8
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.
12*/
13
14#ifndef _HWMON_H_
15#define _HWMON_H_
16
d560168b
GR
17#include <linux/bitops.h>
18
313162d0 19struct device;
bab2243c 20struct attribute_group;
1236441f 21
d560168b
GR
22enum hwmon_sensor_types {
23 hwmon_chip,
24 hwmon_temp,
25 hwmon_in,
26 hwmon_curr,
27 hwmon_power,
28 hwmon_energy,
6bfcca44 29 hwmon_humidity,
8faee73f 30 hwmon_fan,
f9f7bb3a 31 hwmon_pwm,
d560168b
GR
32};
33
34enum hwmon_chip_attributes {
35 hwmon_chip_temp_reset_history,
00d616cf 36 hwmon_chip_in_reset_history,
9b26947c 37 hwmon_chip_curr_reset_history,
b308f5c7 38 hwmon_chip_power_reset_history,
d560168b
GR
39 hwmon_chip_register_tz,
40 hwmon_chip_update_interval,
41 hwmon_chip_alarms,
42};
43
44#define HWMON_C_TEMP_RESET_HISTORY BIT(hwmon_chip_temp_reset_history)
45#define HWMON_C_IN_RESET_HISTORY BIT(hwmon_chip_in_reset_history)
9b26947c 46#define HWMON_C_CURR_RESET_HISTORY BIT(hwmon_chip_curr_reset_history)
b308f5c7 47#define HWMON_C_POWER_RESET_HISTORY BIT(hwmon_chip_power_reset_history)
d560168b
GR
48#define HWMON_C_REGISTER_TZ BIT(hwmon_chip_register_tz)
49#define HWMON_C_UPDATE_INTERVAL BIT(hwmon_chip_update_interval)
50#define HWMON_C_ALARMS BIT(hwmon_chip_alarms)
51
52enum hwmon_temp_attributes {
53 hwmon_temp_input = 0,
54 hwmon_temp_type,
55 hwmon_temp_lcrit,
56 hwmon_temp_lcrit_hyst,
57 hwmon_temp_min,
58 hwmon_temp_min_hyst,
59 hwmon_temp_max,
60 hwmon_temp_max_hyst,
61 hwmon_temp_crit,
62 hwmon_temp_crit_hyst,
63 hwmon_temp_emergency,
64 hwmon_temp_emergency_hyst,
65 hwmon_temp_alarm,
66 hwmon_temp_lcrit_alarm,
67 hwmon_temp_min_alarm,
68 hwmon_temp_max_alarm,
69 hwmon_temp_crit_alarm,
70 hwmon_temp_emergency_alarm,
71 hwmon_temp_fault,
72 hwmon_temp_offset,
73 hwmon_temp_label,
74 hwmon_temp_lowest,
75 hwmon_temp_highest,
76 hwmon_temp_reset_history,
77};
78
79#define HWMON_T_INPUT BIT(hwmon_temp_input)
80#define HWMON_T_TYPE BIT(hwmon_temp_type)
81#define HWMON_T_LCRIT BIT(hwmon_temp_lcrit)
82#define HWMON_T_LCRIT_HYST BIT(hwmon_temp_lcrit_hyst)
83#define HWMON_T_MIN BIT(hwmon_temp_min)
84#define HWMON_T_MIN_HYST BIT(hwmon_temp_min_hyst)
85#define HWMON_T_MAX BIT(hwmon_temp_max)
86#define HWMON_T_MAX_HYST BIT(hwmon_temp_max_hyst)
87#define HWMON_T_CRIT BIT(hwmon_temp_crit)
88#define HWMON_T_CRIT_HYST BIT(hwmon_temp_crit_hyst)
89#define HWMON_T_EMERGENCY BIT(hwmon_temp_emergency)
90#define HWMON_T_EMERGENCY_HYST BIT(hwmon_temp_emergency_hyst)
91#define HWMON_T_MIN_ALARM BIT(hwmon_temp_min_alarm)
92#define HWMON_T_MAX_ALARM BIT(hwmon_temp_max_alarm)
93#define HWMON_T_CRIT_ALARM BIT(hwmon_temp_crit_alarm)
94#define HWMON_T_EMERGENCY_ALARM BIT(hwmon_temp_emergency_alarm)
95#define HWMON_T_FAULT BIT(hwmon_temp_fault)
96#define HWMON_T_OFFSET BIT(hwmon_temp_offset)
97#define HWMON_T_LABEL BIT(hwmon_temp_label)
98#define HWMON_T_LOWEST BIT(hwmon_temp_lowest)
99#define HWMON_T_HIGHEST BIT(hwmon_temp_highest)
100#define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history)
101
00d616cf
GR
102enum hwmon_in_attributes {
103 hwmon_in_input,
104 hwmon_in_min,
105 hwmon_in_max,
106 hwmon_in_lcrit,
107 hwmon_in_crit,
108 hwmon_in_average,
109 hwmon_in_lowest,
110 hwmon_in_highest,
111 hwmon_in_reset_history,
112 hwmon_in_label,
113 hwmon_in_alarm,
114 hwmon_in_min_alarm,
115 hwmon_in_max_alarm,
116 hwmon_in_lcrit_alarm,
117 hwmon_in_crit_alarm,
118};
119
120#define HWMON_I_INPUT BIT(hwmon_in_input)
121#define HWMON_I_MIN BIT(hwmon_in_min)
122#define HWMON_I_MAX BIT(hwmon_in_max)
123#define HWMON_I_LCRIT BIT(hwmon_in_lcrit)
124#define HWMON_I_CRIT BIT(hwmon_in_crit)
125#define HWMON_I_AVERAGE BIT(hwmon_in_average)
126#define HWMON_I_LOWEST BIT(hwmon_in_lowest)
127#define HWMON_I_HIGHEST BIT(hwmon_in_highest)
128#define HWMON_I_RESET_HISTORY BIT(hwmon_in_reset_history)
129#define HWMON_I_LABEL BIT(hwmon_in_label)
130#define HWMON_I_ALARM BIT(hwmon_in_alarm)
131#define HWMON_I_MIN_ALARM BIT(hwmon_in_min_alarm)
132#define HWMON_I_MAX_ALARM BIT(hwmon_in_max_alarm)
133#define HWMON_I_LCRIT_ALARM BIT(hwmon_in_lcrit_alarm)
134#define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm)
135
9b26947c
GR
136enum hwmon_curr_attributes {
137 hwmon_curr_input,
138 hwmon_curr_min,
139 hwmon_curr_max,
140 hwmon_curr_lcrit,
141 hwmon_curr_crit,
142 hwmon_curr_average,
143 hwmon_curr_lowest,
144 hwmon_curr_highest,
145 hwmon_curr_reset_history,
146 hwmon_curr_label,
147 hwmon_curr_alarm,
148 hwmon_curr_min_alarm,
149 hwmon_curr_max_alarm,
150 hwmon_curr_lcrit_alarm,
151 hwmon_curr_crit_alarm,
152};
153
154#define HWMON_C_INPUT BIT(hwmon_curr_input)
155#define HWMON_C_MIN BIT(hwmon_curr_min)
156#define HWMON_C_MAX BIT(hwmon_curr_max)
157#define HWMON_C_LCRIT BIT(hwmon_curr_lcrit)
158#define HWMON_C_CRIT BIT(hwmon_curr_crit)
159#define HWMON_C_AVERAGE BIT(hwmon_curr_average)
160#define HWMON_C_LOWEST BIT(hwmon_curr_lowest)
161#define HWMON_C_HIGHEST BIT(hwmon_curr_highest)
162#define HWMON_C_RESET_HISTORY BIT(hwmon_curr_reset_history)
163#define HWMON_C_LABEL BIT(hwmon_curr_label)
164#define HWMON_C_ALARM BIT(hwmon_curr_alarm)
165#define HWMON_C_MIN_ALARM BIT(hwmon_curr_min_alarm)
166#define HWMON_C_MAX_ALARM BIT(hwmon_curr_max_alarm)
167#define HWMON_C_LCRIT_ALARM BIT(hwmon_curr_lcrit_alarm)
168#define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm)
169
b308f5c7
GR
170enum hwmon_power_attributes {
171 hwmon_power_average,
172 hwmon_power_average_interval,
173 hwmon_power_average_interval_max,
174 hwmon_power_average_interval_min,
175 hwmon_power_average_highest,
176 hwmon_power_average_lowest,
177 hwmon_power_average_max,
178 hwmon_power_average_min,
179 hwmon_power_input,
180 hwmon_power_input_highest,
181 hwmon_power_input_lowest,
182 hwmon_power_reset_history,
183 hwmon_power_accuracy,
184 hwmon_power_cap,
185 hwmon_power_cap_hyst,
186 hwmon_power_cap_max,
187 hwmon_power_cap_min,
188 hwmon_power_max,
189 hwmon_power_crit,
190 hwmon_power_label,
191 hwmon_power_alarm,
192 hwmon_power_cap_alarm,
193 hwmon_power_max_alarm,
194 hwmon_power_crit_alarm,
195};
196
197#define HWMON_P_AVERAGE BIT(hwmon_power_average)
198#define HWMON_P_AVERAGE_INTERVAL BIT(hwmon_power_average_interval)
199#define HWMON_P_AVERAGE_INTERVAL_MAX BIT(hwmon_power_average_interval_max)
200#define HWMON_P_AVERAGE_INTERVAL_MIN BIT(hwmon_power_average_interval_min)
201#define HWMON_P_AVERAGE_HIGHEST BIT(hwmon_power_average_highest)
202#define HWMON_P_AVERAGE_LOWEST BIT(hwmon_power_average_lowest)
203#define HWMON_P_AVERAGE_MAX BIT(hwmon_power_average_max)
204#define HWMON_P_AVERAGE_MIN BIT(hwmon_power_average_min)
205#define HWMON_P_INPUT BIT(hwmon_power_input)
206#define HWMON_P_INPUT_HIGHEST BIT(hwmon_power_input_highest)
207#define HWMON_P_INPUT_LOWEST BIT(hwmon_power_input_lowest)
208#define HWMON_P_RESET_HISTORY BIT(hwmon_power_reset_history)
209#define HWMON_P_ACCURACY BIT(hwmon_power_accuracy)
210#define HWMON_P_CAP BIT(hwmon_power_cap)
211#define HWMON_P_CAP_HYST BIT(hwmon_power_cap_hyst)
212#define HWMON_P_CAP_MAX BIT(hwmon_power_cap_max)
213#define HWMON_P_CAP_MIN BIT(hwmon_power_cap_min)
214#define HWMON_P_MAX BIT(hwmon_power_max)
215#define HWMON_P_CRIT BIT(hwmon_power_crit)
216#define HWMON_P_LABEL BIT(hwmon_power_label)
217#define HWMON_P_ALARM BIT(hwmon_power_alarm)
218#define HWMON_P_CAP_ALARM BIT(hwmon_power_cap_alarm)
219#define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm)
220#define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm)
221
6bfcca44
GR
222enum hwmon_energy_attributes {
223 hwmon_energy_input,
224 hwmon_energy_label,
225};
226
227#define HWMON_E_INPUT BIT(hwmon_energy_input)
228#define HWMON_E_LABEL BIT(hwmon_energy_label)
229
230enum hwmon_humidity_attributes {
231 hwmon_humidity_input,
232 hwmon_humidity_label,
233 hwmon_humidity_min,
234 hwmon_humidity_min_hyst,
235 hwmon_humidity_max,
236 hwmon_humidity_max_hyst,
237 hwmon_humidity_alarm,
238 hwmon_humidity_fault,
239};
240
241#define HWMON_H_INPUT BIT(hwmon_humidity_input)
242#define HWMON_H_LABEL BIT(hwmon_humidity_label)
243#define HWMON_H_MIN BIT(hwmon_humidity_min)
244#define HWMON_H_MIN_HYST BIT(hwmon_humidity_min_hyst)
245#define HWMON_H_MAX BIT(hwmon_humidity_max)
246#define HWMON_H_MAX_HYST BIT(hwmon_humidity_max_hyst)
247#define HWMON_H_ALARM BIT(hwmon_humidity_alarm)
248#define HWMON_H_FAULT BIT(hwmon_humidity_fault)
249
8faee73f
GR
250enum hwmon_fan_attributes {
251 hwmon_fan_input,
252 hwmon_fan_label,
253 hwmon_fan_min,
254 hwmon_fan_max,
255 hwmon_fan_div,
256 hwmon_fan_pulses,
257 hwmon_fan_target,
258 hwmon_fan_alarm,
259 hwmon_fan_min_alarm,
260 hwmon_fan_max_alarm,
261 hwmon_fan_fault,
262};
263
264#define HWMON_F_INPUT BIT(hwmon_fan_input)
265#define HWMON_F_LABEL BIT(hwmon_fan_label)
266#define HWMON_F_MIN BIT(hwmon_fan_min)
267#define HWMON_F_MAX BIT(hwmon_fan_max)
268#define HWMON_F_DIV BIT(hwmon_fan_div)
269#define HWMON_F_PULSES BIT(hwmon_fan_pulses)
270#define HWMON_F_TARGET BIT(hwmon_fan_target)
271#define HWMON_F_ALARM BIT(hwmon_fan_alarm)
272#define HWMON_F_MIN_ALARM BIT(hwmon_fan_min_alarm)
273#define HWMON_F_MAX_ALARM BIT(hwmon_fan_max_alarm)
274#define HWMON_F_FAULT BIT(hwmon_fan_fault)
275
f9f7bb3a
GR
276enum hwmon_pwm_attributes {
277 hwmon_pwm_input,
278 hwmon_pwm_enable,
279 hwmon_pwm_mode,
280 hwmon_pwm_freq,
281};
282
283#define HWMON_PWM_INPUT BIT(hwmon_pwm_input)
284#define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable)
285#define HWMON_PWM_MODE BIT(hwmon_pwm_mode)
286#define HWMON_PWM_FREQ BIT(hwmon_pwm_freq)
287
d560168b
GR
288/**
289 * struct hwmon_ops - hwmon device operations
290 * @is_visible: Callback to return attribute visibility. Mandatory.
291 * Parameters are:
292 * @const void *drvdata:
293 * Pointer to driver-private data structure passed
294 * as argument to hwmon_device_register_with_info().
295 * @type: Sensor type
296 * @attr: Sensor attribute
297 * @channel:
298 * Channel number
299 * The function returns the file permissions.
300 * If the return value is 0, no attribute will be created.
e159ab5c
GR
301 * @read: Read callback for data attributes. Mandatory if readable
302 * data attributes are present.
d560168b
GR
303 * Parameters are:
304 * @dev: Pointer to hardware monitoring device
305 * @type: Sensor type
306 * @attr: Sensor attribute
307 * @channel:
308 * Channel number
309 * @val: Pointer to returned value
310 * The function returns 0 on success or a negative error number.
e159ab5c
GR
311 * @read_string:
312 * Read callback for string attributes. Mandatory if string
313 * attributes are present.
314 * Parameters are:
315 * @dev: Pointer to hardware monitoring device
316 * @type: Sensor type
317 * @attr: Sensor attribute
318 * @channel:
319 * Channel number
320 * @str: Pointer to returned string
321 * The function returns 0 on success or a negative error number.
322 * @write: Write callback for data attributes. Mandatory if writeable
323 * data attributes are present.
d560168b
GR
324 * Parameters are:
325 * @dev: Pointer to hardware monitoring device
326 * @type: Sensor type
327 * @attr: Sensor attribute
328 * @channel:
329 * Channel number
330 * @val: Value to write
331 * The function returns 0 on success or a negative error number.
332 */
333struct hwmon_ops {
334 umode_t (*is_visible)(const void *drvdata, enum hwmon_sensor_types type,
335 u32 attr, int channel);
336 int (*read)(struct device *dev, enum hwmon_sensor_types type,
337 u32 attr, int channel, long *val);
e159ab5c
GR
338 int (*read_string)(struct device *dev, enum hwmon_sensor_types type,
339 u32 attr, int channel, char **str);
d560168b
GR
340 int (*write)(struct device *dev, enum hwmon_sensor_types type,
341 u32 attr, int channel, long val);
342};
343
344/**
345 * Channel information
346 * @type: Channel type.
347 * @config: Pointer to NULL-terminated list of channel parameters.
348 * Use for per-channel attributes.
349 */
350struct hwmon_channel_info {
351 enum hwmon_sensor_types type;
352 const u32 *config;
353};
354
355/**
356 * Chip configuration
357 * @ops: Pointer to hwmon operations.
358 * @info: Null-terminated list of channel information.
359 */
360struct hwmon_chip_info {
361 const struct hwmon_ops *ops;
362 const struct hwmon_channel_info **info;
363};
364
af1bd36c 365/* hwmon_device_register() is deprecated */
1beeffe4 366struct device *hwmon_device_register(struct device *dev);
af1bd36c 367
bab2243c
GR
368struct device *
369hwmon_device_register_with_groups(struct device *dev, const char *name,
370 void *drvdata,
371 const struct attribute_group **groups);
74188cba
GR
372struct device *
373devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
374 void *drvdata,
375 const struct attribute_group **groups);
d560168b
GR
376struct device *
377hwmon_device_register_with_info(struct device *dev,
378 const char *name, void *drvdata,
379 const struct hwmon_chip_info *info,
848ba0a2 380 const struct attribute_group **extra_groups);
d560168b
GR
381struct device *
382devm_hwmon_device_register_with_info(struct device *dev,
848ba0a2
GR
383 const char *name, void *drvdata,
384 const struct hwmon_chip_info *info,
385 const struct attribute_group **extra_groups);
1236441f 386
1beeffe4 387void hwmon_device_unregister(struct device *dev);
74188cba 388void devm_hwmon_device_unregister(struct device *dev);
1236441f
MH
389
390#endif