Lines Matching +full:no +full:- +full:thermistor
1 // SPDX-License-Identifier: GPL-2.0-only
3 * w83795.c - Linux kernel driver for hardware monitoring
11 * w83795g 21 14 8 6 8 0x79 0x5ca3 yes no
12 * w83795adg 18 14 2 6 8 0x79 0x5ca3 yes no
21 #include <linux/hwmon-sysfs.h>
49 /* Multi-Function Pin Ctrl Registers */
64 * only crit and crit_hyst affect real-time alarm status
106 0x8e, /* VSEN1-4 */
107 0x90, /* VSEN5-8 */
108 0x92, /* VSEN9-11 */
125 /* High/Low LSB shift, LSB No. */
309 reg1 = 0x80 | (reg1 - 1); in pwm_freq_to_reg()
312 if (abs(val - best0) > abs(val - best1)) in pwm_freq_to_reg()
329 u8 has_dyn_in; /* Only in2-0 can have this */
332 u8 has_gain; /* has gain: in17-20 * 8 */
334 u16 has_fan; /* Enable fan14-1 or not */
338 u8 has_temp; /* Enable monitor temp6-1 or not */
345 * Enable PECI and SB-TSI,
347 * bit 1: =1 AMD SB-TSI, =0 Intel PECI
356 * no config register, only affected by chip
392 /* Must be called with data->update_lock held, except during initialization */
399 if ((data->bank & 0x07) == bank) in w83795_set_bank()
403 bank |= data->bank & ~0x07; in w83795_set_bank()
406 dev_err(&client->dev, in w83795_set_bank()
411 data->bank = bank; in w83795_set_bank()
416 /* Must be called with data->update_lock held, except during initialization */
427 dev_err(&client->dev, in w83795_read()
435 /* Must be called with data->update_lock held, except during initialization */
446 dev_err(&client->dev, in w83795_write()
459 for (i = 0; i < ARRAY_SIZE(data->in); i++) { in w83795_update_limits()
460 if (!(data->has_in & (1 << i))) in w83795_update_limits()
462 data->in[i][IN_MAX] = in w83795_update_limits()
464 data->in[i][IN_LOW] = in w83795_update_limits()
467 for (i = 0; i < ARRAY_SIZE(data->in_lsb); i++) { in w83795_update_limits()
468 if ((i == 2 && data->chip_type == w83795adg) || in w83795_update_limits()
469 (i >= 4 && !(data->has_in & (1 << (i + 11))))) in w83795_update_limits()
471 data->in_lsb[i][IN_MAX] = in w83795_update_limits()
473 data->in_lsb[i][IN_LOW] = in w83795_update_limits()
479 for (i = 0; i < ARRAY_SIZE(data->fan); i++) { in w83795_update_limits()
484 if ((i & 1) == 0 && (data->has_fan & (3 << i))) in w83795_update_limits()
487 if (!(data->has_fan & (1 << i))) in w83795_update_limits()
489 data->fan_min[i] = in w83795_update_limits()
491 data->fan_min[i] |= in w83795_update_limits()
496 for (i = 0; i < ARRAY_SIZE(data->temp); i++) { in w83795_update_limits()
497 if (!(data->has_temp & (1 << i))) in w83795_update_limits()
500 data->temp[i][limit] = in w83795_update_limits()
505 if (data->enable_dts) { in w83795_update_limits()
507 data->dts_ext[limit] = in w83795_update_limits()
512 if (data->enable_beep) { in w83795_update_limits()
513 for (i = 0; i < ARRAY_SIZE(data->beeps); i++) in w83795_update_limits()
514 data->beeps[i] = in w83795_update_limits()
518 data->valid_limits = 1; in w83795_update_limits()
527 mutex_lock(&data->update_lock); in w83795_update_pwm_config()
529 if (data->valid_pwm_config) in w83795_update_pwm_config()
533 for (i = 0; i < ARRAY_SIZE(data->temp_src); i++) in w83795_update_pwm_config()
534 data->temp_src[i] = w83795_read(client, W83795_REG_TSS(i)); in w83795_update_pwm_config()
537 data->pwm_fcms[0] = w83795_read(client, W83795_REG_FCMS1); in w83795_update_pwm_config()
538 data->pwm_fcms[1] = w83795_read(client, W83795_REG_FCMS2); in w83795_update_pwm_config()
539 for (i = 0; i < ARRAY_SIZE(data->pwm_tfmr); i++) in w83795_update_pwm_config()
540 data->pwm_tfmr[i] = w83795_read(client, W83795_REG_TFMR(i)); in w83795_update_pwm_config()
541 data->pwm_fomc = w83795_read(client, W83795_REG_FOMC); in w83795_update_pwm_config()
542 for (i = 0; i < data->has_pwm; i++) { in w83795_update_pwm_config()
544 data->pwm[i][tmp] = in w83795_update_pwm_config()
547 for (i = 0; i < ARRAY_SIZE(data->target_speed); i++) { in w83795_update_pwm_config()
548 data->target_speed[i] = in w83795_update_pwm_config()
550 data->target_speed[i] |= in w83795_update_pwm_config()
553 data->tol_speed = w83795_read(client, W83795_REG_TFTS) & 0x3f; in w83795_update_pwm_config()
555 for (i = 0; i < ARRAY_SIZE(data->pwm_temp); i++) { in w83795_update_pwm_config()
556 data->pwm_temp[i][TEMP_PWM_TTTI] = in w83795_update_pwm_config()
558 data->pwm_temp[i][TEMP_PWM_CTFS] = in w83795_update_pwm_config()
561 data->pwm_temp[i][TEMP_PWM_HCT] = tmp >> 4; in w83795_update_pwm_config()
562 data->pwm_temp[i][TEMP_PWM_HOT] = tmp & 0x0f; in w83795_update_pwm_config()
566 for (i = 0; i < ARRAY_SIZE(data->sf4_reg); i++) { in w83795_update_pwm_config()
568 data->sf4_reg[i][SF4_TEMP][tmp] = in w83795_update_pwm_config()
571 data->sf4_reg[i][SF4_PWM][tmp] = in w83795_update_pwm_config()
577 for (i = 0; i < ARRAY_SIZE(data->setup_pwm); i++) in w83795_update_pwm_config()
578 data->setup_pwm[i] = in w83795_update_pwm_config()
581 data->valid_pwm_config = 1; in w83795_update_pwm_config()
584 mutex_unlock(&data->update_lock); in w83795_update_pwm_config()
596 mutex_lock(&data->update_lock); in w83795_update_device()
598 if (!data->valid_limits) in w83795_update_device()
601 if (!(time_after(jiffies, data->last_updated + HZ * 2) in w83795_update_device()
602 || !data->valid)) in w83795_update_device()
606 for (i = 0; i < ARRAY_SIZE(data->in); i++) { in w83795_update_device()
607 if (!(data->has_in & (1 << i))) in w83795_update_device()
611 data->in[i][IN_READ] = tmp; in w83795_update_device()
614 /* in0-2 can have dynamic limits (W83795G only) */ in w83795_update_device()
615 if (data->has_dyn_in) { in w83795_update_device()
620 if (!(data->has_dyn_in & (1 << i))) in w83795_update_device()
622 data->in[i][IN_MAX] = in w83795_update_device()
624 data->in[i][IN_LOW] = in w83795_update_device()
626 data->in_lsb[i][IN_MAX] = (lsb_max >> (2 * i)) & 0x03; in w83795_update_device()
627 data->in_lsb[i][IN_LOW] = (lsb_low >> (2 * i)) & 0x03; in w83795_update_device()
632 for (i = 0; i < ARRAY_SIZE(data->fan); i++) { in w83795_update_device()
633 if (!(data->has_fan & (1 << i))) in w83795_update_device()
635 data->fan[i] = w83795_read(client, W83795_REG_FAN(i)) << 4; in w83795_update_device()
636 data->fan[i] |= w83795_read(client, W83795_REG_VRLSB) >> 4; in w83795_update_device()
640 for (i = 0; i < ARRAY_SIZE(data->temp); i++) { in w83795_update_device()
641 data->temp[i][TEMP_READ] = in w83795_update_device()
643 data->temp_read_vrlsb[i] = in w83795_update_device()
648 if (data->enable_dts) { in w83795_update_device()
649 for (i = 0; i < ARRAY_SIZE(data->dts); i++) { in w83795_update_device()
650 if (!(data->has_dts & (1 << i))) in w83795_update_device()
652 data->dts[i] = in w83795_update_device()
654 data->dts_read_vrlsb[i] = in w83795_update_device()
660 for (i = 0; i < data->has_pwm; i++) { in w83795_update_device()
661 data->pwm[i][PWM_OUTPUT] = in w83795_update_device()
676 /* Switch to real-time alarms */ in w83795_update_device()
678 for (i = 0; i < ARRAY_SIZE(data->alarms); i++) in w83795_update_device()
679 data->alarms[i] = w83795_read(client, W83795_REG_ALARM(i)); in w83795_update_device()
680 data->alarms[5] |= intrusion; in w83795_update_device()
686 data->last_updated = jiffies; in w83795_update_device()
687 data->valid = true; in w83795_update_device()
690 mutex_unlock(&data->update_lock); in w83795_update_device()
706 int nr = sensor_attr->nr; in show_alarm_beep()
707 int index = sensor_attr->index >> 3; in show_alarm_beep()
708 int bit = sensor_attr->index & 0x07; in show_alarm_beep()
712 val = (data->alarms[index] >> bit) & 1; in show_alarm_beep()
714 val = (data->beeps[index] >> bit) & 1; in show_alarm_beep()
727 int index = sensor_attr->index >> 3; in store_beep()
728 int shift = sensor_attr->index & 0x07; in store_beep()
733 return -EINVAL; in store_beep()
735 return -EINVAL; in store_beep()
737 mutex_lock(&data->update_lock); in store_beep()
738 data->beeps[index] = w83795_read(client, W83795_REG_BEEP(index)); in store_beep()
739 data->beeps[index] &= ~beep_bit; in store_beep()
740 data->beeps[index] |= val << shift; in store_beep()
741 w83795_write(client, W83795_REG_BEEP(index), data->beeps[index]); in store_beep()
742 mutex_unlock(&data->update_lock); in store_beep()
758 return -EINVAL; in store_chassis_clear()
760 mutex_lock(&data->update_lock); in store_chassis_clear()
767 data->valid = false; in store_chassis_clear()
768 mutex_unlock(&data->update_lock); in store_chassis_clear()
779 int nr = sensor_attr->nr; in show_fan()
780 int index = sensor_attr->index; in show_fan()
785 val = data->fan[index] & 0x0fff; in show_fan()
787 val = data->fan_min[index] & 0x0fff; in show_fan()
798 int index = sensor_attr->index; in store_fan_min()
804 return -EINVAL; in store_fan_min()
807 mutex_lock(&data->update_lock); in store_fan_min()
808 data->fan_min[index] = val; in store_fan_min()
820 mutex_unlock(&data->update_lock); in store_fan_min()
831 int nr = sensor_attr->nr; in show_pwm()
832 int index = sensor_attr->index; in show_pwm()
840 val = time_from_reg(data->pwm[index][nr]); in show_pwm()
843 val = pwm_freq_from_reg(data->pwm[index][nr], data->clkin); in show_pwm()
846 val = data->pwm[index][nr]; in show_pwm()
861 int nr = sensor_attr->nr; in store_pwm()
862 int index = sensor_attr->index; in store_pwm()
866 return -EINVAL; in store_pwm()
868 mutex_lock(&data->update_lock); in store_pwm()
874 val = pwm_freq_to_reg(val, data->clkin); in store_pwm()
881 data->pwm[index][nr] = val; in store_pwm()
882 mutex_unlock(&data->update_lock); in store_pwm()
892 int index = sensor_attr->index; in show_pwm_enable()
896 if (data->pwm_fcms[0] & (1 << index)) { in show_pwm_enable()
902 if (data->pwm_tfmr[tmp] & (1 << index)) { in show_pwm_enable()
922 int index = sensor_attr->index; in store_pwm_enable()
927 return -EINVAL; in store_pwm_enable()
929 return -EINVAL; in store_pwm_enable()
935 return -EOPNOTSUPP; in store_pwm_enable()
939 mutex_lock(&data->update_lock); in store_pwm_enable()
943 data->pwm_fcms[0] &= ~(1 << index); in store_pwm_enable()
944 w83795_write(client, W83795_REG_FCMS1, data->pwm_fcms[0]); in store_pwm_enable()
947 data->pwm_tfmr[i] &= ~(1 << index); in store_pwm_enable()
949 data->pwm_tfmr[i]); in store_pwm_enable()
953 data->pwm_fcms[0] |= (1 << index); in store_pwm_enable()
954 w83795_write(client, W83795_REG_FCMS1, data->pwm_fcms[0]); in store_pwm_enable()
957 mutex_unlock(&data->update_lock); in store_pwm_enable()
965 int index = to_sensor_dev_attr_2(attr)->index; in show_pwm_mode()
968 if (data->pwm_fomc & (1 << index)) in show_pwm_mode()
989 useful += (data->has_temp >> tss_map[i][tsrc]) & 1; in w83795_tss_useful()
991 useful += (data->has_dts >> (tss_map[i][tsrc] - 6)) & 1; in w83795_tss_useful()
1003 int index = sensor_attr->index; in show_temp_src()
1004 u8 tmp = data->temp_src[index / 2]; in show_temp_src()
1011 /* Look-up the actual temperature channel number */ in show_temp_src()
1013 return -EINVAL; /* Shouldn't happen */ in show_temp_src()
1026 int index = sensor_attr->index; in store_temp_src()
1033 return -EINVAL; in store_temp_src()
1037 if (tss_map[tmp][index] == channel - 1) in store_temp_src()
1040 if (tmp == 4) /* No match */ in store_temp_src()
1041 return -EINVAL; in store_temp_src()
1043 mutex_lock(&data->update_lock); in store_temp_src()
1046 data->temp_src[val] &= 0x0f; in store_temp_src()
1048 data->temp_src[val] &= 0xf0; in store_temp_src()
1050 data->temp_src[val] |= tmp; in store_temp_src()
1051 w83795_write(client, W83795_REG_TSS(val), data->temp_src[val]); in store_temp_src()
1052 mutex_unlock(&data->update_lock); in store_temp_src()
1066 int nr = sensor_attr->nr; in show_temp_pwm_enable()
1067 int index = sensor_attr->index; in show_temp_pwm_enable()
1072 tmp = (data->pwm_fcms[1] >> index) & 1; in show_temp_pwm_enable()
1079 tmp = data->pwm_tfmr[index]; in show_temp_pwm_enable()
1094 int nr = sensor_attr->nr; in store_temp_pwm_enable()
1095 int index = sensor_attr->index; in store_temp_pwm_enable()
1099 return -EINVAL; in store_temp_pwm_enable()
1104 return -EINVAL; in store_temp_pwm_enable()
1105 tmp -= 3; in store_temp_pwm_enable()
1106 mutex_lock(&data->update_lock); in store_temp_pwm_enable()
1107 data->pwm_fcms[1] &= ~(1 << index); in store_temp_pwm_enable()
1108 data->pwm_fcms[1] |= tmp << index; in store_temp_pwm_enable()
1109 w83795_write(client, W83795_REG_FCMS2, data->pwm_fcms[1]); in store_temp_pwm_enable()
1110 mutex_unlock(&data->update_lock); in store_temp_pwm_enable()
1113 mutex_lock(&data->update_lock); in store_temp_pwm_enable()
1116 data->pwm_tfmr[index] = tmp; in store_temp_pwm_enable()
1117 mutex_unlock(&data->update_lock); in store_temp_pwm_enable()
1131 int nr = sensor_attr->nr; in show_fanin()
1132 int index = sensor_attr->index; in show_fanin()
1137 tmp = fan_from_reg(data->target_speed[index]); in show_fanin()
1140 tmp = data->tol_speed; in show_fanin()
1155 int nr = sensor_attr->nr; in store_fanin()
1156 int index = sensor_attr->index; in store_fanin()
1160 return -EINVAL; in store_fanin()
1162 mutex_lock(&data->update_lock); in store_fanin()
1168 data->target_speed[index] = val; in store_fanin()
1173 data->tol_speed = val; in store_fanin()
1176 mutex_unlock(&data->update_lock); in store_fanin()
1188 int nr = sensor_attr->nr; in show_temp_pwm()
1189 int index = sensor_attr->index; in show_temp_pwm()
1190 long tmp = temp_from_reg(data->pwm_temp[index][nr]); in show_temp_pwm()
1203 int nr = sensor_attr->nr; in store_temp_pwm()
1204 int index = sensor_attr->index; in store_temp_pwm()
1209 return -EINVAL; in store_temp_pwm()
1212 mutex_lock(&data->update_lock); in store_temp_pwm()
1237 data->pwm_temp[index][nr] = val; in store_temp_pwm()
1238 mutex_unlock(&data->update_lock); in store_temp_pwm()
1249 int nr = sensor_attr->nr; in show_sf4_pwm()
1250 int index = sensor_attr->index; in show_sf4_pwm()
1252 return sprintf(buf, "%u\n", data->sf4_reg[index][SF4_PWM][nr]); in show_sf4_pwm()
1263 int nr = sensor_attr->nr; in store_sf4_pwm()
1264 int index = sensor_attr->index; in store_sf4_pwm()
1268 return -EINVAL; in store_sf4_pwm()
1270 mutex_lock(&data->update_lock); in store_sf4_pwm()
1272 data->sf4_reg[index][SF4_PWM][nr] = val; in store_sf4_pwm()
1273 mutex_unlock(&data->update_lock); in store_sf4_pwm()
1284 int nr = sensor_attr->nr; in show_sf4_temp()
1285 int index = sensor_attr->index; in show_sf4_temp()
1288 (data->sf4_reg[index][SF4_TEMP][nr]) * 1000); in show_sf4_temp()
1299 int nr = sensor_attr->nr; in store_sf4_temp()
1300 int index = sensor_attr->index; in store_sf4_temp()
1304 return -EINVAL; in store_sf4_temp()
1307 mutex_lock(&data->update_lock); in store_sf4_temp()
1309 data->sf4_reg[index][SF4_TEMP][nr] = val; in store_sf4_temp()
1310 mutex_unlock(&data->update_lock); in store_sf4_temp()
1321 int nr = sensor_attr->nr; in show_temp()
1322 int index = sensor_attr->index; in show_temp()
1324 long temp = temp_from_reg(data->temp[index][nr]); in show_temp()
1327 temp += (data->temp_read_vrlsb[index] >> 6) * 250; in show_temp()
1337 int nr = sensor_attr->nr; in store_temp()
1338 int index = sensor_attr->index; in store_temp()
1344 return -EINVAL; in store_temp()
1346 mutex_lock(&data->update_lock); in store_temp()
1347 data->temp[index][nr] = temp_to_reg(tmp, -128, 127); in store_temp()
1348 w83795_write(client, W83795_REG_TEMP[index][nr], data->temp[index][nr]); in store_temp()
1349 mutex_unlock(&data->update_lock); in store_temp()
1360 if (data->enable_dts & 2) in show_dts_mode()
1373 int index = sensor_attr->index; in show_dts()
1375 long temp = temp_from_reg(data->dts[index]); in show_dts()
1377 temp += (data->dts_read_vrlsb[index] >> 6) * 250; in show_dts()
1386 int nr = sensor_attr->nr; in show_dts_ext()
1388 long temp = temp_from_reg(data->dts_ext[nr]); in show_dts_ext()
1399 int nr = sensor_attr->nr; in store_dts_ext()
1405 return -EINVAL; in store_dts_ext()
1407 mutex_lock(&data->update_lock); in store_dts_ext()
1408 data->dts_ext[nr] = temp_to_reg(tmp, -128, 127); in store_dts_ext()
1409 w83795_write(client, W83795_REG_DTS_EXT(nr), data->dts_ext[nr]); in store_dts_ext()
1410 mutex_unlock(&data->update_lock); in store_dts_ext()
1421 int index = sensor_attr->index; in show_temp_mode()
1424 if (data->temp_mode & (1 << index)) in show_temp_mode()
1427 tmp = 4; /* Thermistor */ in show_temp_mode()
1432 /* Only for temp1-4 (temp5-6 can only be thermistor) */
1441 int index = sensor_attr->index; in store_temp_mode()
1447 return -EINVAL; in store_temp_mode()
1449 return -EINVAL; in store_temp_mode()
1451 mutex_lock(&data->update_lock); in store_temp_mode()
1455 data->temp_mode |= 1 << index; in store_temp_mode()
1457 /* Thermistor */ in store_temp_mode()
1459 data->temp_mode &= ~(1 << index); in store_temp_mode()
1468 mutex_unlock(&data->update_lock); in store_temp_mode()
1479 int nr = sensor_attr->nr; in show_in()
1480 int index = sensor_attr->index; in show_in()
1482 u16 val = data->in[index][nr]; in show_in()
1489 !((data->has_gain >> (index - 17)) & 1)) in show_in()
1496 val |= (data->in_lsb[lsb_idx][nr] >> in show_in()
1499 !((data->has_gain >> (index - 17)) & 1)) in show_in()
1514 int nr = sensor_attr->nr; in store_in()
1515 int index = sensor_attr->index; in store_in()
1523 return -EINVAL; in store_in()
1527 !((data->has_gain >> (index - 17)) & 1)) in store_in()
1530 mutex_lock(&data->update_lock); in store_in()
1537 data->in_lsb[lsb_idx][nr] = tmp; in store_in()
1541 data->in[index][nr] = tmp; in store_in()
1543 mutex_unlock(&data->update_lock); in store_in()
1554 int nr = sensor_attr->nr; in show_sf_setup()
1556 u16 val = data->setup_pwm[nr]; in show_sf_setup()
1574 int nr = sensor_attr->nr; in store_sf_setup()
1580 return -EINVAL; in store_sf_setup()
1590 return -EINVAL; in store_sf_setup()
1594 mutex_lock(&data->update_lock); in store_sf_setup()
1595 data->setup_pwm[nr] = val; in store_sf_setup()
1597 mutex_unlock(&data->update_lock); in store_sf_setup()
1603 #define NOT_USED -1
1628 NULL, FAN_INPUT, index - 1), \
1630 show_fan, store_fan_min, FAN_MIN, index - 1), \
1638 store_pwm, PWM_OUTPUT, index - 1), \
1640 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \
1642 show_pwm_mode, NULL, NOT_USED, index - 1), \
1644 show_pwm, store_pwm, PWM_FREQ, index - 1), \
1646 show_pwm, store_pwm, PWM_NONSTOP, index - 1), \
1648 show_pwm, store_pwm, PWM_START, index - 1), \
1650 show_pwm, store_pwm, PWM_STOP_TIME, index - 1), \
1652 show_fanin, store_fanin, FANIN_TARGET, index - 1) }
1660 show_dts_mode, NULL, NOT_USED, index - 7), \
1662 NULL, NOT_USED, index - 7), \
1682 show_temp_mode, store_temp_mode, NOT_USED, index - 1), \
1684 NULL, TEMP_READ, index - 1), \
1686 store_temp, TEMP_CRIT, index - 1), \
1688 show_temp, store_temp, TEMP_CRIT_HYST, index - 1), \
1690 store_temp, TEMP_WARN, index - 1), \
1692 show_temp, store_temp, TEMP_WARN_HYST, index - 1), \
1701 TEMP_PWM_ENABLE, index - 1), \
1704 TEMP_PWM_FAN_MAP, index - 1), \
1706 show_temp_pwm, store_temp_pwm, TEMP_PWM_TTTI, index - 1), \
1708 show_temp_pwm, store_temp_pwm, TEMP_PWM_CTFS, index - 1), \
1710 show_temp_pwm, store_temp_pwm, TEMP_PWM_HCT, index - 1), \
1712 show_temp_pwm, store_temp_pwm, TEMP_PWM_HOT, index - 1), \
1714 show_sf4_pwm, store_sf4_pwm, 0, index - 1), \
1716 show_sf4_pwm, store_sf4_pwm, 1, index - 1), \
1718 show_sf4_pwm, store_sf4_pwm, 2, index - 1), \
1720 show_sf4_pwm, store_sf4_pwm, 3, index - 1), \
1722 show_sf4_pwm, store_sf4_pwm, 4, index - 1), \
1724 show_sf4_pwm, store_sf4_pwm, 5, index - 1), \
1726 show_sf4_pwm, store_sf4_pwm, 6, index - 1), \
1728 show_sf4_temp, store_sf4_temp, 0, index - 1), \
1730 show_sf4_temp, store_sf4_temp, 1, index - 1), \
1732 show_sf4_temp, store_sf4_temp, 2, index - 1), \
1734 show_sf4_temp, store_sf4_temp, 3, index - 1), \
1736 show_sf4_temp, store_sf4_temp, 4, index - 1), \
1738 show_sf4_temp, store_sf4_temp, 5, index - 1), \
1740 show_sf4_temp, store_sf4_temp, 6, index - 1) }
1870 dev_info(&client->dev, "Enabling monitoring operations\n"); in w83795_init_client()
1875 data->clkin = clkin[(config >> 3) & 0x3]; in w83795_init_client()
1876 dev_dbg(&client->dev, "clkin = %u kHz\n", data->clkin); in w83795_init_client()
1901 /* Return 0 if detection is successful, -ENODEV otherwise */
1906 struct i2c_adapter *adapter = client->adapter; in w83795_detect()
1907 unsigned short address = client->addr; in w83795_detect()
1911 return -ENODEV; in w83795_detect()
1914 dev_dbg(&adapter->dev, in w83795_detect()
1917 return -ENODEV; in w83795_detect()
1924 dev_dbg(&adapter->dev, in w83795_detect()
1927 return -ENODEV; in w83795_detect()
1934 dev_dbg(&adapter->dev, in w83795_detect()
1937 return -ENODEV; in w83795_detect()
1948 dev_dbg(&adapter->dev, in w83795_detect()
1951 return -ENODEV; in w83795_detect()
1970 strscpy(info->type, chip_name, I2C_NAME_SIZE); in w83795_detect()
1971 dev_info(&adapter->dev, "Found %s rev. %c at 0x%02hx\n", chip_name, in w83795_detect()
1992 if (!(data->has_in & (1 << i))) in w83795_handle_files()
1995 if (j == 4 && !data->enable_beep) in w83795_handle_files()
2004 if (!(data->has_fan & (1 << i))) in w83795_handle_files()
2007 if (j == 3 && !data->enable_beep) in w83795_handle_files()
2030 if (data->enable_beep) { in w83795_handle_files()
2038 for (i = 0; i < data->has_pwm; i++) { in w83795_handle_files()
2047 if (!(data->has_temp & (1 << i))) in w83795_handle_files()
2050 if (j == 7 && !data->enable_beep) in w83795_handle_files()
2058 if (data->enable_dts) { in w83795_handle_files()
2060 if (!(data->has_dts & (1 << i))) in w83795_handle_files()
2063 if (j == 7 && !data->enable_beep) in w83795_handle_files()
2095 data->has_dyn_in = (vid_ctl >> 3) & 0x07; in w83795_check_dynamic_in_limits()
2097 if (!(data->has_dyn_in & (1 << i))) in w83795_check_dynamic_in_limits()
2100 /* Voltage limits in dynamic mode, switch to read-only */ in w83795_check_dynamic_in_limits()
2101 err_max = sysfs_chmod_file(&client->dev.kobj, in w83795_check_dynamic_in_limits()
2104 err_min = sysfs_chmod_file(&client->dev.kobj, in w83795_check_dynamic_in_limits()
2108 dev_warn(&client->dev, in w83795_check_dynamic_in_limits()
2109 "Failed to set in%d limits read-only (%d, %d)\n", in w83795_check_dynamic_in_limits()
2112 dev_info(&client->dev, in w83795_check_dynamic_in_limits()
2121 /* config is a 2-bit value */ in w83795_apply_temp_config()
2124 data->has_in |= 1 << in_chan; in w83795_apply_temp_config()
2129 data->temp_mode |= 1 << temp_chan; in w83795_apply_temp_config()
2131 case 0x3: /* Thermistor */ in w83795_apply_temp_config()
2132 data->has_temp |= 1 << temp_chan; in w83795_apply_temp_config()
2141 struct device *dev = &client->dev; in w83795_probe()
2147 return -ENOMEM; in w83795_probe()
2150 data->chip_type = (uintptr_t)i2c_get_match_data(client); in w83795_probe()
2151 data->bank = i2c_smbus_read_byte_data(client, W83795_REG_BANKSEL); in w83795_probe()
2152 mutex_init(&data->update_lock); in w83795_probe()
2158 data->has_in = w83795_read(client, W83795_REG_VOLT_CTRL1) in w83795_probe()
2160 data->has_fan = w83795_read(client, W83795_REG_FANIN_CTRL1) in w83795_probe()
2166 data->enable_dts = 1; in w83795_probe()
2176 if (data->enable_dts) { in w83795_probe()
2178 data->enable_dts |= 2; in w83795_probe()
2179 data->has_dts = w83795_read(client, W83795_REG_DTSE); in w83795_probe()
2183 if (data->enable_dts == 1) { in w83795_probe()
2185 if (!(data->has_dts & (1 << i))) in w83795_probe()
2188 dev_info(&client->dev, in w83795_probe()
2194 data->has_gain = w83795_read(client, W83795_REG_VMIGB_CTRL) & 0x0f; in w83795_probe()
2197 if (data->chip_type == w83795g) in w83795_probe()
2198 data->has_pwm = 8; in w83795_probe()
2200 data->has_pwm = 2; in w83795_probe()
2203 if (data->chip_type == w83795g) { in w83795_probe()
2205 data->enable_beep = 1; in w83795_probe()
2213 data->enable_beep = 1; in w83795_probe()
2220 if (data->chip_type == w83795g) in w83795_probe()
2223 data->hwmon_dev = hwmon_device_register(dev); in w83795_probe()
2224 if (IS_ERR(data->hwmon_dev)) { in w83795_probe()
2225 err = PTR_ERR(data->hwmon_dev); in w83795_probe()
2240 hwmon_device_unregister(data->hwmon_dev); in w83795_remove()
2241 w83795_handle_files(&client->dev, device_remove_file_wrapper); in w83795_remove()