Lines Matching +full:temp +full:- +full:alarm
1 // SPDX-License-Identifier: GPL-2.0-or-later
13 #include <linux/hwmon-sysfs.h>
199 u8 temp[ADT7462_TEMP_COUNT]; member
200 /* bits 6-7 are quarter pieces of temp */
222 * 16-bit registers on the ADT7462 are low-byte first. The data sheet says
238 return ADT7462_REG_FAN2_BASE_ADDR + (2 * (fan - 4)); in ADT7462_REG_FAN()
246 if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) in ADT7462_REG_VOLT_MAX()
252 if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) in ADT7462_REG_VOLT_MAX()
256 if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) in ADT7462_REG_VOLT_MAX()
260 if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) in ADT7462_REG_VOLT_MAX()
264 if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) in ADT7462_REG_VOLT_MAX()
268 if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) in ADT7462_REG_VOLT_MAX()
272 if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) in ADT7462_REG_VOLT_MAX()
276 if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT)) in ADT7462_REG_VOLT_MAX()
280 if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT)) in ADT7462_REG_VOLT_MAX()
286 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in ADT7462_REG_VOLT_MAX()
288 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in ADT7462_REG_VOLT_MAX()
292 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in ADT7462_REG_VOLT_MAX()
294 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in ADT7462_REG_VOLT_MAX()
305 if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) in ADT7462_REG_VOLT_MIN()
311 if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) in ADT7462_REG_VOLT_MIN()
315 if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) in ADT7462_REG_VOLT_MIN()
319 if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) in ADT7462_REG_VOLT_MIN()
323 if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) in ADT7462_REG_VOLT_MIN()
327 if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) in ADT7462_REG_VOLT_MIN()
331 if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) in ADT7462_REG_VOLT_MIN()
335 if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT)) in ADT7462_REG_VOLT_MIN()
339 if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT)) in ADT7462_REG_VOLT_MIN()
345 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in ADT7462_REG_VOLT_MIN()
347 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in ADT7462_REG_VOLT_MIN()
351 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in ADT7462_REG_VOLT_MIN()
353 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in ADT7462_REG_VOLT_MIN()
364 if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) in ADT7462_REG_VOLT()
370 if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) in ADT7462_REG_VOLT()
374 if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) in ADT7462_REG_VOLT()
378 if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) in ADT7462_REG_VOLT()
382 if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) in ADT7462_REG_VOLT()
386 if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) in ADT7462_REG_VOLT()
390 if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) in ADT7462_REG_VOLT()
394 if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT)) in ADT7462_REG_VOLT()
398 if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT)) in ADT7462_REG_VOLT()
404 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in ADT7462_REG_VOLT()
406 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in ADT7462_REG_VOLT()
410 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in ADT7462_REG_VOLT()
412 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in ADT7462_REG_VOLT()
424 if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) in voltage_label()
428 switch (MASK_AND_SHIFT(data->pin_cfg[1], ADT7462_PIN23)) { in voltage_label()
440 if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) in voltage_label()
444 if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) in voltage_label()
448 if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) { in voltage_label()
449 if (data->pin_cfg[1] & ADT7462_PIN19_INPUT) in voltage_label()
455 if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) { in voltage_label()
456 if (data->pin_cfg[1] & ADT7462_PIN19_INPUT) in voltage_label()
462 if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) in voltage_label()
466 if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) in voltage_label()
470 switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN26)) { in voltage_label()
478 switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN25)) { in voltage_label()
486 switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN24)) { in voltage_label()
498 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in voltage_label()
500 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in voltage_label()
504 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in voltage_label()
506 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in voltage_label()
518 if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) in voltage_multiplier()
522 switch (MASK_AND_SHIFT(data->pin_cfg[1], ADT7462_PIN23)) { in voltage_multiplier()
524 if (data->pin_cfg[0] & ADT7462_VID_INPUT) in voltage_multiplier()
536 if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) in voltage_multiplier()
540 if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) in voltage_multiplier()
544 if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) { in voltage_multiplier()
545 if (data->pin_cfg[1] & ADT7462_PIN19_INPUT) in voltage_multiplier()
551 if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) { in voltage_multiplier()
552 if (data->pin_cfg[1] & ADT7462_PIN15_INPUT) in voltage_multiplier()
558 if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) in voltage_multiplier()
562 if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) in voltage_multiplier()
566 switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN26)) { in voltage_multiplier()
574 switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN25)) { in voltage_multiplier()
582 switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN24)) { in voltage_multiplier()
595 if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == in voltage_multiplier()
597 !(data->pin_cfg[0] & ADT7462_VID_INPUT)) in voltage_multiplier()
610 if (data->pin_cfg[0] & ADT7462_DIODE1_INPUT) in temp_enabled()
614 if (data->pin_cfg[0] & ADT7462_DIODE3_INPUT) in temp_enabled()
627 if (data->pin_cfg[0] & ADT7462_DIODE1_INPUT) in temp_label()
633 if (data->pin_cfg[0] & ADT7462_DIODE3_INPUT) in temp_label()
669 return -EINVAL; in find_trange_value()
675 struct i2c_client *client = data->client; in adt7462_update_device()
679 mutex_lock(&data->lock); in adt7462_update_device()
680 if (time_before(local_jiffies, data->sensors_last_updated + in adt7462_update_device()
682 && data->sensors_valid) in adt7462_update_device()
690 data->temp_frac[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
692 data->temp[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
697 data->fan[i] = adt7462_read_word_data(client, in adt7462_update_device()
700 data->fan_enabled = i2c_smbus_read_byte_data(client, in adt7462_update_device()
704 data->pwm[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
708 data->pin_cfg[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
714 data->voltages[i] = 0; in adt7462_update_device()
716 data->voltages[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
720 data->alarms[0] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM1); in adt7462_update_device()
721 data->alarms[1] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM2); in adt7462_update_device()
722 data->alarms[2] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM3); in adt7462_update_device()
723 data->alarms[3] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM4); in adt7462_update_device()
725 data->sensors_last_updated = local_jiffies; in adt7462_update_device()
726 data->sensors_valid = 1; in adt7462_update_device()
729 if (time_before(local_jiffies, data->limits_last_updated + in adt7462_update_device()
731 && data->limits_valid) in adt7462_update_device()
735 data->temp_min[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
737 data->temp_max[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
742 data->fan_min[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
747 data->volt_max[i] = in adt7462_update_device()
751 data->volt_min[i] = in adt7462_update_device()
756 data->pwm_min[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
758 data->pwm_tmin[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
760 data->pwm_trange[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
762 data->pwm_cfg[i] = i2c_smbus_read_byte_data(client, in adt7462_update_device()
766 data->pwm_max = i2c_smbus_read_byte_data(client, ADT7462_REG_PWM_MAX); in adt7462_update_device()
768 data->cfg2 = i2c_smbus_read_byte_data(client, ADT7462_REG_CFG2); in adt7462_update_device()
770 data->limits_last_updated = local_jiffies; in adt7462_update_device()
771 data->limits_valid = 1; in adt7462_update_device()
774 mutex_unlock(&data->lock); in adt7462_update_device()
784 if (!temp_enabled(data, attr->index)) in temp_min_show()
787 return sprintf(buf, "%d\n", 1000 * (data->temp_min[attr->index] - 64)); in temp_min_show()
796 struct i2c_client *client = data->client; in temp_min_store()
797 long temp; in temp_min_store() local
799 if (kstrtol(buf, 10, &temp) || !temp_enabled(data, attr->index)) in temp_min_store()
800 return -EINVAL; in temp_min_store()
802 temp = clamp_val(temp, -64000, 191000); in temp_min_store()
803 temp = DIV_ROUND_CLOSEST(temp, 1000) + 64; in temp_min_store()
805 mutex_lock(&data->lock); in temp_min_store()
806 data->temp_min[attr->index] = temp; in temp_min_store()
807 i2c_smbus_write_byte_data(client, ADT7462_TEMP_MIN_REG(attr->index), in temp_min_store()
808 temp); in temp_min_store()
809 mutex_unlock(&data->lock); in temp_min_store()
820 if (!temp_enabled(data, attr->index)) in temp_max_show()
823 return sprintf(buf, "%d\n", 1000 * (data->temp_max[attr->index] - 64)); in temp_max_show()
832 struct i2c_client *client = data->client; in temp_max_store()
833 long temp; in temp_max_store() local
835 if (kstrtol(buf, 10, &temp) || !temp_enabled(data, attr->index)) in temp_max_store()
836 return -EINVAL; in temp_max_store()
838 temp = clamp_val(temp, -64000, 191000); in temp_max_store()
839 temp = DIV_ROUND_CLOSEST(temp, 1000) + 64; in temp_max_store()
841 mutex_lock(&data->lock); in temp_max_store()
842 data->temp_max[attr->index] = temp; in temp_max_store()
843 i2c_smbus_write_byte_data(client, ADT7462_TEMP_MAX_REG(attr->index), in temp_max_store()
844 temp); in temp_max_store()
845 mutex_unlock(&data->lock); in temp_max_store()
855 u8 frac = data->temp_frac[attr->index] >> TEMP_FRAC_OFFSET; in temp_show()
857 if (!temp_enabled(data, attr->index)) in temp_show()
860 return sprintf(buf, "%d\n", 1000 * (data->temp[attr->index] - 64) + in temp_show()
870 return sprintf(buf, "%s\n", temp_label(data, attr->index)); in temp_label_show()
878 int x = voltage_multiplier(data, attr->index); in volt_max_show()
880 x *= data->volt_max[attr->index]; in volt_max_show()
892 struct i2c_client *client = data->client; in volt_max_store()
893 int x = voltage_multiplier(data, attr->index); in volt_max_store()
894 long temp; in volt_max_store() local
896 if (kstrtol(buf, 10, &temp) || !x) in volt_max_store()
897 return -EINVAL; in volt_max_store()
899 temp = clamp_val(temp, 0, 255 * x / 1000); in volt_max_store()
900 temp *= 1000; /* convert mV to uV */ in volt_max_store()
901 temp = DIV_ROUND_CLOSEST(temp, x); in volt_max_store()
903 mutex_lock(&data->lock); in volt_max_store()
904 data->volt_max[attr->index] = temp; in volt_max_store()
906 ADT7462_REG_VOLT_MAX(data, attr->index), in volt_max_store()
907 temp); in volt_max_store()
908 mutex_unlock(&data->lock); in volt_max_store()
918 int x = voltage_multiplier(data, attr->index); in volt_min_show()
920 x *= data->volt_min[attr->index]; in volt_min_show()
932 struct i2c_client *client = data->client; in volt_min_store()
933 int x = voltage_multiplier(data, attr->index); in volt_min_store()
934 long temp; in volt_min_store() local
936 if (kstrtol(buf, 10, &temp) || !x) in volt_min_store()
937 return -EINVAL; in volt_min_store()
939 temp = clamp_val(temp, 0, 255 * x / 1000); in volt_min_store()
940 temp *= 1000; /* convert mV to uV */ in volt_min_store()
941 temp = DIV_ROUND_CLOSEST(temp, x); in volt_min_store()
943 mutex_lock(&data->lock); in volt_min_store()
944 data->volt_min[attr->index] = temp; in volt_min_store()
946 ADT7462_REG_VOLT_MIN(data, attr->index), in volt_min_store()
947 temp); in volt_min_store()
948 mutex_unlock(&data->lock); in volt_min_store()
958 int x = voltage_multiplier(data, attr->index); in voltage_show()
960 x *= data->voltages[attr->index]; in voltage_show()
972 return sprintf(buf, "%s\n", voltage_label(data, attr->index)); in voltage_label_show()
980 int reg = attr->index >> ADT7462_ALARM_REG_SHIFT; in alarm_show()
981 int mask = attr->index & ADT7462_ALARM_FLAG_MASK; in alarm_show()
983 if (data->alarms[reg] & mask) in alarm_show()
991 return data->fan_enabled & (1 << fan); in fan_enabled()
999 u16 temp; in fan_min_show() local
1002 temp = data->fan_min[attr->index]; in fan_min_show()
1003 temp <<= 8; in fan_min_show()
1005 if (!fan_enabled(data, attr->index) || in fan_min_show()
1006 !FAN_DATA_VALID(temp)) in fan_min_show()
1009 return sprintf(buf, "%d\n", FAN_PERIOD_TO_RPM(temp)); in fan_min_show()
1018 struct i2c_client *client = data->client; in fan_min_store()
1019 long temp; in fan_min_store() local
1021 if (kstrtol(buf, 10, &temp) || !temp || in fan_min_store()
1022 !fan_enabled(data, attr->index)) in fan_min_store()
1023 return -EINVAL; in fan_min_store()
1025 temp = FAN_RPM_TO_PERIOD(temp); in fan_min_store()
1026 temp >>= 8; in fan_min_store()
1027 temp = clamp_val(temp, 1, 255); in fan_min_store()
1029 mutex_lock(&data->lock); in fan_min_store()
1030 data->fan_min[attr->index] = temp; in fan_min_store()
1031 i2c_smbus_write_byte_data(client, ADT7462_REG_FAN_MIN(attr->index), in fan_min_store()
1032 temp); in fan_min_store()
1033 mutex_unlock(&data->lock); in fan_min_store()
1044 if (!fan_enabled(data, attr->index) || in fan_show()
1045 !FAN_DATA_VALID(data->fan[attr->index])) in fan_show()
1049 FAN_PERIOD_TO_RPM(data->fan[attr->index])); in fan_show()
1056 return sprintf(buf, "%d\n", (data->cfg2 & ADT7462_FSPD_MASK ? 1 : 0)); in force_pwm_max_show()
1064 struct i2c_client *client = data->client; in force_pwm_max_store()
1065 long temp; in force_pwm_max_store() local
1068 if (kstrtol(buf, 10, &temp)) in force_pwm_max_store()
1069 return -EINVAL; in force_pwm_max_store()
1071 mutex_lock(&data->lock); in force_pwm_max_store()
1073 if (temp) in force_pwm_max_store()
1077 data->cfg2 = reg; in force_pwm_max_store()
1079 mutex_unlock(&data->lock); in force_pwm_max_store()
1089 return sprintf(buf, "%d\n", data->pwm[attr->index]); in pwm_show()
1097 struct i2c_client *client = data->client; in pwm_store()
1098 long temp; in pwm_store() local
1100 if (kstrtol(buf, 10, &temp)) in pwm_store()
1101 return -EINVAL; in pwm_store()
1103 temp = clamp_val(temp, 0, 255); in pwm_store()
1105 mutex_lock(&data->lock); in pwm_store()
1106 data->pwm[attr->index] = temp; in pwm_store()
1107 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM(attr->index), temp); in pwm_store()
1108 mutex_unlock(&data->lock); in pwm_store()
1117 return sprintf(buf, "%d\n", data->pwm_max); in pwm_max_show()
1125 struct i2c_client *client = data->client; in pwm_max_store()
1126 long temp; in pwm_max_store() local
1128 if (kstrtol(buf, 10, &temp)) in pwm_max_store()
1129 return -EINVAL; in pwm_max_store()
1131 temp = clamp_val(temp, 0, 255); in pwm_max_store()
1133 mutex_lock(&data->lock); in pwm_max_store()
1134 data->pwm_max = temp; in pwm_max_store()
1135 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_MAX, temp); in pwm_max_store()
1136 mutex_unlock(&data->lock); in pwm_max_store()
1146 return sprintf(buf, "%d\n", data->pwm_min[attr->index]); in pwm_min_show()
1155 struct i2c_client *client = data->client; in pwm_min_store()
1156 long temp; in pwm_min_store() local
1158 if (kstrtol(buf, 10, &temp)) in pwm_min_store()
1159 return -EINVAL; in pwm_min_store()
1161 temp = clamp_val(temp, 0, 255); in pwm_min_store()
1163 mutex_lock(&data->lock); in pwm_min_store()
1164 data->pwm_min[attr->index] = temp; in pwm_min_store()
1165 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_MIN(attr->index), in pwm_min_store()
1166 temp); in pwm_min_store()
1167 mutex_unlock(&data->lock); in pwm_min_store()
1178 (data->pwm_trange[attr->index] & ADT7462_PWM_HYST_MASK)); in pwm_hyst_show()
1187 struct i2c_client *client = data->client; in pwm_hyst_store()
1188 long temp; in pwm_hyst_store() local
1190 if (kstrtol(buf, 10, &temp)) in pwm_hyst_store()
1191 return -EINVAL; in pwm_hyst_store()
1193 temp = clamp_val(temp, 0, 15000); in pwm_hyst_store()
1194 temp = DIV_ROUND_CLOSEST(temp, 1000); in pwm_hyst_store()
1197 temp &= ADT7462_PWM_HYST_MASK; in pwm_hyst_store()
1198 temp |= data->pwm_trange[attr->index] & ADT7462_PWM_RANGE_MASK; in pwm_hyst_store()
1200 mutex_lock(&data->lock); in pwm_hyst_store()
1201 data->pwm_trange[attr->index] = temp; in pwm_hyst_store()
1202 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_TRANGE(attr->index), in pwm_hyst_store()
1203 temp); in pwm_hyst_store()
1204 mutex_unlock(&data->lock); in pwm_hyst_store()
1216 int trange = trange_values[data->pwm_trange[attr->index] >> in pwm_tmax_show()
1218 int tmin = (data->pwm_tmin[attr->index] - 64) * 1000; in pwm_tmax_show()
1227 int temp; in pwm_tmax_store() local
1230 struct i2c_client *client = data->client; in pwm_tmax_store()
1235 return -EINVAL; in pwm_tmax_store()
1237 /* trange = tmax - tmin */ in pwm_tmax_store()
1238 tmin = (data->pwm_tmin[attr->index] - 64) * 1000; in pwm_tmax_store()
1239 trange_value = find_trange_value(trange - tmin); in pwm_tmax_store()
1243 temp = trange_value << ADT7462_PWM_RANGE_SHIFT; in pwm_tmax_store()
1244 temp |= data->pwm_trange[attr->index] & ADT7462_PWM_HYST_MASK; in pwm_tmax_store()
1246 mutex_lock(&data->lock); in pwm_tmax_store()
1247 data->pwm_trange[attr->index] = temp; in pwm_tmax_store()
1248 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_TRANGE(attr->index), in pwm_tmax_store()
1249 temp); in pwm_tmax_store()
1250 mutex_unlock(&data->lock); in pwm_tmax_store()
1260 return sprintf(buf, "%d\n", 1000 * (data->pwm_tmin[attr->index] - 64)); in pwm_tmin_show()
1269 struct i2c_client *client = data->client; in pwm_tmin_store()
1270 long temp; in pwm_tmin_store() local
1272 if (kstrtol(buf, 10, &temp)) in pwm_tmin_store()
1273 return -EINVAL; in pwm_tmin_store()
1275 temp = clamp_val(temp, -64000, 191000); in pwm_tmin_store()
1276 temp = DIV_ROUND_CLOSEST(temp, 1000) + 64; in pwm_tmin_store()
1278 mutex_lock(&data->lock); in pwm_tmin_store()
1279 data->pwm_tmin[attr->index] = temp; in pwm_tmin_store()
1280 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_TMIN(attr->index), in pwm_tmin_store()
1281 temp); in pwm_tmin_store()
1282 mutex_unlock(&data->lock); in pwm_tmin_store()
1292 int cfg = data->pwm_cfg[attr->index] >> ADT7462_PWM_CHANNEL_SHIFT; in pwm_auto_show()
1309 int temp = data->pwm_cfg[which] & ~ADT7462_PWM_CHANNEL_MASK; in set_pwm_channel() local
1310 temp |= value << ADT7462_PWM_CHANNEL_SHIFT; in set_pwm_channel()
1312 mutex_lock(&data->lock); in set_pwm_channel()
1313 data->pwm_cfg[which] = temp; in set_pwm_channel()
1314 i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_CFG(which), temp); in set_pwm_channel()
1315 mutex_unlock(&data->lock); in set_pwm_channel()
1324 struct i2c_client *client = data->client; in pwm_auto_store()
1325 long temp; in pwm_auto_store() local
1327 if (kstrtol(buf, 10, &temp)) in pwm_auto_store()
1328 return -EINVAL; in pwm_auto_store()
1330 switch (temp) { in pwm_auto_store()
1332 set_pwm_channel(client, data, attr->index, 4); in pwm_auto_store()
1335 set_pwm_channel(client, data, attr->index, 7); in pwm_auto_store()
1338 return -EINVAL; in pwm_auto_store()
1347 int channel = data->pwm_cfg[attr->index] >> ADT7462_PWM_CHANNEL_SHIFT; in pwm_auto_temp_show()
1350 case 0: /* temp[1234] only */ in pwm_auto_temp_show()
1371 return -EINVAL; in cvt_auto_temp()
1381 struct i2c_client *client = data->client; in pwm_auto_temp_store()
1382 long temp; in pwm_auto_temp_store() local
1384 if (kstrtol(buf, 10, &temp)) in pwm_auto_temp_store()
1385 return -EINVAL; in pwm_auto_temp_store()
1387 temp = cvt_auto_temp(temp); in pwm_auto_temp_store()
1388 if (temp < 0) in pwm_auto_temp_store()
1389 return temp; in pwm_auto_temp_store()
1391 set_pwm_channel(client, data, attr->index, temp); in pwm_auto_temp_store()
1406 static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
1407 static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
1408 static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
1409 static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3);
1416 static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm,
1418 static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm,
1420 static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm,
1422 static SENSOR_DEVICE_ATTR_RO(temp4_alarm, alarm,
1481 static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm,
1483 static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm,
1485 static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm,
1487 static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm,
1489 static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm,
1491 static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm,
1493 static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm,
1495 static SENSOR_DEVICE_ATTR_RO(in8_alarm, alarm,
1497 static SENSOR_DEVICE_ATTR_RO(in9_alarm, alarm,
1499 static SENSOR_DEVICE_ATTR_RO(in10_alarm, alarm,
1501 static SENSOR_DEVICE_ATTR_RO(in11_alarm, alarm,
1503 static SENSOR_DEVICE_ATTR_RO(in12_alarm, alarm,
1505 static SENSOR_DEVICE_ATTR_RO(in13_alarm, alarm,
1526 static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm,
1528 static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm,
1530 static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm,
1532 static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm,
1534 static SENSOR_DEVICE_ATTR_RO(fan5_alarm, alarm,
1536 static SENSOR_DEVICE_ATTR_RO(fan6_alarm, alarm,
1538 static SENSOR_DEVICE_ATTR_RO(fan7_alarm, alarm,
1540 static SENSOR_DEVICE_ATTR_RO(fan8_alarm, alarm,
1763 /* Return 0 if detection is successful, -ENODEV otherwise */
1767 struct i2c_adapter *adapter = client->adapter; in adt7462_detect()
1771 return -ENODEV; in adt7462_detect()
1775 return -ENODEV; in adt7462_detect()
1779 return -ENODEV; in adt7462_detect()
1783 return -ENODEV; in adt7462_detect()
1785 strscpy(info->type, "adt7462", I2C_NAME_SIZE); in adt7462_detect()
1792 struct device *dev = &client->dev; in adt7462_probe()
1798 return -ENOMEM; in adt7462_probe()
1800 data->client = client; in adt7462_probe()
1801 mutex_init(&data->lock); in adt7462_probe()
1803 dev_info(&client->dev, "%s chip found\n", client->name); in adt7462_probe()
1805 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, in adt7462_probe()