Lines Matching +full:bypass +full:- +full:attenuator +full:- +full:in1
1 // SPDX-License-Identifier: GPL-2.0-only
3 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
4 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
17 #include <linux/hwmon-sysfs.h>
18 #include <linux/hwmon-vid.h>
36 * These are unique identifiers for the sysfs functions - unlike the
206 u8 bypass_attn; /* Bypass voltage attenuator */
236 if (!(data->config5 & CONFIG5_TWOSCOMP)) { in temp2reg()
237 val = clamp_val(val, -64000, 191000); in temp2reg()
240 val = clamp_val(val, -128000, 127000); in temp2reg()
241 if (val < -500) in temp2reg()
254 if (data->config5 & CONFIG5_TWOSCOMP) { in reg2temp()
256 return (reg - 1024) * 250; in reg2temp()
260 return (reg - 256) * 250; in reg2temp()
342 switch (sattr->nr) { in voltage_show()
345 (data->alarms >> sattr->index) & 1); in voltage_show()
347 val = data->voltage[sattr->nr][sattr->index]; in voltage_show()
349 reg2volt(sattr->index, val, data->bypass_attn)); in voltage_show()
360 struct i2c_client *client = data->client; in voltage_store()
365 return -EINVAL; in voltage_store()
367 mutex_lock(&data->lock); in voltage_store()
369 data->voltage[sattr->nr][sattr->index] = in voltage_store()
370 volt2reg(sattr->index, val, data->bypass_attn); in voltage_store()
372 if (sattr->index < ADT7475_VOLTAGE_COUNT) { in voltage_store()
373 if (sattr->nr == MIN) in voltage_store()
374 reg = VOLTAGE_MIN_REG(sattr->index); in voltage_store()
376 reg = VOLTAGE_MAX_REG(sattr->index); in voltage_store()
377 } else if (sattr->index == 5) { in voltage_store()
378 if (sattr->nr == MIN) in voltage_store()
383 if (sattr->nr == MIN) in voltage_store()
390 data->voltage[sattr->nr][sattr->index] >> 2); in voltage_store()
391 mutex_unlock(&data->lock); in voltage_store()
406 switch (sattr->nr) { in temp_show()
408 mutex_lock(&data->lock); in temp_show()
409 out = data->temp[sattr->nr][sattr->index]; in temp_show()
410 if (sattr->index != 1) in temp_show()
418 out = reg2temp(data, data->temp[THERM][sattr->index]) - in temp_show()
420 mutex_unlock(&data->lock); in temp_show()
428 mutex_lock(&data->lock); in temp_show()
429 out = (s8)data->temp[sattr->nr][sattr->index]; in temp_show()
430 if (data->config5 & CONFIG5_TEMPOFFSET) in temp_show()
434 mutex_unlock(&data->lock); in temp_show()
438 out = (data->alarms >> (sattr->index + 4)) & 1; in temp_show()
442 /* Note - only for remote1 and remote2 */ in temp_show()
443 out = !!(data->alarms & (sattr->index ? 0x8000 : 0x4000)); in temp_show()
448 out = reg2temp(data, data->temp[sattr->nr][sattr->index]); in temp_show()
459 struct i2c_client *client = data->client; in temp_store()
466 return -EINVAL; in temp_store()
468 mutex_lock(&data->lock); in temp_store()
470 /* We need the config register in all cases for temp <-> reg conv. */ in temp_store()
471 data->config5 = adt7475_read(REG_CONFIG5); in temp_store()
473 switch (sattr->nr) { in temp_store()
475 if (data->config5 & CONFIG5_TEMPOFFSET) { in temp_store()
476 val = clamp_val(val, -63000, 127000); in temp_store()
477 out = data->temp[OFFSET][sattr->index] = val / 1000; in temp_store()
479 val = clamp_val(val, -63000, 64000); in temp_store()
480 out = data->temp[OFFSET][sattr->index] = val / 500; in temp_store()
491 data->temp[THERM][sattr->index] = in temp_store()
492 adt7475_read(TEMP_THERM_REG(sattr->index)) << 2; in temp_store()
495 temp = reg2temp(data, data->temp[THERM][sattr->index]); in temp_store()
496 val = clamp_val(val, temp - 15000, temp); in temp_store()
497 val = (temp - val) / 1000; in temp_store()
499 if (sattr->index != 1) { in temp_store()
500 data->temp[HYSTERSIS][sattr->index] &= 0x0F; in temp_store()
501 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4; in temp_store()
503 data->temp[HYSTERSIS][sattr->index] &= 0xF0; in temp_store()
504 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF); in temp_store()
507 out = data->temp[HYSTERSIS][sattr->index]; in temp_store()
511 data->temp[sattr->nr][sattr->index] = temp2reg(data, val); in temp_store()
515 * - shift those back off before writing the value in temp_store()
517 out = (u8) (data->temp[sattr->nr][sattr->index] >> 2); in temp_store()
520 switch (sattr->nr) { in temp_store()
522 reg = TEMP_MIN_REG(sattr->index); in temp_store()
525 reg = TEMP_MAX_REG(sattr->index); in temp_store()
528 reg = TEMP_OFFSET_REG(sattr->index); in temp_store()
531 reg = TEMP_TMIN_REG(sattr->index); in temp_store()
534 reg = TEMP_THERM_REG(sattr->index); in temp_store()
537 if (sattr->index != 2) in temp_store()
547 mutex_unlock(&data->lock); in temp_store()
563 switch (sattr->index) { in temp_st_show()
565 val = data->enh_acoustics[0] & 0xf; in temp_st_show()
568 val = data->enh_acoustics[1] & 0xf; in temp_st_show()
572 val = (data->enh_acoustics[1] >> 4) & 0xf; in temp_st_show()
588 struct i2c_client *client = data->client; in temp_st_store()
594 return -EINVAL; in temp_st_store()
596 switch (sattr->index) { in temp_st_store()
621 mutex_lock(&data->lock); in temp_st_store()
623 data->enh_acoustics[idx] &= ~(0xf << shift); in temp_st_store()
624 data->enh_acoustics[idx] |= (val << shift); in temp_st_store()
626 i2c_smbus_write_byte_data(client, reg, data->enh_acoustics[idx]); in temp_st_store()
628 mutex_unlock(&data->lock); in temp_st_store()
634 * Table of autorange values - the user will write the value in millidegrees,
653 mutex_lock(&data->lock); in point2_show()
654 out = (data->range[sattr->index] >> 4) & 0x0F; in point2_show()
655 val = reg2temp(data, data->temp[AUTOMIN][sattr->index]); in point2_show()
656 mutex_unlock(&data->lock); in point2_show()
665 struct i2c_client *client = data->client; in point2_store()
671 return -EINVAL; in point2_store()
673 mutex_lock(&data->lock); in point2_store()
676 data->config5 = adt7475_read(REG_CONFIG5); in point2_store()
677 data->temp[AUTOMIN][sattr->index] = in point2_store()
678 adt7475_read(TEMP_TMIN_REG(sattr->index)) << 2; in point2_store()
679 data->range[sattr->index] = in point2_store()
680 adt7475_read(TEMP_TRANGE_REG(sattr->index)); in point2_store()
686 temp = reg2temp(data, data->temp[AUTOMIN][sattr->index]); in point2_store()
688 temp + autorange_table[ARRAY_SIZE(autorange_table) - 1]); in point2_store()
689 val -= temp; in point2_store()
694 data->range[sattr->index] &= ~0xF0; in point2_store()
695 data->range[sattr->index] |= val << 4; in point2_store()
697 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), in point2_store()
698 data->range[sattr->index]); in point2_store()
700 mutex_unlock(&data->lock); in point2_store()
714 if (sattr->nr == ALARM) in tach_show()
715 out = (data->alarms >> (sattr->index + 10)) & 1; in tach_show()
717 out = tach2rpm(data->tach[sattr->nr][sattr->index]); in tach_show()
728 struct i2c_client *client = data->client; in tach_store()
732 return -EINVAL; in tach_store()
734 mutex_lock(&data->lock); in tach_store()
736 data->tach[MIN][sattr->index] = rpm2tach(val); in tach_store()
738 adt7475_write_word(client, TACH_MIN_REG(sattr->index), in tach_store()
739 data->tach[MIN][sattr->index]); in tach_store()
741 mutex_unlock(&data->lock); in tach_store()
754 return sprintf(buf, "%d\n", data->pwm[sattr->nr][sattr->index]); in pwm_show()
766 return sprintf(buf, "%d\n", data->pwmchan[sattr->index]); in pwmchan_show()
778 return sprintf(buf, "%d\n", data->pwmctl[sattr->index]); in pwmctrl_show()
787 struct i2c_client *client = data->client; in pwm_store()
792 return -EINVAL; in pwm_store()
794 mutex_lock(&data->lock); in pwm_store()
796 switch (sattr->nr) { in pwm_store()
799 data->pwm[CONTROL][sattr->index] = in pwm_store()
800 adt7475_read(PWM_CONFIG_REG(sattr->index)); in pwm_store()
806 if (((data->pwm[CONTROL][sattr->index] >> 5) & 7) != 7) { in pwm_store()
807 mutex_unlock(&data->lock); in pwm_store()
811 reg = PWM_REG(sattr->index); in pwm_store()
815 reg = PWM_MIN_REG(sattr->index); in pwm_store()
819 reg = PWM_MAX_REG(sattr->index); in pwm_store()
823 data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF); in pwm_store()
825 data->pwm[sattr->nr][sattr->index]); in pwm_store()
826 mutex_unlock(&data->lock); in pwm_store()
837 u8 mask = BIT(5 + sattr->index); in stall_disable_show()
839 return sprintf(buf, "%d\n", !!(data->enh_acoustics[0] & mask)); in stall_disable_show()
848 struct i2c_client *client = data->client; in stall_disable_store()
850 u8 mask = BIT(5 + sattr->index); in stall_disable_store()
853 return -EINVAL; in stall_disable_store()
855 mutex_lock(&data->lock); in stall_disable_store()
857 data->enh_acoustics[0] &= ~mask; in stall_disable_store()
859 data->enh_acoustics[0] |= mask; in stall_disable_store()
862 data->enh_acoustics[0]); in stall_disable_store()
864 mutex_unlock(&data->lock); in stall_disable_store()
907 return -EINVAL; in hw_set_pwm()
911 return -EINVAL; in hw_set_pwm()
914 data->pwmctl[index] = pwmctl; in hw_set_pwm()
915 data->pwmchan[index] = pwmchan; in hw_set_pwm()
917 data->pwm[CONTROL][index] &= ~0xE0; in hw_set_pwm()
918 data->pwm[CONTROL][index] |= (val & 7) << 5; in hw_set_pwm()
921 data->pwm[CONTROL][index]); in hw_set_pwm()
932 struct i2c_client *client = data->client; in pwmchan_store()
937 return -EINVAL; in pwmchan_store()
939 mutex_lock(&data->lock); in pwmchan_store()
941 adt7475_read_pwm(client, sattr->index); in pwmchan_store()
942 r = hw_set_pwm(client, sattr->index, data->pwmctl[sattr->index], val); in pwmchan_store()
945 mutex_unlock(&data->lock); in pwmchan_store()
956 struct i2c_client *client = data->client; in pwmctrl_store()
961 return -EINVAL; in pwmctrl_store()
963 mutex_lock(&data->lock); in pwmctrl_store()
965 adt7475_read_pwm(client, sattr->index); in pwmctrl_store()
966 r = hw_set_pwm(client, sattr->index, val, data->pwmchan[sattr->index]); in pwmctrl_store()
969 mutex_unlock(&data->lock); in pwmctrl_store()
988 idx = clamp_val(data->range[sattr->index] & 0xf, 0, in pwmfreq_show()
989 ARRAY_SIZE(pwmfreq_table) - 1); in pwmfreq_show()
1000 struct i2c_client *client = data->client; in pwmfreq_store()
1005 return -EINVAL; in pwmfreq_store()
1009 mutex_lock(&data->lock); in pwmfreq_store()
1011 data->range[sattr->index] = in pwmfreq_store()
1012 adt7475_read(TEMP_TRANGE_REG(sattr->index)); in pwmfreq_store()
1013 data->range[sattr->index] &= ~0xf; in pwmfreq_store()
1014 data->range[sattr->index] |= out; in pwmfreq_store()
1016 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), in pwmfreq_store()
1017 data->range[sattr->index]); in pwmfreq_store()
1019 mutex_unlock(&data->lock); in pwmfreq_store()
1032 return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY)); in pwm_use_point2_pwm_at_crit_show()
1040 struct i2c_client *client = data->client; in pwm_use_point2_pwm_at_crit_store()
1044 return -EINVAL; in pwm_use_point2_pwm_at_crit_store()
1046 return -EINVAL; in pwm_use_point2_pwm_at_crit_store()
1048 mutex_lock(&data->lock); in pwm_use_point2_pwm_at_crit_store()
1049 data->config4 = i2c_smbus_read_byte_data(client, REG_CONFIG4); in pwm_use_point2_pwm_at_crit_store()
1051 data->config4 |= CONFIG4_MAXDUTY; in pwm_use_point2_pwm_at_crit_store()
1053 data->config4 &= ~CONFIG4_MAXDUTY; in pwm_use_point2_pwm_at_crit_store()
1054 i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4); in pwm_use_point2_pwm_at_crit_store()
1055 mutex_unlock(&data->lock); in pwm_use_point2_pwm_at_crit_store()
1064 return sprintf(buf, "%d\n", (int)data->vrm); in vrm_show()
1074 return -EINVAL; in vrm_store()
1076 return -EINVAL; in vrm_store()
1077 data->vrm = val; in vrm_store()
1090 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); in cpu0_vid_show()
1187 /* Non-standard name, might need revisiting */
1338 struct i2c_adapter *adapter = client->adapter; in adt7475_detect()
1343 return -ENODEV; in adt7475_detect()
1349 return -ENODEV; in adt7475_detect()
1354 else if (devid == 0x75 && client->addr == 0x2e) in adt7475_detect()
1361 dev_dbg(&adapter->dev, in adt7475_detect()
1363 "0x%02x\n", (unsigned int)client->addr); in adt7475_detect()
1364 return -ENODEV; in adt7475_detect()
1367 strscpy(info->type, name, I2C_NAME_SIZE); in adt7475_detect()
1381 data->config4 = ret; in adt7475_update_limits()
1386 data->config5 = ret; in adt7475_update_limits()
1389 if (!(data->has_voltage & (1 << i))) in adt7475_update_limits()
1395 data->voltage[MIN][i] = ret << 2; in adt7475_update_limits()
1400 data->voltage[MAX][i] = ret << 2; in adt7475_update_limits()
1403 if (data->has_voltage & (1 << 5)) { in adt7475_update_limits()
1407 data->voltage[MIN][5] = ret << 2; in adt7475_update_limits()
1412 data->voltage[MAX][5] = ret << 2; in adt7475_update_limits()
1415 if (data->has_voltage & (1 << 6)) { in adt7475_update_limits()
1419 data->voltage[MIN][6] = ret << 2; in adt7475_update_limits()
1424 data->voltage[MAX][6] = ret << 2; in adt7475_update_limits()
1432 data->temp[MIN][i] = ret << 2; in adt7475_update_limits()
1437 data->temp[MAX][i] = ret << 2; in adt7475_update_limits()
1442 data->temp[AUTOMIN][i] = ret << 2; in adt7475_update_limits()
1447 data->temp[THERM][i] = ret << 2; in adt7475_update_limits()
1452 data->temp[OFFSET][i] = ret; in adt7475_update_limits()
1457 if (i == 3 && !data->has_fan4) in adt7475_update_limits()
1462 data->tach[MIN][i] = ret; in adt7475_update_limits()
1466 if (i == 1 && !data->has_pwm2) in adt7475_update_limits()
1471 data->pwm[MAX][i] = ret; in adt7475_update_limits()
1476 data->pwm[MIN][i] = ret; in adt7475_update_limits()
1484 data->range[0] = ret; in adt7475_update_limits()
1489 data->range[1] = ret; in adt7475_update_limits()
1494 data->range[2] = ret; in adt7475_update_limits()
1505 ret = device_property_read_string(&client->dev, propname, &function); in load_config3()
1517 return -EINVAL; in load_config3()
1531 ret = device_property_read_string(&client->dev, propname, &function); in load_config4()
1548 return -EINVAL; in load_config4()
1564 prop1 = "adi,pin5-function"; in load_config()
1565 prop2 = "adi,pin9-function"; in load_config()
1569 prop1 = "adi,pin10-function"; in load_config()
1570 prop2 = "adi,pin14-function"; in load_config()
1576 dev_err(&client->dev, "failed to configure %s\n", prop1); in load_config()
1582 dev_err(&client->dev, "failed to configure %s\n", prop2); in load_config()
1593 int ret = device_property_read_u32(&client->dev, property, in set_property_bit()
1612 set_property_bit(client, "adi,bypass-attenuator-in0", in load_attenuators()
1613 &data->config4, 4); in load_attenuators()
1614 set_property_bit(client, "adi,bypass-attenuator-in1", in load_attenuators()
1615 &data->config4, 5); in load_attenuators()
1616 set_property_bit(client, "adi,bypass-attenuator-in3", in load_attenuators()
1617 &data->config4, 6); in load_attenuators()
1618 set_property_bit(client, "adi,bypass-attenuator-in4", in load_attenuators()
1619 &data->config4, 7); in load_attenuators()
1622 data->config4); in load_attenuators()
1625 set_property_bit(client, "adi,bypass-attenuator-in1", in load_attenuators()
1626 &data->config2, 5); in load_attenuators()
1629 data->config2); in load_attenuators()
1641 ret = device_property_read_u32_array(&client->dev, in adt7475_set_pwm_polarity()
1642 "adi,pwm-active-state", states, in adt7475_set_pwm_polarity()
1681 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); in adt7475_probe()
1683 return -ENOMEM; in adt7475_probe()
1685 mutex_init(&data->lock); in adt7475_probe()
1686 data->client = client; in adt7475_probe()
1689 if (client->dev.of_node) in adt7475_probe()
1690 chip = (uintptr_t)of_device_get_match_data(&client->dev); in adt7475_probe()
1692 chip = id->driver_data; in adt7475_probe()
1694 /* Initialize device-specific values */ in adt7475_probe()
1697 data->has_voltage = 0x0e; /* in1 to in3 */ in adt7475_probe()
1701 data->has_voltage = 0x7e; /* in1 to in6 */ in adt7475_probe()
1707 data->has_voltage = 0x06; /* in1, in2 */ in adt7475_probe()
1718 data->has_pwm2 = 1; in adt7475_probe()
1719 /* Meaning of this bit is inverted for the ADT7473-1 */ in adt7475_probe()
1720 if (id->driver_data == adt7473 && revision >= 1) in adt7475_probe()
1721 data->has_pwm2 = !data->has_pwm2; in adt7475_probe()
1723 data->config4 = adt7475_read(REG_CONFIG4); in adt7475_probe()
1725 if ((data->config4 & CONFIG4_PINFUNC) == 0x0) in adt7475_probe()
1726 data->has_fan4 = 1; in adt7475_probe()
1733 if (id->driver_data == adt7490) { in adt7475_probe()
1734 if ((data->config4 & CONFIG4_PINFUNC) == 0x1 && in adt7475_probe()
1736 data->has_fan4 = 1; in adt7475_probe()
1738 if (id->driver_data == adt7476 || id->driver_data == adt7490) { in adt7475_probe()
1740 (data->config4 & CONFIG4_PINFUNC) == 0x1) in adt7475_probe()
1741 data->has_voltage |= (1 << 0); /* in0 */ in adt7475_probe()
1748 if (id->driver_data == adt7476) { in adt7475_probe()
1751 data->has_voltage |= (1 << 4); /* in4 */ in adt7475_probe()
1753 data->has_vid = !(adt7475_read(REG_CONFIG5) & CONFIG5_VIDGPIO); in adt7475_probe()
1757 data->config2 = adt7475_read(REG_CONFIG2); in adt7475_probe()
1760 dev_warn(&client->dev, "Error configuring attenuator bypass\n"); in adt7475_probe()
1762 if (data->config2 & CONFIG2_ATTN) { in adt7475_probe()
1763 data->bypass_attn = (0x3 << 3) | 0x3; in adt7475_probe()
1765 data->bypass_attn = ((data->config4 & CONFIG4_ATTN_IN10) >> 4) | in adt7475_probe()
1766 ((data->config4 & CONFIG4_ATTN_IN43) >> 3); in adt7475_probe()
1768 data->bypass_attn &= data->has_voltage; in adt7475_probe()
1778 if (ret && ret != -EINVAL) in adt7475_probe()
1779 dev_warn(&client->dev, "Error configuring pwm polarity\n"); in adt7475_probe()
1792 data->groups[group_num++] = &adt7475_attr_group; in adt7475_probe()
1795 if (data->has_fan4) { in adt7475_probe()
1796 data->groups[group_num++] = &fan4_attr_group; in adt7475_probe()
1798 if (data->has_pwm2) { in adt7475_probe()
1799 data->groups[group_num++] = &pwm2_attr_group; in adt7475_probe()
1801 if (data->has_voltage & (1 << 0)) { in adt7475_probe()
1802 data->groups[group_num++] = &in0_attr_group; in adt7475_probe()
1804 if (data->has_voltage & (1 << 3)) { in adt7475_probe()
1805 data->groups[group_num++] = &in3_attr_group; in adt7475_probe()
1807 if (data->has_voltage & (1 << 4)) { in adt7475_probe()
1808 data->groups[group_num++] = &in4_attr_group; in adt7475_probe()
1810 if (data->has_voltage & (1 << 5)) { in adt7475_probe()
1811 data->groups[group_num++] = &in5_attr_group; in adt7475_probe()
1813 if (data->has_voltage & (1 << 6)) { in adt7475_probe()
1814 data->groups[group_num++] = &in6_attr_group; in adt7475_probe()
1816 if (data->has_vid) { in adt7475_probe()
1817 data->vrm = vid_which_vrm(); in adt7475_probe()
1818 data->groups[group_num] = &vid_attr_group; in adt7475_probe()
1822 hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev, in adt7475_probe()
1823 client->name, data, in adt7475_probe()
1824 data->groups); in adt7475_probe()
1831 dev_info(&client->dev, "%s device, revision %d\n", in adt7475_probe()
1832 names[id->driver_data], revision); in adt7475_probe()
1833 if ((data->has_voltage & 0x11) || data->has_fan4 || data->has_pwm2) in adt7475_probe()
1834 dev_info(&client->dev, "Optional features:%s%s%s%s%s\n", in adt7475_probe()
1835 (data->has_voltage & (1 << 0)) ? " in0" : "", in adt7475_probe()
1836 (data->has_voltage & (1 << 4)) ? " in4" : "", in adt7475_probe()
1837 data->has_fan4 ? " fan4" : "", in adt7475_probe()
1838 data->has_pwm2 ? " pwm2" : "", in adt7475_probe()
1839 data->has_vid ? " vid" : ""); in adt7475_probe()
1840 if (data->bypass_attn) in adt7475_probe()
1841 dev_info(&client->dev, "Bypassing attenuators on:%s%s%s%s\n", in adt7475_probe()
1842 (data->bypass_attn & (1 << 0)) ? " in0" : "", in adt7475_probe()
1843 (data->bypass_attn & (1 << 1)) ? " in1" : "", in adt7475_probe()
1844 (data->bypass_attn & (1 << 3)) ? " in3" : "", in adt7475_probe()
1845 (data->bypass_attn & (1 << 4)) ? " in4" : ""); in adt7475_probe()
1871 data->temp[HYSTERSIS][0] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS); in adt7475_read_hystersis()
1872 data->temp[HYSTERSIS][1] = data->temp[HYSTERSIS][0]; in adt7475_read_hystersis()
1873 data->temp[HYSTERSIS][2] = (u16) adt7475_read(REG_REMOTE2_HYSTERSIS); in adt7475_read_hystersis()
1881 data->pwm[CONTROL][index] = adt7475_read(PWM_CONFIG_REG(index)); in adt7475_read_pwm()
1887 v = (data->pwm[CONTROL][index] >> 5) & 7; in adt7475_read_pwm()
1890 data->pwmctl[index] = 0; in adt7475_read_pwm()
1892 data->pwmctl[index] = 1; in adt7475_read_pwm()
1895 * The fan is disabled - we don't want to in adt7475_read_pwm()
1899 data->pwm[INPUT][index] = 0; in adt7475_read_pwm()
1900 data->pwm[CONTROL][index] &= ~0xE0; in adt7475_read_pwm()
1901 data->pwm[CONTROL][index] |= (7 << 5); in adt7475_read_pwm()
1904 data->pwm[INPUT][index]); in adt7475_read_pwm()
1907 data->pwm[CONTROL][index]); in adt7475_read_pwm()
1909 data->pwmctl[index] = 1; in adt7475_read_pwm()
1911 data->pwmctl[index] = 2; in adt7475_read_pwm()
1915 data->pwmchan[index] = 1; in adt7475_read_pwm()
1918 data->pwmchan[index] = 2; in adt7475_read_pwm()
1921 data->pwmchan[index] = 4; in adt7475_read_pwm()
1924 data->pwmchan[index] = 6; in adt7475_read_pwm()
1927 data->pwmchan[index] = 7; in adt7475_read_pwm()
1936 struct i2c_client *client = data->client; in adt7475_update_measure()
1944 data->alarms = ret << 8; in adt7475_update_measure()
1949 data->alarms |= ret; in adt7475_update_measure()
1964 if (!(data->has_voltage & (1 << i))) in adt7475_update_measure()
1969 data->voltage[INPUT][i] = in adt7475_update_measure()
1978 data->temp[INPUT][i] = in adt7475_update_measure()
1983 if (data->has_voltage & (1 << 5)) { in adt7475_update_measure()
1987 data->alarms |= ret << 24; in adt7475_update_measure()
1997 data->voltage[INPUT][5] = ret << 2 | in adt7475_update_measure()
2001 if (data->has_voltage & (1 << 6)) { in adt7475_update_measure()
2005 data->alarms |= ret << 24; in adt7475_update_measure()
2015 data->voltage[INPUT][6] = ret << 2 | in adt7475_update_measure()
2020 if (i == 3 && !data->has_fan4) in adt7475_update_measure()
2025 data->tach[INPUT][i] = ret; in adt7475_update_measure()
2030 if (i == 1 && !data->has_pwm2) in adt7475_update_measure()
2035 data->pwm[INPUT][i] = ret; in adt7475_update_measure()
2038 if (data->has_vid) { in adt7475_update_measure()
2042 data->vid = ret & 0x3f; in adt7475_update_measure()
2053 mutex_lock(&data->lock); in adt7475_update_device()
2056 if (time_after(jiffies, data->measure_updated + HZ * 2) || in adt7475_update_device()
2057 !data->valid) { in adt7475_update_device()
2060 data->valid = false; in adt7475_update_device()
2061 mutex_unlock(&data->lock); in adt7475_update_device()
2064 data->measure_updated = jiffies; in adt7475_update_device()
2065 data->valid = true; in adt7475_update_device()
2068 mutex_unlock(&data->lock); in adt7475_update_device()