hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/hwmon.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring
34
....@@ -6,9 +7,6 @@
67
78 Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
89
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.
1210 */
1311
1412 #ifndef _HWMON_H_
....@@ -29,6 +27,7 @@
2927 hwmon_humidity,
3028 hwmon_fan,
3129 hwmon_pwm,
30
+ hwmon_intrusion,
3231 hwmon_max,
3332 };
3433
....@@ -40,6 +39,11 @@
4039 hwmon_chip_register_tz,
4140 hwmon_chip_update_interval,
4241 hwmon_chip_alarms,
42
+ hwmon_chip_samples,
43
+ hwmon_chip_curr_samples,
44
+ hwmon_chip_in_samples,
45
+ hwmon_chip_power_samples,
46
+ hwmon_chip_temp_samples,
4347 };
4448
4549 #define HWMON_C_TEMP_RESET_HISTORY BIT(hwmon_chip_temp_reset_history)
....@@ -49,9 +53,15 @@
4953 #define HWMON_C_REGISTER_TZ BIT(hwmon_chip_register_tz)
5054 #define HWMON_C_UPDATE_INTERVAL BIT(hwmon_chip_update_interval)
5155 #define HWMON_C_ALARMS BIT(hwmon_chip_alarms)
56
+#define HWMON_C_SAMPLES BIT(hwmon_chip_samples)
57
+#define HWMON_C_CURR_SAMPLES BIT(hwmon_chip_curr_samples)
58
+#define HWMON_C_IN_SAMPLES BIT(hwmon_chip_in_samples)
59
+#define HWMON_C_POWER_SAMPLES BIT(hwmon_chip_power_samples)
60
+#define HWMON_C_TEMP_SAMPLES BIT(hwmon_chip_temp_samples)
5261
5362 enum hwmon_temp_attributes {
54
- hwmon_temp_input = 0,
63
+ hwmon_temp_enable,
64
+ hwmon_temp_input,
5565 hwmon_temp_type,
5666 hwmon_temp_lcrit,
5767 hwmon_temp_lcrit_hyst,
....@@ -75,8 +85,11 @@
7585 hwmon_temp_lowest,
7686 hwmon_temp_highest,
7787 hwmon_temp_reset_history,
88
+ hwmon_temp_rated_min,
89
+ hwmon_temp_rated_max,
7890 };
7991
92
+#define HWMON_T_ENABLE BIT(hwmon_temp_enable)
8093 #define HWMON_T_INPUT BIT(hwmon_temp_input)
8194 #define HWMON_T_TYPE BIT(hwmon_temp_type)
8295 #define HWMON_T_LCRIT BIT(hwmon_temp_lcrit)
....@@ -101,8 +114,11 @@
101114 #define HWMON_T_LOWEST BIT(hwmon_temp_lowest)
102115 #define HWMON_T_HIGHEST BIT(hwmon_temp_highest)
103116 #define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history)
117
+#define HWMON_T_RATED_MIN BIT(hwmon_temp_rated_min)
118
+#define HWMON_T_RATED_MAX BIT(hwmon_temp_rated_max)
104119
105120 enum hwmon_in_attributes {
121
+ hwmon_in_enable,
106122 hwmon_in_input,
107123 hwmon_in_min,
108124 hwmon_in_max,
....@@ -118,8 +134,11 @@
118134 hwmon_in_max_alarm,
119135 hwmon_in_lcrit_alarm,
120136 hwmon_in_crit_alarm,
137
+ hwmon_in_rated_min,
138
+ hwmon_in_rated_max,
121139 };
122140
141
+#define HWMON_I_ENABLE BIT(hwmon_in_enable)
123142 #define HWMON_I_INPUT BIT(hwmon_in_input)
124143 #define HWMON_I_MIN BIT(hwmon_in_min)
125144 #define HWMON_I_MAX BIT(hwmon_in_max)
....@@ -135,8 +154,11 @@
135154 #define HWMON_I_MAX_ALARM BIT(hwmon_in_max_alarm)
136155 #define HWMON_I_LCRIT_ALARM BIT(hwmon_in_lcrit_alarm)
137156 #define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm)
157
+#define HWMON_I_RATED_MIN BIT(hwmon_in_rated_min)
158
+#define HWMON_I_RATED_MAX BIT(hwmon_in_rated_max)
138159
139160 enum hwmon_curr_attributes {
161
+ hwmon_curr_enable,
140162 hwmon_curr_input,
141163 hwmon_curr_min,
142164 hwmon_curr_max,
....@@ -152,8 +174,11 @@
152174 hwmon_curr_max_alarm,
153175 hwmon_curr_lcrit_alarm,
154176 hwmon_curr_crit_alarm,
177
+ hwmon_curr_rated_min,
178
+ hwmon_curr_rated_max,
155179 };
156180
181
+#define HWMON_C_ENABLE BIT(hwmon_curr_enable)
157182 #define HWMON_C_INPUT BIT(hwmon_curr_input)
158183 #define HWMON_C_MIN BIT(hwmon_curr_min)
159184 #define HWMON_C_MAX BIT(hwmon_curr_max)
....@@ -169,8 +194,11 @@
169194 #define HWMON_C_MAX_ALARM BIT(hwmon_curr_max_alarm)
170195 #define HWMON_C_LCRIT_ALARM BIT(hwmon_curr_lcrit_alarm)
171196 #define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm)
197
+#define HWMON_C_RATED_MIN BIT(hwmon_curr_rated_min)
198
+#define HWMON_C_RATED_MAX BIT(hwmon_curr_rated_max)
172199
173200 enum hwmon_power_attributes {
201
+ hwmon_power_enable,
174202 hwmon_power_average,
175203 hwmon_power_average_interval,
176204 hwmon_power_average_interval_max,
....@@ -199,8 +227,11 @@
199227 hwmon_power_max_alarm,
200228 hwmon_power_lcrit_alarm,
201229 hwmon_power_crit_alarm,
230
+ hwmon_power_rated_min,
231
+ hwmon_power_rated_max,
202232 };
203233
234
+#define HWMON_P_ENABLE BIT(hwmon_power_enable)
204235 #define HWMON_P_AVERAGE BIT(hwmon_power_average)
205236 #define HWMON_P_AVERAGE_INTERVAL BIT(hwmon_power_average_interval)
206237 #define HWMON_P_AVERAGE_INTERVAL_MAX BIT(hwmon_power_average_interval_max)
....@@ -229,16 +260,21 @@
229260 #define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm)
230261 #define HWMON_P_LCRIT_ALARM BIT(hwmon_power_lcrit_alarm)
231262 #define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm)
263
+#define HWMON_P_RATED_MIN BIT(hwmon_power_rated_min)
264
+#define HWMON_P_RATED_MAX BIT(hwmon_power_rated_max)
232265
233266 enum hwmon_energy_attributes {
267
+ hwmon_energy_enable,
234268 hwmon_energy_input,
235269 hwmon_energy_label,
236270 };
237271
272
+#define HWMON_E_ENABLE BIT(hwmon_energy_enable)
238273 #define HWMON_E_INPUT BIT(hwmon_energy_input)
239274 #define HWMON_E_LABEL BIT(hwmon_energy_label)
240275
241276 enum hwmon_humidity_attributes {
277
+ hwmon_humidity_enable,
242278 hwmon_humidity_input,
243279 hwmon_humidity_label,
244280 hwmon_humidity_min,
....@@ -247,8 +283,11 @@
247283 hwmon_humidity_max_hyst,
248284 hwmon_humidity_alarm,
249285 hwmon_humidity_fault,
286
+ hwmon_humidity_rated_min,
287
+ hwmon_humidity_rated_max,
250288 };
251289
290
+#define HWMON_H_ENABLE BIT(hwmon_humidity_enable)
252291 #define HWMON_H_INPUT BIT(hwmon_humidity_input)
253292 #define HWMON_H_LABEL BIT(hwmon_humidity_label)
254293 #define HWMON_H_MIN BIT(hwmon_humidity_min)
....@@ -257,8 +296,11 @@
257296 #define HWMON_H_MAX_HYST BIT(hwmon_humidity_max_hyst)
258297 #define HWMON_H_ALARM BIT(hwmon_humidity_alarm)
259298 #define HWMON_H_FAULT BIT(hwmon_humidity_fault)
299
+#define HWMON_H_RATED_MIN BIT(hwmon_humidity_rated_min)
300
+#define HWMON_H_RATED_MAX BIT(hwmon_humidity_rated_max)
260301
261302 enum hwmon_fan_attributes {
303
+ hwmon_fan_enable,
262304 hwmon_fan_input,
263305 hwmon_fan_label,
264306 hwmon_fan_min,
....@@ -272,6 +314,7 @@
272314 hwmon_fan_fault,
273315 };
274316
317
+#define HWMON_F_ENABLE BIT(hwmon_fan_enable)
275318 #define HWMON_F_INPUT BIT(hwmon_fan_input)
276319 #define HWMON_F_LABEL BIT(hwmon_fan_label)
277320 #define HWMON_F_MIN BIT(hwmon_fan_min)
....@@ -295,6 +338,13 @@
295338 #define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable)
296339 #define HWMON_PWM_MODE BIT(hwmon_pwm_mode)
297340 #define HWMON_PWM_FREQ BIT(hwmon_pwm_freq)
341
+
342
+enum hwmon_intrusion_attributes {
343
+ hwmon_intrusion_alarm,
344
+ hwmon_intrusion_beep,
345
+};
346
+#define HWMON_INTRUSION_ALARM BIT(hwmon_intrusion_alarm)
347
+#define HWMON_INTRUSION_BEEP BIT(hwmon_intrusion_beep)
298348
299349 /**
300350 * struct hwmon_ops - hwmon device operations
....@@ -363,6 +413,14 @@
363413 const u32 *config;
364414 };
365415
416
+#define HWMON_CHANNEL_INFO(stype, ...) \
417
+ (&(struct hwmon_channel_info) { \
418
+ .type = hwmon_##stype, \
419
+ .config = (u32 []) { \
420
+ __VA_ARGS__, 0 \
421
+ } \
422
+ })
423
+
366424 /**
367425 * Chip configuration
368426 * @ops: Pointer to hwmon operations.
....@@ -398,6 +456,9 @@
398456 void hwmon_device_unregister(struct device *dev);
399457 void devm_hwmon_device_unregister(struct device *dev);
400458
459
+int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
460
+ u32 attr, int channel);
461
+
401462 /**
402463 * hwmon_is_bad_char - Is the char invalid in a hwmon name
403464 * @ch: the char to be considered