diff options
author | Constantine Shulyupin <const@MakeLinux.com> | 2015-07-04 18:41:31 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-08-09 16:44:25 -0400 |
commit | 876420e05a0fda4801c0a0de67e9bbe9831dffee (patch) | |
tree | dcb10a31b2d757389dac2491705e705ee8e2aa30 /drivers/hwmon | |
parent | ea33597c6f9862d7b926bdb9c3ac25012f307dd5 (diff) |
hwmon: (nct7802) Add pwm mode attributes
Introduced: show_pwm_mode, pwm1_mode, pwm2_mode, pwm2_mode
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/nct7802.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c index 457b0f2678a4..1c80aa48ee04 100644 --- a/drivers/hwmon/nct7802.c +++ b/drivers/hwmon/nct7802.c | |||
@@ -102,6 +102,24 @@ static ssize_t store_temp_type(struct device *dev, | |||
102 | return err ? : count; | 102 | return err ? : count; |
103 | } | 103 | } |
104 | 104 | ||
105 | static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, | ||
106 | char *buf) | ||
107 | { | ||
108 | struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); | ||
109 | struct nct7802_data *data = dev_get_drvdata(dev); | ||
110 | unsigned int regval; | ||
111 | int ret; | ||
112 | |||
113 | if (sattr->index > 1) | ||
114 | return sprintf(buf, "1\n"); | ||
115 | |||
116 | ret = regmap_read(data->regmap, 0x5E, ®val); | ||
117 | if (ret < 0) | ||
118 | return ret; | ||
119 | |||
120 | return sprintf(buf, "%u\n", !(regval & (1 << sattr->index))); | ||
121 | } | ||
122 | |||
105 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, | 123 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, |
106 | char *buf) | 124 | char *buf) |
107 | { | 125 | { |
@@ -765,6 +783,11 @@ static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 2); | |||
765 | static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, | 783 | static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
766 | 0x5b, 2); | 784 | 0x5b, 2); |
767 | 785 | ||
786 | /* 7.2.89 Fan Control Output Type */ | ||
787 | static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); | ||
788 | static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); | ||
789 | static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); | ||
790 | |||
768 | /* 7.2.91... Fan Control Output Value */ | 791 | /* 7.2.91... Fan Control Output Value */ |
769 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x60); | 792 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x60); |
770 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x61); | 793 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x61); |
@@ -809,8 +832,11 @@ static struct attribute_group nct7802_fan_group = { | |||
809 | }; | 832 | }; |
810 | 833 | ||
811 | static struct attribute *nct7802_pwm_attrs[] = { | 834 | static struct attribute *nct7802_pwm_attrs[] = { |
835 | &sensor_dev_attr_pwm1_mode.dev_attr.attr, | ||
812 | &sensor_dev_attr_pwm1.dev_attr.attr, | 836 | &sensor_dev_attr_pwm1.dev_attr.attr, |
837 | &sensor_dev_attr_pwm2_mode.dev_attr.attr, | ||
813 | &sensor_dev_attr_pwm2.dev_attr.attr, | 838 | &sensor_dev_attr_pwm2.dev_attr.attr, |
839 | &sensor_dev_attr_pwm3_mode.dev_attr.attr, | ||
814 | &sensor_dev_attr_pwm3.dev_attr.attr, | 840 | &sensor_dev_attr_pwm3.dev_attr.attr, |
815 | NULL | 841 | NULL |
816 | }; | 842 | }; |