Lines Matching +full:adt7475 +full:- +full:d

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.
18 #include <linux/hwmon-sysfs.h>
19 #include <linux/hwmon-vid.h>
37 * These are unique identifiers for the sysfs functions - unlike the
125 /* ADT7475 Settings */
160 enum chips { adt7473, adt7475, adt7476, adt7490 }; enumerator
164 { "adt7475", adt7475 },
177 .compatible = "adi,adt7475",
178 .data = (void *)adt7475
233 if (!(data->config5 & CONFIG5_TWOSCOMP)) { in temp2reg()
234 val = clamp_val(val, -64000, 191000); in temp2reg()
237 val = clamp_val(val, -128000, 127000); in temp2reg()
238 if (val < -500) in temp2reg()
251 if (data->config5 & CONFIG5_TWOSCOMP) { in reg2temp()
253 return (reg - 1024) * 250; in reg2temp()
257 return (reg - 256) * 250; in reg2temp()
338 switch (sattr->nr) { in voltage_show()
340 return sprintf(buf, "%d\n", in voltage_show()
341 (data->alarms >> sattr->index) & 1); in voltage_show()
343 val = data->voltage[sattr->nr][sattr->index]; in voltage_show()
344 return sprintf(buf, "%d\n", in voltage_show()
345 reg2volt(sattr->index, val, data->bypass_attn)); in voltage_show()
356 struct i2c_client *client = data->client; in voltage_store()
361 return -EINVAL; in voltage_store()
363 mutex_lock(&data->lock); in voltage_store()
365 data->voltage[sattr->nr][sattr->index] = in voltage_store()
366 volt2reg(sattr->index, val, data->bypass_attn); in voltage_store()
368 if (sattr->index < ADT7475_VOLTAGE_COUNT) { in voltage_store()
369 if (sattr->nr == MIN) in voltage_store()
370 reg = VOLTAGE_MIN_REG(sattr->index); in voltage_store()
372 reg = VOLTAGE_MAX_REG(sattr->index); in voltage_store()
374 if (sattr->nr == MIN) in voltage_store()
381 data->voltage[sattr->nr][sattr->index] >> 2); in voltage_store()
382 mutex_unlock(&data->lock); in voltage_store()
397 switch (sattr->nr) { in temp_show()
399 mutex_lock(&data->lock); in temp_show()
400 out = data->temp[sattr->nr][sattr->index]; in temp_show()
401 if (sattr->index != 1) in temp_show()
409 out = reg2temp(data, data->temp[THERM][sattr->index]) - in temp_show()
411 mutex_unlock(&data->lock); in temp_show()
419 mutex_lock(&data->lock); in temp_show()
420 out = (s8)data->temp[sattr->nr][sattr->index]; in temp_show()
421 if (data->config5 & CONFIG5_TEMPOFFSET) in temp_show()
425 mutex_unlock(&data->lock); in temp_show()
429 out = (data->alarms >> (sattr->index + 4)) & 1; in temp_show()
433 /* Note - only for remote1 and remote2 */ in temp_show()
434 out = !!(data->alarms & (sattr->index ? 0x8000 : 0x4000)); in temp_show()
439 out = reg2temp(data, data->temp[sattr->nr][sattr->index]); in temp_show()
442 return sprintf(buf, "%d\n", out); in temp_show()
450 struct i2c_client *client = data->client; in temp_store()
457 return -EINVAL; in temp_store()
459 mutex_lock(&data->lock); in temp_store()
461 /* We need the config register in all cases for temp <-> reg conv. */ in temp_store()
462 data->config5 = adt7475_read(REG_CONFIG5); in temp_store()
464 switch (sattr->nr) { in temp_store()
466 if (data->config5 & CONFIG5_TEMPOFFSET) { in temp_store()
467 val = clamp_val(val, -63000, 127000); in temp_store()
468 out = data->temp[OFFSET][sattr->index] = val / 1000; in temp_store()
470 val = clamp_val(val, -63000, 64000); in temp_store()
471 out = data->temp[OFFSET][sattr->index] = val / 500; in temp_store()
482 data->temp[THERM][sattr->index] = in temp_store()
483 adt7475_read(TEMP_THERM_REG(sattr->index)) << 2; in temp_store()
486 temp = reg2temp(data, data->temp[THERM][sattr->index]); in temp_store()
487 val = clamp_val(val, temp - 15000, temp); in temp_store()
488 val = (temp - val) / 1000; in temp_store()
490 if (sattr->index != 1) { in temp_store()
491 data->temp[HYSTERSIS][sattr->index] &= 0xF0; in temp_store()
492 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4; in temp_store()
494 data->temp[HYSTERSIS][sattr->index] &= 0x0F; in temp_store()
495 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF); in temp_store()
498 out = data->temp[HYSTERSIS][sattr->index]; in temp_store()
502 data->temp[sattr->nr][sattr->index] = temp2reg(data, val); in temp_store()
506 * - shift those back off before writing the value in temp_store()
508 out = (u8) (data->temp[sattr->nr][sattr->index] >> 2); in temp_store()
511 switch (sattr->nr) { in temp_store()
513 reg = TEMP_MIN_REG(sattr->index); in temp_store()
516 reg = TEMP_MAX_REG(sattr->index); in temp_store()
519 reg = TEMP_OFFSET_REG(sattr->index); in temp_store()
522 reg = TEMP_TMIN_REG(sattr->index); in temp_store()
525 reg = TEMP_THERM_REG(sattr->index); in temp_store()
528 if (sattr->index != 2) in temp_store()
538 mutex_unlock(&data->lock); in temp_store()
554 switch (sattr->index) { in temp_st_show()
556 val = data->enh_acoustics[0] & 0xf; in temp_st_show()
559 val = (data->enh_acoustics[1] >> 4) & 0xf; in temp_st_show()
563 val = data->enh_acoustics[1] & 0xf; in temp_st_show()
568 return sprintf(buf, "%d\n", ad7475_st_map[val & 0x7]); in temp_st_show()
579 struct i2c_client *client = data->client; in temp_st_store()
585 return -EINVAL; in temp_st_store()
587 switch (sattr->index) { in temp_st_store()
612 mutex_lock(&data->lock); in temp_st_store()
614 data->enh_acoustics[idx] &= ~(0xf << shift); in temp_st_store()
615 data->enh_acoustics[idx] |= (val << shift); in temp_st_store()
617 i2c_smbus_write_byte_data(client, reg, data->enh_acoustics[idx]); in temp_st_store()
619 mutex_unlock(&data->lock); in temp_st_store()
625 * Table of autorange values - the user will write the value in millidegrees,
644 mutex_lock(&data->lock); in point2_show()
645 out = (data->range[sattr->index] >> 4) & 0x0F; in point2_show()
646 val = reg2temp(data, data->temp[AUTOMIN][sattr->index]); in point2_show()
647 mutex_unlock(&data->lock); in point2_show()
649 return sprintf(buf, "%d\n", val + autorange_table[out]); in point2_show()
656 struct i2c_client *client = data->client; in point2_store()
662 return -EINVAL; in point2_store()
664 mutex_lock(&data->lock); in point2_store()
667 data->config5 = adt7475_read(REG_CONFIG5); in point2_store()
668 data->temp[AUTOMIN][sattr->index] = in point2_store()
669 adt7475_read(TEMP_TMIN_REG(sattr->index)) << 2; in point2_store()
670 data->range[sattr->index] = in point2_store()
671 adt7475_read(TEMP_TRANGE_REG(sattr->index)); in point2_store()
677 temp = reg2temp(data, data->temp[AUTOMIN][sattr->index]); in point2_store()
679 temp + autorange_table[ARRAY_SIZE(autorange_table) - 1]); in point2_store()
680 val -= temp; in point2_store()
685 data->range[sattr->index] &= ~0xF0; in point2_store()
686 data->range[sattr->index] |= val << 4; in point2_store()
688 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), in point2_store()
689 data->range[sattr->index]); in point2_store()
691 mutex_unlock(&data->lock); in point2_store()
705 if (sattr->nr == ALARM) in tach_show()
706 out = (data->alarms >> (sattr->index + 10)) & 1; in tach_show()
708 out = tach2rpm(data->tach[sattr->nr][sattr->index]); in tach_show()
710 return sprintf(buf, "%d\n", out); in tach_show()
719 struct i2c_client *client = data->client; in tach_store()
723 return -EINVAL; in tach_store()
725 mutex_lock(&data->lock); in tach_store()
727 data->tach[MIN][sattr->index] = rpm2tach(val); in tach_store()
729 adt7475_write_word(client, TACH_MIN_REG(sattr->index), in tach_store()
730 data->tach[MIN][sattr->index]); in tach_store()
732 mutex_unlock(&data->lock); in tach_store()
745 return sprintf(buf, "%d\n", data->pwm[sattr->nr][sattr->index]); in pwm_show()
757 return sprintf(buf, "%d\n", data->pwmchan[sattr->index]); in pwmchan_show()
769 return sprintf(buf, "%d\n", data->pwmctl[sattr->index]); in pwmctrl_show()
778 struct i2c_client *client = data->client; in pwm_store()
783 return -EINVAL; in pwm_store()
785 mutex_lock(&data->lock); in pwm_store()
787 switch (sattr->nr) { in pwm_store()
790 data->pwm[CONTROL][sattr->index] = in pwm_store()
791 adt7475_read(PWM_CONFIG_REG(sattr->index)); in pwm_store()
797 if (((data->pwm[CONTROL][sattr->index] >> 5) & 7) != 7) { in pwm_store()
798 mutex_unlock(&data->lock); in pwm_store()
802 reg = PWM_REG(sattr->index); in pwm_store()
806 reg = PWM_MIN_REG(sattr->index); in pwm_store()
810 reg = PWM_MAX_REG(sattr->index); in pwm_store()
814 data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF); in pwm_store()
816 data->pwm[sattr->nr][sattr->index]); in pwm_store()
817 mutex_unlock(&data->lock); in pwm_store()
828 u8 mask = BIT(5 + sattr->index); in stall_disable_show()
830 return sprintf(buf, "%d\n", !!(data->enh_acoustics[0] & mask)); in stall_disable_show()
839 struct i2c_client *client = data->client; in stall_disable_store()
841 u8 mask = BIT(5 + sattr->index); in stall_disable_store()
844 return -EINVAL; in stall_disable_store()
846 mutex_lock(&data->lock); in stall_disable_store()
848 data->enh_acoustics[0] &= ~mask; in stall_disable_store()
850 data->enh_acoustics[0] |= mask; in stall_disable_store()
853 data->enh_acoustics[0]); in stall_disable_store()
855 mutex_unlock(&data->lock); in stall_disable_store()
898 return -EINVAL; in hw_set_pwm()
902 return -EINVAL; in hw_set_pwm()
905 data->pwmctl[index] = pwmctl; in hw_set_pwm()
906 data->pwmchan[index] = pwmchan; in hw_set_pwm()
908 data->pwm[CONTROL][index] &= ~0xE0; in hw_set_pwm()
909 data->pwm[CONTROL][index] |= (val & 7) << 5; in hw_set_pwm()
912 data->pwm[CONTROL][index]); in hw_set_pwm()
923 struct i2c_client *client = data->client; in pwmchan_store()
928 return -EINVAL; in pwmchan_store()
930 mutex_lock(&data->lock); in pwmchan_store()
932 adt7475_read_pwm(client, sattr->index); in pwmchan_store()
933 r = hw_set_pwm(client, sattr->index, data->pwmctl[sattr->index], val); in pwmchan_store()
936 mutex_unlock(&data->lock); in pwmchan_store()
947 struct i2c_client *client = data->client; in pwmctrl_store()
952 return -EINVAL; in pwmctrl_store()
954 mutex_lock(&data->lock); in pwmctrl_store()
956 adt7475_read_pwm(client, sattr->index); in pwmctrl_store()
957 r = hw_set_pwm(client, sattr->index, val, data->pwmchan[sattr->index]); in pwmctrl_store()
960 mutex_unlock(&data->lock); in pwmctrl_store()
979 idx = clamp_val(data->range[sattr->index] & 0xf, 0, in pwmfreq_show()
980 ARRAY_SIZE(pwmfreq_table) - 1); in pwmfreq_show()
982 return sprintf(buf, "%d\n", pwmfreq_table[idx]); in pwmfreq_show()
991 struct i2c_client *client = data->client; in pwmfreq_store()
996 return -EINVAL; in pwmfreq_store()
1000 mutex_lock(&data->lock); in pwmfreq_store()
1002 data->range[sattr->index] = in pwmfreq_store()
1003 adt7475_read(TEMP_TRANGE_REG(sattr->index)); in pwmfreq_store()
1004 data->range[sattr->index] &= ~0xf; in pwmfreq_store()
1005 data->range[sattr->index] |= out; in pwmfreq_store()
1007 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), in pwmfreq_store()
1008 data->range[sattr->index]); in pwmfreq_store()
1010 mutex_unlock(&data->lock); in pwmfreq_store()
1023 return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY)); in pwm_use_point2_pwm_at_crit_show()
1031 struct i2c_client *client = data->client; in pwm_use_point2_pwm_at_crit_store()
1035 return -EINVAL; in pwm_use_point2_pwm_at_crit_store()
1037 return -EINVAL; in pwm_use_point2_pwm_at_crit_store()
1039 mutex_lock(&data->lock); in pwm_use_point2_pwm_at_crit_store()
1040 data->config4 = i2c_smbus_read_byte_data(client, REG_CONFIG4); in pwm_use_point2_pwm_at_crit_store()
1042 data->config4 |= CONFIG4_MAXDUTY; in pwm_use_point2_pwm_at_crit_store()
1044 data->config4 &= ~CONFIG4_MAXDUTY; in pwm_use_point2_pwm_at_crit_store()
1045 i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4); in pwm_use_point2_pwm_at_crit_store()
1046 mutex_unlock(&data->lock); in pwm_use_point2_pwm_at_crit_store()
1055 return sprintf(buf, "%d\n", (int)data->vrm); in vrm_show()
1065 return -EINVAL; in vrm_store()
1067 return -EINVAL; in vrm_store()
1068 data->vrm = val; in vrm_store()
1081 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); in cpu0_vid_show()
1174 /* Non-standard name, might need revisiting */
1316 struct i2c_adapter *adapter = client->adapter; in adt7475_detect()
1321 return -ENODEV; in adt7475_detect()
1327 return -ENODEV; in adt7475_detect()
1332 else if (devid == 0x75 && client->addr == 0x2e) in adt7475_detect()
1333 name = "adt7475"; in adt7475_detect()
1339 dev_dbg(&adapter->dev, in adt7475_detect()
1341 "0x%02x\n", (unsigned int)client->addr); in adt7475_detect()
1342 return -ENODEV; in adt7475_detect()
1345 strscpy(info->type, name, I2C_NAME_SIZE); in adt7475_detect()
1359 data->config4 = ret; in adt7475_update_limits()
1364 data->config5 = ret; in adt7475_update_limits()
1367 if (!(data->has_voltage & (1 << i))) in adt7475_update_limits()
1373 data->voltage[MIN][i] = ret << 2; in adt7475_update_limits()
1378 data->voltage[MAX][i] = ret << 2; in adt7475_update_limits()
1381 if (data->has_voltage & (1 << 5)) { in adt7475_update_limits()
1385 data->voltage[MIN][5] = ret << 2; in adt7475_update_limits()
1390 data->voltage[MAX][5] = ret << 2; in adt7475_update_limits()
1398 data->temp[MIN][i] = ret << 2; in adt7475_update_limits()
1403 data->temp[MAX][i] = ret << 2; in adt7475_update_limits()
1408 data->temp[AUTOMIN][i] = ret << 2; in adt7475_update_limits()
1413 data->temp[THERM][i] = ret << 2; in adt7475_update_limits()
1418 data->temp[OFFSET][i] = ret; in adt7475_update_limits()
1423 if (i == 3 && !data->has_fan4) in adt7475_update_limits()
1428 data->tach[MIN][i] = ret; in adt7475_update_limits()
1432 if (i == 1 && !data->has_pwm2) in adt7475_update_limits()
1437 data->pwm[MAX][i] = ret; in adt7475_update_limits()
1442 data->pwm[MIN][i] = ret; in adt7475_update_limits()
1450 data->range[0] = ret; in adt7475_update_limits()
1455 data->range[1] = ret; in adt7475_update_limits()
1460 data->range[2] = ret; in adt7475_update_limits()
1471 ret = of_property_read_string(client->dev.of_node, propname, &function); in load_config3()
1483 return -EINVAL; in load_config3()
1497 ret = of_property_read_string(client->dev.of_node, propname, &function); in load_config4()
1514 return -EINVAL; in load_config4()
1529 case adt7475: in load_config()
1530 prop1 = "adi,pin5-function"; in load_config()
1531 prop2 = "adi,pin9-function"; in load_config()
1535 prop1 = "adi,pin10-function"; in load_config()
1536 prop2 = "adi,pin14-function"; in load_config()
1542 dev_err(&client->dev, "failed to configure %s\n", prop1); in load_config()
1548 dev_err(&client->dev, "failed to configure %s\n", prop2); in load_config()
1559 int ret = of_property_read_u32(client->dev.of_node, property, in set_property_bit()
1578 set_property_bit(client, "adi,bypass-attenuator-in0", in load_attenuators()
1579 &data->config4, 4); in load_attenuators()
1580 set_property_bit(client, "adi,bypass-attenuator-in1", in load_attenuators()
1581 &data->config4, 5); in load_attenuators()
1582 set_property_bit(client, "adi,bypass-attenuator-in3", in load_attenuators()
1583 &data->config4, 6); in load_attenuators()
1584 set_property_bit(client, "adi,bypass-attenuator-in4", in load_attenuators()
1585 &data->config4, 7); in load_attenuators()
1588 data->config4); in load_attenuators()
1590 case adt7475: in load_attenuators()
1591 set_property_bit(client, "adi,bypass-attenuator-in1", in load_attenuators()
1592 &data->config2, 5); in load_attenuators()
1595 data->config2); in load_attenuators()
1607 ret = of_property_read_u32_array(client->dev.of_node, in adt7475_set_pwm_polarity()
1608 "adi,pwm-active-state", states, in adt7475_set_pwm_polarity()
1636 [adt7475] = "ADT7475", in adt7475_probe()
1647 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); in adt7475_probe()
1649 return -ENOMEM; in adt7475_probe()
1651 mutex_init(&data->lock); in adt7475_probe()
1652 data->client = client; in adt7475_probe()
1655 if (client->dev.of_node) in adt7475_probe()
1656 chip = (enum chips)of_device_get_match_data(&client->dev); in adt7475_probe()
1658 chip = id->driver_data; in adt7475_probe()
1660 /* Initialize device-specific values */ in adt7475_probe()
1663 data->has_voltage = 0x0e; /* in1 to in3 */ in adt7475_probe()
1667 data->has_voltage = 0x3e; /* in1 to in5 */ in adt7475_probe()
1673 data->has_voltage = 0x06; /* in1, in2 */ in adt7475_probe()
1684 data->has_pwm2 = 1; in adt7475_probe()
1685 /* Meaning of this bit is inverted for the ADT7473-1 */ in adt7475_probe()
1686 if (id->driver_data == adt7473 && revision >= 1) in adt7475_probe()
1687 data->has_pwm2 = !data->has_pwm2; in adt7475_probe()
1689 data->config4 = adt7475_read(REG_CONFIG4); in adt7475_probe()
1691 if ((data->config4 & CONFIG4_PINFUNC) == 0x0) in adt7475_probe()
1692 data->has_fan4 = 1; in adt7475_probe()
1699 if (id->driver_data == adt7490) { in adt7475_probe()
1700 if ((data->config4 & CONFIG4_PINFUNC) == 0x1 && in adt7475_probe()
1702 data->has_fan4 = 1; in adt7475_probe()
1704 if (id->driver_data == adt7476 || id->driver_data == adt7490) { in adt7475_probe()
1706 (data->config4 & CONFIG4_PINFUNC) == 0x1) in adt7475_probe()
1707 data->has_voltage |= (1 << 0); /* in0 */ in adt7475_probe()
1714 if (id->driver_data == adt7476) { in adt7475_probe()
1717 data->has_voltage |= (1 << 4); /* in4 */ in adt7475_probe()
1719 data->has_vid = !(adt7475_read(REG_CONFIG5) & CONFIG5_VIDGPIO); in adt7475_probe()
1723 data->config2 = adt7475_read(REG_CONFIG2); in adt7475_probe()
1726 dev_warn(&client->dev, "Error configuring attenuator bypass\n"); in adt7475_probe()
1728 if (data->config2 & CONFIG2_ATTN) { in adt7475_probe()
1729 data->bypass_attn = (0x3 << 3) | 0x3; in adt7475_probe()
1731 data->bypass_attn = ((data->config4 & CONFIG4_ATTN_IN10) >> 4) | in adt7475_probe()
1732 ((data->config4 & CONFIG4_ATTN_IN43) >> 3); in adt7475_probe()
1734 data->bypass_attn &= data->has_voltage; in adt7475_probe()
1744 if (ret && ret != -EINVAL) in adt7475_probe()
1745 dev_warn(&client->dev, "Error configuring pwm polarity\n"); in adt7475_probe()
1749 case adt7475: in adt7475_probe()
1758 data->groups[group_num++] = &adt7475_attr_group; in adt7475_probe()
1761 if (data->has_fan4) { in adt7475_probe()
1762 data->groups[group_num++] = &fan4_attr_group; in adt7475_probe()
1764 if (data->has_pwm2) { in adt7475_probe()
1765 data->groups[group_num++] = &pwm2_attr_group; in adt7475_probe()
1767 if (data->has_voltage & (1 << 0)) { in adt7475_probe()
1768 data->groups[group_num++] = &in0_attr_group; in adt7475_probe()
1770 if (data->has_voltage & (1 << 3)) { in adt7475_probe()
1771 data->groups[group_num++] = &in3_attr_group; in adt7475_probe()
1773 if (data->has_voltage & (1 << 4)) { in adt7475_probe()
1774 data->groups[group_num++] = &in4_attr_group; in adt7475_probe()
1776 if (data->has_voltage & (1 << 5)) { in adt7475_probe()
1777 data->groups[group_num++] = &in5_attr_group; in adt7475_probe()
1779 if (data->has_vid) { in adt7475_probe()
1780 data->vrm = vid_which_vrm(); in adt7475_probe()
1781 data->groups[group_num] = &vid_attr_group; in adt7475_probe()
1785 hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev, in adt7475_probe()
1786 client->name, data, in adt7475_probe()
1787 data->groups); in adt7475_probe()
1794 dev_info(&client->dev, "%s device, revision %d\n", in adt7475_probe()
1795 names[id->driver_data], revision); in adt7475_probe()
1796 if ((data->has_voltage & 0x11) || data->has_fan4 || data->has_pwm2) in adt7475_probe()
1797 dev_info(&client->dev, "Optional features:%s%s%s%s%s\n", in adt7475_probe()
1798 (data->has_voltage & (1 << 0)) ? " in0" : "", in adt7475_probe()
1799 (data->has_voltage & (1 << 4)) ? " in4" : "", in adt7475_probe()
1800 data->has_fan4 ? " fan4" : "", in adt7475_probe()
1801 data->has_pwm2 ? " pwm2" : "", in adt7475_probe()
1802 data->has_vid ? " vid" : ""); in adt7475_probe()
1803 if (data->bypass_attn) in adt7475_probe()
1804 dev_info(&client->dev, "Bypassing attenuators on:%s%s%s%s\n", in adt7475_probe()
1805 (data->bypass_attn & (1 << 0)) ? " in0" : "", in adt7475_probe()
1806 (data->bypass_attn & (1 << 1)) ? " in1" : "", in adt7475_probe()
1807 (data->bypass_attn & (1 << 3)) ? " in3" : "", in adt7475_probe()
1808 (data->bypass_attn & (1 << 4)) ? " in4" : ""); in adt7475_probe()
1821 .name = "adt7475",
1834 data->temp[HYSTERSIS][0] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS); in adt7475_read_hystersis()
1835 data->temp[HYSTERSIS][1] = data->temp[HYSTERSIS][0]; in adt7475_read_hystersis()
1836 data->temp[HYSTERSIS][2] = (u16) adt7475_read(REG_REMOTE2_HYSTERSIS); in adt7475_read_hystersis()
1844 data->pwm[CONTROL][index] = adt7475_read(PWM_CONFIG_REG(index)); in adt7475_read_pwm()
1850 v = (data->pwm[CONTROL][index] >> 5) & 7; in adt7475_read_pwm()
1853 data->pwmctl[index] = 0; in adt7475_read_pwm()
1855 data->pwmctl[index] = 1; in adt7475_read_pwm()
1858 * The fan is disabled - we don't want to in adt7475_read_pwm()
1862 data->pwm[INPUT][index] = 0; in adt7475_read_pwm()
1863 data->pwm[CONTROL][index] &= ~0xE0; in adt7475_read_pwm()
1864 data->pwm[CONTROL][index] |= (7 << 5); in adt7475_read_pwm()
1867 data->pwm[INPUT][index]); in adt7475_read_pwm()
1870 data->pwm[CONTROL][index]); in adt7475_read_pwm()
1872 data->pwmctl[index] = 1; in adt7475_read_pwm()
1874 data->pwmctl[index] = 2; in adt7475_read_pwm()
1878 data->pwmchan[index] = 1; in adt7475_read_pwm()
1881 data->pwmchan[index] = 2; in adt7475_read_pwm()
1884 data->pwmchan[index] = 4; in adt7475_read_pwm()
1887 data->pwmchan[index] = 6; in adt7475_read_pwm()
1890 data->pwmchan[index] = 7; in adt7475_read_pwm()
1899 struct i2c_client *client = data->client; in adt7475_update_measure()
1907 data->alarms = ret << 8; in adt7475_update_measure()
1912 data->alarms |= ret; in adt7475_update_measure()
1927 if (!(data->has_voltage & (1 << i))) in adt7475_update_measure()
1932 data->voltage[INPUT][i] = in adt7475_update_measure()
1941 data->temp[INPUT][i] = in adt7475_update_measure()
1946 if (data->has_voltage & (1 << 5)) { in adt7475_update_measure()
1950 data->alarms |= ret << 24; in adt7475_update_measure()
1960 data->voltage[INPUT][5] = ret << 2 | in adt7475_update_measure()
1965 if (i == 3 && !data->has_fan4) in adt7475_update_measure()
1970 data->tach[INPUT][i] = ret; in adt7475_update_measure()
1975 if (i == 1 && !data->has_pwm2) in adt7475_update_measure()
1980 data->pwm[INPUT][i] = ret; in adt7475_update_measure()
1983 if (data->has_vid) { in adt7475_update_measure()
1987 data->vid = ret & 0x3f; in adt7475_update_measure()
1998 mutex_lock(&data->lock); in adt7475_update_device()
2001 if (time_after(jiffies, data->measure_updated + HZ * 2) || in adt7475_update_device()
2002 !data->valid) { in adt7475_update_device()
2005 data->valid = false; in adt7475_update_device()
2006 mutex_unlock(&data->lock); in adt7475_update_device()
2009 data->measure_updated = jiffies; in adt7475_update_device()
2010 data->valid = true; in adt7475_update_device()
2013 mutex_unlock(&data->lock); in adt7475_update_device()
2021 MODULE_DESCRIPTION("adt7475 driver");