27 #include <linux/module.h>
29 #include <linux/slab.h>
31 #include <linux/i2c.h>
39 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e,
I2C_CLIENT_END };
49 #define LM85_REG_IN(nr) (0x20 + (nr))
50 #define LM85_REG_IN_MIN(nr) (0x44 + (nr) * 2)
51 #define LM85_REG_IN_MAX(nr) (0x45 + (nr) * 2)
53 #define LM85_REG_TEMP(nr) (0x25 + (nr))
54 #define LM85_REG_TEMP_MIN(nr) (0x4e + (nr) * 2)
55 #define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2)
58 #define LM85_REG_FAN(nr) (0x28 + (nr) * 2)
59 #define LM85_REG_FAN_MIN(nr) (0x54 + (nr) * 2)
61 #define LM85_REG_PWM(nr) (0x30 + (nr))
63 #define LM85_REG_COMPANY 0x3e
64 #define LM85_REG_VERSTEP 0x3f
66 #define ADT7468_REG_CFG5 0x7c
67 #define ADT7468_OFF64 (1 << 0)
68 #define ADT7468_HFPWM (1 << 1)
69 #define IS_ADT7468_OFF64(data) \
70 ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_OFF64))
71 #define IS_ADT7468_HFPWM(data) \
72 ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_HFPWM))
75 #define LM85_COMPANY_NATIONAL 0x01
76 #define LM85_COMPANY_ANALOG_DEV 0x41
77 #define LM85_COMPANY_SMSC 0x5c
78 #define LM85_VERSTEP_VMASK 0xf0
79 #define LM85_VERSTEP_GENERIC 0x60
80 #define LM85_VERSTEP_GENERIC2 0x70
81 #define LM85_VERSTEP_LM85C 0x60
82 #define LM85_VERSTEP_LM85B 0x62
83 #define LM85_VERSTEP_LM96000_1 0x68
84 #define LM85_VERSTEP_LM96000_2 0x69
85 #define LM85_VERSTEP_ADM1027 0x60
86 #define LM85_VERSTEP_ADT7463 0x62
87 #define LM85_VERSTEP_ADT7463C 0x6A
88 #define LM85_VERSTEP_ADT7468_1 0x71
89 #define LM85_VERSTEP_ADT7468_2 0x72
90 #define LM85_VERSTEP_EMC6D100_A0 0x60
91 #define LM85_VERSTEP_EMC6D100_A1 0x61
92 #define LM85_VERSTEP_EMC6D102 0x65
93 #define LM85_VERSTEP_EMC6D103_A0 0x68
94 #define LM85_VERSTEP_EMC6D103_A1 0x69
95 #define LM85_VERSTEP_EMC6D103S 0x6A
97 #define LM85_REG_CONFIG 0x40
99 #define LM85_REG_ALARM1 0x41
100 #define LM85_REG_ALARM2 0x42
102 #define LM85_REG_VID 0x43
105 #define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr))
106 #define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr))
107 #define LM85_REG_AFAN_SPIKE1 0x62
108 #define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr))
109 #define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr))
110 #define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr))
111 #define LM85_REG_AFAN_HYST1 0x6d
112 #define LM85_REG_AFAN_HYST2 0x6e
114 #define ADM1027_REG_EXTEND_ADC1 0x76
115 #define ADM1027_REG_EXTEND_ADC2 0x77
117 #define EMC6D100_REG_ALARM3 0x7d
119 #define EMC6D100_REG_IN(nr) (0x70 + ((nr) - 5))
120 #define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr) - 5) * 2)
121 #define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr) - 5) * 2)
122 #define EMC6D102_REG_EXTEND_ADC1 0x85
123 #define EMC6D102_REG_EXTEND_ADC2 0x86
124 #define EMC6D102_REG_EXTEND_ADC3 0x87
125 #define EMC6D102_REG_EXTEND_ADC4 0x88
135 static const int lm85_scaling[] = {
136 2500, 2250, 3300, 5000, 12000,
139 #define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from))
141 #define INS_TO_REG(n, val) \
142 SENSORS_LIMIT(SCALE(val, lm85_scaling[n], 192), 0, 255)
144 #define INSEXT_FROM_REG(n, val, ext) \
145 SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n])
147 #define INS_FROM_REG(n, val) SCALE((val), 192, lm85_scaling[n])
154 return SENSORS_LIMIT(5400000 / val, 1, 0xfffe);
156 #define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \
160 #define TEMP_TO_REG(val) \
161 SENSORS_LIMIT(SCALE(val, 1000, 1), -127, 127)
162 #define TEMPEXT_FROM_REG(val, ext) \
163 SCALE(((val) << 4) + (ext), 16, 1000)
164 #define TEMP_FROM_REG(val) ((val) * 1000)
166 #define PWM_TO_REG(val) SENSORS_LIMIT(val, 0, 255)
167 #define PWM_FROM_REG(val) (val)
190 static const int lm85_range_map[] = {
191 2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000,
192 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
195 static int RANGE_TO_REG(
int range)
200 for (i = 0; i < 15; ++
i) {
201 if (range <= (lm85_range_map[i] + lm85_range_map[i + 1]) / 2)
207 #define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f]
210 static const int lm85_freq_map[8] = {
211 10, 15, 23, 30, 38, 47, 61, 94
213 static const int adm1027_freq_map[8] = {
214 11, 15, 22, 29, 35, 44, 59, 88
217 static int FREQ_TO_REG(
const int *
map,
int freq)
222 for (i = 0; i < 7; ++
i)
223 if (freq <= (map[i] + map[i + 1]) / 2)
228 static int FREQ_FROM_REG(
const int *map,
u8 reg)
230 return map[reg & 0x07];
246 static const int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 };
247 #define ZONE_FROM_REG(val) lm85_zone_map[(val) >> 5]
249 static int ZONE_TO_REG(
int zone)
253 for (i = 0; i <= 7; ++
i)
254 if (zone == lm85_zone_map[i])
261 #define HYST_TO_REG(val) SENSORS_LIMIT(((val) + 500) / 1000, 0, 15)
262 #define HYST_FROM_REG(val) ((val) * 1000)
278 #define LM85_DATA_INTERVAL (HZ + HZ / 2)
279 #define LM85_CONFIG_INTERVAL (1 * 60 * HZ)
372 .remove = lm85_remove,
374 .detect = lm85_detect,
375 .address_list = normal_i2c,
392 struct lm85_data *data = lm85_update_device(dev);
397 const char *buf,
size_t count)
401 struct lm85_data *data = i2c_get_clientdata(client);
405 err = kstrtoul(buf, 10, &val);
416 #define show_fan_offset(offset) \
417 static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
418 show_fan, NULL, offset - 1); \
419 static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
420 show_fan_min, set_fan_min, offset - 1)
432 struct lm85_data *data = lm85_update_device(dev);
443 return sprintf(buf,
"%d\n", vid);
452 return sprintf(buf,
"%ld\n", (
long) data->
vrm);
456 const char *buf,
size_t count)
462 err = kstrtoul(buf, 10, &val);
475 struct lm85_data *data = lm85_update_device(dev);
485 struct lm85_data *data = lm85_update_device(dev);
513 struct lm85_data *data = lm85_update_device(dev);
518 const char *buf,
size_t count)
522 struct lm85_data *data = i2c_get_clientdata(client);
526 err = kstrtoul(buf, 10, &val);
541 struct lm85_data *data = lm85_update_device(dev);
556 return sprintf(buf,
"%d\n", enable);
560 *attr,
const char *buf,
size_t count)
564 struct lm85_data *data = i2c_get_clientdata(client);
569 err = kstrtoul(buf, 10, &val);
592 data->
autofan[
nr].config = lm85_read_value(client,
606 struct lm85_data *data = lm85_update_device(dev);
614 return sprintf(buf,
"%d\n", freq);
622 struct lm85_data *data = i2c_get_clientdata(client);
626 err = kstrtoul(buf, 10, &val);
642 (data->
zone[nr].range << 4)
653 #define show_pwm_reg(offset) \
654 static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
655 show_pwm, set_pwm, offset - 1); \
656 static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
657 show_pwm_enable, set_pwm_enable, offset - 1); \
658 static SENSOR_DEVICE_ATTR(pwm##offset##_freq, S_IRUGO | S_IWUSR, \
659 show_pwm_freq, set_pwm_freq, offset - 1)
671 struct lm85_data *data = lm85_update_device(dev);
680 struct lm85_data *data = lm85_update_device(dev);
685 const char *buf,
size_t count)
689 struct lm85_data *data = i2c_get_clientdata(client);
693 err = kstrtol(buf, 10, &val);
708 struct lm85_data *data = lm85_update_device(dev);
713 const char *buf,
size_t count)
717 struct lm85_data *data = i2c_get_clientdata(client);
721 err = kstrtol(buf, 10, &val);
732 #define show_in_reg(offset) \
733 static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
734 show_in, NULL, offset); \
735 static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
736 show_in_min, set_in_min, offset); \
737 static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
738 show_in_max, set_in_max, offset)
755 struct lm85_data *data = lm85_update_device(dev);
764 struct lm85_data *data = lm85_update_device(dev);
769 const char *buf,
size_t count)
773 struct lm85_data *data = i2c_get_clientdata(client);
777 err = kstrtol(buf, 10, &val);
795 struct lm85_data *data = lm85_update_device(dev);
800 const char *buf,
size_t count)
804 struct lm85_data *data = i2c_get_clientdata(client);
808 err = kstrtol(buf, 10, &val);
822 #define show_temp_reg(offset) \
823 static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
824 show_temp, NULL, offset - 1); \
825 static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
826 show_temp_min, set_temp_min, offset - 1); \
827 static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
828 show_temp_max, set_temp_max, offset - 1);
841 struct lm85_data *data = lm85_update_device(dev);
850 struct lm85_data *data = i2c_get_clientdata(client);
854 err = kstrtol(buf, 10, &val);
871 struct lm85_data *data = lm85_update_device(dev);
880 struct lm85_data *data = i2c_get_clientdata(client);
884 err = kstrtoul(buf, 10, &val);
900 struct lm85_data *data = lm85_update_device(dev);
909 struct lm85_data *data = i2c_get_clientdata(client);
914 err = kstrtol(buf, 10, &val);
921 tmp &= ~(0x20 <<
nr);
929 #define pwm_auto(offset) \
930 static SENSOR_DEVICE_ATTR(pwm##offset##_auto_channels, \
931 S_IRUGO | S_IWUSR, show_pwm_auto_channels, \
932 set_pwm_auto_channels, offset - 1); \
933 static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_min, \
934 S_IRUGO | S_IWUSR, show_pwm_auto_pwm_min, \
935 set_pwm_auto_pwm_min, offset - 1); \
936 static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, \
937 S_IRUGO | S_IWUSR, show_pwm_auto_pwm_minctl, \
938 set_pwm_auto_pwm_minctl, offset - 1)
950 struct lm85_data *data = lm85_update_device(dev);
960 struct lm85_data *data = i2c_get_clientdata(client);
965 err = kstrtol(buf, 10, &val);
972 if (nr == 0 || nr == 1) {
974 (data->
zone[0].hyst << 4)
975 | data->
zone[1].hyst);
978 (data->
zone[2].hyst << 4));
988 struct lm85_data *data = lm85_update_device(dev);
997 struct lm85_data *data = i2c_get_clientdata(client);
1001 err = kstrtol(buf, 10, &val);
1008 data->
zone[nr].limit);
1011 data->
zone[
nr].range = RANGE_TO_REG(
1015 ((data->
zone[nr].range & 0x0f) << 4)
1026 struct lm85_data *data = lm85_update_device(dev);
1036 struct lm85_data *data = i2c_get_clientdata(client);
1041 err = kstrtol(buf, 10, &val);
1048 data->
zone[
nr].range = RANGE_TO_REG(
1051 ((data->
zone[nr].range & 0x0f) << 4)
1061 struct lm85_data *data = lm85_update_device(dev);
1070 struct lm85_data *data = i2c_get_clientdata(client);
1074 err = kstrtol(buf, 10, &val);
1081 data->
zone[nr].critical);
1086 #define temp_auto(offset) \
1087 static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_off, \
1088 S_IRUGO | S_IWUSR, show_temp_auto_temp_off, \
1089 set_temp_auto_temp_off, offset - 1); \
1090 static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_min, \
1091 S_IRUGO | S_IWUSR, show_temp_auto_temp_min, \
1092 set_temp_auto_temp_min, offset - 1); \
1093 static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_max, \
1094 S_IRUGO | S_IWUSR, show_temp_auto_temp_max, \
1095 set_temp_auto_temp_max, offset - 1); \
1096 static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_crit, \
1097 S_IRUGO | S_IWUSR, show_temp_auto_temp_crit, \
1098 set_temp_auto_temp_crit, offset - 1);
1104 static struct attribute *lm85_attributes[] = {
1105 &sensor_dev_attr_fan1_input.dev_attr.attr,
1106 &sensor_dev_attr_fan2_input.dev_attr.attr,
1107 &sensor_dev_attr_fan3_input.dev_attr.attr,
1108 &sensor_dev_attr_fan4_input.dev_attr.attr,
1109 &sensor_dev_attr_fan1_min.dev_attr.attr,
1110 &sensor_dev_attr_fan2_min.dev_attr.attr,
1111 &sensor_dev_attr_fan3_min.dev_attr.attr,
1112 &sensor_dev_attr_fan4_min.dev_attr.attr,
1113 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
1114 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
1115 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1116 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
1118 &sensor_dev_attr_pwm1.dev_attr.attr,
1119 &sensor_dev_attr_pwm2.dev_attr.attr,
1120 &sensor_dev_attr_pwm3.dev_attr.attr,
1121 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1122 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1123 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1124 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1125 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
1126 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
1128 &sensor_dev_attr_in0_input.dev_attr.attr,
1129 &sensor_dev_attr_in1_input.dev_attr.attr,
1130 &sensor_dev_attr_in2_input.dev_attr.attr,
1131 &sensor_dev_attr_in3_input.dev_attr.attr,
1132 &sensor_dev_attr_in0_min.dev_attr.attr,
1133 &sensor_dev_attr_in1_min.dev_attr.attr,
1134 &sensor_dev_attr_in2_min.dev_attr.attr,
1135 &sensor_dev_attr_in3_min.dev_attr.attr,
1136 &sensor_dev_attr_in0_max.dev_attr.attr,
1137 &sensor_dev_attr_in1_max.dev_attr.attr,
1138 &sensor_dev_attr_in2_max.dev_attr.attr,
1139 &sensor_dev_attr_in3_max.dev_attr.attr,
1140 &sensor_dev_attr_in0_alarm.dev_attr.attr,
1141 &sensor_dev_attr_in1_alarm.dev_attr.attr,
1142 &sensor_dev_attr_in2_alarm.dev_attr.attr,
1143 &sensor_dev_attr_in3_alarm.dev_attr.attr,
1145 &sensor_dev_attr_temp1_input.dev_attr.attr,
1146 &sensor_dev_attr_temp2_input.dev_attr.attr,
1147 &sensor_dev_attr_temp3_input.dev_attr.attr,
1148 &sensor_dev_attr_temp1_min.dev_attr.attr,
1149 &sensor_dev_attr_temp2_min.dev_attr.attr,
1150 &sensor_dev_attr_temp3_min.dev_attr.attr,
1151 &sensor_dev_attr_temp1_max.dev_attr.attr,
1152 &sensor_dev_attr_temp2_max.dev_attr.attr,
1153 &sensor_dev_attr_temp3_max.dev_attr.attr,
1154 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
1155 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
1156 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
1157 &sensor_dev_attr_temp1_fault.dev_attr.attr,
1158 &sensor_dev_attr_temp3_fault.dev_attr.attr,
1160 &sensor_dev_attr_pwm1_auto_channels.dev_attr.attr,
1161 &sensor_dev_attr_pwm2_auto_channels.dev_attr.attr,
1162 &sensor_dev_attr_pwm3_auto_channels.dev_attr.attr,
1163 &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr,
1164 &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr,
1165 &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr,
1167 &sensor_dev_attr_temp1_auto_temp_min.dev_attr.attr,
1168 &sensor_dev_attr_temp2_auto_temp_min.dev_attr.attr,
1169 &sensor_dev_attr_temp3_auto_temp_min.dev_attr.attr,
1170 &sensor_dev_attr_temp1_auto_temp_max.dev_attr.attr,
1171 &sensor_dev_attr_temp2_auto_temp_max.dev_attr.attr,
1172 &sensor_dev_attr_temp3_auto_temp_max.dev_attr.attr,
1173 &sensor_dev_attr_temp1_auto_temp_crit.dev_attr.attr,
1174 &sensor_dev_attr_temp2_auto_temp_crit.dev_attr.attr,
1175 &sensor_dev_attr_temp3_auto_temp_crit.dev_attr.attr,
1178 &dev_attr_cpu0_vid.attr,
1179 &dev_attr_alarms.attr,
1184 .attrs = lm85_attributes,
1187 static struct attribute *lm85_attributes_minctl[] = {
1188 &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr,
1189 &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr,
1190 &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr,
1195 .attrs = lm85_attributes_minctl,
1198 static struct attribute *lm85_attributes_temp_off[] = {
1199 &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr,
1200 &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr,
1201 &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr,
1206 .attrs = lm85_attributes_temp_off,
1209 static struct attribute *lm85_attributes_in4[] = {
1210 &sensor_dev_attr_in4_input.dev_attr.attr,
1211 &sensor_dev_attr_in4_min.dev_attr.attr,
1212 &sensor_dev_attr_in4_max.dev_attr.attr,
1213 &sensor_dev_attr_in4_alarm.dev_attr.attr,
1218 .attrs = lm85_attributes_in4,
1221 static struct attribute *lm85_attributes_in567[] = {
1222 &sensor_dev_attr_in5_input.dev_attr.attr,
1223 &sensor_dev_attr_in6_input.dev_attr.attr,
1224 &sensor_dev_attr_in7_input.dev_attr.attr,
1225 &sensor_dev_attr_in5_min.dev_attr.attr,
1226 &sensor_dev_attr_in6_min.dev_attr.attr,
1227 &sensor_dev_attr_in7_min.dev_attr.attr,
1228 &sensor_dev_attr_in5_max.dev_attr.attr,
1229 &sensor_dev_attr_in6_max.dev_attr.attr,
1230 &sensor_dev_attr_in7_max.dev_attr.attr,
1231 &sensor_dev_attr_in5_alarm.dev_attr.attr,
1232 &sensor_dev_attr_in6_alarm.dev_attr.attr,
1233 &sensor_dev_attr_in7_alarm.dev_attr.attr,
1238 .attrs = lm85_attributes_in567,
1241 static void lm85_init_client(
struct i2c_client *client)
1247 if (!(value & 0x01)) {
1254 dev_warn(&client->
dev,
"Device configuration is locked\n");
1255 if (!(value & 0x04))
1259 static int lm85_is_fake(
struct i2c_client *client)
1269 for (i = 0; i < 8; i++) {
1272 if (in_temp != 0x00 || fan != 0xff)
1284 const char *type_name;
1285 int company, verstep;
1296 dev_dbg(&adapter->
dev,
"Detecting device at 0x%02x with "
1297 "COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
1298 address, company, verstep);
1304 "Autodetection failed: unsupported version\n");
1313 type_name =
"lm85c";
1316 type_name =
"lm85b";
1321 if (lm85_is_fake(client)) {
1323 "Found Winbond WPCD377I, ignoring\n");
1331 type_name =
"adm1027";
1335 type_name =
"adt7463";
1339 type_name =
"adt7468";
1347 type_name =
"emc6d100";
1350 type_name =
"emc6d102";
1354 type_name =
"emc6d103";
1357 type_name =
"emc6d103s";
1362 "Autodetection failed: unknown vendor\n");
1384 static int lm85_probe(
struct i2c_client *client,
1394 i2c_set_clientdata(client, data);
1395 data->
type =
id->driver_data;
1399 switch (data->
type) {
1417 lm85_init_client(client);
1428 goto err_remove_files;
1430 &lm85_group_temp_off);
1432 goto err_remove_files;
1448 goto err_remove_files;
1455 goto err_remove_files;
1461 goto err_remove_files;
1468 lm85_remove_files(client, data);
1472 static int lm85_remove(
struct i2c_client *client)
1474 struct lm85_data *data = i2c_get_clientdata(client);
1476 lm85_remove_files(client, data);
1507 static void lm85_write_value(
struct i2c_client *client,
u8 reg,
int value)
1531 struct lm85_data *data = i2c_get_clientdata(client);
1539 dev_dbg(&client->
dev,
"Reading sensor values\n");
1549 int ext1 = lm85_read_value(client,
1551 int ext2 = lm85_read_value(client,
1553 int val = (ext1 << 8) + ext2;
1555 for (i = 0; i <= 4; i++)
1557 ((val >> (i * 2)) & 0x03) << 2;
1559 for (i = 0; i <= 2; i++)
1561 (val >> ((i + 4) * 2)) & 0x0c;
1566 for (i = 0; i <= 3; ++
i) {
1579 for (i = 0; i <= 2; ++
i) {
1586 data->
temp[
i] -= 64;
1593 for (i = 5; i <= 7; ++
i) {
1594 data->
in[
i] = lm85_read_value(client,
1598 data->
alarms |= lm85_read_value(client,
1607 int ext1 = lm85_read_value(client,
1609 int ext2 = lm85_read_value(client,
1611 int ext3 = lm85_read_value(client,
1613 int ext4 = lm85_read_value(client,
1615 data->
in_ext[0] = ext3 & 0x0f;
1616 data->
in_ext[1] = ext4 & 0x0f;
1617 data->
in_ext[2] = ext4 >> 4;
1618 data->
in_ext[3] = ext3 >> 4;
1619 data->
in_ext[4] = ext2 >> 4;
1632 dev_dbg(&client->
dev,
"Reading config values\n");
1634 for (i = 0; i <= 3; ++
i) {
1644 data->
in_min[4] = lm85_read_value(client,
1646 data->
in_max[4] = lm85_read_value(client,
1651 for (i = 5; i <= 7; ++
i) {
1652 data->
in_min[
i] = lm85_read_value(client,
1654 data->
in_max[
i] = lm85_read_value(client,
1659 for (i = 0; i <= 2; ++
i) {
1671 data->
zone[
i].range = val >> 4;
1674 data->
zone[
i].limit =
1676 data->
zone[
i].critical =
1682 data->
zone[
i].limit -= 64;
1683 data->
zone[
i].critical -= 64;
1689 data->
autofan[0].min_off = (i & 0x20) != 0;
1690 data->
autofan[1].min_off = (i & 0x40) != 0;
1691 data->
autofan[2].min_off = (i & 0x80) != 0;
1694 data->
zone[0].hyst = i >> 4;
1695 data->
zone[1].hyst = i & 0x0f;
1698 data->
zone[2].hyst = i >> 4;