adt7475.c (b180d0508475c5c55085839d22f454c69379eacc) | adt7475.c (f99318b2540da75e663603e1a0faef30a3bb0c92) |
---|---|
1/* 2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives 3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc. 4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> 5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> 6 7 * Derived from the lm83 driver by Jean Delvare 8 * --- 62 unchanged lines hidden (view full) --- 71#define REG_REMOTE1_HYSTERSIS 0x6D 72#define REG_REMOTE2_HYSTERSIS 0x6E 73 74#define REG_TEMP_OFFSET_BASE 0x70 75 76#define REG_EXTEND1 0x76 77#define REG_EXTEND2 0x77 78#define REG_CONFIG5 0x7C | 1/* 2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives 3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc. 4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> 5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> 6 7 * Derived from the lm83 driver by Jean Delvare 8 * --- 62 unchanged lines hidden (view full) --- 71#define REG_REMOTE1_HYSTERSIS 0x6D 72#define REG_REMOTE2_HYSTERSIS 0x6E 73 74#define REG_TEMP_OFFSET_BASE 0x70 75 76#define REG_EXTEND1 0x76 77#define REG_EXTEND2 0x77 78#define REG_CONFIG5 0x7C |
79#define REG_CONFIG4 0x7D |
|
79 | 80 |
81#define CONFIG4_MAXDUTY 0x08 82 |
|
80#define CONFIG5_TWOSCOMP 0x01 81#define CONFIG5_TEMPOFFSET 0x02 82 83/* ADT7475 Settings */ 84 85#define ADT7475_VOLTAGE_COUNT 2 86#define ADT7475_TEMP_COUNT 3 87#define ADT7475_TACH_COUNT 4 --- 39 unchanged lines hidden (view full) --- 127struct adt7475_data { 128 struct device *hwmon_dev; 129 struct mutex lock; 130 131 unsigned long measure_updated; 132 unsigned long limits_updated; 133 char valid; 134 | 83#define CONFIG5_TWOSCOMP 0x01 84#define CONFIG5_TEMPOFFSET 0x02 85 86/* ADT7475 Settings */ 87 88#define ADT7475_VOLTAGE_COUNT 2 89#define ADT7475_TEMP_COUNT 3 90#define ADT7475_TACH_COUNT 4 --- 39 unchanged lines hidden (view full) --- 130struct adt7475_data { 131 struct device *hwmon_dev; 132 struct mutex lock; 133 134 unsigned long measure_updated; 135 unsigned long limits_updated; 136 char valid; 137 |
138 u8 config4; |
|
135 u8 config5; 136 u16 alarms; 137 u16 voltage[3][3]; 138 u16 temp[7][3]; 139 u16 tach[2][4]; 140 u8 pwm[4][3]; 141 u8 range[3]; 142 u8 pwmctl[3]; --- 631 unchanged lines hidden (view full) --- 774 775 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), 776 data->range[sattr->index]); 777 778 mutex_unlock(&data->lock); 779 return count; 780} 781 | 139 u8 config5; 140 u16 alarms; 141 u16 voltage[3][3]; 142 u16 temp[7][3]; 143 u16 tach[2][4]; 144 u8 pwm[4][3]; 145 u8 range[3]; 146 u8 pwmctl[3]; --- 631 unchanged lines hidden (view full) --- 778 779 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), 780 data->range[sattr->index]); 781 782 mutex_unlock(&data->lock); 783 return count; 784} 785 |
786static ssize_t show_pwm_at_crit(struct device *dev, 787 struct device_attribute *devattr, char *buf) 788{ 789 struct adt7475_data *data = adt7475_update_device(dev); 790 return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY)); 791} 792 793static ssize_t set_pwm_at_crit(struct device *dev, 794 struct device_attribute *devattr, 795 const char *buf, size_t count) 796{ 797 struct i2c_client *client = to_i2c_client(dev); 798 struct adt7475_data *data = i2c_get_clientdata(client); 799 long val; 800 801 if (strict_strtol(buf, 10, &val)) 802 return -EINVAL; 803 if (val != 0 && val != 1) 804 return -EINVAL; 805 806 mutex_lock(&data->lock); 807 data->config4 = i2c_smbus_read_byte_data(client, REG_CONFIG4); 808 if (val) 809 data->config4 |= CONFIG4_MAXDUTY; 810 else 811 data->config4 &= ~CONFIG4_MAXDUTY; 812 i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4); 813 mutex_unlock(&data->lock); 814 815 return count; 816} 817 |
|
782static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0); 783static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, 784 set_voltage, MAX, 0); 785static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage, 786 set_voltage, MIN, 0); 787static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0); 788static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 1); 789static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage, --- 99 unchanged lines hidden (view full) --- 889 set_pwmctrl, INPUT, 2); 890static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR, 891 show_pwmchan, set_pwmchan, INPUT, 2); 892static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, 893 set_pwm, MIN, 2); 894static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, 895 set_pwm, MAX, 2); 896 | 818static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0); 819static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, 820 set_voltage, MAX, 0); 821static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage, 822 set_voltage, MIN, 0); 823static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0); 824static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 1); 825static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage, --- 99 unchanged lines hidden (view full) --- 925 set_pwmctrl, INPUT, 2); 926static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR, 927 show_pwmchan, set_pwmchan, INPUT, 2); 928static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, 929 set_pwm, MIN, 2); 930static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, 931 set_pwm, MAX, 2); 932 |
933/* Non-standard name, might need revisiting */ 934static DEVICE_ATTR(pwm_use_point2_pwm_at_crit, S_IWUSR | S_IRUGO, 935 show_pwm_at_crit, set_pwm_at_crit); 936 |
|
897static struct attribute *adt7475_attrs[] = { 898 &sensor_dev_attr_in1_input.dev_attr.attr, 899 &sensor_dev_attr_in1_max.dev_attr.attr, 900 &sensor_dev_attr_in1_min.dev_attr.attr, 901 &sensor_dev_attr_in1_alarm.dev_attr.attr, 902 &sensor_dev_attr_in2_input.dev_attr.attr, 903 &sensor_dev_attr_in2_max.dev_attr.attr, 904 &sensor_dev_attr_in2_min.dev_attr.attr, --- 52 unchanged lines hidden (view full) --- 957 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, 958 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, 959 &sensor_dev_attr_pwm3.dev_attr.attr, 960 &sensor_dev_attr_pwm3_freq.dev_attr.attr, 961 &sensor_dev_attr_pwm3_enable.dev_attr.attr, 962 &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, 963 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, 964 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | 937static struct attribute *adt7475_attrs[] = { 938 &sensor_dev_attr_in1_input.dev_attr.attr, 939 &sensor_dev_attr_in1_max.dev_attr.attr, 940 &sensor_dev_attr_in1_min.dev_attr.attr, 941 &sensor_dev_attr_in1_alarm.dev_attr.attr, 942 &sensor_dev_attr_in2_input.dev_attr.attr, 943 &sensor_dev_attr_in2_max.dev_attr.attr, 944 &sensor_dev_attr_in2_min.dev_attr.attr, --- 52 unchanged lines hidden (view full) --- 997 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, 998 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, 999 &sensor_dev_attr_pwm3.dev_attr.attr, 1000 &sensor_dev_attr_pwm3_freq.dev_attr.attr, 1001 &sensor_dev_attr_pwm3_enable.dev_attr.attr, 1002 &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, 1003 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, 1004 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, |
1005 &dev_attr_pwm_use_point2_pwm_at_crit.attr, |
|
965 NULL, 966}; 967 968struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; 969 970static int adt7475_detect(struct i2c_client *client, int kind, 971 struct i2c_board_info *info) 972{ --- 182 unchanged lines hidden (view full) --- 1155 data->pwm[INPUT][i] = adt7475_read(PWM_REG(i)); 1156 1157 data->measure_updated = jiffies; 1158 } 1159 1160 /* Limits and settings, should never change update every 60 seconds */ 1161 if (time_after(jiffies, data->limits_updated + HZ * 60) || 1162 !data->valid) { | 1006 NULL, 1007}; 1008 1009struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; 1010 1011static int adt7475_detect(struct i2c_client *client, int kind, 1012 struct i2c_board_info *info) 1013{ --- 182 unchanged lines hidden (view full) --- 1196 data->pwm[INPUT][i] = adt7475_read(PWM_REG(i)); 1197 1198 data->measure_updated = jiffies; 1199 } 1200 1201 /* Limits and settings, should never change update every 60 seconds */ 1202 if (time_after(jiffies, data->limits_updated + HZ * 60) || 1203 !data->valid) { |
1204 data->config4 = adt7475_read(REG_CONFIG4); |
|
1163 data->config5 = adt7475_read(REG_CONFIG5); 1164 1165 for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { 1166 /* Adjust values so they match the input precision */ 1167 data->voltage[MIN][i] = 1168 adt7475_read(VOLTAGE_MIN_REG(i)) << 2; 1169 data->voltage[MAX][i] = 1170 adt7475_read(VOLTAGE_MAX_REG(i)) << 2; --- 57 unchanged lines hidden --- | 1205 data->config5 = adt7475_read(REG_CONFIG5); 1206 1207 for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { 1208 /* Adjust values so they match the input precision */ 1209 data->voltage[MIN][i] = 1210 adt7475_read(VOLTAGE_MIN_REG(i)) << 2; 1211 data->voltage[MAX][i] = 1212 adt7475_read(VOLTAGE_MAX_REG(i)) << 2; --- 57 unchanged lines hidden --- |