adt7475.c (e4651640403307d79559dff113da4933c0921714) adt7475.c (1d58f5efbf2d8599a9062e4c800a072e2f015625)
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 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
7 *
8 * Derived from the lm83 driver by Jean Delvare

--- 65 unchanged lines hidden (view full) ---

74#define REG_TEMP_MAX_BASE 0x4F
75
76#define REG_TACH_MIN_BASE 0x54
77
78#define REG_PWM_CONFIG_BASE 0x5C
79
80#define REG_TEMP_TRANGE_BASE 0x5F
81
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 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
7 *
8 * Derived from the lm83 driver by Jean Delvare

--- 65 unchanged lines hidden (view full) ---

74#define REG_TEMP_MAX_BASE 0x4F
75
76#define REG_TACH_MIN_BASE 0x54
77
78#define REG_PWM_CONFIG_BASE 0x5C
79
80#define REG_TEMP_TRANGE_BASE 0x5F
81
82#define REG_ENHANCE_ACOUSTICS1 0x62
83#define REG_ENHANCE_ACOUSTICS2 0x63
84
82#define REG_PWM_MIN_BASE 0x64
83
84#define REG_TEMP_TMIN_BASE 0x67
85#define REG_TEMP_THERM_BASE 0x6A
86
87#define REG_REMOTE1_HYSTERSIS 0x6D
88#define REG_REMOTE2_HYSTERSIS 0x6E
89

--- 114 unchanged lines hidden (view full) ---

204 u32 alarms;
205 u16 voltage[3][6];
206 u16 temp[7][3];
207 u16 tach[2][4];
208 u8 pwm[4][3];
209 u8 range[3];
210 u8 pwmctl[3];
211 u8 pwmchan[3];
85#define REG_PWM_MIN_BASE 0x64
86
87#define REG_TEMP_TMIN_BASE 0x67
88#define REG_TEMP_THERM_BASE 0x6A
89
90#define REG_REMOTE1_HYSTERSIS 0x6D
91#define REG_REMOTE2_HYSTERSIS 0x6E
92

--- 114 unchanged lines hidden (view full) ---

207 u32 alarms;
208 u16 voltage[3][6];
209 u16 temp[7][3];
210 u16 tach[2][4];
211 u8 pwm[4][3];
212 u8 range[3];
213 u8 pwmctl[3];
214 u8 pwmchan[3];
215 u8 enh_acoustics[2];
212
213 u8 vid;
214 u8 vrm;
215};
216
217static struct i2c_driver adt7475_driver;
218static struct adt7475_data *adt7475_update_device(struct device *dev);
219static void adt7475_read_hystersis(struct i2c_client *client);

--- 475 unchanged lines hidden (view full) ---

695 case MAX:
696 reg = PWM_MAX_REG(sattr->index);
697 break;
698 }
699
700 data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF);
701 i2c_smbus_write_byte_data(client, reg,
702 data->pwm[sattr->nr][sattr->index]);
216
217 u8 vid;
218 u8 vrm;
219};
220
221static struct i2c_driver adt7475_driver;
222static struct adt7475_data *adt7475_update_device(struct device *dev);
223static void adt7475_read_hystersis(struct i2c_client *client);

--- 475 unchanged lines hidden (view full) ---

