diff options
author | Guenter Roeck <linux@roeck-us.net> | 2016-06-20 14:27:36 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2016-09-09 00:34:15 -0400 |
commit | b308f5c744522de020da4706718de9076adeada7 (patch) | |
tree | 29da2480525e877189e58f98be8d3c4d314b2196 | |
parent | 9b26947ce5b6a6d5f260d9564195e8971cc9713d (diff) |
hwmon: (core) Add power attribute support to new API
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/hwmon.c | 30 | ||||
-rw-r--r-- | include/linux/hwmon.h | 54 |
2 files changed, 84 insertions, 0 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 9229229a99a5..85f4e27548cb 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -261,6 +261,7 @@ static const char * const hwmon_chip_attr_templates[] = { | |||
261 | [hwmon_chip_temp_reset_history] = "temp_reset_history", | 261 | [hwmon_chip_temp_reset_history] = "temp_reset_history", |
262 | [hwmon_chip_in_reset_history] = "in_reset_history", | 262 | [hwmon_chip_in_reset_history] = "in_reset_history", |
263 | [hwmon_chip_curr_reset_history] = "curr_reset_history", | 263 | [hwmon_chip_curr_reset_history] = "curr_reset_history", |
264 | [hwmon_chip_power_reset_history] = "power_reset_history", | ||
264 | [hwmon_chip_update_interval] = "update_interval", | 265 | [hwmon_chip_update_interval] = "update_interval", |
265 | [hwmon_chip_alarms] = "alarms", | 266 | [hwmon_chip_alarms] = "alarms", |
266 | }; | 267 | }; |
@@ -328,11 +329,39 @@ static const char * const hwmon_curr_attr_templates[] = { | |||
328 | [hwmon_curr_crit_alarm] = "curr%d_crit_alarm", | 329 | [hwmon_curr_crit_alarm] = "curr%d_crit_alarm", |
329 | }; | 330 | }; |
330 | 331 | ||
332 | static const char * const hwmon_power_attr_templates[] = { | ||
333 | [hwmon_power_average] = "power%d_average", | ||
334 | [hwmon_power_average_interval] = "power%d_average_interval", | ||
335 | [hwmon_power_average_interval_max] = "power%d_interval_max", | ||
336 | [hwmon_power_average_interval_min] = "power%d_interval_min", | ||
337 | [hwmon_power_average_highest] = "power%d_average_highest", | ||
338 | [hwmon_power_average_lowest] = "power%d_average_lowest", | ||
339 | [hwmon_power_average_max] = "power%d_average_max", | ||
340 | [hwmon_power_average_min] = "power%d_average_min", | ||
341 | [hwmon_power_input] = "power%d_input", | ||
342 | [hwmon_power_input_highest] = "power%d_input_highest", | ||
343 | [hwmon_power_input_lowest] = "power%d_input_lowest", | ||
344 | [hwmon_power_reset_history] = "power%d_reset_history", | ||
345 | [hwmon_power_accuracy] = "power%d_accuracy", | ||
346 | [hwmon_power_cap] = "power%d_cap", | ||
347 | [hwmon_power_cap_hyst] = "power%d_cap_hyst", | ||
348 | [hwmon_power_cap_max] = "power%d_cap_max", | ||
349 | [hwmon_power_cap_min] = "power%d_cap_min", | ||
350 | [hwmon_power_max] = "power%d_max", | ||
351 | [hwmon_power_crit] = "power%d_crit", | ||
352 | [hwmon_power_label] = "power%d_label", | ||
353 | [hwmon_power_alarm] = "power%d_alarm", | ||
354 | [hwmon_power_cap_alarm] = "power%d_cap_alarm", | ||
355 | [hwmon_power_max_alarm] = "power%d_max_alarm", | ||
356 | [hwmon_power_crit_alarm] = "power%d_crit_alarm", | ||
357 | }; | ||
358 | |||
331 | static const char * const *__templates[] = { | 359 | static const char * const *__templates[] = { |
332 | [hwmon_chip] = hwmon_chip_attr_templates, | 360 | [hwmon_chip] = hwmon_chip_attr_templates, |
333 | [hwmon_temp] = hwmon_temp_attr_templates, | 361 | [hwmon_temp] = hwmon_temp_attr_templates, |
334 | [hwmon_in] = hwmon_in_attr_templates, | 362 | [hwmon_in] = hwmon_in_attr_templates, |
335 | [hwmon_curr] = hwmon_curr_attr_templates, | 363 | [hwmon_curr] = hwmon_curr_attr_templates, |
364 | [hwmon_power] = hwmon_power_attr_templates, | ||
336 | }; | 365 | }; |
337 | 366 | ||
338 | static const int __templates_size[] = { | 367 | static const int __templates_size[] = { |
@@ -340,6 +369,7 @@ static const int __templates_size[] = { | |||
340 | [hwmon_temp] = ARRAY_SIZE(hwmon_temp_attr_templates), | 369 | [hwmon_temp] = ARRAY_SIZE(hwmon_temp_attr_templates), |
341 | [hwmon_in] = ARRAY_SIZE(hwmon_in_attr_templates), | 370 | [hwmon_in] = ARRAY_SIZE(hwmon_in_attr_templates), |
342 | [hwmon_curr] = ARRAY_SIZE(hwmon_curr_attr_templates), | 371 | [hwmon_curr] = ARRAY_SIZE(hwmon_curr_attr_templates), |
372 | [hwmon_power] = ARRAY_SIZE(hwmon_power_attr_templates), | ||
343 | }; | 373 | }; |
344 | 374 | ||
345 | static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info) | 375 | static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info) |
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index 8781c2253b1d..d7e432ef7c2a 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h | |||
@@ -32,6 +32,7 @@ enum hwmon_chip_attributes { | |||
32 | hwmon_chip_temp_reset_history, | 32 | hwmon_chip_temp_reset_history, |
33 | hwmon_chip_in_reset_history, | 33 | hwmon_chip_in_reset_history, |
34 | hwmon_chip_curr_reset_history, | 34 | hwmon_chip_curr_reset_history, |
35 | hwmon_chip_power_reset_history, | ||
35 | hwmon_chip_register_tz, | 36 | hwmon_chip_register_tz, |
36 | hwmon_chip_update_interval, | 37 | hwmon_chip_update_interval, |
37 | hwmon_chip_alarms, | 38 | hwmon_chip_alarms, |
@@ -40,6 +41,7 @@ enum hwmon_chip_attributes { | |||
40 | #define HWMON_C_TEMP_RESET_HISTORY BIT(hwmon_chip_temp_reset_history) | 41 | #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_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_CURR_RESET_HISTORY BIT(hwmon_chip_curr_reset_history) |
44 | #define HWMON_C_POWER_RESET_HISTORY BIT(hwmon_chip_power_reset_history) | ||
43 | #define HWMON_C_REGISTER_TZ BIT(hwmon_chip_register_tz) | 45 | #define HWMON_C_REGISTER_TZ BIT(hwmon_chip_register_tz) |
44 | #define HWMON_C_UPDATE_INTERVAL BIT(hwmon_chip_update_interval) | 46 | #define HWMON_C_UPDATE_INTERVAL BIT(hwmon_chip_update_interval) |
45 | #define HWMON_C_ALARMS BIT(hwmon_chip_alarms) | 47 | #define HWMON_C_ALARMS BIT(hwmon_chip_alarms) |
@@ -162,6 +164,58 @@ enum hwmon_curr_attributes { | |||
162 | #define HWMON_C_LCRIT_ALARM BIT(hwmon_curr_lcrit_alarm) | 164 | #define HWMON_C_LCRIT_ALARM BIT(hwmon_curr_lcrit_alarm) |
163 | #define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm) | 165 | #define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm) |
164 | 166 | ||
167 | enum hwmon_power_attributes { | ||
168 | hwmon_power_average, | ||
169 | hwmon_power_average_interval, | ||
170 | hwmon_power_average_interval_max, | ||
171 | hwmon_power_average_interval_min, | ||
172 | hwmon_power_average_highest, | ||
173 | hwmon_power_average_lowest, | ||
174 | hwmon_power_average_max, | ||
175 | hwmon_power_average_min, | ||
176 | hwmon_power_input, | ||
177 | hwmon_power_input_highest, | ||
178 | hwmon_power_input_lowest, | ||
179 | hwmon_power_reset_history, | ||
180 | hwmon_power_accuracy, | ||
181 | hwmon_power_cap, | ||
182 | hwmon_power_cap_hyst, | ||
183 | hwmon_power_cap_max, | ||
184 | hwmon_power_cap_min, | ||
185 | hwmon_power_max, | ||
186 | hwmon_power_crit, | ||
187 | hwmon_power_label, | ||
188 | hwmon_power_alarm, | ||
189 | hwmon_power_cap_alarm, | ||
190 | hwmon_power_max_alarm, | ||
191 | hwmon_power_crit_alarm, | ||
192 | }; | ||
193 | |||
194 | #define HWMON_P_AVERAGE BIT(hwmon_power_average) | ||
195 | #define HWMON_P_AVERAGE_INTERVAL BIT(hwmon_power_average_interval) | ||
196 | #define HWMON_P_AVERAGE_INTERVAL_MAX BIT(hwmon_power_average_interval_max) | ||
197 | #define HWMON_P_AVERAGE_INTERVAL_MIN BIT(hwmon_power_average_interval_min) | ||
198 | #define HWMON_P_AVERAGE_HIGHEST BIT(hwmon_power_average_highest) | ||
199 | #define HWMON_P_AVERAGE_LOWEST BIT(hwmon_power_average_lowest) | ||
200 | #define HWMON_P_AVERAGE_MAX BIT(hwmon_power_average_max) | ||
201 | #define HWMON_P_AVERAGE_MIN BIT(hwmon_power_average_min) | ||
202 | #define HWMON_P_INPUT BIT(hwmon_power_input) | ||
203 | #define HWMON_P_INPUT_HIGHEST BIT(hwmon_power_input_highest) | ||
204 | #define HWMON_P_INPUT_LOWEST BIT(hwmon_power_input_lowest) | ||
205 | #define HWMON_P_RESET_HISTORY BIT(hwmon_power_reset_history) | ||
206 | #define HWMON_P_ACCURACY BIT(hwmon_power_accuracy) | ||
207 | #define HWMON_P_CAP BIT(hwmon_power_cap) | ||
208 | #define HWMON_P_CAP_HYST BIT(hwmon_power_cap_hyst) | ||
209 | #define HWMON_P_CAP_MAX BIT(hwmon_power_cap_max) | ||
210 | #define HWMON_P_CAP_MIN BIT(hwmon_power_cap_min) | ||
211 | #define HWMON_P_MAX BIT(hwmon_power_max) | ||
212 | #define HWMON_P_CRIT BIT(hwmon_power_crit) | ||
213 | #define HWMON_P_LABEL BIT(hwmon_power_label) | ||
214 | #define HWMON_P_ALARM BIT(hwmon_power_alarm) | ||
215 | #define HWMON_P_CAP_ALARM BIT(hwmon_power_cap_alarm) | ||
216 | #define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm) | ||
217 | #define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm) | ||
218 | |||
165 | /** | 219 | /** |
166 | * struct hwmon_ops - hwmon device operations | 220 | * struct hwmon_ops - hwmon device operations |
167 | * @is_visible: Callback to return attribute visibility. Mandatory. | 221 | * @is_visible: Callback to return attribute visibility. Mandatory. |