Lines Matching +full:reg +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * nct6775 - Driver for the hardware monitoring functionality of
4 * Nuvoton NCT677x Super-I/O chips
6 * Copyright (C) 2012 Guenter Roeck <linux@roeck-us.net>
9 * Copyright (C) 2005-2012 Jean Delvare <jdelvare@suse.de>
14 * Copyright (C) 2010 Sheng-Yuan Huang (Nuvoton) (PS00)
36 * nct6796d-s 18 7 7 6+2 0xd801 0xc1 0x5ca3
37 * nct6799d-r 18 7 7 6+2 0xd802 0xc1 0x5ca3
50 #include <linux/hwmon-sysfs.h>
64 /* used to set data->name = nct6775_device_names[data->sio_kind] */
81 /* Common and NCT6775 specific data */
85 * min/max: 15-17 for NCT6799 only
105 0, 1, 2, 3, 8, 21, 20, 16, 17, -1, -1, -1, /* in0-in11 */
106 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
107 6, 7, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
108 4, 5, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
109 12, -1, /* intr0-intr1 */
115 0, 1, 2, 3, 8, 9, 10, 16, 17, -1, -1, -1, /* in0-in11 */
116 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
117 6, 7, 11, 28, -1, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
118 4, 5, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
119 12, -1, 21 /* intr0-intr1, beep_en */
192 #define NCT6775_AUTO_TEMP(data, nr, p) ((data)->REG_AUTO_TEMP[nr] + (p)) argument
193 #define NCT6775_AUTO_PWM(data, nr, p) ((data)->REG_AUTO_PWM[nr] + (p)) argument
207 "AMD SB-TSI",
248 /* NCT6776 specific data */
255 0, 1, 2, 3, 8, 21, 20, 16, 17, -1, -1, -1, /* in0-in11 */
256 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
257 6, 7, 11, 10, 23, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
258 4, 5, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
259 12, 9, /* intr0-intr1 */
266 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1, -1, /* in0-in11 */
267 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
268 25, 26, 27, 28, 29, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
269 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
270 30, 31, 24 /* intr0-intr1, beep_en */
333 /* NCT6779 specific data */
336 * 15-17 for NCT6799 only, register labels are:
350 0, 1, 2, 3, 8, 21, 20, 16, 17, 24, 25, 26, /* in0-in11 */
351 27, 28, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
352 6, 7, 11, 10, 23, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
353 4, 5, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
354 12, 9, /* intr0-intr1 */
358 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, /* in0-in11 */
359 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
360 25, 26, 27, 28, 29, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
361 16, 17, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
362 30, 31, 24 /* intr0-intr1, beep_en */
439 /* NCT6791 specific data */
452 0, 1, 2, 3, 8, 21, 20, 16, 17, 24, 25, 26, /* in0-in11 */
453 27, 28, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
454 6, 7, 11, 10, 23, 33, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
455 4, 5, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
456 12, 9, /* intr0-intr1 */
459 /* NCT6792/NCT6793 specific data */
684 0, 1, 2, 3, 8, -1, 20, 16, 17, 24, 25, 26, /* in0-in11 */
685 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
686 6, 7, 11, 10, 23, 33, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
687 4, 5, 40, 41, 42, 43, 44, -1, -1, -1, -1, -1, /* temp1-temp12 */
688 12, 9, /* intr0-intr1 */
692 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, /* in0-in11 */
693 12, 13, 14, 15, 34, 35, -1, -1, -1, -1, -1, -1, /* in12-in23 */
694 25, 26, 27, 28, 29, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
695 16, 17, 18, 19, 20, 21, 22, 23, -1, -1, -1, -1, /* temp1-temp12 */
696 30, 31, 24 /* intr0-intr1, beep_en */
699 /* PECI Calibration only for NCT6799D, not NCT6796D-S */
738 /* NCT6102D/NCT6106D specific data */
808 0, 1, 2, 3, 4, 5, 7, 8, 9, -1, -1, -1, /* in0-in11 */
809 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
810 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
811 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
812 48, -1, /* intr0-intr1 */
819 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, /* in0-in11 */
820 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
821 24, 25, 26, 27, 28, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
822 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
823 34, -1, 32 /* intr0-intr1, beep_en */
839 /* NCT6112D/NCT6114D/NCT6116D specific data */
884 0, 1, 2, 3, 4, 5, 7, 8, 9, -1, -1, -1, /* in0-in11 */
885 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
886 32, 33, 34, 35, 36, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
887 16, 17, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
888 48, -1, /* intr0-intr1 */
892 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, /* in0-in11 */
893 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* in12-in23 */
894 24, 25, 26, 27, 28, -1, -1, -1, -1, -1, -1, -1, /* fan1-fan12 */
895 16, 17, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* temp1-temp12 */
896 34, -1, 32 /* intr0-intr1, beep_en */
912 return mode - 1; in pwm_enable_to_reg()
920 static unsigned int step_time_from_reg(u8 reg, u8 mode) in step_time_from_reg() argument
922 return mode ? 400 * reg : 100 * reg; in step_time_from_reg()
931 static unsigned int fan_from_reg8(u16 reg, unsigned int divreg) in fan_from_reg8() argument
933 if (reg == 0 || reg == 255) in fan_from_reg8()
935 return 1350000U / (reg << divreg); in fan_from_reg8()
938 static unsigned int fan_from_reg13(u16 reg, unsigned int divreg) in fan_from_reg13() argument
940 if ((reg & 0xff1f) == 0xff1f) in fan_from_reg13()
943 reg = (reg & 0x1f) | ((reg & 0xff00) >> 3); in fan_from_reg13()
945 if (reg == 0) in fan_from_reg13()
948 return 1350000U / reg; in fan_from_reg13()
951 static unsigned int fan_from_reg16(u16 reg, unsigned int divreg) in fan_from_reg16() argument
953 if (reg == 0 || reg == 0xffff) in fan_from_reg16()
960 return 1350000U / (reg << divreg); in fan_from_reg16()
963 static unsigned int fan_from_reg_rpm(u16 reg, unsigned int divreg) in fan_from_reg_rpm() argument
965 return reg; in fan_from_reg_rpm()
977 div_from_reg(u8 reg) in div_from_reg() argument
979 return BIT(reg); in div_from_reg()
995 * 15-17 for NCT6799 only
1002 static inline long in_from_reg(u8 reg, u8 nr, const u16 *scales) in in_from_reg() argument
1004 return DIV_ROUND_CLOSEST(reg * scales[nr], 100); in in_from_reg()
1013 static inline unsigned int tsi_temp_from_reg(unsigned int reg) in tsi_temp_from_reg() argument
1015 return (reg >> 5) * 125; in tsi_temp_from_reg()
1019 * Data structures and manipulation thereof
1077 static int nct6775_add_template_attr_group(struct device *dev, struct nct6775_data *data, in nct6775_add_template_attr_group() argument
1089 return -EINVAL; in nct6775_add_template_attr_group()
1091 t = tg->templates; in nct6775_add_template_attr_group()
1096 return -EINVAL; in nct6775_add_template_attr_group()
1100 return -ENOMEM; in nct6775_add_template_attr_group()
1105 return -ENOMEM; in nct6775_add_template_attr_group()
1110 return -ENOMEM; in nct6775_add_template_attr_group()
1112 group->attrs = attrs; in nct6775_add_template_attr_group()
1113 group->is_visible = tg->is_visible; in nct6775_add_template_attr_group()
1116 t = tg->templates; in nct6775_add_template_attr_group()
1118 snprintf(su->name, sizeof(su->name), in nct6775_add_template_attr_group()
1119 (*t)->dev_attr.attr.name, tg->base + i); in nct6775_add_template_attr_group()
1120 if ((*t)->s2) { in nct6775_add_template_attr_group()
1121 a2 = &su->u.a2; in nct6775_add_template_attr_group()
1122 sysfs_attr_init(&a2->dev_attr.attr); in nct6775_add_template_attr_group()
1123 a2->dev_attr.attr.name = su->name; in nct6775_add_template_attr_group()
1124 a2->nr = (*t)->u.s.nr + i; in nct6775_add_template_attr_group()
1125 a2->index = (*t)->u.s.index; in nct6775_add_template_attr_group()
1126 a2->dev_attr.attr.mode = in nct6775_add_template_attr_group()
1127 (*t)->dev_attr.attr.mode; in nct6775_add_template_attr_group()
1128 a2->dev_attr.show = (*t)->dev_attr.show; in nct6775_add_template_attr_group()
1129 a2->dev_attr.store = (*t)->dev_attr.store; in nct6775_add_template_attr_group()
1130 *attrs = &a2->dev_attr.attr; in nct6775_add_template_attr_group()
1132 a = &su->u.a1; in nct6775_add_template_attr_group()
1133 sysfs_attr_init(&a->dev_attr.attr); in nct6775_add_template_attr_group()
1134 a->dev_attr.attr.name = su->name; in nct6775_add_template_attr_group()
1135 a->index = (*t)->u.index + i; in nct6775_add_template_attr_group()
1136 a->dev_attr.attr.mode = in nct6775_add_template_attr_group()
1137 (*t)->dev_attr.attr.mode; in nct6775_add_template_attr_group()
1138 a->dev_attr.show = (*t)->dev_attr.show; in nct6775_add_template_attr_group()
1139 a->dev_attr.store = (*t)->dev_attr.store; in nct6775_add_template_attr_group()
1140 *attrs = &a->dev_attr.attr; in nct6775_add_template_attr_group()
1148 return nct6775_add_attr_group(data, group); in nct6775_add_template_attr_group()
1151 bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg) in nct6775_reg_is_word_sized() argument
1153 switch (data->kind) { in nct6775_reg_is_word_sized()
1155 return reg == 0x20 || reg == 0x22 || reg == 0x24 || in nct6775_reg_is_word_sized()
1156 (reg >= 0x59 && reg < 0x69 && (reg & 1)) || in nct6775_reg_is_word_sized()
1157 reg == 0xe0 || reg == 0xe2 || reg == 0xe4 || in nct6775_reg_is_word_sized()
1158 reg == 0x111 || reg == 0x121 || reg == 0x131; in nct6775_reg_is_word_sized()
1160 return reg == 0x20 || reg == 0x22 || reg == 0x24 || in nct6775_reg_is_word_sized()
1161 reg == 0x26 || reg == 0x28 || reg == 0x59 || reg == 0x5b || in nct6775_reg_is_word_sized()
1162 reg == 0xe0 || reg == 0xe2 || reg == 0xe4 || reg == 0xe6 || in nct6775_reg_is_word_sized()
1163 reg == 0xe8 || reg == 0x111 || reg == 0x121 || reg == 0x131 || in nct6775_reg_is_word_sized()
1164 reg == 0x191 || reg == 0x1a1; in nct6775_reg_is_word_sized()
1166 return (((reg & 0xff00) == 0x100 || in nct6775_reg_is_word_sized()
1167 (reg & 0xff00) == 0x200) && in nct6775_reg_is_word_sized()
1168 ((reg & 0x00ff) == 0x50 || in nct6775_reg_is_word_sized()
1169 (reg & 0x00ff) == 0x53 || in nct6775_reg_is_word_sized()
1170 (reg & 0x00ff) == 0x55)) || in nct6775_reg_is_word_sized()
1171 (reg & 0xfff0) == 0x630 || in nct6775_reg_is_word_sized()
1172 reg == 0x640 || reg == 0x642 || in nct6775_reg_is_word_sized()
1173 reg == 0x662 || reg == 0x669 || in nct6775_reg_is_word_sized()
1174 ((reg & 0xfff0) == 0x650 && (reg & 0x000f) >= 0x06) || in nct6775_reg_is_word_sized()
1175 reg == 0x73 || reg == 0x75 || reg == 0x77; in nct6775_reg_is_word_sized()
1177 return (((reg & 0xff00) == 0x100 || in nct6775_reg_is_word_sized()
1178 (reg & 0xff00) == 0x200) && in nct6775_reg_is_word_sized()
1179 ((reg & 0x00ff) == 0x50 || in nct6775_reg_is_word_sized()
1180 (reg & 0x00ff) == 0x53 || in nct6775_reg_is_word_sized()
1181 (reg & 0x00ff) == 0x55)) || in nct6775_reg_is_word_sized()
1182 (reg & 0xfff0) == 0x630 || in nct6775_reg_is_word_sized()
1183 reg == 0x402 || in nct6775_reg_is_word_sized()
1184 (reg >= 0x409 && reg < 0x419 && (reg & 1)) || in nct6775_reg_is_word_sized()
1185 reg == 0x640 || reg == 0x642 || in nct6775_reg_is_word_sized()
1186 ((reg & 0xfff0) == 0x650 && (reg & 0x000f) >= 0x06) || in nct6775_reg_is_word_sized()
1187 reg == 0x73 || reg == 0x75 || reg == 0x77; in nct6775_reg_is_word_sized()
1197 return reg == 0x150 || reg == 0x153 || reg == 0x155 || in nct6775_reg_is_word_sized()
1198 (reg & 0xfff0) == 0x4c0 || in nct6775_reg_is_word_sized()
1199 reg == 0x402 || in nct6775_reg_is_word_sized()
1200 (reg >= 0x409 && reg < 0x419 && (reg & 1)) || in nct6775_reg_is_word_sized()
1201 reg == 0x63a || reg == 0x63c || reg == 0x63e || in nct6775_reg_is_word_sized()
1202 reg == 0x640 || reg == 0x642 || reg == 0x64a || in nct6775_reg_is_word_sized()
1203 reg == 0x64c || in nct6775_reg_is_word_sized()
1204 reg == 0x73 || reg == 0x75 || reg == 0x77 || reg == 0x79 || in nct6775_reg_is_word_sized()
1205 reg == 0x7b || reg == 0x7d; in nct6775_reg_is_word_sized()
1211 /* We left-align 8-bit temperature values to make the code simpler */
1212 static int nct6775_read_temp(struct nct6775_data *data, u16 reg, u16 *val) in nct6775_read_temp() argument
1216 err = nct6775_read_value(data, reg, val); in nct6775_read_temp()
1220 if (!nct6775_reg_is_word_sized(data, reg)) in nct6775_read_temp()
1226 /* This function assumes that the caller holds data->update_lock */
1227 static int nct6775_write_fan_div(struct nct6775_data *data, int nr) in nct6775_write_fan_div() argument
1229 u16 reg; in nct6775_write_fan_div() local
1234 err = nct6775_read_value(data, fandiv_reg, ®); in nct6775_write_fan_div()
1237 reg &= 0x70 >> oddshift; in nct6775_write_fan_div()
1238 reg |= (data->fan_div[nr] & 0x7) << oddshift; in nct6775_write_fan_div()
1239 return nct6775_write_value(data, fandiv_reg, reg); in nct6775_write_fan_div()
1242 static int nct6775_write_fan_div_common(struct nct6775_data *data, int nr) in nct6775_write_fan_div_common() argument
1244 if (data->kind == nct6775) in nct6775_write_fan_div_common()
1245 return nct6775_write_fan_div(data, nr); in nct6775_write_fan_div_common()
1249 static int nct6775_update_fan_div(struct nct6775_data *data) in nct6775_update_fan_div() argument
1254 err = nct6775_read_value(data, NCT6775_REG_FANDIV1, &i); in nct6775_update_fan_div()
1257 data->fan_div[0] = i & 0x7; in nct6775_update_fan_div()
1258 data->fan_div[1] = (i & 0x70) >> 4; in nct6775_update_fan_div()
1259 err = nct6775_read_value(data, NCT6775_REG_FANDIV2, &i); in nct6775_update_fan_div()
1262 data->fan_div[2] = i & 0x7; in nct6775_update_fan_div()
1263 if (data->has_fan & BIT(3)) in nct6775_update_fan_div()
1264 data->fan_div[3] = (i & 0x70) >> 4; in nct6775_update_fan_div()
1269 static int nct6775_update_fan_div_common(struct nct6775_data *data) in nct6775_update_fan_div_common() argument
1271 if (data->kind == nct6775) in nct6775_update_fan_div_common()
1272 return nct6775_update_fan_div(data); in nct6775_update_fan_div_common()
1276 static int nct6775_init_fan_div(struct nct6775_data *data) in nct6775_init_fan_div() argument
1280 err = nct6775_update_fan_div_common(data); in nct6775_init_fan_div()
1290 for (i = 0; i < ARRAY_SIZE(data->fan_div); i++) { in nct6775_init_fan_div()
1291 if (!(data->has_fan & BIT(i))) in nct6775_init_fan_div()
1293 if (data->fan_div[i] == 0) { in nct6775_init_fan_div()
1294 data->fan_div[i] = 7; in nct6775_init_fan_div()
1295 err = nct6775_write_fan_div_common(data, i); in nct6775_init_fan_div()
1305 struct nct6775_data *data) in nct6775_init_fan_common() argument
1308 u16 reg; in nct6775_init_fan_common() local
1310 if (data->has_fan_div) { in nct6775_init_fan_common()
1311 err = nct6775_init_fan_div(data); in nct6775_init_fan_common()
1320 for (i = 0; i < ARRAY_SIZE(data->fan_min); i++) { in nct6775_init_fan_common()
1321 if (data->has_fan_min & BIT(i)) { in nct6775_init_fan_common()
1322 err = nct6775_read_value(data, data->REG_FAN_MIN[i], ®); in nct6775_init_fan_common()
1325 if (!reg) { in nct6775_init_fan_common()
1326 err = nct6775_write_value(data, data->REG_FAN_MIN[i], in nct6775_init_fan_common()
1327 data->has_fan_div ? 0xff : 0xff1f); in nct6775_init_fan_common()
1338 struct nct6775_data *data, int nr, u16 reg) in nct6775_select_fan_div() argument
1341 u8 fan_div = data->fan_div[nr]; in nct6775_select_fan_div()
1344 if (!data->has_fan_div) in nct6775_select_fan_div()
1352 if (reg == 0x00 && fan_div < 0x07) in nct6775_select_fan_div()
1354 else if (reg != 0x00 && reg < 0x30 && fan_div > 0) in nct6775_select_fan_div()
1355 fan_div--; in nct6775_select_fan_div()
1357 if (fan_div != data->fan_div[nr]) { in nct6775_select_fan_div()
1359 nr + 1, div_from_reg(data->fan_div[nr]), in nct6775_select_fan_div()
1363 if (data->has_fan_min & BIT(nr)) { in nct6775_select_fan_div()
1364 fan_min = data->fan_min[nr]; in nct6775_select_fan_div()
1365 if (fan_div > data->fan_div[nr]) { in nct6775_select_fan_div()
1375 if (fan_min != data->fan_min[nr]) { in nct6775_select_fan_div()
1376 data->fan_min[nr] = fan_min; in nct6775_select_fan_div()
1377 err = nct6775_write_value(data, data->REG_FAN_MIN[nr], fan_min); in nct6775_select_fan_div()
1382 data->fan_div[nr] = fan_div; in nct6775_select_fan_div()
1383 err = nct6775_write_fan_div_common(data, nr); in nct6775_select_fan_div()
1393 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_update_pwm() local
1395 u16 fanmodecfg, reg; in nct6775_update_pwm() local
1398 for (i = 0; i < data->pwm_num; i++) { in nct6775_update_pwm()
1399 if (!(data->has_pwm & BIT(i))) in nct6775_update_pwm()
1402 err = nct6775_read_value(data, data->REG_PWM_MODE[i], ®); in nct6775_update_pwm()
1405 duty_is_dc = data->REG_PWM_MODE[i] && (reg & data->PWM_MODE_MASK[i]); in nct6775_update_pwm()
1406 data->pwm_mode[i] = !duty_is_dc; in nct6775_update_pwm()
1408 err = nct6775_read_value(data, data->REG_FAN_MODE[i], &fanmodecfg); in nct6775_update_pwm()
1411 for (j = 0; j < ARRAY_SIZE(data->REG_PWM); j++) { in nct6775_update_pwm()
1412 if (data->REG_PWM[j] && data->REG_PWM[j][i]) { in nct6775_update_pwm()
1413 err = nct6775_read_value(data, data->REG_PWM[j][i], ®); in nct6775_update_pwm()
1416 data->pwm[j][i] = reg; in nct6775_update_pwm()
1420 data->pwm_enable[i] = reg_to_pwm_enable(data->pwm[0][i], in nct6775_update_pwm()
1423 if (!data->temp_tolerance[0][i] || in nct6775_update_pwm()
1424 data->pwm_enable[i] != speed_cruise) in nct6775_update_pwm()
1425 data->temp_tolerance[0][i] = fanmodecfg & 0x0f; in nct6775_update_pwm()
1426 if (!data->target_speed_tolerance[i] || in nct6775_update_pwm()
1427 data->pwm_enable[i] == speed_cruise) { in nct6775_update_pwm()
1430 if (data->REG_TOLERANCE_H) { in nct6775_update_pwm()
1431 err = nct6775_read_value(data, data->REG_TOLERANCE_H[i], ®); in nct6775_update_pwm()
1434 t |= (reg & 0x70) >> 1; in nct6775_update_pwm()
1436 data->target_speed_tolerance[i] = t; in nct6775_update_pwm()
1439 err = nct6775_read_value(data, data->REG_CRITICAL_TEMP_TOLERANCE[i], ®); in nct6775_update_pwm()
1442 data->temp_tolerance[1][i] = reg; in nct6775_update_pwm()
1444 err = nct6775_read_value(data, data->REG_TEMP_SEL[i], ®); in nct6775_update_pwm()
1447 data->pwm_temp_sel[i] = reg & 0x1f; in nct6775_update_pwm()
1449 if (reg & 0x80) in nct6775_update_pwm()
1450 data->pwm[2][i] = 0; in nct6775_update_pwm()
1452 if (!data->REG_WEIGHT_TEMP_SEL[i]) in nct6775_update_pwm()
1455 err = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[i], ®); in nct6775_update_pwm()
1458 data->pwm_weight_temp_sel[i] = reg & 0x1f; in nct6775_update_pwm()
1460 if (!(reg & 0x80)) in nct6775_update_pwm()
1461 data->pwm_weight_temp_sel[i] = 0; in nct6775_update_pwm()
1463 /* Weight temp data */ in nct6775_update_pwm()
1464 for (j = 0; j < ARRAY_SIZE(data->weight_temp); j++) { in nct6775_update_pwm()
1465 err = nct6775_read_value(data, data->REG_WEIGHT_TEMP[j][i], ®); in nct6775_update_pwm()
1468 data->weight_temp[j][i] = reg; in nct6775_update_pwm()
1477 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_update_pwm_limits() local
1479 u16 reg, reg_t; in nct6775_update_pwm_limits() local
1481 for (i = 0; i < data->pwm_num; i++) { in nct6775_update_pwm_limits()
1482 if (!(data->has_pwm & BIT(i))) in nct6775_update_pwm_limits()
1485 for (j = 0; j < ARRAY_SIZE(data->fan_time); j++) { in nct6775_update_pwm_limits()
1486 err = nct6775_read_value(data, data->REG_FAN_TIME[j][i], ®); in nct6775_update_pwm_limits()
1489 data->fan_time[j][i] = reg; in nct6775_update_pwm_limits()
1492 err = nct6775_read_value(data, data->REG_TARGET[i], ®_t); in nct6775_update_pwm_limits()
1497 if (!data->target_temp[i] || in nct6775_update_pwm_limits()
1498 data->pwm_enable[i] == thermal_cruise) in nct6775_update_pwm_limits()
1499 data->target_temp[i] = reg_t & data->target_temp_mask; in nct6775_update_pwm_limits()
1500 if (!data->target_speed[i] || in nct6775_update_pwm_limits()
1501 data->pwm_enable[i] == speed_cruise) { in nct6775_update_pwm_limits()
1502 if (data->REG_TOLERANCE_H) { in nct6775_update_pwm_limits()
1503 err = nct6775_read_value(data, data->REG_TOLERANCE_H[i], ®); in nct6775_update_pwm_limits()
1506 reg_t |= (reg & 0x0f) << 8; in nct6775_update_pwm_limits()
1508 data->target_speed[i] = reg_t; in nct6775_update_pwm_limits()
1511 for (j = 0; j < data->auto_pwm_num; j++) { in nct6775_update_pwm_limits()
1512 err = nct6775_read_value(data, NCT6775_AUTO_PWM(data, i, j), ®); in nct6775_update_pwm_limits()
1515 data->auto_pwm[i][j] = reg; in nct6775_update_pwm_limits()
1517 err = nct6775_read_value(data, NCT6775_AUTO_TEMP(data, i, j), ®); in nct6775_update_pwm_limits()
1520 data->auto_temp[i][j] = reg; in nct6775_update_pwm_limits()
1523 /* critical auto_pwm temperature data */ in nct6775_update_pwm_limits()
1524 err = nct6775_read_value(data, data->REG_CRITICAL_TEMP[i], ®); in nct6775_update_pwm_limits()
1527 data->auto_temp[i][data->auto_pwm_num] = reg; in nct6775_update_pwm_limits()
1529 switch (data->kind) { in nct6775_update_pwm_limits()
1531 err = nct6775_read_value(data, NCT6775_REG_CRITICAL_ENAB[i], ®); in nct6775_update_pwm_limits()
1534 data->auto_pwm[i][data->auto_pwm_num] = in nct6775_update_pwm_limits()
1535 (reg & 0x02) ? 0xff : 0x00; in nct6775_update_pwm_limits()
1538 data->auto_pwm[i][data->auto_pwm_num] = 0xff; in nct6775_update_pwm_limits()
1551 err = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[i], ®); in nct6775_update_pwm_limits()
1554 if (reg & data->CRITICAL_PWM_ENABLE_MASK) { in nct6775_update_pwm_limits()
1555 err = nct6775_read_value(data, data->REG_CRITICAL_PWM[i], ®); in nct6775_update_pwm_limits()
1559 reg = 0xff; in nct6775_update_pwm_limits()
1561 data->auto_pwm[i][data->auto_pwm_num] = reg; in nct6775_update_pwm_limits()
1571 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_update_device() local
1573 u16 reg; in nct6775_update_device() local
1575 mutex_lock(&data->update_lock); in nct6775_update_device()
1577 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) in nct6775_update_device()
1578 || !data->valid) { in nct6775_update_device()
1580 err = nct6775_update_fan_div_common(data); in nct6775_update_device()
1585 for (i = 0; i < data->in_num; i++) { in nct6775_update_device()
1586 if (!(data->have_in & BIT(i))) in nct6775_update_device()
1589 err = nct6775_read_value(data, data->REG_VIN[i], ®); in nct6775_update_device()
1592 data->in[i][0] = reg; in nct6775_update_device()
1594 err = nct6775_read_value(data, data->REG_IN_MINMAX[0][i], ®); in nct6775_update_device()
1597 data->in[i][1] = reg; in nct6775_update_device()
1599 err = nct6775_read_value(data, data->REG_IN_MINMAX[1][i], ®); in nct6775_update_device()
1602 data->in[i][2] = reg; in nct6775_update_device()
1606 for (i = 0; i < ARRAY_SIZE(data->rpm); i++) { in nct6775_update_device()
1607 if (!(data->has_fan & BIT(i))) in nct6775_update_device()
1610 err = nct6775_read_value(data, data->REG_FAN[i], ®); in nct6775_update_device()
1613 data->rpm[i] = data->fan_from_reg(reg, in nct6775_update_device()
1614 data->fan_div[i]); in nct6775_update_device()
1616 if (data->has_fan_min & BIT(i)) { in nct6775_update_device()
1619 err = nct6775_read_value(data, data->REG_FAN_MIN[i], &tmp); in nct6775_update_device()
1622 data->fan_min[i] = tmp; in nct6775_update_device()
1625 if (data->REG_FAN_PULSES[i]) { in nct6775_update_device()
1628 err = nct6775_read_value(data, data->REG_FAN_PULSES[i], &tmp); in nct6775_update_device()
1631 data->fan_pulses[i] = (tmp >> data->FAN_PULSE_SHIFT[i]) & 0x03; in nct6775_update_device()
1634 err = nct6775_select_fan_div(dev, data, i, reg); in nct6775_update_device()
1649 if (!(data->have_temp & BIT(i))) in nct6775_update_device()
1651 for (j = 0; j < ARRAY_SIZE(data->reg_temp); j++) { in nct6775_update_device()
1652 if (data->reg_temp[j][i]) { in nct6775_update_device()
1653 err = nct6775_read_temp(data, data->reg_temp[j][i], ®); in nct6775_update_device()
1656 data->temp[j][i] = reg; in nct6775_update_device()
1660 !(data->have_temp_fixed & BIT(i))) in nct6775_update_device()
1662 err = nct6775_read_value(data, data->REG_TEMP_OFFSET[i], ®); in nct6775_update_device()
1665 data->temp_offset[i] = reg; in nct6775_update_device()
1669 if (!(data->have_tsi_temp & BIT(i))) in nct6775_update_device()
1671 err = nct6775_read_value(data, data->REG_TSI_TEMP[i], ®); in nct6775_update_device()
1674 data->tsi_temp[i] = reg; in nct6775_update_device()
1677 data->alarms = 0; in nct6775_update_device()
1681 if (!data->REG_ALARM[i]) in nct6775_update_device()
1683 err = nct6775_read_value(data, data->REG_ALARM[i], &alarm); in nct6775_update_device()
1686 data->alarms |= ((u64)alarm) << (i << 3); in nct6775_update_device()
1689 data->beeps = 0; in nct6775_update_device()
1693 if (!data->REG_BEEP[i]) in nct6775_update_device()
1695 err = nct6775_read_value(data, data->REG_BEEP[i], &beep); in nct6775_update_device()
1698 data->beeps |= ((u64)beep) << (i << 3); in nct6775_update_device()
1701 data->last_updated = jiffies; in nct6775_update_device()
1702 data->valid = true; in nct6775_update_device()
1705 mutex_unlock(&data->update_lock); in nct6775_update_device()
1706 return err ? ERR_PTR(err) : data; in nct6775_update_device()
1716 struct nct6775_data *data = nct6775_update_device(dev); in show_in_reg() local
1718 int index = sattr->index; in show_in_reg()
1719 int nr = sattr->nr; in show_in_reg()
1721 if (IS_ERR(data)) in show_in_reg()
1722 return PTR_ERR(data); in show_in_reg()
1725 in_from_reg(data->in[nr][index], nr, data->scale_in)); in show_in_reg()
1732 struct nct6775_data *data = dev_get_drvdata(dev); in store_in_reg() local
1734 int index = sattr->index; in store_in_reg()
1735 int nr = sattr->nr; in store_in_reg()
1742 mutex_lock(&data->update_lock); in store_in_reg()
1743 data->in[nr][index] = in_to_reg(val, nr, data->scale_in); in store_in_reg()
1744 err = nct6775_write_value(data, data->REG_IN_MINMAX[index - 1][nr], data->in[nr][index]); in store_in_reg()
1745 mutex_unlock(&data->update_lock); in store_in_reg()
1752 struct nct6775_data *data = nct6775_update_device(dev); in nct6775_show_alarm() local
1756 if (IS_ERR(data)) in nct6775_show_alarm()
1757 return PTR_ERR(data); in nct6775_show_alarm()
1759 nr = data->ALARM_BITS[sattr->index]; in nct6775_show_alarm()
1761 (unsigned int)((data->alarms >> nr) & 0x01)); in nct6775_show_alarm()
1765 static int find_temp_source(struct nct6775_data *data, int index, int count) in find_temp_source() argument
1767 int source = data->temp_src[index]; in find_temp_source()
1773 err = nct6775_read_value(data, data->REG_TEMP_SOURCE[nr], &src); in find_temp_source()
1779 return -ENODEV; in find_temp_source()
1786 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_alarm() local
1790 if (IS_ERR(data)) in show_temp_alarm()
1791 return PTR_ERR(data); in show_temp_alarm()
1797 nr = find_temp_source(data, sattr->index, data->num_temp_alarms); in show_temp_alarm()
1799 int bit = data->ALARM_BITS[nr + TEMP_ALARM_BASE]; in show_temp_alarm()
1801 alarm = (data->alarms >> bit) & 0x01; in show_temp_alarm()
1810 struct nct6775_data *data = nct6775_update_device(dev); in nct6775_show_beep() local
1813 if (IS_ERR(data)) in nct6775_show_beep()
1814 return PTR_ERR(data); in nct6775_show_beep()
1816 nr = data->BEEP_BITS[sattr->index]; in nct6775_show_beep()
1819 (unsigned int)((data->beeps >> nr) & 0x01)); in nct6775_show_beep()
1827 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_store_beep() local
1828 int nr = data->BEEP_BITS[sattr->index]; in nct6775_store_beep()
1837 return -EINVAL; in nct6775_store_beep()
1839 mutex_lock(&data->update_lock); in nct6775_store_beep()
1841 data->beeps |= (1ULL << nr); in nct6775_store_beep()
1843 data->beeps &= ~(1ULL << nr); in nct6775_store_beep()
1844 err = nct6775_write_value(data, data->REG_BEEP[regindex], in nct6775_store_beep()
1845 (data->beeps >> (regindex << 3)) & 0xff); in nct6775_store_beep()
1846 mutex_unlock(&data->update_lock); in nct6775_store_beep()
1855 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_beep() local
1859 if (IS_ERR(data)) in show_temp_beep()
1860 return PTR_ERR(data); in show_temp_beep()
1867 nr = find_temp_source(data, sattr->index, data->num_temp_beeps); in show_temp_beep()
1869 int bit = data->BEEP_BITS[nr + TEMP_ALARM_BASE]; in show_temp_beep()
1871 beep = (data->beeps >> bit) & 0x01; in show_temp_beep()
1881 struct nct6775_data *data = dev_get_drvdata(dev); in store_temp_beep() local
1890 return -EINVAL; in store_temp_beep()
1892 nr = find_temp_source(data, sattr->index, data->num_temp_beeps); in store_temp_beep()
1896 bit = data->BEEP_BITS[nr + TEMP_ALARM_BASE]; in store_temp_beep()
1899 mutex_lock(&data->update_lock); in store_temp_beep()
1901 data->beeps |= (1ULL << bit); in store_temp_beep()
1903 data->beeps &= ~(1ULL << bit); in store_temp_beep()
1904 err = nct6775_write_value(data, data->REG_BEEP[regindex], in store_temp_beep()
1905 (data->beeps >> (regindex << 3)) & 0xff); in store_temp_beep()
1906 mutex_unlock(&data->update_lock); in store_temp_beep()
1915 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_in_is_visible() local
1919 if (nr == 1 && data->ALARM_BITS[in] == -1) in nct6775_in_is_visible()
1922 if (!(data->have_in & BIT(in))) in nct6775_in_is_visible()
1925 return nct6775_attr_mode(data, attr); in nct6775_in_is_visible()
1956 struct nct6775_data *data = nct6775_update_device(dev); in show_fan() local
1958 int nr = sattr->index; in show_fan()
1960 if (IS_ERR(data)) in show_fan()
1961 return PTR_ERR(data); in show_fan()
1963 return sprintf(buf, "%d\n", data->rpm[nr]); in show_fan()
1969 struct nct6775_data *data = nct6775_update_device(dev); in show_fan_min() local
1971 int nr = sattr->index; in show_fan_min()
1973 if (IS_ERR(data)) in show_fan_min()
1974 return PTR_ERR(data); in show_fan_min()
1977 data->fan_from_reg_min(data->fan_min[nr], in show_fan_min()
1978 data->fan_div[nr])); in show_fan_min()
1984 struct nct6775_data *data = nct6775_update_device(dev); in show_fan_div() local
1986 int nr = sattr->index; in show_fan_div()
1988 if (IS_ERR(data)) in show_fan_div()
1989 return PTR_ERR(data); in show_fan_div()
1991 return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr])); in show_fan_div()
1998 struct nct6775_data *data = dev_get_drvdata(dev); in store_fan_min() local
2000 int nr = sattr->index; in store_fan_min()
2002 unsigned int reg; in store_fan_min() local
2010 mutex_lock(&data->update_lock); in store_fan_min()
2011 if (!data->has_fan_div) { in store_fan_min()
2021 data->fan_min[nr] = val; in store_fan_min()
2026 data->fan_min[nr] = 255; in store_fan_min()
2027 new_div = data->fan_div[nr]; /* No change */ in store_fan_min()
2031 reg = 1350000U / val; in store_fan_min()
2032 if (reg >= 128 * 255) { in store_fan_min()
2037 data->fan_min[nr] = 254; in store_fan_min()
2041 nr + 1, val, data->fan_from_reg_min(254, 7)); in store_fan_min()
2042 } else if (!reg) { in store_fan_min()
2047 data->fan_min[nr] = 1; in store_fan_min()
2051 nr + 1, val, data->fan_from_reg_min(1, 0)); in store_fan_min()
2059 while (reg > 192 && new_div < 7) { in store_fan_min()
2060 reg >>= 1; in store_fan_min()
2063 data->fan_min[nr] = reg; in store_fan_min()
2071 if (new_div != data->fan_div[nr]) { in store_fan_min()
2073 nr + 1, div_from_reg(data->fan_div[nr]), in store_fan_min()
2075 data->fan_div[nr] = new_div; in store_fan_min()
2076 err = nct6775_write_fan_div_common(data, nr); in store_fan_min()
2080 data->last_updated = jiffies; in store_fan_min()
2084 err = nct6775_write_value(data, data->REG_FAN_MIN[nr], data->fan_min[nr]); in store_fan_min()
2085 mutex_unlock(&data->update_lock); in store_fan_min()
2093 struct nct6775_data *data = nct6775_update_device(dev); in show_fan_pulses() local
2097 if (IS_ERR(data)) in show_fan_pulses()
2098 return PTR_ERR(data); in show_fan_pulses()
2100 p = data->fan_pulses[sattr->index]; in show_fan_pulses()
2108 struct nct6775_data *data = dev_get_drvdata(dev); in store_fan_pulses() local
2110 int nr = sattr->index; in store_fan_pulses()
2113 u16 reg; in store_fan_pulses() local
2120 return -EINVAL; in store_fan_pulses()
2122 mutex_lock(&data->update_lock); in store_fan_pulses()
2123 data->fan_pulses[nr] = val & 3; in store_fan_pulses()
2124 err = nct6775_read_value(data, data->REG_FAN_PULSES[nr], ®); in store_fan_pulses()
2127 reg &= ~(0x03 << data->FAN_PULSE_SHIFT[nr]); in store_fan_pulses()
2128 reg |= (val & 3) << data->FAN_PULSE_SHIFT[nr]; in store_fan_pulses()
2129 err = nct6775_write_value(data, data->REG_FAN_PULSES[nr], reg); in store_fan_pulses()
2131 mutex_unlock(&data->update_lock); in store_fan_pulses()
2140 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_fan_is_visible() local
2144 if (!(data->has_fan & BIT(fan))) in nct6775_fan_is_visible()
2147 if (nr == 1 && data->ALARM_BITS[FAN_ALARM_BASE + fan] == -1) in nct6775_fan_is_visible()
2149 if (nr == 2 && data->BEEP_BITS[FAN_ALARM_BASE + fan] == -1) in nct6775_fan_is_visible()
2151 if (nr == 3 && !data->REG_FAN_PULSES[fan]) in nct6775_fan_is_visible()
2153 if (nr == 4 && !(data->has_fan_min & BIT(fan))) in nct6775_fan_is_visible()
2155 if (nr == 5 && data->kind != nct6775) in nct6775_fan_is_visible()
2158 return nct6775_attr_mode(data, attr); in nct6775_fan_is_visible()
2193 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_label() local
2195 int nr = sattr->index; in show_temp_label()
2197 if (IS_ERR(data)) in show_temp_label()
2198 return PTR_ERR(data); in show_temp_label()
2200 return sprintf(buf, "%s\n", data->temp_label[data->temp_src[nr]]); in show_temp_label()
2206 struct nct6775_data *data = nct6775_update_device(dev); in show_temp() local
2208 int nr = sattr->nr; in show_temp()
2209 int index = sattr->index; in show_temp()
2211 if (IS_ERR(data)) in show_temp()
2212 return PTR_ERR(data); in show_temp()
2214 return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->temp[index][nr])); in show_temp()
2221 struct nct6775_data *data = dev_get_drvdata(dev); in store_temp() local
2223 int nr = sattr->nr; in store_temp()
2224 int index = sattr->index; in store_temp()
2232 mutex_lock(&data->update_lock); in store_temp()
2233 data->temp[index][nr] = LM75_TEMP_TO_REG(val); in store_temp()
2234 err = nct6775_write_temp(data, data->reg_temp[index][nr], data->temp[index][nr]); in store_temp()
2235 mutex_unlock(&data->update_lock); in store_temp()
2242 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_offset() local
2245 if (IS_ERR(data)) in show_temp_offset()
2246 return PTR_ERR(data); in show_temp_offset()
2248 return sprintf(buf, "%d\n", data->temp_offset[sattr->index] * 1000); in show_temp_offset()
2255 struct nct6775_data *data = dev_get_drvdata(dev); in store_temp_offset() local
2257 int nr = sattr->index; in store_temp_offset()
2265 val = DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), 1000); in store_temp_offset()
2267 mutex_lock(&data->update_lock); in store_temp_offset()
2268 data->temp_offset[nr] = val; in store_temp_offset()
2269 err = nct6775_write_value(data, data->REG_TEMP_OFFSET[nr], val); in store_temp_offset()
2270 mutex_unlock(&data->update_lock); in store_temp_offset()
2278 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_type() local
2280 int nr = sattr->index; in show_temp_type()
2282 if (IS_ERR(data)) in show_temp_type()
2283 return PTR_ERR(data); in show_temp_type()
2285 return sprintf(buf, "%d\n", (int)data->temp_type[nr]); in show_temp_type()
2292 struct nct6775_data *data = nct6775_update_device(dev); in store_temp_type() local
2294 int nr = sattr->index; in store_temp_type()
2300 if (IS_ERR(data)) in store_temp_type()
2301 return PTR_ERR(data); in store_temp_type()
2308 return -EINVAL; in store_temp_type()
2310 mutex_lock(&data->update_lock); in store_temp_type()
2312 data->temp_type[nr] = val; in store_temp_type()
2314 dbit = data->DIODE_MASK << nr; in store_temp_type()
2316 err = nct6775_read_value(data, data->REG_VBAT, &vbat); in store_temp_type()
2321 err = nct6775_read_value(data, data->REG_DIODE, &diode); in store_temp_type()
2337 err = nct6775_write_value(data, data->REG_VBAT, vbat); in store_temp_type()
2340 err = nct6775_write_value(data, data->REG_DIODE, diode); in store_temp_type()
2342 mutex_unlock(&data->update_lock); in store_temp_type()
2350 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_temp_is_visible() local
2354 if (!(data->have_temp & BIT(temp))) in nct6775_temp_is_visible()
2357 if (nr == 1 && !data->temp_label) in nct6775_temp_is_visible()
2360 if (nr == 2 && find_temp_source(data, temp, data->num_temp_alarms) < 0) in nct6775_temp_is_visible()
2363 if (nr == 3 && find_temp_source(data, temp, data->num_temp_beeps) < 0) in nct6775_temp_is_visible()
2366 if (nr == 4 && !data->reg_temp[1][temp]) /* max */ in nct6775_temp_is_visible()
2369 if (nr == 5 && !data->reg_temp[2][temp]) /* max_hyst */ in nct6775_temp_is_visible()
2372 if (nr == 6 && !data->reg_temp[3][temp]) /* crit */ in nct6775_temp_is_visible()
2375 if (nr == 7 && !data->reg_temp[4][temp]) /* lcrit */ in nct6775_temp_is_visible()
2379 if (nr > 7 && !(data->have_temp_fixed & BIT(temp))) in nct6775_temp_is_visible()
2382 return nct6775_attr_mode(data, attr); in nct6775_temp_is_visible()
2423 struct nct6775_data *data = nct6775_update_device(dev); in show_tsi_temp() local
2426 if (IS_ERR(data)) in show_tsi_temp()
2427 return PTR_ERR(data); in show_tsi_temp()
2429 return sysfs_emit(buf, "%u\n", tsi_temp_from_reg(data->tsi_temp[sattr->index])); in show_tsi_temp()
2436 return sysfs_emit(buf, "TSI%d_TEMP\n", sattr->index); in show_tsi_temp_label()
2446 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_tsi_temp_is_visible() local
2449 return (data->have_tsi_temp & BIT(temp)) ? nct6775_attr_mode(data, attr) : 0; in nct6775_tsi_temp_is_visible()
2465 struct nct6775_data *data = nct6775_update_device(dev); in show_pwm_mode() local
2468 if (IS_ERR(data)) in show_pwm_mode()
2469 return PTR_ERR(data); in show_pwm_mode()
2471 return sprintf(buf, "%d\n", data->pwm_mode[sattr->index]); in show_pwm_mode()
2478 struct nct6775_data *data = dev_get_drvdata(dev); in store_pwm_mode() local
2480 int nr = sattr->index; in store_pwm_mode()
2483 u16 reg; in store_pwm_mode() local
2490 return -EINVAL; in store_pwm_mode()
2493 if (data->REG_PWM_MODE[nr] == 0) { in store_pwm_mode()
2495 return -EINVAL; in store_pwm_mode()
2499 mutex_lock(&data->update_lock); in store_pwm_mode()
2500 data->pwm_mode[nr] = val; in store_pwm_mode()
2501 err = nct6775_read_value(data, data->REG_PWM_MODE[nr], ®); in store_pwm_mode()
2504 reg &= ~data->PWM_MODE_MASK[nr]; in store_pwm_mode()
2506 reg |= data->PWM_MODE_MASK[nr]; in store_pwm_mode()
2507 err = nct6775_write_value(data, data->REG_PWM_MODE[nr], reg); in store_pwm_mode()
2509 mutex_unlock(&data->update_lock); in store_pwm_mode()
2516 struct nct6775_data *data = nct6775_update_device(dev); in show_pwm() local
2518 int nr = sattr->nr; in show_pwm()
2519 int index = sattr->index; in show_pwm()
2523 if (IS_ERR(data)) in show_pwm()
2524 return PTR_ERR(data); in show_pwm()
2530 if (index == 0 && data->pwm_enable[nr] > manual) { in show_pwm()
2531 err = nct6775_read_value(data, data->REG_PWM_READ[nr], &pwm); in show_pwm()
2535 pwm = data->pwm[index][nr]; in show_pwm()
2545 struct nct6775_data *data = dev_get_drvdata(dev); in store_pwm() local
2547 int nr = sattr->nr; in store_pwm()
2548 int index = sattr->index; in store_pwm()
2550 int minval[7] = { 0, 1, 1, data->pwm[2][nr], 0, 0, 0 }; in store_pwm()
2552 = { 255, 255, data->pwm[3][nr] ? : 255, 255, 255, 255, 255 }; in store_pwm()
2554 u16 reg; in store_pwm() local
2560 if (index == 0 && data->pwm_enable[nr] > manual) in store_pwm()
2561 return -EBUSY; in store_pwm()
2568 mutex_lock(&data->update_lock); in store_pwm()
2569 data->pwm[index][nr] = val; in store_pwm()
2570 err = nct6775_write_value(data, data->REG_PWM[index][nr], val); in store_pwm()
2574 err = nct6775_read_value(data, data->REG_TEMP_SEL[nr], ®); in store_pwm()
2577 reg &= 0x7f; in store_pwm()
2579 reg |= 0x80; in store_pwm()
2580 err = nct6775_write_value(data, data->REG_TEMP_SEL[nr], reg); in store_pwm()
2583 mutex_unlock(&data->update_lock); in store_pwm()
2587 /* Returns 0 if OK, -EINVAL otherwise */
2588 static int check_trip_points(struct nct6775_data *data, int nr) in check_trip_points() argument
2592 for (i = 0; i < data->auto_pwm_num - 1; i++) { in check_trip_points()
2593 if (data->auto_temp[nr][i] > data->auto_temp[nr][i + 1]) in check_trip_points()
2594 return -EINVAL; in check_trip_points()
2596 for (i = 0; i < data->auto_pwm_num - 1; i++) { in check_trip_points()
2597 if (data->auto_pwm[nr][i] > data->auto_pwm[nr][i + 1]) in check_trip_points()
2598 return -EINVAL; in check_trip_points()
2601 if (data->auto_pwm[nr][data->auto_pwm_num]) { in check_trip_points()
2602 if (data->auto_temp[nr][data->auto_pwm_num - 1] > in check_trip_points()
2603 data->auto_temp[nr][data->auto_pwm_num] || in check_trip_points()
2604 data->auto_pwm[nr][data->auto_pwm_num - 1] > in check_trip_points()
2605 data->auto_pwm[nr][data->auto_pwm_num]) in check_trip_points()
2606 return -EINVAL; in check_trip_points()
2611 static int pwm_update_registers(struct nct6775_data *data, int nr) in pwm_update_registers() argument
2613 u16 reg; in pwm_update_registers() local
2616 switch (data->pwm_enable[nr]) { in pwm_update_registers()
2621 err = nct6775_read_value(data, data->REG_FAN_MODE[nr], ®); in pwm_update_registers()
2624 reg = (reg & ~data->tolerance_mask) | in pwm_update_registers()
2625 (data->target_speed_tolerance[nr] & data->tolerance_mask); in pwm_update_registers()
2626 err = nct6775_write_value(data, data->REG_FAN_MODE[nr], reg); in pwm_update_registers()
2629 err = nct6775_write_value(data, data->REG_TARGET[nr], in pwm_update_registers()
2630 data->target_speed[nr] & 0xff); in pwm_update_registers()
2633 if (data->REG_TOLERANCE_H) { in pwm_update_registers()
2634 reg = (data->target_speed[nr] >> 8) & 0x0f; in pwm_update_registers()
2635 reg |= (data->target_speed_tolerance[nr] & 0x38) << 1; in pwm_update_registers()
2636 err = nct6775_write_value(data, data->REG_TOLERANCE_H[nr], reg); in pwm_update_registers()
2642 err = nct6775_write_value(data, data->REG_TARGET[nr], data->target_temp[nr]); in pwm_update_registers()
2647 err = nct6775_read_value(data, data->REG_FAN_MODE[nr], ®); in pwm_update_registers()
2650 reg = (reg & ~data->tolerance_mask) | in pwm_update_registers()
2651 data->temp_tolerance[0][nr]; in pwm_update_registers()
2652 err = nct6775_write_value(data, data->REG_FAN_MODE[nr], reg); in pwm_update_registers()
2664 struct nct6775_data *data = nct6775_update_device(dev); in show_pwm_enable() local
2667 if (IS_ERR(data)) in show_pwm_enable()
2668 return PTR_ERR(data); in show_pwm_enable()
2670 return sprintf(buf, "%d\n", data->pwm_enable[sattr->index]); in show_pwm_enable()
2677 struct nct6775_data *data = dev_get_drvdata(dev); in store_pwm_enable() local
2679 int nr = sattr->index; in store_pwm_enable()
2682 u16 reg; in store_pwm_enable() local
2689 return -EINVAL; in store_pwm_enable()
2691 if (val == sf3 && data->kind != nct6775) in store_pwm_enable()
2692 return -EINVAL; in store_pwm_enable()
2694 if (val == sf4 && check_trip_points(data, nr)) { in store_pwm_enable()
2697 return -EINVAL; in store_pwm_enable()
2700 mutex_lock(&data->update_lock); in store_pwm_enable()
2701 data->pwm_enable[nr] = val; in store_pwm_enable()
2706 data->pwm[0][nr] = 255; in store_pwm_enable()
2707 err = nct6775_write_value(data, data->REG_PWM[0][nr], 255); in store_pwm_enable()
2711 err = pwm_update_registers(data, nr); in store_pwm_enable()
2714 err = nct6775_read_value(data, data->REG_FAN_MODE[nr], ®); in store_pwm_enable()
2717 reg &= 0x0f; in store_pwm_enable()
2718 reg |= pwm_enable_to_reg(val) << 4; in store_pwm_enable()
2719 err = nct6775_write_value(data, data->REG_FAN_MODE[nr], reg); in store_pwm_enable()
2721 mutex_unlock(&data->update_lock); in store_pwm_enable()
2726 show_pwm_temp_sel_common(struct nct6775_data *data, char *buf, int src) in show_pwm_temp_sel_common() argument
2731 if (!(data->have_temp & BIT(i))) in show_pwm_temp_sel_common()
2733 if (src == data->temp_src[i]) { in show_pwm_temp_sel_common()
2745 struct nct6775_data *data = nct6775_update_device(dev); in show_pwm_temp_sel() local
2747 int index = sattr->index; in show_pwm_temp_sel()
2749 if (IS_ERR(data)) in show_pwm_temp_sel()
2750 return PTR_ERR(data); in show_pwm_temp_sel()
2752 return show_pwm_temp_sel_common(data, buf, data->pwm_temp_sel[index]); in show_pwm_temp_sel()
2759 struct nct6775_data *data = nct6775_update_device(dev); in store_pwm_temp_sel() local
2761 int nr = sattr->index; in store_pwm_temp_sel()
2764 u16 reg; in store_pwm_temp_sel() local
2766 if (IS_ERR(data)) in store_pwm_temp_sel()
2767 return PTR_ERR(data); in store_pwm_temp_sel()
2773 return -EINVAL; in store_pwm_temp_sel()
2774 if (!(data->have_temp & BIT(val - 1)) || !data->temp_src[val - 1]) in store_pwm_temp_sel()
2775 return -EINVAL; in store_pwm_temp_sel()
2777 mutex_lock(&data->update_lock); in store_pwm_temp_sel()
2778 src = data->temp_src[val - 1]; in store_pwm_temp_sel()
2779 data->pwm_temp_sel[nr] = src; in store_pwm_temp_sel()
2780 err = nct6775_read_value(data, data->REG_TEMP_SEL[nr], ®); in store_pwm_temp_sel()
2783 reg &= 0xe0; in store_pwm_temp_sel()
2784 reg |= src; in store_pwm_temp_sel()
2785 err = nct6775_write_value(data, data->REG_TEMP_SEL[nr], reg); in store_pwm_temp_sel()
2787 mutex_unlock(&data->update_lock); in store_pwm_temp_sel()
2796 struct nct6775_data *data = nct6775_update_device(dev); in show_pwm_weight_temp_sel() local
2798 int index = sattr->index; in show_pwm_weight_temp_sel()
2800 if (IS_ERR(data)) in show_pwm_weight_temp_sel()
2801 return PTR_ERR(data); in show_pwm_weight_temp_sel()
2803 return show_pwm_temp_sel_common(data, buf, in show_pwm_weight_temp_sel()
2804 data->pwm_weight_temp_sel[index]); in show_pwm_weight_temp_sel()
2811 struct nct6775_data *data = nct6775_update_device(dev); in store_pwm_weight_temp_sel() local
2813 int nr = sattr->index; in store_pwm_weight_temp_sel()
2816 u16 reg; in store_pwm_weight_temp_sel() local
2818 if (IS_ERR(data)) in store_pwm_weight_temp_sel()
2819 return PTR_ERR(data); in store_pwm_weight_temp_sel()
2825 return -EINVAL; in store_pwm_weight_temp_sel()
2827 if (val && (!(data->have_temp & BIT(val - 1)) || in store_pwm_weight_temp_sel()
2828 !data->temp_src[val - 1])) in store_pwm_weight_temp_sel()
2829 return -EINVAL; in store_pwm_weight_temp_sel()
2831 mutex_lock(&data->update_lock); in store_pwm_weight_temp_sel()
2833 src = data->temp_src[val - 1]; in store_pwm_weight_temp_sel()
2834 data->pwm_weight_temp_sel[nr] = src; in store_pwm_weight_temp_sel()
2835 err = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[nr], ®); in store_pwm_weight_temp_sel()
2838 reg &= 0xe0; in store_pwm_weight_temp_sel()
2839 reg |= (src | 0x80); in store_pwm_weight_temp_sel()
2840 err = nct6775_write_value(data, data->REG_WEIGHT_TEMP_SEL[nr], reg); in store_pwm_weight_temp_sel()
2842 data->pwm_weight_temp_sel[nr] = 0; in store_pwm_weight_temp_sel()
2843 err = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[nr], ®); in store_pwm_weight_temp_sel()
2846 reg &= 0x7f; in store_pwm_weight_temp_sel()
2847 err = nct6775_write_value(data, data->REG_WEIGHT_TEMP_SEL[nr], reg); in store_pwm_weight_temp_sel()
2850 mutex_unlock(&data->update_lock); in store_pwm_weight_temp_sel()
2858 struct nct6775_data *data = nct6775_update_device(dev); in show_target_temp() local
2861 if (IS_ERR(data)) in show_target_temp()
2862 return PTR_ERR(data); in show_target_temp()
2864 return sprintf(buf, "%d\n", data->target_temp[sattr->index] * 1000); in show_target_temp()
2871 struct nct6775_data *data = dev_get_drvdata(dev); in store_target_temp() local
2873 int nr = sattr->index; in store_target_temp()
2881 val = DIV_ROUND_CLOSEST(clamp_val(val, 0, data->target_temp_mask * 1000), 1000); in store_target_temp()
2883 mutex_lock(&data->update_lock); in store_target_temp()
2884 data->target_temp[nr] = val; in store_target_temp()
2885 err = pwm_update_registers(data, nr); in store_target_temp()
2886 mutex_unlock(&data->update_lock); in store_target_temp()
2893 struct nct6775_data *data = nct6775_update_device(dev); in show_target_speed() local
2895 int nr = sattr->index; in show_target_speed()
2897 if (IS_ERR(data)) in show_target_speed()
2898 return PTR_ERR(data); in show_target_speed()
2901 fan_from_reg16(data->target_speed[nr], in show_target_speed()
2902 data->fan_div[nr])); in show_target_speed()
2909 struct nct6775_data *data = dev_get_drvdata(dev); in store_target_speed() local
2911 int nr = sattr->index; in store_target_speed()
2921 speed = fan_to_reg(val, data->fan_div[nr]); in store_target_speed()
2923 mutex_lock(&data->update_lock); in store_target_speed()
2924 data->target_speed[nr] = speed; in store_target_speed()
2925 err = pwm_update_registers(data, nr); in store_target_speed()
2926 mutex_unlock(&data->update_lock); in store_target_speed()
2934 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_tolerance() local
2936 int nr = sattr->nr; in show_temp_tolerance()
2937 int index = sattr->index; in show_temp_tolerance()
2939 if (IS_ERR(data)) in show_temp_tolerance()
2940 return PTR_ERR(data); in show_temp_tolerance()
2942 return sprintf(buf, "%d\n", data->temp_tolerance[index][nr] * 1000); in show_temp_tolerance()
2949 struct nct6775_data *data = dev_get_drvdata(dev); in store_temp_tolerance() local
2951 int nr = sattr->nr; in store_temp_tolerance()
2952 int index = sattr->index; in store_temp_tolerance()
2961 val = DIV_ROUND_CLOSEST(clamp_val(val, 0, data->tolerance_mask * 1000), 1000); in store_temp_tolerance()
2963 mutex_lock(&data->update_lock); in store_temp_tolerance()
2964 data->temp_tolerance[index][nr] = val; in store_temp_tolerance()
2966 err = pwm_update_registers(data, nr); in store_temp_tolerance()
2968 err = nct6775_write_value(data, data->REG_CRITICAL_TEMP_TOLERANCE[nr], val); in store_temp_tolerance()
2969 mutex_unlock(&data->update_lock); in store_temp_tolerance()
2984 struct nct6775_data *data = nct6775_update_device(dev); in show_speed_tolerance() local
2986 int nr = sattr->index; in show_speed_tolerance()
2989 if (IS_ERR(data)) in show_speed_tolerance()
2990 return PTR_ERR(data); in show_speed_tolerance()
2992 target = data->target_speed[nr]; in show_speed_tolerance()
2995 int low = target - data->target_speed_tolerance[nr]; in show_speed_tolerance()
2996 int high = target + data->target_speed_tolerance[nr]; in show_speed_tolerance()
3005 tolerance = (fan_from_reg16(low, data->fan_div[nr]) in show_speed_tolerance()
3006 - fan_from_reg16(high, data->fan_div[nr])) / 2; in show_speed_tolerance()
3016 struct nct6775_data *data = dev_get_drvdata(dev); in store_speed_tolerance() local
3018 int nr = sattr->index; in store_speed_tolerance()
3027 high = fan_from_reg16(data->target_speed[nr], data->fan_div[nr]) + val; in store_speed_tolerance()
3028 low = fan_from_reg16(data->target_speed[nr], data->fan_div[nr]) - val; in store_speed_tolerance()
3034 val = (fan_to_reg(low, data->fan_div[nr]) - in store_speed_tolerance()
3035 fan_to_reg(high, data->fan_div[nr])) / 2; in store_speed_tolerance()
3038 val = clamp_val(val, 0, data->speed_tolerance_limit); in store_speed_tolerance()
3040 mutex_lock(&data->update_lock); in store_speed_tolerance()
3041 data->target_speed_tolerance[nr] = val; in store_speed_tolerance()
3042 err = pwm_update_registers(data, nr); in store_speed_tolerance()
3043 mutex_unlock(&data->update_lock); in store_speed_tolerance()
3061 struct nct6775_data *data = nct6775_update_device(dev); in show_weight_temp() local
3063 int nr = sattr->nr; in show_weight_temp()
3064 int index = sattr->index; in show_weight_temp()
3066 if (IS_ERR(data)) in show_weight_temp()
3067 return PTR_ERR(data); in show_weight_temp()
3069 return sprintf(buf, "%d\n", data->weight_temp[index][nr] * 1000); in show_weight_temp()
3076 struct nct6775_data *data = dev_get_drvdata(dev); in store_weight_temp() local
3078 int nr = sattr->nr; in store_weight_temp()
3079 int index = sattr->index; in store_weight_temp()
3089 mutex_lock(&data->update_lock); in store_weight_temp()
3090 data->weight_temp[index][nr] = val; in store_weight_temp()
3091 err = nct6775_write_value(data, data->REG_WEIGHT_TEMP[index][nr], val); in store_weight_temp()
3092 mutex_unlock(&data->update_lock); in store_weight_temp()
3110 struct nct6775_data *data = nct6775_update_device(dev); in show_fan_time() local
3112 int nr = sattr->nr; in show_fan_time()
3113 int index = sattr->index; in show_fan_time()
3115 if (IS_ERR(data)) in show_fan_time()
3116 return PTR_ERR(data); in show_fan_time()
3119 step_time_from_reg(data->fan_time[index][nr], in show_fan_time()
3120 data->pwm_mode[nr])); in show_fan_time()
3127 struct nct6775_data *data = dev_get_drvdata(dev); in store_fan_time() local
3129 int nr = sattr->nr; in store_fan_time()
3130 int index = sattr->index; in store_fan_time()
3138 val = step_time_to_reg(val, data->pwm_mode[nr]); in store_fan_time()
3139 mutex_lock(&data->update_lock); in store_fan_time()
3140 data->fan_time[index][nr] = val; in store_fan_time()
3141 err = nct6775_write_value(data, data->REG_FAN_TIME[index][nr], val); in store_fan_time()
3142 mutex_unlock(&data->update_lock); in store_fan_time()
3149 struct nct6775_data *data = nct6775_update_device(dev); in show_auto_pwm() local
3152 if (IS_ERR(data)) in show_auto_pwm()
3153 return PTR_ERR(data); in show_auto_pwm()
3155 return sprintf(buf, "%d\n", data->auto_pwm[sattr->nr][sattr->index]); in show_auto_pwm()
3162 struct nct6775_data *data = dev_get_drvdata(dev); in store_auto_pwm() local
3164 int nr = sattr->nr; in store_auto_pwm()
3165 int point = sattr->index; in store_auto_pwm()
3168 u16 reg; in store_auto_pwm() local
3174 return -EINVAL; in store_auto_pwm()
3176 if (point == data->auto_pwm_num) { in store_auto_pwm()
3177 if (data->kind != nct6775 && !val) in store_auto_pwm()
3178 return -EINVAL; in store_auto_pwm()
3179 if (data->kind != nct6779 && val) in store_auto_pwm()
3183 mutex_lock(&data->update_lock); in store_auto_pwm()
3184 data->auto_pwm[nr][point] = val; in store_auto_pwm()
3185 if (point < data->auto_pwm_num) { in store_auto_pwm()
3186 err = nct6775_write_value(data, NCT6775_AUTO_PWM(data, nr, point), in store_auto_pwm()
3187 data->auto_pwm[nr][point]); in store_auto_pwm()
3189 switch (data->kind) { in store_auto_pwm()
3192 err = nct6775_read_value(data, NCT6775_REG_CRITICAL_ENAB[nr], ®); in store_auto_pwm()
3196 reg |= 0x02; in store_auto_pwm()
3198 reg &= ~0x02; in store_auto_pwm()
3199 err = nct6775_write_value(data, NCT6775_REG_CRITICAL_ENAB[nr], reg); in store_auto_pwm()
3214 err = nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], val); in store_auto_pwm()
3217 err = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[nr], ®); in store_auto_pwm()
3221 reg &= ~data->CRITICAL_PWM_ENABLE_MASK; in store_auto_pwm()
3223 reg |= data->CRITICAL_PWM_ENABLE_MASK; in store_auto_pwm()
3224 err = nct6775_write_value(data, data->REG_CRITICAL_PWM_ENABLE[nr], reg); in store_auto_pwm()
3228 mutex_unlock(&data->update_lock); in store_auto_pwm()
3235 struct nct6775_data *data = nct6775_update_device(dev); in show_auto_temp() local
3237 int nr = sattr->nr; in show_auto_temp()
3238 int point = sattr->index; in show_auto_temp()
3240 if (IS_ERR(data)) in show_auto_temp()
3241 return PTR_ERR(data); in show_auto_temp()
3247 return sprintf(buf, "%d\n", data->auto_temp[nr][point] * 1000); in show_auto_temp()
3254 struct nct6775_data *data = dev_get_drvdata(dev); in store_auto_temp() local
3256 int nr = sattr->nr; in store_auto_temp()
3257 int point = sattr->index; in store_auto_temp()
3265 return -EINVAL; in store_auto_temp()
3267 mutex_lock(&data->update_lock); in store_auto_temp()
3268 data->auto_temp[nr][point] = DIV_ROUND_CLOSEST(val, 1000); in store_auto_temp()
3269 if (point < data->auto_pwm_num) { in store_auto_temp()
3270 err = nct6775_write_value(data, NCT6775_AUTO_TEMP(data, nr, point), in store_auto_temp()
3271 data->auto_temp[nr][point]); in store_auto_temp()
3273 err = nct6775_write_value(data, data->REG_CRITICAL_TEMP[nr], in store_auto_temp()
3274 data->auto_temp[nr][point]); in store_auto_temp()
3276 mutex_unlock(&data->update_lock); in store_auto_temp()
3284 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_pwm_is_visible() local
3288 if (!(data->has_pwm & BIT(pwm))) in nct6775_pwm_is_visible()
3292 if (!data->REG_WEIGHT_TEMP_SEL[pwm]) in nct6775_pwm_is_visible()
3294 if (nr == 19 && data->REG_PWM[3] == NULL) /* pwm_max */ in nct6775_pwm_is_visible()
3296 if (nr == 20 && data->REG_PWM[4] == NULL) /* pwm_step */ in nct6775_pwm_is_visible()
3298 if (nr == 21 && data->REG_PWM[6] == NULL) /* weight_duty_base */ in nct6775_pwm_is_visible()
3302 int api = (nr - 22) / 2; /* auto point index */ in nct6775_pwm_is_visible()
3304 if (api > data->auto_pwm_num) in nct6775_pwm_is_visible()
3307 return nct6775_attr_mode(data, attr); in nct6775_pwm_is_visible()
3413 static inline int nct6775_init_device(struct nct6775_data *data) in nct6775_init_device() argument
3419 if (data->REG_CONFIG) { in nct6775_init_device()
3420 err = nct6775_read_value(data, data->REG_CONFIG, &tmp); in nct6775_init_device()
3424 err = nct6775_write_value(data, data->REG_CONFIG, tmp | 0x01); in nct6775_init_device()
3432 if (!(data->have_temp & BIT(i))) in nct6775_init_device()
3434 if (!data->reg_temp_config[i]) in nct6775_init_device()
3436 err = nct6775_read_value(data, data->reg_temp_config[i], &tmp); in nct6775_init_device()
3440 err = nct6775_write_value(data, data->reg_temp_config[i], tmp & 0xfe); in nct6775_init_device()
3447 err = nct6775_read_value(data, data->REG_VBAT, &tmp); in nct6775_init_device()
3451 err = nct6775_write_value(data, data->REG_VBAT, tmp | 0x01); in nct6775_init_device()
3456 err = nct6775_read_value(data, data->REG_DIODE, &diode); in nct6775_init_device()
3460 for (i = 0; i < data->temp_fixed_num; i++) { in nct6775_init_device()
3461 if (!(data->have_temp_fixed & BIT(i))) in nct6775_init_device()
3463 if ((tmp & (data->DIODE_MASK << i))) /* diode */ in nct6775_init_device()
3464 data->temp_type[i] in nct6775_init_device()
3465 = 3 - ((diode >> i) & data->DIODE_MASK); in nct6775_init_device()
3467 data->temp_type[i] = 4; in nct6775_init_device()
3473 static int add_temp_sensors(struct nct6775_data *data, const u16 *regp, in add_temp_sensors() argument
3479 for (i = 0; i < data->pwm_num && *available; i++) { in add_temp_sensors()
3484 err = nct6775_read_value(data, regp[i], &src); in add_temp_sensors()
3490 if (!(data->temp_mask & BIT(src))) in add_temp_sensors()
3494 err = nct6775_write_value(data, data->REG_TEMP_SOURCE[index], src); in add_temp_sensors()
3504 int nct6775_probe(struct device *dev, struct nct6775_data *data, in nct6775_probe() argument
3518 data->regmap = devm_regmap_init(dev, NULL, data, regmapcfg); in nct6775_probe()
3519 if (IS_ERR(data->regmap)) in nct6775_probe()
3520 return PTR_ERR(data->regmap); in nct6775_probe()
3522 mutex_init(&data->update_lock); in nct6775_probe()
3523 data->name = nct6775_device_names[data->kind]; in nct6775_probe()
3524 data->bank = 0xff; /* Force initial bank selection */ in nct6775_probe()
3525 data->scale_in = scale_in; in nct6775_probe()
3527 switch (data->kind) { in nct6775_probe()
3529 data->in_num = 9; in nct6775_probe()
3530 data->pwm_num = 3; in nct6775_probe()
3531 data->auto_pwm_num = 4; in nct6775_probe()
3532 data->temp_fixed_num = 3; in nct6775_probe()
3533 data->num_temp_alarms = 6; in nct6775_probe()
3534 data->num_temp_beeps = 6; in nct6775_probe()
3536 data->fan_from_reg = fan_from_reg13; in nct6775_probe()
3537 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3539 data->temp_label = nct6776_temp_label; in nct6775_probe()
3540 data->temp_mask = NCT6776_TEMP_MASK; in nct6775_probe()
3541 data->virt_temp_mask = NCT6776_VIRT_TEMP_MASK; in nct6775_probe()
3543 data->REG_VBAT = NCT6106_REG_VBAT; in nct6775_probe()
3544 data->REG_DIODE = NCT6106_REG_DIODE; in nct6775_probe()
3545 data->DIODE_MASK = NCT6106_DIODE_MASK; in nct6775_probe()
3546 data->REG_VIN = NCT6106_REG_IN; in nct6775_probe()
3547 data->REG_IN_MINMAX[0] = NCT6106_REG_IN_MIN; in nct6775_probe()
3548 data->REG_IN_MINMAX[1] = NCT6106_REG_IN_MAX; in nct6775_probe()
3549 data->REG_TARGET = NCT6106_REG_TARGET; in nct6775_probe()
3550 data->REG_FAN = NCT6106_REG_FAN; in nct6775_probe()
3551 data->REG_FAN_MODE = NCT6106_REG_FAN_MODE; in nct6775_probe()
3552 data->REG_FAN_MIN = NCT6106_REG_FAN_MIN; in nct6775_probe()
3553 data->REG_FAN_PULSES = NCT6106_REG_FAN_PULSES; in nct6775_probe()
3554 data->FAN_PULSE_SHIFT = NCT6106_FAN_PULSE_SHIFT; in nct6775_probe()
3555 data->REG_FAN_TIME[0] = NCT6106_REG_FAN_STOP_TIME; in nct6775_probe()
3556 data->REG_FAN_TIME[1] = NCT6106_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3557 data->REG_FAN_TIME[2] = NCT6106_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3558 data->REG_TOLERANCE_H = NCT6106_REG_TOLERANCE_H; in nct6775_probe()
3559 data->REG_PWM[0] = NCT6116_REG_PWM; in nct6775_probe()
3560 data->REG_PWM[1] = NCT6106_REG_FAN_START_OUTPUT; in nct6775_probe()
3561 data->REG_PWM[2] = NCT6106_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3562 data->REG_PWM[5] = NCT6106_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3563 data->REG_PWM[6] = NCT6106_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3564 data->REG_PWM_READ = NCT6106_REG_PWM_READ; in nct6775_probe()
3565 data->REG_PWM_MODE = NCT6106_REG_PWM_MODE; in nct6775_probe()
3566 data->PWM_MODE_MASK = NCT6106_PWM_MODE_MASK; in nct6775_probe()
3567 data->REG_AUTO_TEMP = NCT6106_REG_AUTO_TEMP; in nct6775_probe()
3568 data->REG_AUTO_PWM = NCT6106_REG_AUTO_PWM; in nct6775_probe()
3569 data->REG_CRITICAL_TEMP = NCT6106_REG_CRITICAL_TEMP; in nct6775_probe()
3570 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3572 data->REG_CRITICAL_PWM_ENABLE = NCT6106_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3573 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3575 data->REG_CRITICAL_PWM = NCT6106_REG_CRITICAL_PWM; in nct6775_probe()
3576 data->REG_TEMP_OFFSET = NCT6106_REG_TEMP_OFFSET; in nct6775_probe()
3577 data->REG_TEMP_SOURCE = NCT6106_REG_TEMP_SOURCE; in nct6775_probe()
3578 data->REG_TEMP_SEL = NCT6116_REG_TEMP_SEL; in nct6775_probe()
3579 data->REG_WEIGHT_TEMP_SEL = NCT6106_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3580 data->REG_WEIGHT_TEMP[0] = NCT6106_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3581 data->REG_WEIGHT_TEMP[1] = NCT6106_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3582 data->REG_WEIGHT_TEMP[2] = NCT6106_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3583 data->REG_ALARM = NCT6106_REG_ALARM; in nct6775_probe()
3584 data->ALARM_BITS = NCT6106_ALARM_BITS; in nct6775_probe()
3585 data->REG_BEEP = NCT6106_REG_BEEP; in nct6775_probe()
3586 data->BEEP_BITS = NCT6106_BEEP_BITS; in nct6775_probe()
3587 data->REG_TSI_TEMP = NCT6106_REG_TSI_TEMP; in nct6775_probe()
3605 data->in_num = 9; in nct6775_probe()
3606 data->pwm_num = 3; in nct6775_probe()
3607 data->auto_pwm_num = 4; in nct6775_probe()
3608 data->temp_fixed_num = 3; in nct6775_probe()
3609 data->num_temp_alarms = 3; in nct6775_probe()
3610 data->num_temp_beeps = 3; in nct6775_probe()
3612 data->fan_from_reg = fan_from_reg13; in nct6775_probe()
3613 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3615 data->temp_label = nct6776_temp_label; in nct6775_probe()
3616 data->temp_mask = NCT6776_TEMP_MASK; in nct6775_probe()
3617 data->virt_temp_mask = NCT6776_VIRT_TEMP_MASK; in nct6775_probe()
3619 data->REG_VBAT = NCT6106_REG_VBAT; in nct6775_probe()
3620 data->REG_DIODE = NCT6106_REG_DIODE; in nct6775_probe()
3621 data->DIODE_MASK = NCT6106_DIODE_MASK; in nct6775_probe()
3622 data->REG_VIN = NCT6106_REG_IN; in nct6775_probe()
3623 data->REG_IN_MINMAX[0] = NCT6106_REG_IN_MIN; in nct6775_probe()
3624 data->REG_IN_MINMAX[1] = NCT6106_REG_IN_MAX; in nct6775_probe()
3625 data->REG_TARGET = NCT6116_REG_TARGET; in nct6775_probe()
3626 data->REG_FAN = NCT6116_REG_FAN; in nct6775_probe()
3627 data->REG_FAN_MODE = NCT6116_REG_FAN_MODE; in nct6775_probe()
3628 data->REG_FAN_MIN = NCT6116_REG_FAN_MIN; in nct6775_probe()
3629 data->REG_FAN_PULSES = NCT6116_REG_FAN_PULSES; in nct6775_probe()
3630 data->FAN_PULSE_SHIFT = NCT6116_FAN_PULSE_SHIFT; in nct6775_probe()
3631 data->REG_FAN_TIME[0] = NCT6116_REG_FAN_STOP_TIME; in nct6775_probe()
3632 data->REG_FAN_TIME[1] = NCT6116_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3633 data->REG_FAN_TIME[2] = NCT6116_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3634 data->REG_TOLERANCE_H = NCT6116_REG_TOLERANCE_H; in nct6775_probe()
3635 data->REG_PWM[0] = NCT6116_REG_PWM; in nct6775_probe()
3636 data->REG_PWM[1] = NCT6116_REG_FAN_START_OUTPUT; in nct6775_probe()
3637 data->REG_PWM[2] = NCT6116_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3638 data->REG_PWM[5] = NCT6106_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3639 data->REG_PWM[6] = NCT6106_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3640 data->REG_PWM_READ = NCT6106_REG_PWM_READ; in nct6775_probe()
3641 data->REG_PWM_MODE = NCT6106_REG_PWM_MODE; in nct6775_probe()
3642 data->PWM_MODE_MASK = NCT6106_PWM_MODE_MASK; in nct6775_probe()
3643 data->REG_AUTO_TEMP = NCT6116_REG_AUTO_TEMP; in nct6775_probe()
3644 data->REG_AUTO_PWM = NCT6116_REG_AUTO_PWM; in nct6775_probe()
3645 data->REG_CRITICAL_TEMP = NCT6116_REG_CRITICAL_TEMP; in nct6775_probe()
3646 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3648 data->REG_CRITICAL_PWM_ENABLE = NCT6116_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3649 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3651 data->REG_CRITICAL_PWM = NCT6116_REG_CRITICAL_PWM; in nct6775_probe()
3652 data->REG_TEMP_OFFSET = NCT6106_REG_TEMP_OFFSET; in nct6775_probe()
3653 data->REG_TEMP_SOURCE = NCT6116_REG_TEMP_SOURCE; in nct6775_probe()
3654 data->REG_TEMP_SEL = NCT6116_REG_TEMP_SEL; in nct6775_probe()
3655 data->REG_WEIGHT_TEMP_SEL = NCT6106_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3656 data->REG_WEIGHT_TEMP[0] = NCT6106_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3657 data->REG_WEIGHT_TEMP[1] = NCT6106_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3658 data->REG_WEIGHT_TEMP[2] = NCT6106_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3659 data->REG_ALARM = NCT6106_REG_ALARM; in nct6775_probe()
3660 data->ALARM_BITS = NCT6116_ALARM_BITS; in nct6775_probe()
3661 data->REG_BEEP = NCT6106_REG_BEEP; in nct6775_probe()
3662 data->BEEP_BITS = NCT6116_BEEP_BITS; in nct6775_probe()
3663 data->REG_TSI_TEMP = NCT6116_REG_TSI_TEMP; in nct6775_probe()
3681 data->in_num = 9; in nct6775_probe()
3682 data->pwm_num = 3; in nct6775_probe()
3683 data->auto_pwm_num = 6; in nct6775_probe()
3684 data->has_fan_div = true; in nct6775_probe()
3685 data->temp_fixed_num = 3; in nct6775_probe()
3686 data->num_temp_alarms = 3; in nct6775_probe()
3687 data->num_temp_beeps = 3; in nct6775_probe()
3689 data->ALARM_BITS = NCT6775_ALARM_BITS; in nct6775_probe()
3690 data->BEEP_BITS = NCT6775_BEEP_BITS; in nct6775_probe()
3692 data->fan_from_reg = fan_from_reg16; in nct6775_probe()
3693 data->fan_from_reg_min = fan_from_reg8; in nct6775_probe()
3694 data->target_temp_mask = 0x7f; in nct6775_probe()
3695 data->tolerance_mask = 0x0f; in nct6775_probe()
3696 data->speed_tolerance_limit = 15; in nct6775_probe()
3698 data->temp_label = nct6775_temp_label; in nct6775_probe()
3699 data->temp_mask = NCT6775_TEMP_MASK; in nct6775_probe()
3700 data->virt_temp_mask = NCT6775_VIRT_TEMP_MASK; in nct6775_probe()
3702 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3703 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3704 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3705 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3706 data->REG_VIN = NCT6775_REG_IN; in nct6775_probe()
3707 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3708 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3709 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3710 data->REG_FAN = NCT6775_REG_FAN; in nct6775_probe()
3711 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3712 data->REG_FAN_MIN = NCT6775_REG_FAN_MIN; in nct6775_probe()
3713 data->REG_FAN_PULSES = NCT6775_REG_FAN_PULSES; in nct6775_probe()
3714 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3715 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3716 data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3717 data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3718 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3719 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3720 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3721 data->REG_PWM[3] = NCT6775_REG_FAN_MAX_OUTPUT; in nct6775_probe()
3722 data->REG_PWM[4] = NCT6775_REG_FAN_STEP_OUTPUT; in nct6775_probe()
3723 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3724 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3725 data->REG_PWM_MODE = NCT6775_REG_PWM_MODE; in nct6775_probe()
3726 data->PWM_MODE_MASK = NCT6775_PWM_MODE_MASK; in nct6775_probe()
3727 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3728 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3729 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3730 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3732 data->REG_TEMP_OFFSET = NCT6775_REG_TEMP_OFFSET; in nct6775_probe()
3733 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
3734 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
3735 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3736 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3737 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3738 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3739 data->REG_ALARM = NCT6775_REG_ALARM; in nct6775_probe()
3740 data->REG_BEEP = NCT6775_REG_BEEP; in nct6775_probe()
3741 data->REG_TSI_TEMP = NCT6775_REG_TSI_TEMP; in nct6775_probe()
3757 data->in_num = 9; in nct6775_probe()
3758 data->pwm_num = 3; in nct6775_probe()
3759 data->auto_pwm_num = 4; in nct6775_probe()
3760 data->has_fan_div = false; in nct6775_probe()
3761 data->temp_fixed_num = 3; in nct6775_probe()
3762 data->num_temp_alarms = 3; in nct6775_probe()
3763 data->num_temp_beeps = 6; in nct6775_probe()
3765 data->ALARM_BITS = NCT6776_ALARM_BITS; in nct6775_probe()
3766 data->BEEP_BITS = NCT6776_BEEP_BITS; in nct6775_probe()
3768 data->fan_from_reg = fan_from_reg13; in nct6775_probe()
3769 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3770 data->target_temp_mask = 0xff; in nct6775_probe()
3771 data->tolerance_mask = 0x07; in nct6775_probe()
3772 data->speed_tolerance_limit = 63; in nct6775_probe()
3774 data->temp_label = nct6776_temp_label; in nct6775_probe()
3775 data->temp_mask = NCT6776_TEMP_MASK; in nct6775_probe()
3776 data->virt_temp_mask = NCT6776_VIRT_TEMP_MASK; in nct6775_probe()
3778 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3779 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3780 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3781 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3782 data->REG_VIN = NCT6775_REG_IN; in nct6775_probe()
3783 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3784 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3785 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3786 data->REG_FAN = NCT6775_REG_FAN; in nct6775_probe()
3787 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3788 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
3789 data->REG_FAN_PULSES = NCT6776_REG_FAN_PULSES; in nct6775_probe()
3790 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3791 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3792 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3793 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3794 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
3795 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3796 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3797 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3798 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3799 data->REG_PWM[6] = NCT6776_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3800 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3801 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
3802 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
3803 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3804 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3805 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3806 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3808 data->REG_TEMP_OFFSET = NCT6775_REG_TEMP_OFFSET; in nct6775_probe()
3809 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
3810 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
3811 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3812 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3813 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3814 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3815 data->REG_ALARM = NCT6775_REG_ALARM; in nct6775_probe()
3816 data->REG_BEEP = NCT6776_REG_BEEP; in nct6775_probe()
3817 data->REG_TSI_TEMP = NCT6776_REG_TSI_TEMP; in nct6775_probe()
3833 data->in_num = 15; in nct6775_probe()
3834 data->pwm_num = 5; in nct6775_probe()
3835 data->auto_pwm_num = 4; in nct6775_probe()
3836 data->has_fan_div = false; in nct6775_probe()
3837 data->temp_fixed_num = 6; in nct6775_probe()
3838 data->num_temp_alarms = 2; in nct6775_probe()
3839 data->num_temp_beeps = 2; in nct6775_probe()
3841 data->ALARM_BITS = NCT6779_ALARM_BITS; in nct6775_probe()
3842 data->BEEP_BITS = NCT6779_BEEP_BITS; in nct6775_probe()
3844 data->fan_from_reg = fan_from_reg_rpm; in nct6775_probe()
3845 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3846 data->target_temp_mask = 0xff; in nct6775_probe()
3847 data->tolerance_mask = 0x07; in nct6775_probe()
3848 data->speed_tolerance_limit = 63; in nct6775_probe()
3850 data->temp_label = nct6779_temp_label; in nct6775_probe()
3851 data->temp_mask = NCT6779_TEMP_MASK; in nct6775_probe()
3852 data->virt_temp_mask = NCT6779_VIRT_TEMP_MASK; in nct6775_probe()
3854 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3855 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3856 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3857 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3858 data->REG_VIN = NCT6779_REG_IN; in nct6775_probe()
3859 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3860 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3861 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3862 data->REG_FAN = NCT6779_REG_FAN; in nct6775_probe()
3863 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3864 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
3865 data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; in nct6775_probe()
3866 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3867 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3868 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3869 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3870 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
3871 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3872 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3873 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3874 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3875 data->REG_PWM[6] = NCT6776_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3876 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3877 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
3878 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
3879 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3880 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3881 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3882 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3884 data->REG_CRITICAL_PWM_ENABLE = NCT6779_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3885 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3887 data->REG_CRITICAL_PWM = NCT6779_REG_CRITICAL_PWM; in nct6775_probe()
3888 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; in nct6775_probe()
3889 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
3890 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
3891 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3892 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3893 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3894 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3895 data->REG_ALARM = NCT6779_REG_ALARM; in nct6775_probe()
3896 data->REG_BEEP = NCT6776_REG_BEEP; in nct6775_probe()
3897 data->REG_TSI_TEMP = NCT6776_REG_TSI_TEMP; in nct6775_probe()
3918 data->in_num = 15; in nct6775_probe()
3919 data->pwm_num = (data->kind == nct6796 || in nct6775_probe()
3920 data->kind == nct6797) ? 7 : 6; in nct6775_probe()
3921 data->auto_pwm_num = 4; in nct6775_probe()
3922 data->has_fan_div = false; in nct6775_probe()
3923 data->temp_fixed_num = 6; in nct6775_probe()
3924 data->num_temp_alarms = 2; in nct6775_probe()
3925 data->num_temp_beeps = 2; in nct6775_probe()
3927 data->ALARM_BITS = NCT6791_ALARM_BITS; in nct6775_probe()
3928 data->BEEP_BITS = NCT6779_BEEP_BITS; in nct6775_probe()
3930 data->fan_from_reg = fan_from_reg_rpm; in nct6775_probe()
3931 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3932 data->target_temp_mask = 0xff; in nct6775_probe()
3933 data->tolerance_mask = 0x07; in nct6775_probe()
3934 data->speed_tolerance_limit = 63; in nct6775_probe()
3936 switch (data->kind) { in nct6775_probe()
3939 data->temp_label = nct6779_temp_label; in nct6775_probe()
3940 data->temp_mask = NCT6791_TEMP_MASK; in nct6775_probe()
3941 data->virt_temp_mask = NCT6791_VIRT_TEMP_MASK; in nct6775_probe()
3944 data->temp_label = nct6792_temp_label; in nct6775_probe()
3945 data->temp_mask = NCT6792_TEMP_MASK; in nct6775_probe()
3946 data->virt_temp_mask = NCT6792_VIRT_TEMP_MASK; in nct6775_probe()
3949 data->temp_label = nct6793_temp_label; in nct6775_probe()
3950 data->temp_mask = NCT6793_TEMP_MASK; in nct6775_probe()
3951 data->virt_temp_mask = NCT6793_VIRT_TEMP_MASK; in nct6775_probe()
3955 data->temp_label = nct6795_temp_label; in nct6775_probe()
3956 data->temp_mask = NCT6795_TEMP_MASK; in nct6775_probe()
3957 data->virt_temp_mask = NCT6795_VIRT_TEMP_MASK; in nct6775_probe()
3960 data->temp_label = nct6796_temp_label; in nct6775_probe()
3961 data->temp_mask = NCT6796_TEMP_MASK; in nct6775_probe()
3962 data->virt_temp_mask = NCT6796_VIRT_TEMP_MASK; in nct6775_probe()
3966 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3967 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3968 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3969 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3970 data->REG_VIN = NCT6779_REG_IN; in nct6775_probe()
3971 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3972 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3973 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3974 data->REG_FAN = NCT6779_REG_FAN; in nct6775_probe()
3975 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3976 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
3977 data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; in nct6775_probe()
3978 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3979 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3980 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3981 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3982 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
3983 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3984 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3985 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3986 data->REG_PWM[5] = NCT6791_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3987 data->REG_PWM[6] = NCT6791_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3988 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3989 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
3990 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
3991 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3992 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3993 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3994 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3996 data->REG_CRITICAL_PWM_ENABLE = NCT6779_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3997 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3999 data->REG_CRITICAL_PWM = NCT6779_REG_CRITICAL_PWM; in nct6775_probe()
4000 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; in nct6775_probe()
4001 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
4002 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
4003 data->REG_WEIGHT_TEMP_SEL = NCT6791_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
4004 data->REG_WEIGHT_TEMP[0] = NCT6791_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
4005 data->REG_WEIGHT_TEMP[1] = NCT6791_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
4006 data->REG_WEIGHT_TEMP[2] = NCT6791_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
4007 data->REG_ALARM = NCT6791_REG_ALARM; in nct6775_probe()
4008 if (data->kind == nct6791) in nct6775_probe()
4009 data->REG_BEEP = NCT6776_REG_BEEP; in nct6775_probe()
4011 data->REG_BEEP = NCT6792_REG_BEEP; in nct6775_probe()
4012 switch (data->kind) { in nct6775_probe()
4016 data->REG_TSI_TEMP = NCT6776_REG_TSI_TEMP; in nct6775_probe()
4022 data->REG_TSI_TEMP = NCT6796_REG_TSI_TEMP; in nct6775_probe()
4032 if (data->kind == nct6791) { in nct6775_probe()
4049 data->in_num = data->kind == nct6799 ? 18 : 15; in nct6775_probe()
4050 data->scale_in = scale_in_6798; in nct6775_probe()
4051 data->pwm_num = 7; in nct6775_probe()
4052 data->auto_pwm_num = 4; in nct6775_probe()
4053 data->has_fan_div = false; in nct6775_probe()
4054 data->temp_fixed_num = 6; in nct6775_probe()
4055 data->num_temp_alarms = 7; in nct6775_probe()
4056 data->num_temp_beeps = 8; in nct6775_probe()
4058 data->ALARM_BITS = NCT6799_ALARM_BITS; in nct6775_probe()
4059 data->BEEP_BITS = NCT6799_BEEP_BITS; in nct6775_probe()
4061 data->fan_from_reg = fan_from_reg_rpm; in nct6775_probe()
4062 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
4063 data->target_temp_mask = 0xff; in nct6775_probe()
4064 data->tolerance_mask = 0x07; in nct6775_probe()
4065 data->speed_tolerance_limit = 63; in nct6775_probe()
4067 switch (data->kind) { in nct6775_probe()
4070 data->temp_label = nct6798_temp_label; in nct6775_probe()
4071 data->temp_mask = NCT6798_TEMP_MASK; in nct6775_probe()
4072 data->virt_temp_mask = NCT6798_VIRT_TEMP_MASK; in nct6775_probe()
4075 data->temp_label = nct6799_temp_label; in nct6775_probe()
4076 data->temp_mask = NCT6799_TEMP_MASK; in nct6775_probe()
4077 data->virt_temp_mask = NCT6799_VIRT_TEMP_MASK; in nct6775_probe()
4081 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
4082 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
4083 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
4084 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
4085 data->REG_VIN = NCT6779_REG_IN; in nct6775_probe()
4086 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
4087 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
4088 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
4089 data->REG_FAN = NCT6779_REG_FAN; in nct6775_probe()
4090 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
4091 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
4092 data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; in nct6775_probe()
4093 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
4094 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
4095 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
4096 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
4097 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
4098 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
4099 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
4100 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
4101 data->REG_PWM[5] = NCT6791_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
4102 data->REG_PWM[6] = NCT6791_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
4103 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
4104 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
4105 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
4106 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
4107 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
4108 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
4109 data->REG_CRITICAL_TEMP_TOLERANCE = NCT6775_REG_CRITICAL_TEMP_TOLERANCE; in nct6775_probe()
4110 data->REG_CRITICAL_PWM_ENABLE = NCT6779_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
4111 data->CRITICAL_PWM_ENABLE_MASK = NCT6779_CRITICAL_PWM_ENABLE_MASK; in nct6775_probe()
4112 data->REG_CRITICAL_PWM = NCT6779_REG_CRITICAL_PWM; in nct6775_probe()
4113 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; in nct6775_probe()
4114 data->REG_TEMP_SOURCE = NCT6798_REG_TEMP_SOURCE; in nct6775_probe()
4115 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
4116 data->REG_WEIGHT_TEMP_SEL = NCT6791_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
4117 data->REG_WEIGHT_TEMP[0] = NCT6791_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
4118 data->REG_WEIGHT_TEMP[1] = NCT6791_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
4119 data->REG_WEIGHT_TEMP[2] = NCT6791_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
4120 data->REG_ALARM = NCT6799_REG_ALARM; in nct6775_probe()
4121 data->REG_BEEP = NCT6792_REG_BEEP; in nct6775_probe()
4122 data->REG_TSI_TEMP = NCT6796_REG_TSI_TEMP; in nct6775_probe()
4138 return -ENODEV; in nct6775_probe()
4140 data->have_in = BIT(data->in_num) - 1; in nct6775_probe()
4141 data->have_temp = 0; in nct6775_probe()
4157 err = nct6775_read_value(data, data->REG_TEMP_SOURCE[i], &src); in nct6775_probe()
4171 err = add_temp_sensors(data, data->REG_TEMP_SEL, &available, &mask); in nct6775_probe()
4174 err = add_temp_sensors(data, data->REG_WEIGHT_TEMP_SEL, &available, &mask); in nct6775_probe()
4184 err = nct6775_read_value(data, data->REG_TEMP_SOURCE[i], &src); in nct6775_probe()
4191 if (!(data->temp_mask & BIT(src))) { in nct6775_probe()
4194 src, i, data->REG_TEMP_SOURCE[i], reg_temp[i]); in nct6775_probe()
4201 if (src <= data->temp_fixed_num) { in nct6775_probe()
4202 data->have_temp |= BIT(src - 1); in nct6775_probe()
4203 data->have_temp_fixed |= BIT(src - 1); in nct6775_probe()
4204 data->reg_temp[0][src - 1] = reg_temp[i]; in nct6775_probe()
4205 data->reg_temp[1][src - 1] = reg_temp_over[i]; in nct6775_probe()
4206 data->reg_temp[2][src - 1] = reg_temp_hyst[i]; in nct6775_probe()
4208 data->reg_temp[3][src - 1] = reg_temp_crit_h[i]; in nct6775_probe()
4209 else if (reg_temp_crit[src - 1]) in nct6775_probe()
4210 data->reg_temp[3][src - 1] in nct6775_probe()
4211 = reg_temp_crit[src - 1]; in nct6775_probe()
4213 data->reg_temp[4][src - 1] = reg_temp_crit_l[i]; in nct6775_probe()
4215 data->reg_temp_config[src - 1] = reg_temp_config[i]; in nct6775_probe()
4216 data->temp_src[src - 1] = src; in nct6775_probe()
4224 data->have_temp |= BIT(s); in nct6775_probe()
4225 data->reg_temp[0][s] = reg_temp[i]; in nct6775_probe()
4226 data->reg_temp[1][s] = reg_temp_over[i]; in nct6775_probe()
4227 data->reg_temp[2][s] = reg_temp_hyst[i]; in nct6775_probe()
4229 data->reg_temp_config[s] = reg_temp_config[i]; in nct6775_probe()
4231 data->reg_temp[3][s] = reg_temp_crit_h[i]; in nct6775_probe()
4232 else if (reg_temp_crit[src - 1]) in nct6775_probe()
4233 data->reg_temp[3][s] = reg_temp_crit[src - 1]; in nct6775_probe()
4235 data->reg_temp[4][s] = reg_temp_crit_l[i]; in nct6775_probe()
4237 data->temp_src[s] = src; in nct6775_probe()
4249 err = nct6775_read_value(data, data->REG_TEMP_SEL[i], &src); in nct6775_probe()
4256 if (!(data->temp_mask & BIT(src))) { in nct6775_probe()
4259 src, i, data->REG_TEMP_SEL[i], in nct6775_probe()
4269 if (!(data->virt_temp_mask & BIT(src))) { in nct6775_probe()
4276 if (src <= data->temp_fixed_num) { in nct6775_probe()
4277 if (data->have_temp & BIT(src - 1)) in nct6775_probe()
4279 data->have_temp |= BIT(src - 1); in nct6775_probe()
4280 data->have_temp_fixed |= BIT(src - 1); in nct6775_probe()
4281 data->reg_temp[0][src - 1] = reg_temp_mon[i]; in nct6775_probe()
4282 data->temp_src[src - 1] = src; in nct6775_probe()
4290 data->have_temp |= BIT(s); in nct6775_probe()
4291 data->reg_temp[0][s] = reg_temp_mon[i]; in nct6775_probe()
4292 data->temp_src[s] = src; in nct6775_probe()
4304 if (!(data->temp_mask & BIT(i + 1))) in nct6775_probe()
4310 if (i < data->temp_fixed_num) { in nct6775_probe()
4311 if (data->have_temp & BIT(i)) in nct6775_probe()
4313 data->have_temp |= BIT(i); in nct6775_probe()
4314 data->have_temp_fixed |= BIT(i); in nct6775_probe()
4315 data->reg_temp[0][i] = reg_temp_alternate[i]; in nct6775_probe()
4317 data->reg_temp[1][i] = reg_temp_over[i]; in nct6775_probe()
4318 data->reg_temp[2][i] = reg_temp_hyst[i]; in nct6775_probe()
4320 data->temp_src[i] = i + 1; in nct6775_probe()
4327 data->have_temp |= BIT(s); in nct6775_probe()
4328 data->reg_temp[0][s] = reg_temp_alternate[i]; in nct6775_probe()
4329 data->temp_src[s] = i + 1; in nct6775_probe()
4338 err = nct6775_read_value(data, data->REG_TSI_TEMP[i], &tmp); in nct6775_probe()
4342 data->have_tsi_temp |= BIT(i); in nct6775_probe()
4346 err = nct6775_init_device(data); in nct6775_probe()
4350 if (data->driver_init) { in nct6775_probe()
4351 err = data->driver_init(data); in nct6775_probe()
4357 err = nct6775_init_fan_common(dev, data); in nct6775_probe()
4362 err = nct6775_add_template_attr_group(dev, data, &nct6775_pwm_template_group, in nct6775_probe()
4363 data->pwm_num); in nct6775_probe()
4367 err = nct6775_add_template_attr_group(dev, data, &nct6775_in_template_group, in nct6775_probe()
4368 fls(data->have_in)); in nct6775_probe()
4372 err = nct6775_add_template_attr_group(dev, data, &nct6775_fan_template_group, in nct6775_probe()
4373 fls(data->has_fan)); in nct6775_probe()
4377 err = nct6775_add_template_attr_group(dev, data, &nct6775_temp_template_group, in nct6775_probe()
4378 fls(data->have_temp)); in nct6775_probe()
4382 if (data->have_tsi_temp) { in nct6775_probe()
4385 tsi_temp_tg.base = fls(data->have_temp) + 1; in nct6775_probe()
4386 err = nct6775_add_template_attr_group(dev, data, &tsi_temp_tg, in nct6775_probe()
4387 fls(data->have_tsi_temp)); in nct6775_probe()
4392 hwmon_dev = devm_hwmon_device_register_with_groups(dev, data->name, in nct6775_probe()
4393 data, data->groups); in nct6775_probe()
4398 MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>");