38 #include <linux/module.h>
40 #include <linux/slab.h>
41 #include <linux/i2c.h>
50 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
55 static unsigned short force_subclients[4];
58 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
65 static const u8 W83792D_REG_IN[9] = {
76 #define W83792D_REG_LOW_BITS1 0x3E
77 #define W83792D_REG_LOW_BITS2 0x3F
78 static const u8 W83792D_REG_IN_MAX[9] = {
89 static const u8 W83792D_REG_IN_MIN[9] = {
100 static const u8 W83792D_REG_FAN[7] = {
109 static const u8 W83792D_REG_FAN_MIN[7] = {
118 #define W83792D_REG_FAN_CFG 0x84
119 static const u8 W83792D_REG_FAN_DIV[4] = {
125 static const u8 W83792D_REG_PWM[7] = {
134 #define W83792D_REG_BANK 0x4E
135 #define W83792D_REG_TEMP2_CONFIG 0xC2
136 #define W83792D_REG_TEMP3_CONFIG 0xCA
138 static const u8 W83792D_REG_TEMP1[3] = {
144 static const u8 W83792D_REG_TEMP_ADD[2][6] = {
159 static const u8 W83792D_REG_THERMAL[3] = {
165 static const u8 W83792D_REG_TOLERANCE[3] = {
171 static const u8 W83792D_REG_POINTS[3][4] = {
186 static const u8 W83792D_REG_LEVELS[3][4] = {
201 #define W83792D_REG_GPIO_EN 0x1A
202 #define W83792D_REG_CONFIG 0x40
203 #define W83792D_REG_VID_FANDIV 0x47
204 #define W83792D_REG_CHIPID 0x49
205 #define W83792D_REG_WCHIPID 0x58
206 #define W83792D_REG_CHIPMAN 0x4F
207 #define W83792D_REG_PIN 0x4B
208 #define W83792D_REG_I2C_SUBADDR 0x4A
210 #define W83792D_REG_ALARM1 0xA9
211 #define W83792D_REG_ALARM2 0xAA
212 #define W83792D_REG_ALARM3 0xAB
213 #define W83792D_REG_CHASSIS 0x42
214 #define W83792D_REG_CHASSIS_CLR 0x44
217 #define W83792D_REG_VID_IN_B 0x17
219 #define W83792D_REG_VBAT 0x5D
220 #define W83792D_REG_I2C_ADDR 0x48
228 #define IN_FROM_REG(nr, val) (((nr) <= 1) ? ((val) * 2) : \
229 ((((nr) == 6) || ((nr) == 7)) ? ((val) * 6) : ((val) * 4)))
230 #define IN_TO_REG(nr, val) (((nr) <= 1) ? ((val) / 2) : \
231 ((((nr) == 6) || ((nr) == 7)) ? ((val) / 6) : ((val) / 4)))
238 rpm = SENSORS_LIMIT(rpm, 1, 1000000);
239 return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
242 #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : \
243 ((val) == 255 ? 0 : \
244 1350000 / ((val) * (div))))
247 #define TEMP1_TO_REG(val) (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
248 : (val)) / 1000, 0, 0xff))
249 #define TEMP1_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
251 #define TEMP_ADD_FROM_REG(val1, val2) \
252 ((((val1) & 0x80 ? (val1)-0x100 \
253 : (val1)) * 1000) + ((val2 & 0x80) ? 500 : 0))
254 #define TEMP_ADD_TO_REG_HIGH(val) \
255 (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
256 : (val)) / 1000, 0, 0xff))
257 #define TEMP_ADD_TO_REG_LOW(val) ((val%1000) ? 0x80 : 0x00)
259 #define DIV_FROM_REG(val) (1 << (val))
265 val = SENSORS_LIMIT(val, 1, 128) >> 1;
266 for (i = 0; i < 7; i++) {
330 .probe = w83792d_probe,
331 .remove = w83792d_remove,
332 .id_table = w83792d_id,
333 .detect = w83792d_detect,
334 .address_list = normal_i2c,
340 return (data->
in[nr] << 2) | ((data->
low_bits >> (2 *
nr)) & 0x03);
364 int nr = sensor_attr->
index;
370 #define show_in_reg(reg) \
371 static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
374 struct sensor_device_attribute *sensor_attr \
375 = to_sensor_dev_attr(attr); \
376 int nr = sensor_attr->index; \
377 struct w83792d_data *data = w83792d_update_device(dev); \
378 return sprintf(buf, "%ld\n", \
379 (long)(IN_FROM_REG(nr, data->reg[nr]) * 4)); \
385 #define store_in_reg(REG, reg) \
386 static ssize_t store_in_##reg(struct device *dev, \
387 struct device_attribute *attr, \
388 const char *buf, size_t count) \
390 struct sensor_device_attribute *sensor_attr \
391 = to_sensor_dev_attr(attr); \
392 int nr = sensor_attr->index; \
393 struct i2c_client *client = to_i2c_client(dev); \
394 struct w83792d_data *data = i2c_get_clientdata(client); \
396 int err = kstrtoul(buf, 10, &val); \
399 mutex_lock(&data->update_lock); \
400 data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val) / 4, 0, 255); \
401 w83792d_write_value(client, W83792D_REG_IN_##REG[nr], \
402 data->in_##reg[nr]); \
403 mutex_unlock(&data->update_lock); \
410 #define show_fan_reg(reg) \
411 static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
414 struct sensor_device_attribute *sensor_attr \
415 = to_sensor_dev_attr(attr); \
416 int nr = sensor_attr->index - 1; \
417 struct w83792d_data *data = w83792d_update_device(dev); \
418 return sprintf(buf, "%d\n", \
419 FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \
427 const char *buf,
size_t count)
430 int nr = sensor_attr->
index - 1;
436 err = kstrtoul(buf, 10, &val);
442 w83792d_write_value(client, W83792D_REG_FAN_MIN[nr],
454 int nr = sensor_attr->
index;
467 const char *buf,
size_t count)
470 int nr = sensor_attr->
index - 1;
480 err = kstrtoul(buf, 10, &val);
491 fan_div_reg = w83792d_read_value(client, W83792D_REG_FAN_DIV[nr >> 1]);
492 fan_div_reg &= (nr & 0x01) ? 0x8f : 0xf8;
493 tmp_fan_div = (nr & 0x01) ? (((data->
fan_div[nr]) << 4) & 0x70)
495 w83792d_write_value(client, W83792D_REG_FAN_DIV[nr >> 1],
496 fan_div_reg | tmp_fan_div);
500 w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], data->
fan_min[nr]);
512 int nr = sensor_attr->
index;
518 const char *buf,
size_t count)
521 int nr = sensor_attr->
index;
527 err = kstrtol(buf, 10, &val);
533 w83792d_write_value(client, W83792D_REG_TEMP1[nr],
547 int nr = sensor_attr->
nr;
556 const char *buf,
size_t count)
560 int nr = sensor_attr->
nr;
561 int index = sensor_attr->
index;
567 err = kstrtol(buf, 10, &val);
574 w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index],
576 w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index+1],
595 int nr = sensor_attr->
index;
605 int nr = sensor_attr->
index;
607 return sprintf(buf,
"%d\n", (data->
pwm[nr] & 0x0f) << 4);
615 int nr = sensor_attr->
index - 1;
617 long pwm_enable_tmp = 1;
631 return sprintf(buf,
"%ld\n", pwm_enable_tmp);
636 const char *buf,
size_t count)
639 int nr = sensor_attr->
index;
645 err = kstrtoul(buf, 10, &val);
648 val = SENSORS_LIMIT(val, 0, 255) >> 4;
651 val |= w83792d_read_value(client, W83792D_REG_PWM[nr]) & 0xf0;
653 w83792d_write_value(client, W83792D_REG_PWM[nr], data->
pwm[nr]);
661 const char *buf,
size_t count)
664 int nr = sensor_attr->
index - 1;
667 u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp;
671 err = kstrtoul(buf, 10, &val);
675 if (val < 1 || val > 3)
694 fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp;
706 int nr = sensor_attr->
index;
708 return sprintf(buf,
"%d\n", data->
pwm[nr] >> 7);
713 const char *buf,
size_t count)
716 int nr = sensor_attr->
index;
722 err = kstrtoul(buf, 10, &val);
729 data->
pwm[
nr] = w83792d_read_value(client, W83792D_REG_PWM[nr]);
731 data->
pwm[
nr] |= 0x80;
733 data->
pwm[
nr] &= 0x7f;
735 w83792d_write_value(client, W83792D_REG_PWM[nr], data->
pwm[nr]);
751 const char *buf,
size_t count)
758 if (kstrtoul(buf, 10, &val) || val != 0)
776 int nr = sensor_attr->
index;
783 const char *buf,
size_t count)
786 int nr = sensor_attr->
index - 1;
789 u8 target_tmp = 0, target_mask = 0;
793 err = kstrtoul(buf, 10, &val);
798 target_tmp = target_tmp & 0x7f;
800 target_mask = w83792d_read_value(client,
801 W83792D_REG_THERMAL[nr]) & 0x80;
803 w83792d_write_value(client, W83792D_REG_THERMAL[nr],
816 int nr = sensor_attr->
index;
823 const char *buf,
size_t count)
826 int nr = sensor_attr->
index - 1;
829 u8 tol_tmp, tol_mask;
833 err = kstrtoul(buf, 10, &val);
838 tol_mask = w83792d_read_value(client,
839 W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0);
840 tol_tmp = SENSORS_LIMIT(val, 0, 15);
845 w83792d_write_value(client, W83792D_REG_TOLERANCE[nr],
859 int nr = sensor_attr->
nr;
860 int index = sensor_attr->
index;
867 const char *buf,
size_t count)
871 int nr = sensor_attr->
nr - 1;
872 int index = sensor_attr->
index - 1;
879 err = kstrtoul(buf, 10, &val);
885 mask_tmp = w83792d_read_value(client,
886 W83792D_REG_POINTS[index][nr]) & 0x80;
887 w83792d_write_value(client, W83792D_REG_POINTS[index][nr],
900 int nr = sensor_attr->
nr;
901 int index = sensor_attr->
index;
904 (((data->
sf2_levels[index-1][nr]) * 100) / 15));
909 const char *buf,
size_t count)
913 int nr = sensor_attr->
nr;
914 int index = sensor_attr->
index - 1;
917 u8 mask_tmp = 0, level_tmp = 0;
921 err = kstrtoul(buf, 10, &val);
927 mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr])
928 & ((nr == 3) ? 0xf0 : 0x0f);
933 w83792d_write_value(client, W83792D_REG_LEVELS[index][nr],
934 level_tmp | mask_tmp);
942 w83792d_detect_subclients(
struct i2c_client *new_client)
948 struct w83792d_data *data = i2c_get_clientdata(new_client);
950 id = i2c_adapter_id(adapter);
951 if (force_subclients[0] ==
id && force_subclients[1] == address) {
952 for (i = 2; i <= 3; i++) {
953 if (force_subclients[i] < 0x48 ||
954 force_subclients[i] > 0x4f) {
955 dev_err(&new_client->
dev,
"invalid subclient "
956 "address %d; must be 0x48-0x4f\n",
957 force_subclients[i]);
963 (force_subclients[2] & 0x07) |
964 ((force_subclients[3] & 0x07) << 4));
972 ((val & 0x7) == ((val >> 4) & 0x7))) {
973 dev_err(&new_client->
dev,
"duplicate addresses 0x%x, "
974 "use force_subclient\n", data->
lm75[0]->addr);
979 0x48 + ((val >> 4) & 0x7));
1003 show_in_min, store_in_min, 0);
1005 show_in_min, store_in_min, 1);
1007 show_in_min, store_in_min, 2);
1009 show_in_min, store_in_min, 3);
1011 show_in_min, store_in_min, 4);
1013 show_in_min, store_in_min, 5);
1015 show_in_min, store_in_min, 6);
1017 show_in_min, store_in_min, 7);
1019 show_in_min, store_in_min, 8);
1021 show_in_max, store_in_max, 0);
1023 show_in_max, store_in_max, 1);
1025 show_in_max, store_in_max, 2);
1027 show_in_max, store_in_max, 3);
1029 show_in_max, store_in_max, 4);
1031 show_in_max, store_in_max, 5);
1033 show_in_max, store_in_max, 6);
1035 show_in_max, store_in_max, 7);
1037 show_in_max, store_in_max, 8);
1042 show_temp1, store_temp1, 0, 1);
1044 store_temp23, 0, 2);
1046 store_temp23, 1, 2);
1048 show_temp1, store_temp1, 0, 2);
1050 show_temp23, store_temp23, 0, 4);
1052 show_temp23, store_temp23, 1, 4);
1074 show_chassis_clear, store_chassis_clear);
1079 show_pwmenable, store_pwmenable, 1);
1081 show_pwmenable, store_pwmenable, 2);
1083 show_pwmenable, store_pwmenable, 3);
1085 show_pwm_mode, store_pwm_mode, 0);
1087 show_pwm_mode, store_pwm_mode, 1);
1089 show_pwm_mode, store_pwm_mode, 2);
1091 show_tolerance, store_tolerance, 1);
1093 show_tolerance, store_tolerance, 2);
1095 show_tolerance, store_tolerance, 3);
1097 show_thermal_cruise, store_thermal_cruise, 1);
1099 show_thermal_cruise, store_thermal_cruise, 2);
1101 show_thermal_cruise, store_thermal_cruise, 3);
1103 show_sf2_point, store_sf2_point, 1, 1);
1105 show_sf2_point, store_sf2_point, 2, 1);
1107 show_sf2_point, store_sf2_point, 3, 1);
1109 show_sf2_point, store_sf2_point, 4, 1);
1111 show_sf2_point, store_sf2_point, 1, 2);
1113 show_sf2_point, store_sf2_point, 2, 2);
1115 show_sf2_point, store_sf2_point, 3, 2);
1117 show_sf2_point, store_sf2_point, 4, 2);
1119 show_sf2_point, store_sf2_point, 1, 3);
1121 show_sf2_point, store_sf2_point, 2, 3);
1123 show_sf2_point, store_sf2_point, 3, 3);
1125 show_sf2_point, store_sf2_point, 4, 3);
1127 show_sf2_level, store_sf2_level, 1, 1);
1129 show_sf2_level, store_sf2_level, 2, 1);
1131 show_sf2_level, store_sf2_level, 3, 1);
1133 show_sf2_level, store_sf2_level, 1, 2);
1135 show_sf2_level, store_sf2_level, 2, 2);
1137 show_sf2_level, store_sf2_level, 3, 2);
1139 show_sf2_level, store_sf2_level, 1, 3);
1141 show_sf2_level, store_sf2_level, 2, 3);
1143 show_sf2_level, store_sf2_level, 3, 3);
1152 show_fan_min, store_fan_min, 1);
1154 show_fan_min, store_fan_min, 2);
1156 show_fan_min, store_fan_min, 3);
1158 show_fan_min, store_fan_min, 4);
1160 show_fan_min, store_fan_min, 5);
1162 show_fan_min, store_fan_min, 6);
1164 show_fan_min, store_fan_min, 7);
1166 show_fan_div, store_fan_div, 1);
1168 show_fan_div, store_fan_div, 2);
1170 show_fan_div, store_fan_div, 3);
1172 show_fan_div, store_fan_div, 4);
1174 show_fan_div, store_fan_div, 5);
1176 show_fan_div, store_fan_div, 6);
1178 show_fan_div, store_fan_div, 7);
1180 static struct attribute *w83792d_attributes_fan[4][5] = {
1182 &sensor_dev_attr_fan4_input.dev_attr.attr,
1183 &sensor_dev_attr_fan4_min.dev_attr.attr,
1184 &sensor_dev_attr_fan4_div.dev_attr.attr,
1185 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
1188 &sensor_dev_attr_fan5_input.dev_attr.attr,
1189 &sensor_dev_attr_fan5_min.dev_attr.attr,
1190 &sensor_dev_attr_fan5_div.dev_attr.attr,
1191 &sensor_dev_attr_fan5_alarm.dev_attr.attr,
1194 &sensor_dev_attr_fan6_input.dev_attr.attr,
1195 &sensor_dev_attr_fan6_min.dev_attr.attr,
1196 &sensor_dev_attr_fan6_div.dev_attr.attr,
1197 &sensor_dev_attr_fan6_alarm.dev_attr.attr,
1200 &sensor_dev_attr_fan7_input.dev_attr.attr,
1201 &sensor_dev_attr_fan7_min.dev_attr.attr,
1202 &sensor_dev_attr_fan7_div.dev_attr.attr,
1203 &sensor_dev_attr_fan7_alarm.dev_attr.attr,
1209 { .attrs = w83792d_attributes_fan[0] },
1210 { .attrs = w83792d_attributes_fan[1] },
1211 { .attrs = w83792d_attributes_fan[2] },
1212 { .attrs = w83792d_attributes_fan[3] },
1215 static struct attribute *w83792d_attributes[] = {
1216 &sensor_dev_attr_in0_input.dev_attr.attr,
1217 &sensor_dev_attr_in0_max.dev_attr.attr,
1218 &sensor_dev_attr_in0_min.dev_attr.attr,
1219 &sensor_dev_attr_in1_input.dev_attr.attr,
1220 &sensor_dev_attr_in1_max.dev_attr.attr,
1221 &sensor_dev_attr_in1_min.dev_attr.attr,
1222 &sensor_dev_attr_in2_input.dev_attr.attr,
1223 &sensor_dev_attr_in2_max.dev_attr.attr,
1224 &sensor_dev_attr_in2_min.dev_attr.attr,
1225 &sensor_dev_attr_in3_input.dev_attr.attr,
1226 &sensor_dev_attr_in3_max.dev_attr.attr,
1227 &sensor_dev_attr_in3_min.dev_attr.attr,
1228 &sensor_dev_attr_in4_input.dev_attr.attr,
1229 &sensor_dev_attr_in4_max.dev_attr.attr,
1230 &sensor_dev_attr_in4_min.dev_attr.attr,
1231 &sensor_dev_attr_in5_input.dev_attr.attr,
1232 &sensor_dev_attr_in5_max.dev_attr.attr,
1233 &sensor_dev_attr_in5_min.dev_attr.attr,
1234 &sensor_dev_attr_in6_input.dev_attr.attr,
1235 &sensor_dev_attr_in6_max.dev_attr.attr,
1236 &sensor_dev_attr_in6_min.dev_attr.attr,
1237 &sensor_dev_attr_in7_input.dev_attr.attr,
1238 &sensor_dev_attr_in7_max.dev_attr.attr,
1239 &sensor_dev_attr_in7_min.dev_attr.attr,
1240 &sensor_dev_attr_in8_input.dev_attr.attr,
1241 &sensor_dev_attr_in8_max.dev_attr.attr,
1242 &sensor_dev_attr_in8_min.dev_attr.attr,
1243 &sensor_dev_attr_in0_alarm.dev_attr.attr,
1244 &sensor_dev_attr_in1_alarm.dev_attr.attr,
1245 &sensor_dev_attr_in2_alarm.dev_attr.attr,
1246 &sensor_dev_attr_in3_alarm.dev_attr.attr,
1247 &sensor_dev_attr_in4_alarm.dev_attr.attr,
1248 &sensor_dev_attr_in5_alarm.dev_attr.attr,
1249 &sensor_dev_attr_in6_alarm.dev_attr.attr,
1250 &sensor_dev_attr_in7_alarm.dev_attr.attr,
1251 &sensor_dev_attr_in8_alarm.dev_attr.attr,
1252 &sensor_dev_attr_temp1_input.dev_attr.attr,
1253 &sensor_dev_attr_temp1_max.dev_attr.attr,
1254 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
1255 &sensor_dev_attr_temp2_input.dev_attr.attr,
1256 &sensor_dev_attr_temp2_max.dev_attr.attr,
1257 &sensor_dev_attr_temp2_max_hyst.dev_attr.attr,
1258 &sensor_dev_attr_temp3_input.dev_attr.attr,
1259 &sensor_dev_attr_temp3_max.dev_attr.attr,
1260 &sensor_dev_attr_temp3_max_hyst.dev_attr.attr,
1261 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
1262 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
1263 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
1264 &sensor_dev_attr_pwm1.dev_attr.attr,
1265 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
1266 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1267 &sensor_dev_attr_pwm2.dev_attr.attr,
1268 &sensor_dev_attr_pwm2_mode.dev_attr.attr,
1269 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1270 &sensor_dev_attr_pwm3.dev_attr.attr,
1271 &sensor_dev_attr_pwm3_mode.dev_attr.attr,
1272 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1273 &dev_attr_alarms.attr,
1274 &dev_attr_intrusion0_alarm.attr,
1275 &sensor_dev_attr_tolerance1.dev_attr.attr,
1276 &sensor_dev_attr_thermal_cruise1.dev_attr.attr,
1277 &sensor_dev_attr_tolerance2.dev_attr.attr,
1278 &sensor_dev_attr_thermal_cruise2.dev_attr.attr,
1279 &sensor_dev_attr_tolerance3.dev_attr.attr,
1280 &sensor_dev_attr_thermal_cruise3.dev_attr.attr,
1281 &sensor_dev_attr_sf2_point1_fan1.dev_attr.attr,
1282 &sensor_dev_attr_sf2_point2_fan1.dev_attr.attr,
1283 &sensor_dev_attr_sf2_point3_fan1.dev_attr.attr,
1284 &sensor_dev_attr_sf2_point4_fan1.dev_attr.attr,
1285 &sensor_dev_attr_sf2_point1_fan2.dev_attr.attr,
1286 &sensor_dev_attr_sf2_point2_fan2.dev_attr.attr,
1287 &sensor_dev_attr_sf2_point3_fan2.dev_attr.attr,
1288 &sensor_dev_attr_sf2_point4_fan2.dev_attr.attr,
1289 &sensor_dev_attr_sf2_point1_fan3.dev_attr.attr,
1290 &sensor_dev_attr_sf2_point2_fan3.dev_attr.attr,
1291 &sensor_dev_attr_sf2_point3_fan3.dev_attr.attr,
1292 &sensor_dev_attr_sf2_point4_fan3.dev_attr.attr,
1293 &sensor_dev_attr_sf2_level1_fan1.dev_attr.attr,
1294 &sensor_dev_attr_sf2_level2_fan1.dev_attr.attr,
1295 &sensor_dev_attr_sf2_level3_fan1.dev_attr.attr,
1296 &sensor_dev_attr_sf2_level1_fan2.dev_attr.attr,
1297 &sensor_dev_attr_sf2_level2_fan2.dev_attr.attr,
1298 &sensor_dev_attr_sf2_level3_fan2.dev_attr.attr,
1299 &sensor_dev_attr_sf2_level1_fan3.dev_attr.attr,
1300 &sensor_dev_attr_sf2_level2_fan3.dev_attr.attr,
1301 &sensor_dev_attr_sf2_level3_fan3.dev_attr.attr,
1302 &sensor_dev_attr_fan1_input.dev_attr.attr,
1303 &sensor_dev_attr_fan1_min.dev_attr.attr,
1304 &sensor_dev_attr_fan1_div.dev_attr.attr,
1305 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
1306 &sensor_dev_attr_fan2_input.dev_attr.attr,
1307 &sensor_dev_attr_fan2_min.dev_attr.attr,
1308 &sensor_dev_attr_fan2_div.dev_attr.attr,
1309 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
1310 &sensor_dev_attr_fan3_input.dev_attr.attr,
1311 &sensor_dev_attr_fan3_min.dev_attr.attr,
1312 &sensor_dev_attr_fan3_div.dev_attr.attr,
1313 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1318 .attrs = w83792d_attributes,
1327 unsigned short address = client->
addr;
1338 if (!(val1 & 0x07)) {
1339 if ((!(val1 & 0x80) && val2 != 0xa3) ||
1340 ((val1 & 0x80) && val2 != 0x5c))
1351 w83792d_write_value(client,
1353 (w83792d_read_value(client,
1359 if (val1 != 0x7a || val2 != 0x5c)
1378 i2c_set_clientdata(client, data);
1382 err = w83792d_detect_subclients(client);
1387 w83792d_init_client(client);
1390 for (i = 0; i < 7; i++) {
1391 data->
fan_min[
i] = w83792d_read_value(client,
1392 W83792D_REG_FAN_MIN[i]);
1398 goto exit_i2c_unregister;
1406 if (!(val1 & 0x40)) {
1409 goto exit_remove_files;
1412 if (!(val1 & 0x20)) {
1415 goto exit_remove_files;
1422 goto exit_remove_files;
1428 goto exit_remove_files;
1434 goto exit_remove_files;
1441 for (i = 0; i <
ARRAY_SIZE(w83792d_group_fan); i++)
1443 exit_i2c_unregister:
1454 struct w83792d_data *data = i2c_get_clientdata(client);
1459 for (i = 0; i <
ARRAY_SIZE(w83792d_group_fan); i++)
1461 &w83792d_group_fan[i]);
1472 w83792d_init_client(
struct i2c_client *client)
1474 u8 temp2_cfg, temp3_cfg, vid_in_b;
1499 (w83792d_read_value(client,
1507 struct w83792d_data *data = i2c_get_clientdata(client);
1509 u8 reg_array_tmp[4], reg_tmp;
1516 dev_dbg(dev,
"Starting device update\n");
1519 for (i = 0; i < 9; i++) {
1520 data->
in[
i] = w83792d_read_value(client,
1522 data->
in_max[
i] = w83792d_read_value(client,
1523 W83792D_REG_IN_MAX[i]);
1524 data->
in_min[
i] = w83792d_read_value(client,
1525 W83792D_REG_IN_MIN[i]);
1527 data->
low_bits = w83792d_read_value(client,
1529 (w83792d_read_value(client,
1531 for (i = 0; i < 7; i++) {
1533 data->
fan[
i] = w83792d_read_value(client,
1534 W83792D_REG_FAN[i]);
1535 data->
fan_min[
i] = w83792d_read_value(client,
1536 W83792D_REG_FAN_MIN[i]);
1538 data->
pwm[
i] = w83792d_read_value(client,
1539 W83792D_REG_PWM[i]);
1544 data->
pwmenable[1] = (reg_tmp>>2) & 0x03;
1545 data->
pwmenable[2] = (reg_tmp>>4) & 0x03;
1547 for (i = 0; i < 3; i++) {
1548 data->
temp1[
i] = w83792d_read_value(client,
1549 W83792D_REG_TEMP1[i]);
1551 for (i = 0; i < 2; i++) {
1552 for (j = 0; j < 6; j++) {
1554 client, W83792D_REG_TEMP_ADD[i][j]);
1559 for (i = 0; i < 4; i++) {
1560 reg_array_tmp[
i] = w83792d_read_value(client,
1561 W83792D_REG_FAN_DIV[i]);
1563 data->
fan_div[0] = reg_array_tmp[0] & 0x07;
1564 data->
fan_div[1] = (reg_array_tmp[0] >> 4) & 0x07;
1565 data->
fan_div[2] = reg_array_tmp[1] & 0x07;
1566 data->
fan_div[3] = (reg_array_tmp[1] >> 4) & 0x07;
1567 data->
fan_div[4] = reg_array_tmp[2] & 0x07;
1568 data->
fan_div[5] = (reg_array_tmp[2] >> 4) & 0x07;
1569 data->
fan_div[6] = reg_array_tmp[3] & 0x07;
1577 data->
chassis = (w83792d_read_value(client,
1581 for (i = 0; i < 3; i++) {
1583 w83792d_read_value(client,
1584 W83792D_REG_THERMAL[i]) & 0x7f;
1588 reg_tmp = w83792d_read_value(client, W83792D_REG_TOLERANCE[0]);
1590 data->
tolerance[1] = (reg_tmp >> 4) & 0x0f;
1591 data->
tolerance[2] = w83792d_read_value(client,
1592 W83792D_REG_TOLERANCE[2]) & 0x0f;
1595 for (i = 0; i < 3; i++) {
1596 for (j = 0; j < 4; j++) {
1598 = w83792d_read_value(client,
1599 W83792D_REG_POINTS[i][j]) & 0x7f;
1604 for (i = 0; i < 3; i++) {
1605 reg_tmp = w83792d_read_value(client,
1606 W83792D_REG_LEVELS[i][0]);
1609 reg_tmp = w83792d_read_value(client,
1610 W83792D_REG_LEVELS[i][2]);
1622 w83792d_print_debug(data, dev);
1632 dev_dbg(dev,
"==========The following is the debug message...========\n");
1633 dev_dbg(dev,
"9 set of Voltages: =====>\n");
1634 for (i = 0; i < 9; i++) {
1635 dev_dbg(dev,
"vin[%d] is: 0x%x\n", i, data->
in[i]);
1641 dev_dbg(dev,
"7 set of Fan Counts and Duty Cycles: =====>\n");
1642 for (i = 0; i < 7; i++) {
1643 dev_dbg(dev,
"fan[%d] is: 0x%x\n", i, data->
fan[i]);
1645 dev_dbg(dev,
"pwm[%d] is: 0x%x\n", i, data->
pwm[i]);
1647 dev_dbg(dev,
"3 set of Temperatures: =====>\n");
1648 for (i = 0; i < 3; i++)
1649 dev_dbg(dev,
"temp1[%d] is: 0x%x\n", i, data->
temp1[i]);
1651 for (i = 0; i < 2; i++) {
1652 for (j = 0; j < 6; j++) {
1653 dev_dbg(dev,
"temp_add[%d][%d] is: 0x%x\n", i, j,
1658 for (i = 0; i < 7; i++)
1661 dev_dbg(dev,
"==========End of the debug message...================\n");