699 case MAX:
700 reg = PWM_MAX_REG(sattr->index);
701 break;
702 }
703
704 data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF);
705 i2c_smbus_write_byte_data(client, reg,
706 data->pwm[sattr->nr][sattr->index]);
707 mutex_unlock(&data->lock);
703
708
709 return count;
710}
711
712static ssize_t show_stall_disable(struct device *dev,
713 struct device_attribute *attr, char *buf)
714{
715 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
716 struct i2c_client *client = to_i2c_client(dev);
717 struct adt7475_data *data = i2c_get_clientdata(client);
718 u8 mask = BIT(5 + sattr->index);
719
720 return sprintf(buf, "%d\n", !!(data->enh_acoustics[0] & mask));
721}
722
723static ssize_t set_stall_disable(struct device *dev,
724 struct device_attribute *attr, const char *buf,
725 size_t count)
726{
727 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
728 struct i2c_client *client = to_i2c_client(dev);
729 struct adt7475_data *data = i2c_get_clientdata(client);
730 long val;
731 u8 mask = BIT(5 + sattr->index);
732
733 if (kstrtol(buf, 10, &val))
734 return -EINVAL;
735
736 mutex_lock(&data->lock);
737
738 data->enh_acoustics[0] &= ~mask;
739 if (val)
740 data->enh_acoustics[0] |= mask;
741
742 i2c_smbus_write_byte_data(client, REG_ENHANCE_ACOUSTICS1,
743 data->enh_acoustics[0]);
744
704 mutex_unlock(&data->lock);
705
706 return count;
707}
708
709/* Called by set_pwmctrl and set_pwmchan */
710
711static int hw_set_pwm(struct i2c_client *client, int index,

--- 311 unchanged lines hidden (view full) ---

1023static SENSOR_DEVICE_ATTR_2(pwm1_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
1024 set_pwmctrl, INPUT, 0);
1025static SENSOR_DEVICE_ATTR_2(pwm1_auto_channels_temp, S_IRUGO | S_IWUSR,
1026 show_pwmchan, set_pwmchan, INPUT, 0);
1027static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1028 set_pwm, MIN, 0);
1029static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1030 set_pwm, MAX, 0);
745 mutex_unlock(&data->lock);
746
747 return count;
748}
749
750/* Called by set_pwmctrl and set_pwmchan */
751
752static int hw_set_pwm(struct i2c_client *client, int index,

--- 311 unchanged lines hidden (view full) ---

1064static SENSOR_DEVICE_ATTR_2(pwm1_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
1065 set_pwmctrl, INPUT, 0);
1066static SENSOR_DEVICE_ATTR_2(pwm1_auto_channels_temp, S_IRUGO | S_IWUSR,
1067 show_pwmchan, set_pwmchan, INPUT, 0);
1068static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1069 set_pwm, MIN, 0);
1070static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1071 set_pwm, MAX, 0);
1072static SENSOR_DEVICE_ATTR_2(pwm1_stall_disable, S_IRUGO | S_IWUSR,
1073 show_stall_disable, set_stall_disable, 0, 0);
1031static SENSOR_DEVICE_ATTR_2(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
1032 1);
1033static SENSOR_DEVICE_ATTR_2(pwm2_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
1034 set_pwmfreq, INPUT, 1);
1035static SENSOR_DEVICE_ATTR_2(pwm2_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
1036 set_pwmctrl, INPUT, 1);
1037static SENSOR_DEVICE_ATTR_2(pwm2_auto_channels_temp, S_IRUGO | S_IWUSR,
1038 show_pwmchan, set_pwmchan, INPUT, 1);
1039static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1040 set_pwm, MIN, 1);
1041static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1042 set_pwm, MAX, 1);
1074static SENSOR_DEVICE_ATTR_2(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
1075 1);
1076static SENSOR_DEVICE_ATTR_2(pwm2_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
1077 set_pwmfreq, INPUT, 1);
1078static SENSOR_DEVICE_ATTR_2(pwm2_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
1079 set_pwmctrl, INPUT, 1);
1080static SENSOR_DEVICE_ATTR_2(pwm2_auto_channels_temp, S_IRUGO | S_IWUSR,
1081 show_pwmchan, set_pwmchan, INPUT, 1);
1082static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1083 set_pwm, MIN, 1);
1084static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1085 set_pwm, MAX, 1);
1086static SENSOR_DEVICE_ATTR_2(pwm2_stall_disable, S_IRUGO | S_IWUSR,
1087 show_stall_disable, set_stall_disable, 0, 1);
1043static SENSOR_DEVICE_ATTR_2(pwm3, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
1044 2);
1045static SENSOR_DEVICE_ATTR_2(pwm3_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
1046 set_pwmfreq, INPUT, 2);
1047static SENSOR_DEVICE_ATTR_2(pwm3_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
1048 set_pwmctrl, INPUT, 2);
1049static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR,
1050 show_pwmchan, set_pwmchan, INPUT, 2);
1051static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1052 set_pwm, MIN, 2);
1053static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1054 set_pwm, MAX, 2);
1088static SENSOR_DEVICE_ATTR_2(pwm3, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
1089 2);
1090static SENSOR_DEVICE_ATTR_2(pwm3_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
1091 set_pwmfreq, INPUT, 2);
1092static SENSOR_DEVICE_ATTR_2(pwm3_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
1093 set_pwmctrl, INPUT, 2);
1094static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR,
1095 show_pwmchan, set_pwmchan, INPUT, 2);
1096static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1097 set_pwm, MIN, 2);
1098static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1099 set_pwm, MAX, 2);
1100static SENSOR_DEVICE_ATTR_2(pwm3_stall_disable, S_IRUGO | S_IWUSR,
1101 show_stall_disable, set_stall_disable, 0, 2);
1055
1056/* Non-standard name, might need revisiting */
1057static DEVICE_ATTR_RW(pwm_use_point2_pwm_at_crit);
1058
1059static DEVICE_ATTR_RW(vrm);
1060static DEVICE_ATTR_RO(cpu0_vid);
1061
1062static struct attribute *adt7475_attrs[] = {

--- 44 unchanged lines hidden (view full) ---

1107 &sensor_dev_attr_fan3_min.dev_attr.attr,
1108 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1109 &sensor_dev_attr_pwm1.dev_attr.attr,
1110 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1111 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1112 &sensor_dev_attr_pwm1_auto_channels_temp.dev_attr.attr,
1113 &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
1114 &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr,
1102
1103/* Non-standard name, might need revisiting */
1104static DEVICE_ATTR_RW(pwm_use_point2_pwm_at_crit);
1105
1106static DEVICE_ATTR_RW(vrm);
1107static DEVICE_ATTR_RO(cpu0_vid);
1108
1109static struct attribute *adt7475_attrs[] = {

--- 44 unchanged lines hidden (view full) ---

1154 &sensor_dev_attr_fan3_min.dev_attr.attr,
1155 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1156 &sensor_dev_attr_pwm1.dev_attr.attr,
1157 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1158 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1159 &sensor_dev_attr_pwm1_auto_channels_temp.dev_attr.attr,
1160 &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
1161 &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr,
1162 &sensor_dev_attr_pwm1_stall_disable.dev_attr.attr,
1115 &sensor_dev_attr_pwm3.dev_attr.attr,
1116 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
1117 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1118 &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr,
1119 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr,
1120 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr,
1163 &sensor_dev_attr_pwm3.dev_attr.attr,
1164 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
1165 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1166 &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr,
1167 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr,
1168 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr,
1169 &sensor_dev_attr_pwm3_stall_disable.dev_attr.attr,
1121 &dev_attr_pwm_use_point2_pwm_at_crit.attr,
1122 NULL,
1123};
1124
1125static struct attribute *fan4_attrs[] = {
1126 &sensor_dev_attr_fan4_input.dev_attr.attr,
1127 &sensor_dev_attr_fan4_min.dev_attr.attr,
1128 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
1129 NULL
1130};
1131
1132static struct attribute *pwm2_attrs[] = {
1133 &sensor_dev_attr_pwm2.dev_attr.attr,
1134 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
1135 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1136 &sensor_dev_attr_pwm2_auto_channels_temp.dev_attr.attr,
1137 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
1138 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr,
1170 &dev_attr_pwm_use_point2_pwm_at_crit.attr,
1171 NULL,
1172};
1173
1174static struct attribute *fan4_attrs[] = {
1175 &sensor_dev_attr_fan4_input.dev_attr.attr,
1176 &sensor_dev_attr_fan4_min.dev_attr.attr,
1177 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
1178 NULL
1179};
1180
1181static struct attribute *pwm2_attrs[] = {
1182 &sensor_dev_attr_pwm2.dev_attr.attr,
1183 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
1184 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1185 &sensor_dev_attr_pwm2_auto_channels_temp.dev_attr.attr,
1186 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
1187 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr,
1188 &sensor_dev_attr_pwm2_stall_disable.dev_attr.attr,
1139 NULL
1140};
1141
1142static struct attribute *in0_attrs[] = {
1143 &sensor_dev_attr_in0_input.dev_attr.attr,
1144 &sensor_dev_attr_in0_max.dev_attr.attr,
1145 &sensor_dev_attr_in0_min.dev_attr.attr,
1146 &sensor_dev_attr_in0_alarm.dev_attr.attr,

--- 499 unchanged lines hidden ---
1189 NULL
1190};
1191
1192static struct attribute *in0_attrs[] = {
1193 &sensor_dev_attr_in0_input.dev_attr.attr,
1194 &sensor_dev_attr_in0_max.dev_attr.attr,
1195 &sensor_dev_attr_in0_min.dev_attr.attr,
1196 &sensor_dev_attr_in0_alarm.dev_attr.attr,

--- 499 unchanged lines hidden ---