Lines Matching +full:scaled +full:- +full:output +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * adm1026.c - Part of lm_sensors, Linux kernel modules for hardware
19 #include <linux/hwmon-sysfs.h>
20 #include <linux/hwmon-vid.h>
27 static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
28 -1, -1, -1, -1, -1, -1, -1, -1 };
29 static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
30 -1, -1, -1, -1, -1, -1, -1, -1 };
31 static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
32 -1, -1, -1, -1, -1, -1, -1, -1 };
33 static int gpio_normal[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
34 -1, -1, -1, -1, -1, -1, -1, -1 };
35 static int gpio_fan[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };
37 MODULE_PARM_DESC(gpio_input, "List of GPIO pins (0-16) to program as inputs");
40 "List of GPIO pins (0-16) to program as outputs");
43 "List of GPIO pins (0-16) to program as inverted");
46 "List of GPIO pins (0-16) to program as normal/non-inverted");
48 MODULE_PARM_DESC(gpio_fan, "List of GPIO pins (0-7) to program as fan tachs");
83 * 0 - 9 = AIN0 - AIN9
90 * 16 = -12V
110 * 0 - Internal
111 * 1 - External 1
112 * 2 - External 2
158 #define ADM1026_FAN_ACTIVATION_TEMP_HYST -6
169 * IN are scaled according to built-in resistors. These are the
171 * NOTE: The -12V input needs an additional factor to account
173 * NEG12_OFFSET = SCALE * Vref / V-192 - Vref
174 * = 13875 * 2.50 / 1.875 - 2500
194 * and we assume a 2 pulse-per-rev fan tach signal
200 #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : (val) == 0xff ? 0 : \
206 #define TEMP_TO_REG(val) DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), \
209 #define OFFSET_TO_REG(val) DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), \
220 * Analog output is a voltage, and scaled to millivolts. The datasheet
240 #define ADM1026_DATA_INTERVAL (1 * HZ)
241 #define ADM1026_CONFIG_INTERVAL (5 * 60 * HZ)
247 * at client->data. The adm1026_data structure is dynamically
322 struct i2c_client *client = data->client; in adm1026_update_device()
326 mutex_lock(&data->update_lock); in adm1026_update_device()
327 if (!data->valid in adm1026_update_device()
329 data->last_reading + ADM1026_DATA_INTERVAL)) { in adm1026_update_device()
331 dev_dbg(&client->dev, "Reading sensor values\n"); in adm1026_update_device()
333 data->in[i] = in adm1026_update_device()
338 data->fan[i] = in adm1026_update_device()
347 data->temp[i] = in adm1026_update_device()
351 data->pwm1.pwm = adm1026_read_value(client, in adm1026_update_device()
353 data->analog_out = adm1026_read_value(client, in adm1026_update_device()
365 data->alarms = alarms; in adm1026_update_device()
373 data->gpio = gpio; in adm1026_update_device()
375 data->last_reading = jiffies; in adm1026_update_device()
378 if (!data->valid || in adm1026_update_device()
379 time_after(jiffies, data->last_config + ADM1026_CONFIG_INTERVAL)) { in adm1026_update_device()
381 dev_dbg(&client->dev, "Reading config values\n"); in adm1026_update_device()
383 data->in_min[i] = adm1026_read_value(client, in adm1026_update_device()
385 data->in_max[i] = adm1026_read_value(client, in adm1026_update_device()
393 data->fan_min[i] = adm1026_read_value(client, in adm1026_update_device()
395 data->fan_div[i] = DIV_FROM_REG(value & 0x03); in adm1026_update_device()
404 data->temp_min[i] = adm1026_read_value(client, in adm1026_update_device()
406 data->temp_max[i] = adm1026_read_value(client, in adm1026_update_device()
408 data->temp_tmin[i] = adm1026_read_value(client, in adm1026_update_device()
410 data->temp_crit[i] = adm1026_read_value(client, in adm1026_update_device()
412 data->temp_offset[i] = adm1026_read_value(client, in adm1026_update_device()
425 data->alarm_mask = alarms; in adm1026_update_device()
432 data->gpio_mask = gpio; in adm1026_update_device()
435 data->config1 = adm1026_read_value(client, in adm1026_update_device()
437 if (data->config1 & CFG1_PWM_AFC) { in adm1026_update_device()
438 data->pwm1.enable = 2; in adm1026_update_device()
439 data->pwm1.auto_pwm_min = in adm1026_update_device()
440 PWM_MIN_FROM_REG(data->pwm1.pwm); in adm1026_update_device()
443 data->config2 = adm1026_read_value(client, in adm1026_update_device()
445 data->config3 = adm1026_read_value(client, in adm1026_update_device()
447 data->gpio_config[16] = (data->config3 >> 6) & 0x03; in adm1026_update_device()
455 data->gpio_config[i] = value & 0x03; in adm1026_update_device()
459 data->last_config = jiffies; in adm1026_update_device()
462 data->valid = true; in adm1026_update_device()
463 mutex_unlock(&data->update_lock); in adm1026_update_device()
471 int nr = sensor_attr->index; in in_show()
473 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in[nr])); in in_show()
479 int nr = sensor_attr->index; in in_min_show()
481 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); in in_min_show()
487 int nr = sensor_attr->index; in in_min_store()
489 struct i2c_client *client = data->client; in in_min_store()
497 mutex_lock(&data->update_lock); in in_min_store()
498 data->in_min[nr] = INS_TO_REG(nr, val); in in_min_store()
499 adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); in in_min_store()
500 mutex_unlock(&data->update_lock); in in_min_store()
507 int nr = sensor_attr->index; in in_max_show()
509 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); in in_max_show()
515 int nr = sensor_attr->index; in in_max_store()
517 struct i2c_client *client = data->client; in in_max_store()
525 mutex_lock(&data->update_lock); in in_max_store()
526 data->in_max[nr] = INS_TO_REG(nr, val); in in_max_store()
527 adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); in in_max_store()
528 mutex_unlock(&data->update_lock); in in_max_store()
585 return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in[16]) - in in16_show()
592 return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_min[16]) in in16_min_show()
593 - NEG12_OFFSET); in in16_min_show()
600 struct i2c_client *client = data->client; in in16_min_store()
608 mutex_lock(&data->update_lock); in in16_min_store()
609 data->in_min[16] = INS_TO_REG(16, in in16_min_store()
611 INT_MAX - NEG12_OFFSET) + in in16_min_store()
613 adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); in in16_min_store()
614 mutex_unlock(&data->update_lock); in in16_min_store()
621 return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_max[16]) in in16_max_show()
622 - NEG12_OFFSET); in in16_max_show()
629 struct i2c_client *client = data->client; in in16_max_store()
637 mutex_lock(&data->update_lock); in in16_max_store()
638 data->in_max[16] = INS_TO_REG(16, in in16_max_store()
640 INT_MAX - NEG12_OFFSET) + in in16_max_store()
642 adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); in in16_max_store()
643 mutex_unlock(&data->update_lock); in in16_max_store()
657 int nr = sensor_attr->index; in fan_show()
659 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], in fan_show()
660 data->fan_div[nr])); in fan_show()
666 int nr = sensor_attr->index; in fan_min_show()
668 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], in fan_min_show()
669 data->fan_div[nr])); in fan_min_show()
676 int nr = sensor_attr->index; in fan_min_store()
678 struct i2c_client *client = data->client; in fan_min_store()
686 mutex_lock(&data->update_lock); in fan_min_store()
687 data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); in fan_min_store()
689 data->fan_min[nr]); in fan_min_store()
690 mutex_unlock(&data->update_lock); in fan_min_store()
715 struct i2c_client *client = data->client; in fixup_fan_min()
717 int new_div = data->fan_div[fan]; in fixup_fan_min()
720 if (data->fan_min[fan] == 0 || data->fan_min[fan] == 0xff) in fixup_fan_min()
723 new_min = data->fan_min[fan] * old_div / new_div; in fixup_fan_min()
725 data->fan_min[fan] = new_min; in fixup_fan_min()
734 int nr = sensor_attr->index; in fan_div_show()
736 return sprintf(buf, "%d\n", data->fan_div[nr]); in fan_div_show()
743 int nr = sensor_attr->index; in fan_div_store()
745 struct i2c_client *client = data->client; in fan_div_store()
756 mutex_lock(&data->update_lock); in fan_div_store()
757 orig_div = data->fan_div[nr]; in fan_div_store()
758 data->fan_div[nr] = DIV_FROM_REG(new_div); in fan_div_store()
762 (DIV_TO_REG(data->fan_div[0]) << 0) | in fan_div_store()
763 (DIV_TO_REG(data->fan_div[1]) << 2) | in fan_div_store()
764 (DIV_TO_REG(data->fan_div[2]) << 4) | in fan_div_store()
765 (DIV_TO_REG(data->fan_div[3]) << 6)); in fan_div_store()
768 (DIV_TO_REG(data->fan_div[4]) << 0) | in fan_div_store()
769 (DIV_TO_REG(data->fan_div[5]) << 2) | in fan_div_store()
770 (DIV_TO_REG(data->fan_div[6]) << 4) | in fan_div_store()
771 (DIV_TO_REG(data->fan_div[7]) << 6)); in fan_div_store()
774 if (data->fan_div[nr] != orig_div) in fan_div_store()
777 mutex_unlock(&data->update_lock); in fan_div_store()
795 int nr = sensor_attr->index; in temp_show()
797 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); in temp_show()
803 int nr = sensor_attr->index; in temp_min_show()
805 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); in temp_min_show()
812 int nr = sensor_attr->index; in temp_min_store()
814 struct i2c_client *client = data->client; in temp_min_store()
822 mutex_lock(&data->update_lock); in temp_min_store()
823 data->temp_min[nr] = TEMP_TO_REG(val); in temp_min_store()
825 data->temp_min[nr]); in temp_min_store()
826 mutex_unlock(&data->update_lock); in temp_min_store()
833 int nr = sensor_attr->index; in temp_max_show()
835 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); in temp_max_show()
842 int nr = sensor_attr->index; in temp_max_store()
844 struct i2c_client *client = data->client; in temp_max_store()
852 mutex_lock(&data->update_lock); in temp_max_store()
853 data->temp_max[nr] = TEMP_TO_REG(val); in temp_max_store()
855 data->temp_max[nr]); in temp_max_store()
856 mutex_unlock(&data->update_lock); in temp_max_store()
874 int nr = sensor_attr->index; in temp_offset_show()
876 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_offset[nr])); in temp_offset_show()
883 int nr = sensor_attr->index; in temp_offset_store()
885 struct i2c_client *client = data->client; in temp_offset_store()
893 mutex_lock(&data->update_lock); in temp_offset_store()
894 data->temp_offset[nr] = TEMP_TO_REG(val); in temp_offset_store()
896 data->temp_offset[nr]); in temp_offset_store()
897 mutex_unlock(&data->update_lock); in temp_offset_store()
910 int nr = sensor_attr->index; in temp_auto_point1_temp_hyst_show()
913 ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); in temp_auto_point1_temp_hyst_show()
920 int nr = sensor_attr->index; in temp_auto_point2_temp_show()
922 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + in temp_auto_point2_temp_show()
930 int nr = sensor_attr->index; in temp_auto_point1_temp_show()
932 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); in temp_auto_point1_temp_show()
939 int nr = sensor_attr->index; in temp_auto_point1_temp_store()
941 struct i2c_client *client = data->client; in temp_auto_point1_temp_store()
949 mutex_lock(&data->update_lock); in temp_auto_point1_temp_store()
950 data->temp_tmin[nr] = TEMP_TO_REG(val); in temp_auto_point1_temp_store()
952 data->temp_tmin[nr]); in temp_auto_point1_temp_store()
953 mutex_unlock(&data->update_lock); in temp_auto_point1_temp_store()
974 return sprintf(buf, "%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); in show_temp_crit_enable()
980 struct i2c_client *client = data->client; in set_temp_crit_enable()
989 return -EINVAL; in set_temp_crit_enable()
991 mutex_lock(&data->update_lock); in set_temp_crit_enable()
992 data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); in set_temp_crit_enable()
993 adm1026_write_value(client, ADM1026_REG_CONFIG1, data->config1); in set_temp_crit_enable()
994 mutex_unlock(&data->update_lock); in set_temp_crit_enable()
1010 int nr = sensor_attr->index; in temp_crit_show()
1012 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr])); in temp_crit_show()
1019 int nr = sensor_attr->index; in temp_crit_store()
1021 struct i2c_client *client = data->client; in temp_crit_store()
1029 mutex_lock(&data->update_lock); in temp_crit_store()
1030 data->temp_crit[nr] = TEMP_TO_REG(val); in temp_crit_store()
1032 data->temp_crit[nr]); in temp_crit_store()
1033 mutex_unlock(&data->update_lock); in temp_crit_store()
1045 return sprintf(buf, "%d\n", DAC_FROM_REG(data->analog_out)); in analog_out_show()
1052 struct i2c_client *client = data->client; in analog_out_store()
1060 mutex_lock(&data->update_lock); in analog_out_store()
1061 data->analog_out = DAC_TO_REG(val); in analog_out_store()
1062 adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); in analog_out_store()
1063 mutex_unlock(&data->update_lock); in analog_out_store()
1073 int vid = (data->gpio >> 11) & 0x1f; in cpu0_vid_show()
1075 dev_dbg(dev, "Setting VID from GPIO11-15.\n"); in cpu0_vid_show()
1076 return sprintf(buf, "%d\n", vid_from_reg(vid, data->vrm)); in cpu0_vid_show()
1085 return sprintf(buf, "%d\n", data->vrm); in vrm_show()
1100 return -EINVAL; in vrm_store()
1102 data->vrm = val; in vrm_store()
1112 return sprintf(buf, "%ld\n", data->alarms); in alarms_show()
1121 int bitnr = to_sensor_dev_attr(attr)->index; in alarm_show()
1122 return sprintf(buf, "%ld\n", (data->alarms >> bitnr) & 1); in alarm_show()
1158 return sprintf(buf, "%ld\n", data->alarm_mask); in alarm_mask_show()
1165 struct i2c_client *client = data->client; in alarm_mask_store()
1174 mutex_lock(&data->update_lock); in alarm_mask_store()
1175 data->alarm_mask = val & 0x7fffffff; in alarm_mask_store()
1176 mask = data->alarm_mask in alarm_mask_store()
1177 | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); in alarm_mask_store()
1189 mutex_unlock(&data->update_lock); in alarm_mask_store()
1199 return sprintf(buf, "%ld\n", data->gpio); in gpio_show()
1205 struct i2c_client *client = data->client; in gpio_store()
1214 mutex_lock(&data->update_lock); in gpio_store()
1215 data->gpio = val & 0x1ffff; in gpio_store()
1216 gpio = data->gpio; in gpio_store()
1220 gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); in gpio_store()
1222 mutex_unlock(&data->update_lock); in gpio_store()
1233 return sprintf(buf, "%ld\n", data->gpio_mask); in gpio_mask_show()
1240 struct i2c_client *client = data->client; in gpio_mask_store()
1249 mutex_lock(&data->update_lock); in gpio_mask_store()
1250 data->gpio_mask = val & 0x1ffff; in gpio_mask_store()
1251 mask = data->gpio_mask; in gpio_mask_store()
1255 mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); in gpio_mask_store()
1257 mutex_unlock(&data->update_lock); in gpio_mask_store()
1267 return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm1.pwm)); in pwm1_show()
1274 struct i2c_client *client = data->client; in pwm1_store()
1276 if (data->pwm1.enable == 1) { in pwm1_store()
1284 mutex_lock(&data->update_lock); in pwm1_store()
1285 data->pwm1.pwm = PWM_TO_REG(val); in pwm1_store()
1286 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); in pwm1_store()
1287 mutex_unlock(&data->update_lock); in pwm1_store()
1297 return sprintf(buf, "%d\n", data->pwm1.auto_pwm_min); in temp1_auto_point1_pwm_show()
1305 struct i2c_client *client = data->client; in temp1_auto_point1_pwm_store()
1313 mutex_lock(&data->update_lock); in temp1_auto_point1_pwm_store()
1314 data->pwm1.auto_pwm_min = clamp_val(val, 0, 255); in temp1_auto_point1_pwm_store()
1315 if (data->pwm1.enable == 2) { /* apply immediately */ in temp1_auto_point1_pwm_store()
1316 data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | in temp1_auto_point1_pwm_store()
1317 PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); in temp1_auto_point1_pwm_store()
1318 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); in temp1_auto_point1_pwm_store()
1320 mutex_unlock(&data->update_lock); in temp1_auto_point1_pwm_store()
1335 return sprintf(buf, "%d\n", data->pwm1.enable); in pwm1_enable_show()
1343 struct i2c_client *client = data->client; in pwm1_enable_store()
1353 return -EINVAL; in pwm1_enable_store()
1355 mutex_lock(&data->update_lock); in pwm1_enable_store()
1356 old_enable = data->pwm1.enable; in pwm1_enable_store()
1357 data->pwm1.enable = val; in pwm1_enable_store()
1358 data->config1 = (data->config1 & ~CFG1_PWM_AFC) in pwm1_enable_store()
1360 adm1026_write_value(client, ADM1026_REG_CONFIG1, data->config1); in pwm1_enable_store()
1362 data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | in pwm1_enable_store()
1363 PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); in pwm1_enable_store()
1364 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); in pwm1_enable_store()
1367 data->pwm1.pwm = 255; in pwm1_enable_store()
1368 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); in pwm1_enable_store()
1370 mutex_unlock(&data->update_lock); in pwm1_enable_store()
1569 /* Return 0 if detection is successful, -ENODEV otherwise */
1573 struct i2c_adapter *adapter = client->adapter; in adm1026_detect()
1574 int address = client->addr; in adm1026_detect()
1579 return -ENODEV; in adm1026_detect()
1587 dev_dbg(&adapter->dev, in adm1026_detect()
1589 i2c_adapter_id(client->adapter), client->addr, in adm1026_detect()
1593 dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x...\n", in adm1026_detect()
1600 dev_err(&adapter->dev, in adm1026_detect()
1604 dev_err(&adapter->dev, in adm1026_detect()
1608 dev_dbg(&adapter->dev, "Autodetection failed\n"); in adm1026_detect()
1610 return -ENODEV; in adm1026_detect()
1613 strscpy(info->type, "adm1026", I2C_NAME_SIZE); in adm1026_detect()
1623 dev_dbg(&client->dev, "GPIO config is:\n"); in adm1026_print_gpio()
1625 if (data->config2 & (1 << i)) { in adm1026_print_gpio()
1626 dev_dbg(&client->dev, "\t%sGP%s%d\n", in adm1026_print_gpio()
1627 data->gpio_config[i] & 0x02 ? "" : "!", in adm1026_print_gpio()
1628 data->gpio_config[i] & 0x01 ? "OUT" : "IN", in adm1026_print_gpio()
1631 dev_dbg(&client->dev, "\tFAN%d\n", i); in adm1026_print_gpio()
1635 dev_dbg(&client->dev, "\t%sGP%s%d\n", in adm1026_print_gpio()
1636 data->gpio_config[i] & 0x02 ? "" : "!", in adm1026_print_gpio()
1637 data->gpio_config[i] & 0x01 ? "OUT" : "IN", in adm1026_print_gpio()
1640 if (data->config3 & CFG3_GPIO16_ENABLE) { in adm1026_print_gpio()
1641 dev_dbg(&client->dev, "\t%sGP%s16\n", in adm1026_print_gpio()
1642 data->gpio_config[16] & 0x02 ? "" : "!", in adm1026_print_gpio()
1643 data->gpio_config[16] & 0x01 ? "OUT" : "IN"); in adm1026_print_gpio()
1646 dev_dbg(&client->dev, "\tTHERM\n"); in adm1026_print_gpio()
1658 * We may need to unlock/stop monitoring or soft-reset the in adm1026_fixup_gpio()
1666 data->gpio_config[gpio_output[i]] |= 0x01; in adm1026_fixup_gpio()
1667 /* if GPIO0-7 is output, it isn't a FAN tach */ in adm1026_fixup_gpio()
1669 data->config2 |= 1 << gpio_output[i]; in adm1026_fixup_gpio()
1672 /* Input overrides output */ in adm1026_fixup_gpio()
1675 data->gpio_config[gpio_input[i]] &= ~0x01; in adm1026_fixup_gpio()
1676 /* if GPIO0-7 is input, it isn't a FAN tach */ in adm1026_fixup_gpio()
1678 data->config2 |= 1 << gpio_input[i]; in adm1026_fixup_gpio()
1684 data->gpio_config[gpio_inverted[i]] &= ~0x02; in adm1026_fixup_gpio()
1690 data->gpio_config[gpio_normal[i]] |= 0x02; in adm1026_fixup_gpio()
1693 /* Fan overrides input and output */ in adm1026_fixup_gpio()
1696 data->config2 &= ~(1 << gpio_fan[i]); in adm1026_fixup_gpio()
1700 adm1026_write_value(client, ADM1026_REG_CONFIG2, data->config2); in adm1026_fixup_gpio()
1701 data->config3 = (data->config3 & 0x3f) in adm1026_fixup_gpio()
1702 | ((data->gpio_config[16] & 0x03) << 6); in adm1026_fixup_gpio()
1703 adm1026_write_value(client, ADM1026_REG_CONFIG3, data->config3); in adm1026_fixup_gpio()
1704 for (i = 15, value = 0; i >= 0; --i) { in adm1026_fixup_gpio()
1706 value |= data->gpio_config[i] & 0x03; in adm1026_fixup_gpio()
1724 dev_dbg(&client->dev, "Initializing device\n"); in adm1026_init_client()
1726 data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1); in adm1026_init_client()
1727 data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2); in adm1026_init_client()
1728 data->config3 = adm1026_read_value(client, ADM1026_REG_CONFIG3); in adm1026_init_client()
1731 dev_dbg(&client->dev, "ADM1026_REG_CONFIG1 is: 0x%02x\n", in adm1026_init_client()
1732 data->config1); in adm1026_init_client()
1733 if ((data->config1 & CFG1_MONITOR) == 0) { in adm1026_init_client()
1734 dev_dbg(&client->dev, in adm1026_init_client()
1737 if (data->config1 & CFG1_INT_ENABLE) { in adm1026_init_client()
1738 dev_dbg(&client->dev, in adm1026_init_client()
1741 if (data->config1 & CFG1_AIN8_9) { in adm1026_init_client()
1742 dev_dbg(&client->dev, in adm1026_init_client()
1745 dev_dbg(&client->dev, in adm1026_init_client()
1748 if (data->config1 & CFG1_THERM_HOT) { in adm1026_init_client()
1749 dev_dbg(&client->dev, in adm1026_init_client()
1753 if (data->config3 & CFG3_GPIO16_ENABLE) { in adm1026_init_client()
1754 dev_dbg(&client->dev, in adm1026_init_client()
1757 dev_dbg(&client->dev, in adm1026_init_client()
1760 if (data->config3 & CFG3_VREF_250) in adm1026_init_client()
1761 dev_dbg(&client->dev, "Vref is 2.50 Volts.\n"); in adm1026_init_client()
1763 dev_dbg(&client->dev, "Vref is 1.82 Volts.\n"); in adm1026_init_client()
1771 data->gpio_config[i] = value & 0x03; in adm1026_init_client()
1774 data->gpio_config[16] = (data->config3 >> 6) & 0x03; in adm1026_init_client()
1783 if (gpio_input[0] != -1 || gpio_output[0] != -1 in adm1026_init_client()
1784 || gpio_inverted[0] != -1 || gpio_normal[0] != -1 in adm1026_init_client()
1785 || gpio_fan[0] != -1) { in adm1026_init_client()
1794 * control and will suffice until 'sensors -s' in adm1026_init_client()
1801 data->pwm1.auto_pwm_min = 255; in adm1026_init_client()
1806 dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value); in adm1026_init_client()
1807 data->config1 = value; in adm1026_init_client()
1814 data->fan_div[i] = DIV_FROM_REG(value & 0x03); in adm1026_init_client()
1821 struct device *dev = &client->dev; in adm1026_probe()
1827 return -ENOMEM; in adm1026_probe()
1830 data->client = client; in adm1026_probe()
1831 mutex_init(&data->update_lock); in adm1026_probe()
1834 data->vrm = vid_which_vrm(); in adm1026_probe()
1840 data->groups[0] = &adm1026_group; in adm1026_probe()
1841 if (data->config1 & CFG1_AIN8_9) in adm1026_probe()
1842 data->groups[1] = &adm1026_group_in8_9; in adm1026_probe()
1844 data->groups[1] = &adm1026_group_temp3; in adm1026_probe()
1846 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, in adm1026_probe()
1847 data, data->groups); in adm1026_probe()