Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (core) Add basic pwm attribute support to new API

Add basic pwm attribute support (no auto attributes) to new API.

Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

+24
+2
Documentation/hwmon/hwmon-kernel-api.txt
··· 168 168 * hwmon_energy Energy sensor 169 169 * hwmon_humidity Humidity sensor 170 170 * hwmon_fan Fan speed sensor 171 + * hwmon_pwm PWM control 171 172 172 173 * config: Pointer to a 0-terminated list of configuration values for each 173 174 sensor of the given type. Each value is a combination of bit values ··· 231 230 HWMON_E_xxxx Energy attributes, for use with hwmon_energy. 232 231 HWMON_H_xxxx Humidity attributes, for use with hwmon_humidity. 233 232 HWMON_F_xxxx Fan speed attributes, for use with hwmon_fan. 233 + HWMON_PWM_xxxx PWM control attributes, for use with hwmon_pwm. 234 234 235 235 Driver callback functions 236 236 -------------------------
+9
drivers/hwmon/hwmon.c
··· 386 386 [hwmon_fan_fault] = "fan%d_fault", 387 387 }; 388 388 389 + static const char * const hwmon_pwm_attr_templates[] = { 390 + [hwmon_pwm_input] = "pwm%d", 391 + [hwmon_pwm_enable] = "pwm%d_enable", 392 + [hwmon_pwm_mode] = "pwm%d_mode", 393 + [hwmon_pwm_freq] = "pwm%d_freq", 394 + }; 395 + 389 396 static const char * const *__templates[] = { 390 397 [hwmon_chip] = hwmon_chip_attr_templates, 391 398 [hwmon_temp] = hwmon_temp_attr_templates, ··· 402 395 [hwmon_energy] = hwmon_energy_attr_templates, 403 396 [hwmon_humidity] = hwmon_humidity_attr_templates, 404 397 [hwmon_fan] = hwmon_fan_attr_templates, 398 + [hwmon_pwm] = hwmon_pwm_attr_templates, 405 399 }; 406 400 407 401 static const int __templates_size[] = { ··· 414 406 [hwmon_energy] = ARRAY_SIZE(hwmon_energy_attr_templates), 415 407 [hwmon_humidity] = ARRAY_SIZE(hwmon_humidity_attr_templates), 416 408 [hwmon_fan] = ARRAY_SIZE(hwmon_fan_attr_templates), 409 + [hwmon_pwm] = ARRAY_SIZE(hwmon_pwm_attr_templates), 417 410 }; 418 411 419 412 static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info)
+13
include/linux/hwmon.h
··· 28 28 hwmon_energy, 29 29 hwmon_humidity, 30 30 hwmon_fan, 31 + hwmon_pwm, 31 32 }; 32 33 33 34 enum hwmon_chip_attributes { ··· 272 271 #define HWMON_F_MIN_ALARM BIT(hwmon_fan_min_alarm) 273 272 #define HWMON_F_MAX_ALARM BIT(hwmon_fan_max_alarm) 274 273 #define HWMON_F_FAULT BIT(hwmon_fan_fault) 274 + 275 + enum hwmon_pwm_attributes { 276 + hwmon_pwm_input, 277 + hwmon_pwm_enable, 278 + hwmon_pwm_mode, 279 + hwmon_pwm_freq, 280 + }; 281 + 282 + #define HWMON_PWM_INPUT BIT(hwmon_pwm_input) 283 + #define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable) 284 + #define HWMON_PWM_MODE BIT(hwmon_pwm_mode) 285 + #define HWMON_PWM_FREQ BIT(hwmon_pwm_freq) 275 286 276 287 /** 277 288 * struct hwmon_ops - hwmon device operations