aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/w83627hf.c142
1 files changed, 139 insertions, 3 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 185ae1b8027d..c02c3bbde19f 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -717,6 +717,29 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
717} 717}
718static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 718static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
719 719
720static ssize_t
721show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
722{
723 struct w83627hf_data *data = w83627hf_update_device(dev);
724 int bitnr = to_sensor_dev_attr(attr)->index;
725 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
726}
727static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
728static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
729static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
730static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
731static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
732static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9);
733static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 10);
734static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 16);
735static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 17);
736static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
737static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
738static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11);
739static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
740static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
741static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
742
720#define show_beep_reg(REG, reg) \ 743#define show_beep_reg(REG, reg) \
721static ssize_t show_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \ 744static ssize_t show_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \
722{ \ 745{ \
@@ -778,6 +801,91 @@ sysfs_beep(ENABLE, enable);
778sysfs_beep(MASK, mask); 801sysfs_beep(MASK, mask);
779 802
780static ssize_t 803static ssize_t
804show_beep(struct device *dev, struct device_attribute *attr, char *buf)
805{
806 struct w83627hf_data *data = w83627hf_update_device(dev);
807 int bitnr = to_sensor_dev_attr(attr)->index;
808 return sprintf(buf, "%u\n", (data->beep_mask >> bitnr) & 1);
809}
810
811static ssize_t
812store_beep(struct device *dev, struct device_attribute *attr,
813 const char *buf, size_t count)
814{
815 struct w83627hf_data *data = dev_get_drvdata(dev);
816 int bitnr = to_sensor_dev_attr(attr)->index;
817 unsigned long bit;
818 u8 reg;
819
820 bit = simple_strtoul(buf, NULL, 10);
821 if (bit & ~1)
822 return -EINVAL;
823
824 mutex_lock(&data->update_lock);
825 if (bit)
826 data->beep_mask |= (1 << bitnr);
827 else
828 data->beep_mask &= ~(1 << bitnr);
829
830 if (bitnr < 8) {
831 reg = w83627hf_read_value(data, W83781D_REG_BEEP_INTS1);
832 if (bit)
833 reg |= (1 << bitnr);
834 else
835 reg &= ~(1 << bitnr);
836 w83627hf_write_value(data, W83781D_REG_BEEP_INTS1, reg);
837 } else if (bitnr < 16) {
838 reg = w83627hf_read_value(data, W83781D_REG_BEEP_INTS2);
839 if (bit)
840 reg |= (1 << (bitnr - 8));
841 else
842 reg &= ~(1 << (bitnr - 8));
843 w83627hf_write_value(data, W83781D_REG_BEEP_INTS2, reg);
844 } else {
845 reg = w83627hf_read_value(data, W83781D_REG_BEEP_INTS3);
846 if (bit)
847 reg |= (1 << (bitnr - 16));
848 else
849 reg &= ~(1 << (bitnr - 16));
850 w83627hf_write_value(data, W83781D_REG_BEEP_INTS3, reg);
851 }
852 mutex_unlock(&data->update_lock);
853
854 return count;
855}
856
857static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO | S_IWUSR,
858 show_beep, store_beep, 0);
859static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO | S_IWUSR,
860 show_beep, store_beep, 1);
861static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO | S_IWUSR,
862 show_beep, store_beep, 2);
863static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO | S_IWUSR,
864 show_beep, store_beep, 3);
865static SENSOR_DEVICE_ATTR(in4_beep, S_IRUGO | S_IWUSR,
866 show_beep, store_beep, 8);
867static SENSOR_DEVICE_ATTR(in5_beep, S_IRUGO | S_IWUSR,
868 show_beep, store_beep, 9);
869static SENSOR_DEVICE_ATTR(in6_beep, S_IRUGO | S_IWUSR,
870 show_beep, store_beep, 10);
871static SENSOR_DEVICE_ATTR(in7_beep, S_IRUGO | S_IWUSR,
872 show_beep, store_beep, 16);
873static SENSOR_DEVICE_ATTR(in8_beep, S_IRUGO | S_IWUSR,
874 show_beep, store_beep, 17);
875static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO | S_IWUSR,
876 show_beep, store_beep, 6);
877static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO | S_IWUSR,
878 show_beep, store_beep, 7);
879static SENSOR_DEVICE_ATTR(fan3_beep, S_IRUGO | S_IWUSR,
880 show_beep, store_beep, 11);
881static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO | S_IWUSR,
882 show_beep, store_beep, 4);
883static SENSOR_DEVICE_ATTR(temp2_beep, S_IRUGO | S_IWUSR,
884 show_beep, store_beep, 5);
885static SENSOR_DEVICE_ATTR(temp3_beep, S_IRUGO | S_IWUSR,
886 show_beep, store_beep, 13);
887
888static ssize_t
781show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) 889show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
782{ 890{
783 int nr = to_sensor_dev_attr(devattr)->index; 891 int nr = to_sensor_dev_attr(devattr)->index;
@@ -1077,23 +1185,31 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
1077#define VIN_UNIT_ATTRS(_X_) \ 1185#define VIN_UNIT_ATTRS(_X_) \
1078 &sensor_dev_attr_in##_X_##_input.dev_attr.attr, \ 1186 &sensor_dev_attr_in##_X_##_input.dev_attr.attr, \
1079 &sensor_dev_attr_in##_X_##_min.dev_attr.attr, \ 1187 &sensor_dev_attr_in##_X_##_min.dev_attr.attr, \
1080 &sensor_dev_attr_in##_X_##_max.dev_attr.attr 1188 &sensor_dev_attr_in##_X_##_max.dev_attr.attr, \
1189 &sensor_dev_attr_in##_X_##_alarm.dev_attr.attr, \
1190 &sensor_dev_attr_in##_X_##_beep.dev_attr.attr
1081 1191
1082#define FAN_UNIT_ATTRS(_X_) \ 1192#define FAN_UNIT_ATTRS(_X_) \
1083 &sensor_dev_attr_fan##_X_##_input.dev_attr.attr, \ 1193 &sensor_dev_attr_fan##_X_##_input.dev_attr.attr, \
1084 &sensor_dev_attr_fan##_X_##_min.dev_attr.attr, \ 1194 &sensor_dev_attr_fan##_X_##_min.dev_attr.attr, \
1085 &sensor_dev_attr_fan##_X_##_div.dev_attr.attr 1195 &sensor_dev_attr_fan##_X_##_div.dev_attr.attr, \
1196 &sensor_dev_attr_fan##_X_##_alarm.dev_attr.attr, \
1197 &sensor_dev_attr_fan##_X_##_beep.dev_attr.attr
1086 1198
1087#define TEMP_UNIT_ATTRS(_X_) \ 1199#define TEMP_UNIT_ATTRS(_X_) \
1088 &sensor_dev_attr_temp##_X_##_input.dev_attr.attr, \ 1200 &sensor_dev_attr_temp##_X_##_input.dev_attr.attr, \
1089 &sensor_dev_attr_temp##_X_##_max.dev_attr.attr, \ 1201 &sensor_dev_attr_temp##_X_##_max.dev_attr.attr, \
1090 &sensor_dev_attr_temp##_X_##_max_hyst.dev_attr.attr, \ 1202 &sensor_dev_attr_temp##_X_##_max_hyst.dev_attr.attr, \
1091 &sensor_dev_attr_temp##_X_##_type.dev_attr.attr 1203 &sensor_dev_attr_temp##_X_##_type.dev_attr.attr, \
1204 &sensor_dev_attr_temp##_X_##_alarm.dev_attr.attr, \
1205 &sensor_dev_attr_temp##_X_##_beep.dev_attr.attr
1092 1206
1093static struct attribute *w83627hf_attributes[] = { 1207static struct attribute *w83627hf_attributes[] = {
1094 &dev_attr_in0_input.attr, 1208 &dev_attr_in0_input.attr,
1095 &dev_attr_in0_min.attr, 1209 &dev_attr_in0_min.attr,
1096 &dev_attr_in0_max.attr, 1210 &dev_attr_in0_max.attr,
1211 &sensor_dev_attr_in0_alarm.dev_attr.attr,
1212 &sensor_dev_attr_in0_beep.dev_attr.attr,
1097 VIN_UNIT_ATTRS(2), 1213 VIN_UNIT_ATTRS(2),
1098 VIN_UNIT_ATTRS(3), 1214 VIN_UNIT_ATTRS(3),
1099 VIN_UNIT_ATTRS(4), 1215 VIN_UNIT_ATTRS(4),
@@ -1197,12 +1313,20 @@ static int __devinit w83627hf_probe(struct platform_device *pdev)
1197 || (err = device_create_file(dev, 1313 || (err = device_create_file(dev,
1198 &sensor_dev_attr_in5_max.dev_attr)) 1314 &sensor_dev_attr_in5_max.dev_attr))
1199 || (err = device_create_file(dev, 1315 || (err = device_create_file(dev,
1316 &sensor_dev_attr_in5_alarm.dev_attr))
1317 || (err = device_create_file(dev,
1318 &sensor_dev_attr_in5_beep.dev_attr))
1319 || (err = device_create_file(dev,
1200 &sensor_dev_attr_in6_input.dev_attr)) 1320 &sensor_dev_attr_in6_input.dev_attr))
1201 || (err = device_create_file(dev, 1321 || (err = device_create_file(dev,
1202 &sensor_dev_attr_in6_min.dev_attr)) 1322 &sensor_dev_attr_in6_min.dev_attr))
1203 || (err = device_create_file(dev, 1323 || (err = device_create_file(dev,
1204 &sensor_dev_attr_in6_max.dev_attr)) 1324 &sensor_dev_attr_in6_max.dev_attr))
1205 || (err = device_create_file(dev, 1325 || (err = device_create_file(dev,
1326 &sensor_dev_attr_in6_alarm.dev_attr))
1327 || (err = device_create_file(dev,
1328 &sensor_dev_attr_in6_beep.dev_attr))
1329 || (err = device_create_file(dev,
1206 &sensor_dev_attr_pwm1_freq.dev_attr)) 1330 &sensor_dev_attr_pwm1_freq.dev_attr))
1207 || (err = device_create_file(dev, 1331 || (err = device_create_file(dev,
1208 &sensor_dev_attr_pwm2_freq.dev_attr))) 1332 &sensor_dev_attr_pwm2_freq.dev_attr)))
@@ -1216,18 +1340,30 @@ static int __devinit w83627hf_probe(struct platform_device *pdev)
1216 || (err = device_create_file(dev, 1340 || (err = device_create_file(dev,
1217 &sensor_dev_attr_in1_max.dev_attr)) 1341 &sensor_dev_attr_in1_max.dev_attr))
1218 || (err = device_create_file(dev, 1342 || (err = device_create_file(dev,
1343 &sensor_dev_attr_in1_alarm.dev_attr))
1344 || (err = device_create_file(dev,
1345 &sensor_dev_attr_in1_beep.dev_attr))
1346 || (err = device_create_file(dev,
1219 &sensor_dev_attr_fan3_input.dev_attr)) 1347 &sensor_dev_attr_fan3_input.dev_attr))
1220 || (err = device_create_file(dev, 1348 || (err = device_create_file(dev,
1221 &sensor_dev_attr_fan3_min.dev_attr)) 1349 &sensor_dev_attr_fan3_min.dev_attr))
1222 || (err = device_create_file(dev, 1350 || (err = device_create_file(dev,
1223 &sensor_dev_attr_fan3_div.dev_attr)) 1351 &sensor_dev_attr_fan3_div.dev_attr))
1224 || (err = device_create_file(dev, 1352 || (err = device_create_file(dev,
1353 &sensor_dev_attr_fan3_alarm.dev_attr))
1354 || (err = device_create_file(dev,
1355 &sensor_dev_attr_fan3_beep.dev_attr))
1356 || (err = device_create_file(dev,
1225 &sensor_dev_attr_temp3_input.dev_attr)) 1357 &sensor_dev_attr_temp3_input.dev_attr))
1226 || (err = device_create_file(dev, 1358 || (err = device_create_file(dev,
1227 &sensor_dev_attr_temp3_max.dev_attr)) 1359 &sensor_dev_attr_temp3_max.dev_attr))
1228 || (err = device_create_file(dev, 1360 || (err = device_create_file(dev,
1229 &sensor_dev_attr_temp3_max_hyst.dev_attr)) 1361 &sensor_dev_attr_temp3_max_hyst.dev_attr))
1230 || (err = device_create_file(dev, 1362 || (err = device_create_file(dev,
1363 &sensor_dev_attr_temp3_alarm.dev_attr))
1364 || (err = device_create_file(dev,
1365 &sensor_dev_attr_temp3_beep.dev_attr))
1366 || (err = device_create_file(dev,
1231 &sensor_dev_attr_temp3_type.dev_attr))) 1367 &sensor_dev_attr_temp3_type.dev_attr)))
1232 goto ERROR4; 1368 goto ERROR4;
1233 1369