1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef _HWMON_H_
15#define _HWMON_H_
16
17#include <linux/bitops.h>
18
19struct device;
20struct attribute_group;
21
22enum hwmon_sensor_types {
23 hwmon_chip,
24 hwmon_temp,
25 hwmon_in,
26 hwmon_curr,
27 hwmon_power,
28 hwmon_energy,
29 hwmon_humidity,
30 hwmon_fan,
31 hwmon_pwm,
32};
33
34enum hwmon_chip_attributes {
35 hwmon_chip_temp_reset_history,
36 hwmon_chip_in_reset_history,
37 hwmon_chip_curr_reset_history,
38 hwmon_chip_power_reset_history,
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)
46#define HWMON_C_CURR_RESET_HISTORY BIT(hwmon_chip_curr_reset_history)
47#define HWMON_C_POWER_RESET_HISTORY BIT(hwmon_chip_power_reset_history)
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_ALARM BIT(hwmon_temp_alarm)
92#define HWMON_T_MIN_ALARM BIT(hwmon_temp_min_alarm)
93#define HWMON_T_MAX_ALARM BIT(hwmon_temp_max_alarm)
94#define HWMON_T_CRIT_ALARM BIT(hwmon_temp_crit_alarm)
95#define HWMON_T_EMERGENCY_ALARM BIT(hwmon_temp_emergency_alarm)
96#define HWMON_T_FAULT BIT(hwmon_temp_fault)
97#define HWMON_T_OFFSET BIT(hwmon_temp_offset)
98#define HWMON_T_LABEL BIT(hwmon_temp_label)
99#define HWMON_T_LOWEST BIT(hwmon_temp_lowest)
100#define HWMON_T_HIGHEST BIT(hwmon_temp_highest)
101#define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history)
102
103enum hwmon_in_attributes {
104 hwmon_in_input,
105 hwmon_in_min,
106 hwmon_in_max,
107 hwmon_in_lcrit,
108 hwmon_in_crit,
109 hwmon_in_average,
110 hwmon_in_lowest,
111 hwmon_in_highest,
112 hwmon_in_reset_history,
113 hwmon_in_label,
114 hwmon_in_alarm,
115 hwmon_in_min_alarm,
116 hwmon_in_max_alarm,
117 hwmon_in_lcrit_alarm,
118 hwmon_in_crit_alarm,
119};
120
121#define HWMON_I_INPUT BIT(hwmon_in_input)
122#define HWMON_I_MIN BIT(hwmon_in_min)
123#define HWMON_I_MAX BIT(hwmon_in_max)
124#define HWMON_I_LCRIT BIT(hwmon_in_lcrit)
125#define HWMON_I_CRIT BIT(hwmon_in_crit)
126#define HWMON_I_AVERAGE BIT(hwmon_in_average)
127#define HWMON_I_LOWEST BIT(hwmon_in_lowest)
128#define HWMON_I_HIGHEST BIT(hwmon_in_highest)
129#define HWMON_I_RESET_HISTORY BIT(hwmon_in_reset_history)
130#define HWMON_I_LABEL BIT(hwmon_in_label)
131#define HWMON_I_ALARM BIT(hwmon_in_alarm)
132#define HWMON_I_MIN_ALARM BIT(hwmon_in_min_alarm)
133#define HWMON_I_MAX_ALARM BIT(hwmon_in_max_alarm)
134#define HWMON_I_LCRIT_ALARM BIT(hwmon_in_lcrit_alarm)
135#define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm)
136
137enum hwmon_curr_attributes {
138 hwmon_curr_input,
139 hwmon_curr_min,
140 hwmon_curr_max,
141 hwmon_curr_lcrit,
142 hwmon_curr_crit,
143 hwmon_curr_average,
144 hwmon_curr_lowest,
145 hwmon_curr_highest,
146 hwmon_curr_reset_history,
147 hwmon_curr_label,
148 hwmon_curr_alarm,
149 hwmon_curr_min_alarm,
150 hwmon_curr_max_alarm,
151 hwmon_curr_lcrit_alarm,
152 hwmon_curr_crit_alarm,
153};
154
155#define HWMON_C_INPUT BIT(hwmon_curr_input)
156#define HWMON_C_MIN BIT(hwmon_curr_min)
157#define HWMON_C_MAX BIT(hwmon_curr_max)
158#define HWMON_C_LCRIT BIT(hwmon_curr_lcrit)
159#define HWMON_C_CRIT BIT(hwmon_curr_crit)
160#define HWMON_C_AVERAGE BIT(hwmon_curr_average)
161#define HWMON_C_LOWEST BIT(hwmon_curr_lowest)
162#define HWMON_C_HIGHEST BIT(hwmon_curr_highest)
163#define HWMON_C_RESET_HISTORY BIT(hwmon_curr_reset_history)
164#define HWMON_C_LABEL BIT(hwmon_curr_label)
165#define HWMON_C_ALARM BIT(hwmon_curr_alarm)
166#define HWMON_C_MIN_ALARM BIT(hwmon_curr_min_alarm)
167#define HWMON_C_MAX_ALARM BIT(hwmon_curr_max_alarm)
168#define HWMON_C_LCRIT_ALARM BIT(hwmon_curr_lcrit_alarm)
169#define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm)
170
171enum hwmon_power_attributes {
172 hwmon_power_average,
173 hwmon_power_average_interval,
174 hwmon_power_average_interval_max,
175 hwmon_power_average_interval_min,
176 hwmon_power_average_highest,
177 hwmon_power_average_lowest,
178 hwmon_power_average_max,
179 hwmon_power_average_min,
180 hwmon_power_input,
181 hwmon_power_input_highest,
182 hwmon_power_input_lowest,
183 hwmon_power_reset_history,
184 hwmon_power_accuracy,
185 hwmon_power_cap,
186 hwmon_power_cap_hyst,
187 hwmon_power_cap_max,
188 hwmon_power_cap_min,
189 hwmon_power_max,
190 hwmon_power_crit,
191 hwmon_power_label,
192 hwmon_power_alarm,
193 hwmon_power_cap_alarm,
194 hwmon_power_max_alarm,
195 hwmon_power_crit_alarm,
196};
197
198#define HWMON_P_AVERAGE BIT(hwmon_power_average)
199#define HWMON_P_AVERAGE_INTERVAL BIT(hwmon_power_average_interval)
200#define HWMON_P_AVERAGE_INTERVAL_MAX BIT(hwmon_power_average_interval_max)
201#define HWMON_P_AVERAGE_INTERVAL_MIN BIT(hwmon_power_average_interval_min)
202#define HWMON_P_AVERAGE_HIGHEST BIT(hwmon_power_average_highest)
203#define HWMON_P_AVERAGE_LOWEST BIT(hwmon_power_average_lowest)
204#define HWMON_P_AVERAGE_MAX BIT(hwmon_power_average_max)
205#define HWMON_P_AVERAGE_MIN BIT(hwmon_power_average_min)
206#define HWMON_P_INPUT BIT(hwmon_power_input)
207#define HWMON_P_INPUT_HIGHEST BIT(hwmon_power_input_highest)
208#define HWMON_P_INPUT_LOWEST BIT(hwmon_power_input_lowest)
209#define HWMON_P_RESET_HISTORY BIT(hwmon_power_reset_history)
210#define HWMON_P_ACCURACY BIT(hwmon_power_accuracy)
211#define HWMON_P_CAP BIT(hwmon_power_cap)
212#define HWMON_P_CAP_HYST BIT(hwmon_power_cap_hyst)
213#define HWMON_P_CAP_MAX BIT(hwmon_power_cap_max)
214#define HWMON_P_CAP_MIN BIT(hwmon_power_cap_min)
215#define HWMON_P_MAX BIT(hwmon_power_max)
216#define HWMON_P_CRIT BIT(hwmon_power_crit)
217#define HWMON_P_LABEL BIT(hwmon_power_label)
218#define HWMON_P_ALARM BIT(hwmon_power_alarm)
219#define HWMON_P_CAP_ALARM BIT(hwmon_power_cap_alarm)
220#define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm)
221#define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm)
222
223enum hwmon_energy_attributes {
224 hwmon_energy_input,
225 hwmon_energy_label,
226};
227
228#define HWMON_E_INPUT BIT(hwmon_energy_input)
229#define HWMON_E_LABEL BIT(hwmon_energy_label)
230
231enum hwmon_humidity_attributes {
232 hwmon_humidity_input,
233 hwmon_humidity_label,
234 hwmon_humidity_min,
235 hwmon_humidity_min_hyst,
236 hwmon_humidity_max,
237 hwmon_humidity_max_hyst,
238 hwmon_humidity_alarm,
239 hwmon_humidity_fault,
240};
241
242#define HWMON_H_INPUT BIT(hwmon_humidity_input)
243#define HWMON_H_LABEL BIT(hwmon_humidity_label)
244#define HWMON_H_MIN BIT(hwmon_humidity_min)
245#define HWMON_H_MIN_HYST BIT(hwmon_humidity_min_hyst)
246#define HWMON_H_MAX BIT(hwmon_humidity_max)
247#define HWMON_H_MAX_HYST BIT(hwmon_humidity_max_hyst)
248#define HWMON_H_ALARM BIT(hwmon_humidity_alarm)
249#define HWMON_H_FAULT BIT(hwmon_humidity_fault)
250
251enum hwmon_fan_attributes {
252 hwmon_fan_input,
253 hwmon_fan_label,
254 hwmon_fan_min,
255 hwmon_fan_max,
256 hwmon_fan_div,
257 hwmon_fan_pulses,
258 hwmon_fan_target,
259 hwmon_fan_alarm,
260 hwmon_fan_min_alarm,
261 hwmon_fan_max_alarm,
262 hwmon_fan_fault,
263};
264
265#define HWMON_F_INPUT BIT(hwmon_fan_input)
266#define HWMON_F_LABEL BIT(hwmon_fan_label)
267#define HWMON_F_MIN BIT(hwmon_fan_min)
268#define HWMON_F_MAX BIT(hwmon_fan_max)
269#define HWMON_F_DIV BIT(hwmon_fan_div)
270#define HWMON_F_PULSES BIT(hwmon_fan_pulses)
271#define HWMON_F_TARGET BIT(hwmon_fan_target)
272#define HWMON_F_ALARM BIT(hwmon_fan_alarm)
273#define HWMON_F_MIN_ALARM BIT(hwmon_fan_min_alarm)
274#define HWMON_F_MAX_ALARM BIT(hwmon_fan_max_alarm)
275#define HWMON_F_FAULT BIT(hwmon_fan_fault)
276
277enum hwmon_pwm_attributes {
278 hwmon_pwm_input,
279 hwmon_pwm_enable,
280 hwmon_pwm_mode,
281 hwmon_pwm_freq,
282};
283
284#define HWMON_PWM_INPUT BIT(hwmon_pwm_input)
285#define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable)
286#define HWMON_PWM_MODE BIT(hwmon_pwm_mode)
287#define HWMON_PWM_FREQ BIT(hwmon_pwm_freq)
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334struct hwmon_ops {
335 umode_t (*is_visible)(const void *drvdata, enum hwmon_sensor_types type,
336 u32 attr, int channel);
337 int (*read)(struct device *dev, enum hwmon_sensor_types type,
338 u32 attr, int channel, long *val);
339 int (*read_string)(struct device *dev, enum hwmon_sensor_types type,
340 u32 attr, int channel, const char **str);
341 int (*write)(struct device *dev, enum hwmon_sensor_types type,
342 u32 attr, int channel, long val);
343};
344
345
346
347
348
349
350
351struct hwmon_channel_info {
352 enum hwmon_sensor_types type;
353 const u32 *config;
354};
355
356
357
358
359
360
361struct hwmon_chip_info {
362 const struct hwmon_ops *ops;
363 const struct hwmon_channel_info **info;
364};
365
366
367struct device *hwmon_device_register(struct device *dev);
368
369struct device *
370hwmon_device_register_with_groups(struct device *dev, const char *name,
371 void *drvdata,
372 const struct attribute_group **groups);
373struct device *
374devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
375 void *drvdata,
376 const struct attribute_group **groups);
377struct device *
378hwmon_device_register_with_info(struct device *dev,
379 const char *name, void *drvdata,
380 const struct hwmon_chip_info *info,
381 const struct attribute_group **extra_groups);
382struct device *
383devm_hwmon_device_register_with_info(struct device *dev,
384 const char *name, void *drvdata,
385 const struct hwmon_chip_info *info,
386 const struct attribute_group **extra_groups);
387
388void hwmon_device_unregister(struct device *dev);
389void devm_hwmon_device_unregister(struct device *dev);
390
391#endif
392