aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adt7470.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@us.ibm.com>2007-12-19 17:11:25 -0500
committerMark M. Hoffman <mhoffman@lightlink.com>2008-02-07 20:39:42 -0500
commitfe03f28cf35bf8dd0d3cba5e0c00a22530b73bfb (patch)
treef23fe5f248345fcc9abfed993b26d5a953a59e3d /drivers/hwmon/adt7470.c
parent7845cd791d87b9d5e6171452143dbef15aba00dc (diff)
hwmon: (adt7470) Support per-sensor alarm files
Remove the old alarms hack and replace it with per-sensor alarm files. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/adt7470.c')
-rw-r--r--drivers/hwmon/adt7470.c96
1 files changed, 84 insertions, 12 deletions
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index a2155605e318..747693ab2ff1 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -48,7 +48,22 @@ I2C_CLIENT_INSMOD_1(adt7470);
48#define ADT7470_REG_CFG 0x40 48#define ADT7470_REG_CFG 0x40
49#define ADT7470_FSPD_MASK 0x04 49#define ADT7470_FSPD_MASK 0x04
50#define ADT7470_REG_ALARM1 0x41 50#define ADT7470_REG_ALARM1 0x41
51#define ADT7470_R1T_ALARM 0x01
52#define ADT7470_R2T_ALARM 0x02
53#define ADT7470_R3T_ALARM 0x04
54#define ADT7470_R4T_ALARM 0x08
55#define ADT7470_R5T_ALARM 0x10
56#define ADT7470_R6T_ALARM 0x20
57#define ADT7470_R7T_ALARM 0x40
58#define ADT7470_OOL_ALARM 0x80
51#define ADT7470_REG_ALARM2 0x42 59#define ADT7470_REG_ALARM2 0x42
60#define ADT7470_R8T_ALARM 0x01
61#define ADT7470_R9T_ALARM 0x02
62#define ADT7470_R10T_ALARM 0x04
63#define ADT7470_FAN1_ALARM 0x10
64#define ADT7470_FAN2_ALARM 0x20
65#define ADT7470_FAN3_ALARM 0x40
66#define ADT7470_FAN4_ALARM 0x80
52#define ADT7470_REG_TEMP_LIMITS_BASE_ADDR 0x44 67#define ADT7470_REG_TEMP_LIMITS_BASE_ADDR 0x44
53#define ADT7470_REG_TEMP_LIMITS_MAX_ADDR 0x57 68#define ADT7470_REG_TEMP_LIMITS_MAX_ADDR 0x57
54#define ADT7470_REG_FAN_MIN_BASE_ADDR 0x58 69#define ADT7470_REG_FAN_MIN_BASE_ADDR 0x58
@@ -97,6 +112,8 @@ I2C_CLIENT_INSMOD_1(adt7470);
97#define ADT7470_REG_PWM_AUTO_TEMP(x) (ADT7470_REG_PWM_AUTO_TEMP_BASE_ADDR + \ 112#define ADT7470_REG_PWM_AUTO_TEMP(x) (ADT7470_REG_PWM_AUTO_TEMP_BASE_ADDR + \
98 ((x) / 2)) 113 ((x) / 2))
99 114
115#define ALARM2(x) ((x) << 8)
116
100#define ADT7470_VENDOR 0x41 117#define ADT7470_VENDOR 0x41
101#define ADT7470_DEVICE 0x70 118#define ADT7470_DEVICE 0x70
102/* datasheet only mentions a revision 2 */ 119/* datasheet only mentions a revision 2 */
@@ -136,7 +153,8 @@ struct adt7470_data {
136 u16 fan[ADT7470_FAN_COUNT]; 153 u16 fan[ADT7470_FAN_COUNT];
137 u16 fan_min[ADT7470_FAN_COUNT]; 154 u16 fan_min[ADT7470_FAN_COUNT];
138 u16 fan_max[ADT7470_FAN_COUNT]; 155 u16 fan_max[ADT7470_FAN_COUNT];
139 u16 alarms, alarms_mask; 156 u16 alarm;
157 u16 alarms_mask;
140 u8 force_pwm_max; 158 u8 force_pwm_max;
141 u8 pwm[ADT7470_PWM_COUNT]; 159 u8 pwm[ADT7470_PWM_COUNT];
142 u8 pwm_max[ADT7470_PWM_COUNT]; 160 u8 pwm_max[ADT7470_PWM_COUNT];
@@ -260,7 +278,10 @@ static struct adt7470_data *adt7470_update_device(struct device *dev)
260 else 278 else
261 data->force_pwm_max = 0; 279 data->force_pwm_max = 0;
262 280
263 data->alarms = adt7470_read_word_data(client, ADT7470_REG_ALARM1); 281 data->alarm = i2c_smbus_read_byte_data(client, ADT7470_REG_ALARM1);
282 if (data->alarm & ADT7470_OOL_ALARM)
283 data->alarm |= ALARM2(i2c_smbus_read_byte_data(client,
284 ADT7470_REG_ALARM2));
264 data->alarms_mask = adt7470_read_word_data(client, 285 data->alarms_mask = adt7470_read_word_data(client,
265 ADT7470_REG_ALARM1_MASK); 286 ADT7470_REG_ALARM1_MASK);
266 287
@@ -368,17 +389,13 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
368 return sprintf(buf, "%d\n", 1000 * data->temp[attr->index]); 389 return sprintf(buf, "%d\n", 1000 * data->temp[attr->index]);
369} 390}
370 391
371static ssize_t show_alarms(struct device *dev, 392static ssize_t show_alarm_mask(struct device *dev,
372 struct device_attribute *devattr, 393 struct device_attribute *devattr,
373 char *buf) 394 char *buf)
374{ 395{
375 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
376 struct adt7470_data *data = adt7470_update_device(dev); 396 struct adt7470_data *data = adt7470_update_device(dev);
377 397
378 if (attr->index) 398 return sprintf(buf, "%x\n", data->alarms_mask);
379 return sprintf(buf, "%x\n", data->alarms);
380 else
381 return sprintf(buf, "%x\n", data->alarms_mask);
382} 399}
383 400
384static ssize_t show_fan_max(struct device *dev, 401static ssize_t show_fan_max(struct device *dev,
@@ -713,8 +730,20 @@ static ssize_t set_pwm_auto_temp(struct device *dev,
713 return count; 730 return count;
714} 731}
715 732
716static SENSOR_DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL, 0); 733static ssize_t show_alarm(struct device *dev,
717static SENSOR_DEVICE_ATTR(alarm_mask, S_IRUGO, show_alarms, NULL, 1); 734 struct device_attribute *devattr,
735 char *buf)
736{
737 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
738 struct adt7470_data *data = adt7470_update_device(dev);
739
740 if (data->alarm & attr->index)
741 return sprintf(buf, "1\n");
742 else
743 return sprintf(buf, "0\n");
744}
745
746static DEVICE_ATTR(alarm_mask, S_IRUGO, show_alarm_mask, NULL);
718 747
719static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, 748static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
720 set_temp_max, 0); 749 set_temp_max, 0);
@@ -769,6 +798,27 @@ static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp, NULL, 7);
769static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_temp, NULL, 8); 798static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_temp, NULL, 8);
770static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_temp, NULL, 9); 799static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_temp, NULL, 9);
771 800
801static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL,
802 ADT7470_R1T_ALARM);
803static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL,
804 ADT7470_R2T_ALARM);
805static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL,
806 ADT7470_R3T_ALARM);
807static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL,
808 ADT7470_R4T_ALARM);
809static SENSOR_DEVICE_ATTR(temp5_alarm, S_IRUGO, show_alarm, NULL,
810 ADT7470_R5T_ALARM);
811static SENSOR_DEVICE_ATTR(temp6_alarm, S_IRUGO, show_alarm, NULL,
812 ADT7470_R6T_ALARM);
813static SENSOR_DEVICE_ATTR(temp7_alarm, S_IRUGO, show_alarm, NULL,
814 ADT7470_R7T_ALARM);
815static SENSOR_DEVICE_ATTR(temp8_alarm, S_IRUGO, show_alarm, NULL,
816 ALARM2(ADT7470_R8T_ALARM));
817static SENSOR_DEVICE_ATTR(temp9_alarm, S_IRUGO, show_alarm, NULL,
818 ALARM2(ADT7470_R9T_ALARM));
819static SENSOR_DEVICE_ATTR(temp10_alarm, S_IRUGO, show_alarm, NULL,
820 ALARM2(ADT7470_R10T_ALARM));
821
772static SENSOR_DEVICE_ATTR(fan1_max, S_IWUSR | S_IRUGO, show_fan_max, 822static SENSOR_DEVICE_ATTR(fan1_max, S_IWUSR | S_IRUGO, show_fan_max,
773 set_fan_max, 0); 823 set_fan_max, 0);
774static SENSOR_DEVICE_ATTR(fan2_max, S_IWUSR | S_IRUGO, show_fan_max, 824static SENSOR_DEVICE_ATTR(fan2_max, S_IWUSR | S_IRUGO, show_fan_max,
@@ -792,6 +842,15 @@ static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
792static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); 842static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
793static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); 843static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3);
794 844
845static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL,
846 ALARM2(ADT7470_FAN1_ALARM));
847static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL,
848 ALARM2(ADT7470_FAN2_ALARM));
849static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL,
850 ALARM2(ADT7470_FAN3_ALARM));
851static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL,
852 ALARM2(ADT7470_FAN4_ALARM));
853
795static SENSOR_DEVICE_ATTR(force_pwm_max, S_IWUSR | S_IRUGO, 854static SENSOR_DEVICE_ATTR(force_pwm_max, S_IWUSR | S_IRUGO,
796 show_force_pwm_max, set_force_pwm_max, 0); 855 show_force_pwm_max, set_force_pwm_max, 0);
797 856
@@ -856,8 +915,7 @@ static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO,
856 915
857static struct attribute *adt7470_attr[] = 916static struct attribute *adt7470_attr[] =
858{ 917{
859 &sensor_dev_attr_alarms.dev_attr.attr, 918 &dev_attr_alarm_mask.attr,
860 &sensor_dev_attr_alarm_mask.dev_attr.attr,
861 &sensor_dev_attr_temp1_max.dev_attr.attr, 919 &sensor_dev_attr_temp1_max.dev_attr.attr,
862 &sensor_dev_attr_temp2_max.dev_attr.attr, 920 &sensor_dev_attr_temp2_max.dev_attr.attr,
863 &sensor_dev_attr_temp3_max.dev_attr.attr, 921 &sensor_dev_attr_temp3_max.dev_attr.attr,
@@ -888,6 +946,16 @@ static struct attribute *adt7470_attr[] =
888 &sensor_dev_attr_temp8_input.dev_attr.attr, 946 &sensor_dev_attr_temp8_input.dev_attr.attr,
889 &sensor_dev_attr_temp9_input.dev_attr.attr, 947 &sensor_dev_attr_temp9_input.dev_attr.attr,
890 &sensor_dev_attr_temp10_input.dev_attr.attr, 948 &sensor_dev_attr_temp10_input.dev_attr.attr,
949 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
950 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
951 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
952 &sensor_dev_attr_temp4_alarm.dev_attr.attr,
953 &sensor_dev_attr_temp5_alarm.dev_attr.attr,
954 &sensor_dev_attr_temp6_alarm.dev_attr.attr,
955 &sensor_dev_attr_temp7_alarm.dev_attr.attr,
956 &sensor_dev_attr_temp8_alarm.dev_attr.attr,
957 &sensor_dev_attr_temp9_alarm.dev_attr.attr,
958 &sensor_dev_attr_temp10_alarm.dev_attr.attr,
891 &sensor_dev_attr_fan1_max.dev_attr.attr, 959 &sensor_dev_attr_fan1_max.dev_attr.attr,
892 &sensor_dev_attr_fan2_max.dev_attr.attr, 960 &sensor_dev_attr_fan2_max.dev_attr.attr,
893 &sensor_dev_attr_fan3_max.dev_attr.attr, 961 &sensor_dev_attr_fan3_max.dev_attr.attr,
@@ -900,6 +968,10 @@ static struct attribute *adt7470_attr[] =
900 &sensor_dev_attr_fan2_input.dev_attr.attr, 968 &sensor_dev_attr_fan2_input.dev_attr.attr,
901 &sensor_dev_attr_fan3_input.dev_attr.attr, 969 &sensor_dev_attr_fan3_input.dev_attr.attr,
902 &sensor_dev_attr_fan4_input.dev_attr.attr, 970 &sensor_dev_attr_fan4_input.dev_attr.attr,
971 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
972 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
973 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
974 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
903 &sensor_dev_attr_force_pwm_max.dev_attr.attr, 975 &sensor_dev_attr_force_pwm_max.dev_attr.attr,
904 &sensor_dev_attr_pwm1.dev_attr.attr, 976 &sensor_dev_attr_pwm1.dev_attr.attr,
905 &sensor_dev_attr_pwm2.dev_attr.attr, 977 &sensor_dev_attr_pwm2.dev_attr.attr,