diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:36:03 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:36:03 -0500 |
commit | f99318b2540da75e663603e1a0faef30a3bb0c92 (patch) | |
tree | f2de8f5addf130ea0fe82d48566d125602897331 | |
parent | f890c6a3b6c3ed06719e696fed9267cc6b40aabd (diff) |
hwmon: (adt7475) Implement pwm_use_point2_pwm_at_crit
Implement the non-standard pwm_use_point2_pwm_at_crit sysfs attribute
as the adt7473 driver did.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jordan Crouse <jordan@cosmicpenguin.net>
Cc: "Darrick J. Wong" <djwong@us.ibm.com>
-rw-r--r-- | drivers/hwmon/adt7475.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index fba2f016e4d8..188ae428ccdd 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c | |||
@@ -76,6 +76,9 @@ | |||
76 | #define REG_EXTEND1 0x76 | 76 | #define REG_EXTEND1 0x76 |
77 | #define REG_EXTEND2 0x77 | 77 | #define REG_EXTEND2 0x77 |
78 | #define REG_CONFIG5 0x7C | 78 | #define REG_CONFIG5 0x7C |
79 | #define REG_CONFIG4 0x7D | ||
80 | |||
81 | #define CONFIG4_MAXDUTY 0x08 | ||
79 | 82 | ||
80 | #define CONFIG5_TWOSCOMP 0x01 | 83 | #define CONFIG5_TWOSCOMP 0x01 |
81 | #define CONFIG5_TEMPOFFSET 0x02 | 84 | #define CONFIG5_TEMPOFFSET 0x02 |
@@ -132,6 +135,7 @@ struct adt7475_data { | |||
132 | unsigned long limits_updated; | 135 | unsigned long limits_updated; |
133 | char valid; | 136 | char valid; |
134 | 137 | ||
138 | u8 config4; | ||
135 | u8 config5; | 139 | u8 config5; |
136 | u16 alarms; | 140 | u16 alarms; |
137 | u16 voltage[3][3]; | 141 | u16 voltage[3][3]; |
@@ -779,6 +783,38 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, | |||
779 | return count; | 783 | return count; |
780 | } | 784 | } |
781 | 785 | ||
786 | static ssize_t show_pwm_at_crit(struct device *dev, | ||
787 | struct device_attribute *devattr, char *buf) | ||
788 | { | ||
789 | struct adt7475_data *data = adt7475_update_device(dev); | ||
790 | return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY)); | ||
791 | } | ||
792 | |||
793 | static ssize_t set_pwm_at_crit(struct device *dev, | ||
794 | struct device_attribute *devattr, | ||
795 | const char *buf, size_t count) | ||
796 | { | ||
797 | struct i2c_client *client = to_i2c_client(dev); | ||
798 | struct adt7475_data *data = i2c_get_clientdata(client); | ||
799 | long val; | ||
800 | |||
801 | if (strict_strtol(buf, 10, &val)) | ||
802 | return -EINVAL; | ||
803 | if (val != 0 && val != 1) | ||
804 | return -EINVAL; | ||
805 | |||
806 | mutex_lock(&data->lock); | ||
807 | data->config4 = i2c_smbus_read_byte_data(client, REG_CONFIG4); | ||
808 | if (val) | ||
809 | data->config4 |= CONFIG4_MAXDUTY; | ||
810 | else | ||
811 | data->config4 &= ~CONFIG4_MAXDUTY; | ||
812 | i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4); | ||
813 | mutex_unlock(&data->lock); | ||
814 | |||
815 | return count; | ||
816 | } | ||
817 | |||
782 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0); | 818 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0); |
783 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, | 819 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, |
784 | set_voltage, MAX, 0); | 820 | set_voltage, MAX, 0); |
@@ -894,6 +930,10 @@ static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, | |||
894 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, | 930 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, |
895 | set_pwm, MAX, 2); | 931 | set_pwm, MAX, 2); |
896 | 932 | ||
933 | /* Non-standard name, might need revisiting */ | ||
934 | static DEVICE_ATTR(pwm_use_point2_pwm_at_crit, S_IWUSR | S_IRUGO, | ||
935 | show_pwm_at_crit, set_pwm_at_crit); | ||
936 | |||
897 | static struct attribute *adt7475_attrs[] = { | 937 | static struct attribute *adt7475_attrs[] = { |
898 | &sensor_dev_attr_in1_input.dev_attr.attr, | 938 | &sensor_dev_attr_in1_input.dev_attr.attr, |
899 | &sensor_dev_attr_in1_max.dev_attr.attr, | 939 | &sensor_dev_attr_in1_max.dev_attr.attr, |
@@ -962,6 +1002,7 @@ static struct attribute *adt7475_attrs[] = { | |||
962 | &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, | 1002 | &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, |
963 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | 1003 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, |
964 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | 1004 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, |
1005 | &dev_attr_pwm_use_point2_pwm_at_crit.attr, | ||
965 | NULL, | 1006 | NULL, |
966 | }; | 1007 | }; |
967 | 1008 | ||
@@ -1160,6 +1201,7 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) | |||
1160 | /* Limits and settings, should never change update every 60 seconds */ | 1201 | /* Limits and settings, should never change update every 60 seconds */ |
1161 | if (time_after(jiffies, data->limits_updated + HZ * 60) || | 1202 | if (time_after(jiffies, data->limits_updated + HZ * 60) || |
1162 | !data->valid) { | 1203 | !data->valid) { |
1204 | data->config4 = adt7475_read(REG_CONFIG4); | ||
1163 | data->config5 = adt7475_read(REG_CONFIG5); | 1205 | data->config5 = adt7475_read(REG_CONFIG5); |
1164 | 1206 | ||
1165 | for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { | 1207 | for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { |