Lines Matching refs:data

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
1077 static int nct6775_add_template_attr_group(struct device *dev, struct nct6775_data *data, in nct6775_add_template_attr_group() argument
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()
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()
1227 static int nct6775_write_fan_div(struct nct6775_data *data, int nr) in nct6775_write_fan_div() argument
1234 err = nct6775_read_value(data, fandiv_reg, &reg); 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
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], &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()
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
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], &reg); 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], &reg); 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], &reg); 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], &reg); 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], &reg); in nct6775_update_pwm()
1447 data->pwm_temp_sel[i] = reg & 0x1f; 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], &reg); in nct6775_update_pwm()
1458 data->pwm_weight_temp_sel[i] = reg & 0x1f; in nct6775_update_pwm()
1461 data->pwm_weight_temp_sel[i] = 0; 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], &reg); 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
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], &reg); 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], &reg_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], &reg); 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), &reg); 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), &reg); in nct6775_update_pwm_limits()
1520 data->auto_temp[i][j] = reg; in nct6775_update_pwm_limits()
1524 err = nct6775_read_value(data, data->REG_CRITICAL_TEMP[i], &reg); 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], &reg); in nct6775_update_pwm_limits()
1534 data->auto_pwm[i][data->auto_pwm_num] = 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], &reg); 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], &reg); 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
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], &reg); 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], &reg); 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], &reg); 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], &reg); 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], &reg); 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], &reg); 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], &reg); 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
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
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()
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()
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
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
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
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
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
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()
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()
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()
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
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], &reg); 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
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
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
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
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
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
2300 if (IS_ERR(data)) in store_temp_type()
2301 return PTR_ERR(data); 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()
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
2493 if (data->REG_PWM_MODE[nr] == 0) { 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], &reg); 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
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
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()
2560 if (index == 0 && data->pwm_enable[nr] > manual) 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], &reg); 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()
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()
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()
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()
2611 static int pwm_update_registers(struct nct6775_data *data, int nr) in pwm_update_registers() argument
2616 switch (data->pwm_enable[nr]) { in pwm_update_registers()
2621 err = nct6775_read_value(data, data->REG_FAN_MODE[nr], &reg); 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], &reg); 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
2691 if (val == sf3 && data->kind != nct6775) in store_pwm_enable()
2694 if (val == sf4 && check_trip_points(data, nr)) { 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], &reg); 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
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
2766 if (IS_ERR(data)) in store_pwm_temp_sel()
2767 return PTR_ERR(data); in store_pwm_temp_sel()
2774 if (!(data->have_temp & BIT(val - 1)) || !data->temp_src[val - 1]) 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], &reg); 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
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
2818 if (IS_ERR(data)) in store_pwm_weight_temp_sel()
2819 return PTR_ERR(data); 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()
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], &reg); 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], &reg); 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
2882 data->target_temp_mask); in store_target_temp()
2884 mutex_lock(&data->update_lock); in store_target_temp()
2885 data->target_temp[nr] = val; in store_target_temp()
2886 err = pwm_update_registers(data, nr); in store_target_temp()
2887 mutex_unlock(&data->update_lock); in store_target_temp()
2894 struct nct6775_data *data = nct6775_update_device(dev); in show_target_speed() local
2898 if (IS_ERR(data)) in show_target_speed()
2899 return PTR_ERR(data); in show_target_speed()
2902 fan_from_reg16(data->target_speed[nr], in show_target_speed()
2903 data->fan_div[nr])); in show_target_speed()
2910 struct nct6775_data *data = dev_get_drvdata(dev); in store_target_speed() local
2922 speed = fan_to_reg(val, data->fan_div[nr]); in store_target_speed()
2924 mutex_lock(&data->update_lock); in store_target_speed()
2925 data->target_speed[nr] = speed; in store_target_speed()
2926 err = pwm_update_registers(data, nr); in store_target_speed()
2927 mutex_unlock(&data->update_lock); in store_target_speed()
2935 struct nct6775_data *data = nct6775_update_device(dev); in show_temp_tolerance() local
2940 if (IS_ERR(data)) in show_temp_tolerance()
2941 return PTR_ERR(data); in show_temp_tolerance()
2943 return sprintf(buf, "%d\n", data->temp_tolerance[index][nr] * 1000); in show_temp_tolerance()
2950 struct nct6775_data *data = dev_get_drvdata(dev); in store_temp_tolerance() local
2962 val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, data->tolerance_mask); in store_temp_tolerance()
2964 mutex_lock(&data->update_lock); in store_temp_tolerance()
2965 data->temp_tolerance[index][nr] = val; in store_temp_tolerance()
2967 err = pwm_update_registers(data, nr); in store_temp_tolerance()
2969 err = nct6775_write_value(data, data->REG_CRITICAL_TEMP_TOLERANCE[nr], val); in store_temp_tolerance()
2970 mutex_unlock(&data->update_lock); in store_temp_tolerance()
2985 struct nct6775_data *data = nct6775_update_device(dev); in show_speed_tolerance() local
2990 if (IS_ERR(data)) in show_speed_tolerance()
2991 return PTR_ERR(data); in show_speed_tolerance()
2993 target = data->target_speed[nr]; in show_speed_tolerance()
2996 int low = target - data->target_speed_tolerance[nr]; in show_speed_tolerance()
2997 int high = target + data->target_speed_tolerance[nr]; in show_speed_tolerance()
3006 tolerance = (fan_from_reg16(low, data->fan_div[nr]) in show_speed_tolerance()
3007 - fan_from_reg16(high, data->fan_div[nr])) / 2; in show_speed_tolerance()
3017 struct nct6775_data *data = dev_get_drvdata(dev); in store_speed_tolerance() local
3028 high = fan_from_reg16(data->target_speed[nr], data->fan_div[nr]) + val; in store_speed_tolerance()
3029 low = fan_from_reg16(data->target_speed[nr], data->fan_div[nr]) - val; in store_speed_tolerance()
3035 val = (fan_to_reg(low, data->fan_div[nr]) - in store_speed_tolerance()
3036 fan_to_reg(high, data->fan_div[nr])) / 2; in store_speed_tolerance()
3039 val = clamp_val(val, 0, data->speed_tolerance_limit); in store_speed_tolerance()
3041 mutex_lock(&data->update_lock); in store_speed_tolerance()
3042 data->target_speed_tolerance[nr] = val; in store_speed_tolerance()
3043 err = pwm_update_registers(data, nr); in store_speed_tolerance()
3044 mutex_unlock(&data->update_lock); in store_speed_tolerance()
3062 struct nct6775_data *data = nct6775_update_device(dev); in show_weight_temp() local
3067 if (IS_ERR(data)) in show_weight_temp()
3068 return PTR_ERR(data); in show_weight_temp()
3070 return sprintf(buf, "%d\n", data->weight_temp[index][nr] * 1000); in show_weight_temp()
3077 struct nct6775_data *data = dev_get_drvdata(dev); in store_weight_temp() local
3090 mutex_lock(&data->update_lock); in store_weight_temp()
3091 data->weight_temp[index][nr] = val; in store_weight_temp()
3092 err = nct6775_write_value(data, data->REG_WEIGHT_TEMP[index][nr], val); in store_weight_temp()
3093 mutex_unlock(&data->update_lock); in store_weight_temp()
3111 struct nct6775_data *data = nct6775_update_device(dev); in show_fan_time() local
3116 if (IS_ERR(data)) in show_fan_time()
3117 return PTR_ERR(data); in show_fan_time()
3120 step_time_from_reg(data->fan_time[index][nr], in show_fan_time()
3121 data->pwm_mode[nr])); in show_fan_time()
3128 struct nct6775_data *data = dev_get_drvdata(dev); in store_fan_time() local
3139 val = step_time_to_reg(val, data->pwm_mode[nr]); in store_fan_time()
3140 mutex_lock(&data->update_lock); in store_fan_time()
3141 data->fan_time[index][nr] = val; in store_fan_time()
3142 err = nct6775_write_value(data, data->REG_FAN_TIME[index][nr], val); in store_fan_time()
3143 mutex_unlock(&data->update_lock); in store_fan_time()
3150 struct nct6775_data *data = nct6775_update_device(dev); in show_auto_pwm() local
3153 if (IS_ERR(data)) in show_auto_pwm()
3154 return PTR_ERR(data); in show_auto_pwm()
3156 return sprintf(buf, "%d\n", data->auto_pwm[sattr->nr][sattr->index]); in show_auto_pwm()
3163 struct nct6775_data *data = dev_get_drvdata(dev); in store_auto_pwm() local
3177 if (point == data->auto_pwm_num) { in store_auto_pwm()
3178 if (data->kind != nct6775 && !val) in store_auto_pwm()
3180 if (data->kind != nct6779 && val) in store_auto_pwm()
3184 mutex_lock(&data->update_lock); in store_auto_pwm()
3185 data->auto_pwm[nr][point] = val; in store_auto_pwm()
3186 if (point < data->auto_pwm_num) { in store_auto_pwm()
3187 err = nct6775_write_value(data, NCT6775_AUTO_PWM(data, nr, point), in store_auto_pwm()
3188 data->auto_pwm[nr][point]); in store_auto_pwm()
3190 switch (data->kind) { in store_auto_pwm()
3193 err = nct6775_read_value(data, NCT6775_REG_CRITICAL_ENAB[nr], &reg); in store_auto_pwm()
3200 err = nct6775_write_value(data, NCT6775_REG_CRITICAL_ENAB[nr], reg); in store_auto_pwm()
3215 err = nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], val); in store_auto_pwm()
3218 err = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[nr], &reg); in store_auto_pwm()
3222 reg &= ~data->CRITICAL_PWM_ENABLE_MASK; in store_auto_pwm()
3224 reg |= data->CRITICAL_PWM_ENABLE_MASK; in store_auto_pwm()
3225 err = nct6775_write_value(data, data->REG_CRITICAL_PWM_ENABLE[nr], reg); in store_auto_pwm()
3229 mutex_unlock(&data->update_lock); in store_auto_pwm()
3236 struct nct6775_data *data = nct6775_update_device(dev); in show_auto_temp() local
3241 if (IS_ERR(data)) in show_auto_temp()
3242 return PTR_ERR(data); in show_auto_temp()
3248 return sprintf(buf, "%d\n", data->auto_temp[nr][point] * 1000); in show_auto_temp()
3255 struct nct6775_data *data = dev_get_drvdata(dev); in store_auto_temp() local
3268 mutex_lock(&data->update_lock); in store_auto_temp()
3269 data->auto_temp[nr][point] = DIV_ROUND_CLOSEST(val, 1000); in store_auto_temp()
3270 if (point < data->auto_pwm_num) { in store_auto_temp()
3271 err = nct6775_write_value(data, NCT6775_AUTO_TEMP(data, nr, point), in store_auto_temp()
3272 data->auto_temp[nr][point]); in store_auto_temp()
3274 err = nct6775_write_value(data, data->REG_CRITICAL_TEMP[nr], in store_auto_temp()
3275 data->auto_temp[nr][point]); in store_auto_temp()
3277 mutex_unlock(&data->update_lock); in store_auto_temp()
3285 struct nct6775_data *data = dev_get_drvdata(dev); in nct6775_pwm_is_visible() local
3289 if (!(data->has_pwm & BIT(pwm))) in nct6775_pwm_is_visible()
3293 if (!data->REG_WEIGHT_TEMP_SEL[pwm]) in nct6775_pwm_is_visible()
3295 if (nr == 19 && data->REG_PWM[3] == NULL) /* pwm_max */ in nct6775_pwm_is_visible()
3297 if (nr == 20 && data->REG_PWM[4] == NULL) /* pwm_step */ in nct6775_pwm_is_visible()
3299 if (nr == 21 && data->REG_PWM[6] == NULL) /* weight_duty_base */ in nct6775_pwm_is_visible()
3305 if (api > data->auto_pwm_num) in nct6775_pwm_is_visible()
3308 return nct6775_attr_mode(data, attr); in nct6775_pwm_is_visible()
3414 static inline int nct6775_init_device(struct nct6775_data *data) in nct6775_init_device() argument
3420 if (data->REG_CONFIG) { in nct6775_init_device()
3421 err = nct6775_read_value(data, data->REG_CONFIG, &tmp); in nct6775_init_device()
3425 err = nct6775_write_value(data, data->REG_CONFIG, tmp | 0x01); in nct6775_init_device()
3433 if (!(data->have_temp & BIT(i))) in nct6775_init_device()
3435 if (!data->reg_temp_config[i]) in nct6775_init_device()
3437 err = nct6775_read_value(data, data->reg_temp_config[i], &tmp); in nct6775_init_device()
3441 err = nct6775_write_value(data, data->reg_temp_config[i], tmp & 0xfe); in nct6775_init_device()
3448 err = nct6775_read_value(data, data->REG_VBAT, &tmp); in nct6775_init_device()
3452 err = nct6775_write_value(data, data->REG_VBAT, tmp | 0x01); in nct6775_init_device()
3457 err = nct6775_read_value(data, data->REG_DIODE, &diode); in nct6775_init_device()
3461 for (i = 0; i < data->temp_fixed_num; i++) { in nct6775_init_device()
3462 if (!(data->have_temp_fixed & BIT(i))) in nct6775_init_device()
3464 if ((tmp & (data->DIODE_MASK << i))) /* diode */ in nct6775_init_device()
3465 data->temp_type[i] in nct6775_init_device()
3466 = 3 - ((diode >> i) & data->DIODE_MASK); in nct6775_init_device()
3468 data->temp_type[i] = 4; in nct6775_init_device()
3474 static int add_temp_sensors(struct nct6775_data *data, const u16 *regp, in add_temp_sensors() argument
3480 for (i = 0; i < data->pwm_num && *available; i++) { in add_temp_sensors()
3485 err = nct6775_read_value(data, regp[i], &src); in add_temp_sensors()
3491 if (!(data->temp_mask & BIT(src))) in add_temp_sensors()
3495 err = nct6775_write_value(data, data->REG_TEMP_SOURCE[index], src); in add_temp_sensors()
3505 int nct6775_probe(struct device *dev, struct nct6775_data *data, in nct6775_probe() argument
3519 data->regmap = devm_regmap_init(dev, NULL, data, regmapcfg); in nct6775_probe()
3520 if (IS_ERR(data->regmap)) in nct6775_probe()
3521 return PTR_ERR(data->regmap); in nct6775_probe()
3523 mutex_init(&data->update_lock); in nct6775_probe()
3524 data->name = nct6775_device_names[data->kind]; in nct6775_probe()
3525 data->bank = 0xff; /* Force initial bank selection */ in nct6775_probe()
3526 data->scale_in = scale_in; in nct6775_probe()
3528 switch (data->kind) { in nct6775_probe()
3530 data->in_num = 9; in nct6775_probe()
3531 data->pwm_num = 3; in nct6775_probe()
3532 data->auto_pwm_num = 4; in nct6775_probe()
3533 data->temp_fixed_num = 3; in nct6775_probe()
3534 data->num_temp_alarms = 6; in nct6775_probe()
3535 data->num_temp_beeps = 6; in nct6775_probe()
3537 data->fan_from_reg = fan_from_reg13; in nct6775_probe()
3538 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3540 data->temp_label = nct6776_temp_label; in nct6775_probe()
3541 data->temp_mask = NCT6776_TEMP_MASK; in nct6775_probe()
3542 data->virt_temp_mask = NCT6776_VIRT_TEMP_MASK; in nct6775_probe()
3544 data->REG_VBAT = NCT6106_REG_VBAT; in nct6775_probe()
3545 data->REG_DIODE = NCT6106_REG_DIODE; in nct6775_probe()
3546 data->DIODE_MASK = NCT6106_DIODE_MASK; in nct6775_probe()
3547 data->REG_VIN = NCT6106_REG_IN; in nct6775_probe()
3548 data->REG_IN_MINMAX[0] = NCT6106_REG_IN_MIN; in nct6775_probe()
3549 data->REG_IN_MINMAX[1] = NCT6106_REG_IN_MAX; in nct6775_probe()
3550 data->REG_TARGET = NCT6106_REG_TARGET; in nct6775_probe()
3551 data->REG_FAN = NCT6106_REG_FAN; in nct6775_probe()
3552 data->REG_FAN_MODE = NCT6106_REG_FAN_MODE; in nct6775_probe()
3553 data->REG_FAN_MIN = NCT6106_REG_FAN_MIN; in nct6775_probe()
3554 data->REG_FAN_PULSES = NCT6106_REG_FAN_PULSES; in nct6775_probe()
3555 data->FAN_PULSE_SHIFT = NCT6106_FAN_PULSE_SHIFT; in nct6775_probe()
3556 data->REG_FAN_TIME[0] = NCT6106_REG_FAN_STOP_TIME; in nct6775_probe()
3557 data->REG_FAN_TIME[1] = NCT6106_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3558 data->REG_FAN_TIME[2] = NCT6106_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3559 data->REG_TOLERANCE_H = NCT6106_REG_TOLERANCE_H; in nct6775_probe()
3560 data->REG_PWM[0] = NCT6116_REG_PWM; in nct6775_probe()
3561 data->REG_PWM[1] = NCT6106_REG_FAN_START_OUTPUT; in nct6775_probe()
3562 data->REG_PWM[2] = NCT6106_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3563 data->REG_PWM[5] = NCT6106_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3564 data->REG_PWM[6] = NCT6106_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3565 data->REG_PWM_READ = NCT6106_REG_PWM_READ; in nct6775_probe()
3566 data->REG_PWM_MODE = NCT6106_REG_PWM_MODE; in nct6775_probe()
3567 data->PWM_MODE_MASK = NCT6106_PWM_MODE_MASK; in nct6775_probe()
3568 data->REG_AUTO_TEMP = NCT6106_REG_AUTO_TEMP; in nct6775_probe()
3569 data->REG_AUTO_PWM = NCT6106_REG_AUTO_PWM; in nct6775_probe()
3570 data->REG_CRITICAL_TEMP = NCT6106_REG_CRITICAL_TEMP; in nct6775_probe()
3571 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3573 data->REG_CRITICAL_PWM_ENABLE = NCT6106_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3574 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3576 data->REG_CRITICAL_PWM = NCT6106_REG_CRITICAL_PWM; in nct6775_probe()
3577 data->REG_TEMP_OFFSET = NCT6106_REG_TEMP_OFFSET; in nct6775_probe()
3578 data->REG_TEMP_SOURCE = NCT6106_REG_TEMP_SOURCE; in nct6775_probe()
3579 data->REG_TEMP_SEL = NCT6116_REG_TEMP_SEL; in nct6775_probe()
3580 data->REG_WEIGHT_TEMP_SEL = NCT6106_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3581 data->REG_WEIGHT_TEMP[0] = NCT6106_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3582 data->REG_WEIGHT_TEMP[1] = NCT6106_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3583 data->REG_WEIGHT_TEMP[2] = NCT6106_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3584 data->REG_ALARM = NCT6106_REG_ALARM; in nct6775_probe()
3585 data->ALARM_BITS = NCT6106_ALARM_BITS; in nct6775_probe()
3586 data->REG_BEEP = NCT6106_REG_BEEP; in nct6775_probe()
3587 data->BEEP_BITS = NCT6106_BEEP_BITS; in nct6775_probe()
3588 data->REG_TSI_TEMP = NCT6106_REG_TSI_TEMP; in nct6775_probe()
3606 data->in_num = 9; in nct6775_probe()
3607 data->pwm_num = 3; in nct6775_probe()
3608 data->auto_pwm_num = 4; in nct6775_probe()
3609 data->temp_fixed_num = 3; in nct6775_probe()
3610 data->num_temp_alarms = 3; in nct6775_probe()
3611 data->num_temp_beeps = 3; in nct6775_probe()
3613 data->fan_from_reg = fan_from_reg13; in nct6775_probe()
3614 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3616 data->temp_label = nct6776_temp_label; in nct6775_probe()
3617 data->temp_mask = NCT6776_TEMP_MASK; in nct6775_probe()
3618 data->virt_temp_mask = NCT6776_VIRT_TEMP_MASK; in nct6775_probe()
3620 data->REG_VBAT = NCT6106_REG_VBAT; in nct6775_probe()
3621 data->REG_DIODE = NCT6106_REG_DIODE; in nct6775_probe()
3622 data->DIODE_MASK = NCT6106_DIODE_MASK; in nct6775_probe()
3623 data->REG_VIN = NCT6106_REG_IN; in nct6775_probe()
3624 data->REG_IN_MINMAX[0] = NCT6106_REG_IN_MIN; in nct6775_probe()
3625 data->REG_IN_MINMAX[1] = NCT6106_REG_IN_MAX; in nct6775_probe()
3626 data->REG_TARGET = NCT6116_REG_TARGET; in nct6775_probe()
3627 data->REG_FAN = NCT6116_REG_FAN; in nct6775_probe()
3628 data->REG_FAN_MODE = NCT6116_REG_FAN_MODE; in nct6775_probe()
3629 data->REG_FAN_MIN = NCT6116_REG_FAN_MIN; in nct6775_probe()
3630 data->REG_FAN_PULSES = NCT6116_REG_FAN_PULSES; in nct6775_probe()
3631 data->FAN_PULSE_SHIFT = NCT6116_FAN_PULSE_SHIFT; in nct6775_probe()
3632 data->REG_FAN_TIME[0] = NCT6116_REG_FAN_STOP_TIME; in nct6775_probe()
3633 data->REG_FAN_TIME[1] = NCT6116_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3634 data->REG_FAN_TIME[2] = NCT6116_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3635 data->REG_TOLERANCE_H = NCT6116_REG_TOLERANCE_H; in nct6775_probe()
3636 data->REG_PWM[0] = NCT6116_REG_PWM; in nct6775_probe()
3637 data->REG_PWM[1] = NCT6116_REG_FAN_START_OUTPUT; in nct6775_probe()
3638 data->REG_PWM[2] = NCT6116_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3639 data->REG_PWM[5] = NCT6106_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3640 data->REG_PWM[6] = NCT6106_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3641 data->REG_PWM_READ = NCT6106_REG_PWM_READ; in nct6775_probe()
3642 data->REG_PWM_MODE = NCT6106_REG_PWM_MODE; in nct6775_probe()
3643 data->PWM_MODE_MASK = NCT6106_PWM_MODE_MASK; in nct6775_probe()
3644 data->REG_AUTO_TEMP = NCT6116_REG_AUTO_TEMP; in nct6775_probe()
3645 data->REG_AUTO_PWM = NCT6116_REG_AUTO_PWM; in nct6775_probe()
3646 data->REG_CRITICAL_TEMP = NCT6116_REG_CRITICAL_TEMP; in nct6775_probe()
3647 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3649 data->REG_CRITICAL_PWM_ENABLE = NCT6116_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3650 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3652 data->REG_CRITICAL_PWM = NCT6116_REG_CRITICAL_PWM; in nct6775_probe()
3653 data->REG_TEMP_OFFSET = NCT6106_REG_TEMP_OFFSET; in nct6775_probe()
3654 data->REG_TEMP_SOURCE = NCT6116_REG_TEMP_SOURCE; in nct6775_probe()
3655 data->REG_TEMP_SEL = NCT6116_REG_TEMP_SEL; in nct6775_probe()
3656 data->REG_WEIGHT_TEMP_SEL = NCT6106_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3657 data->REG_WEIGHT_TEMP[0] = NCT6106_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3658 data->REG_WEIGHT_TEMP[1] = NCT6106_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3659 data->REG_WEIGHT_TEMP[2] = NCT6106_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3660 data->REG_ALARM = NCT6106_REG_ALARM; in nct6775_probe()
3661 data->ALARM_BITS = NCT6116_ALARM_BITS; in nct6775_probe()
3662 data->REG_BEEP = NCT6106_REG_BEEP; in nct6775_probe()
3663 data->BEEP_BITS = NCT6116_BEEP_BITS; in nct6775_probe()
3664 data->REG_TSI_TEMP = NCT6116_REG_TSI_TEMP; in nct6775_probe()
3682 data->in_num = 9; in nct6775_probe()
3683 data->pwm_num = 3; in nct6775_probe()
3684 data->auto_pwm_num = 6; in nct6775_probe()
3685 data->has_fan_div = true; in nct6775_probe()
3686 data->temp_fixed_num = 3; in nct6775_probe()
3687 data->num_temp_alarms = 3; in nct6775_probe()
3688 data->num_temp_beeps = 3; in nct6775_probe()
3690 data->ALARM_BITS = NCT6775_ALARM_BITS; in nct6775_probe()
3691 data->BEEP_BITS = NCT6775_BEEP_BITS; in nct6775_probe()
3693 data->fan_from_reg = fan_from_reg16; in nct6775_probe()
3694 data->fan_from_reg_min = fan_from_reg8; in nct6775_probe()
3695 data->target_temp_mask = 0x7f; in nct6775_probe()
3696 data->tolerance_mask = 0x0f; in nct6775_probe()
3697 data->speed_tolerance_limit = 15; in nct6775_probe()
3699 data->temp_label = nct6775_temp_label; in nct6775_probe()
3700 data->temp_mask = NCT6775_TEMP_MASK; in nct6775_probe()
3701 data->virt_temp_mask = NCT6775_VIRT_TEMP_MASK; in nct6775_probe()
3703 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3704 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3705 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3706 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3707 data->REG_VIN = NCT6775_REG_IN; in nct6775_probe()
3708 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3709 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3710 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3711 data->REG_FAN = NCT6775_REG_FAN; in nct6775_probe()
3712 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3713 data->REG_FAN_MIN = NCT6775_REG_FAN_MIN; in nct6775_probe()
3714 data->REG_FAN_PULSES = NCT6775_REG_FAN_PULSES; in nct6775_probe()
3715 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3716 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3717 data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3718 data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3719 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3720 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3721 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3722 data->REG_PWM[3] = NCT6775_REG_FAN_MAX_OUTPUT; in nct6775_probe()
3723 data->REG_PWM[4] = NCT6775_REG_FAN_STEP_OUTPUT; in nct6775_probe()
3724 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3725 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3726 data->REG_PWM_MODE = NCT6775_REG_PWM_MODE; in nct6775_probe()
3727 data->PWM_MODE_MASK = NCT6775_PWM_MODE_MASK; in nct6775_probe()
3728 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3729 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3730 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3731 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3733 data->REG_TEMP_OFFSET = NCT6775_REG_TEMP_OFFSET; in nct6775_probe()
3734 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
3735 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
3736 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3737 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3738 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3739 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3740 data->REG_ALARM = NCT6775_REG_ALARM; in nct6775_probe()
3741 data->REG_BEEP = NCT6775_REG_BEEP; in nct6775_probe()
3742 data->REG_TSI_TEMP = NCT6775_REG_TSI_TEMP; in nct6775_probe()
3758 data->in_num = 9; in nct6775_probe()
3759 data->pwm_num = 3; in nct6775_probe()
3760 data->auto_pwm_num = 4; in nct6775_probe()
3761 data->has_fan_div = false; in nct6775_probe()
3762 data->temp_fixed_num = 3; in nct6775_probe()
3763 data->num_temp_alarms = 3; in nct6775_probe()
3764 data->num_temp_beeps = 6; in nct6775_probe()
3766 data->ALARM_BITS = NCT6776_ALARM_BITS; in nct6775_probe()
3767 data->BEEP_BITS = NCT6776_BEEP_BITS; in nct6775_probe()
3769 data->fan_from_reg = fan_from_reg13; in nct6775_probe()
3770 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3771 data->target_temp_mask = 0xff; in nct6775_probe()
3772 data->tolerance_mask = 0x07; in nct6775_probe()
3773 data->speed_tolerance_limit = 63; in nct6775_probe()
3775 data->temp_label = nct6776_temp_label; in nct6775_probe()
3776 data->temp_mask = NCT6776_TEMP_MASK; in nct6775_probe()
3777 data->virt_temp_mask = NCT6776_VIRT_TEMP_MASK; in nct6775_probe()
3779 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3780 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3781 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3782 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3783 data->REG_VIN = NCT6775_REG_IN; in nct6775_probe()
3784 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3785 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3786 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3787 data->REG_FAN = NCT6775_REG_FAN; in nct6775_probe()
3788 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3789 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
3790 data->REG_FAN_PULSES = NCT6776_REG_FAN_PULSES; in nct6775_probe()
3791 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3792 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3793 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3794 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3795 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
3796 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3797 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3798 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3799 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3800 data->REG_PWM[6] = NCT6776_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3801 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3802 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
3803 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
3804 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3805 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3806 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3807 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3809 data->REG_TEMP_OFFSET = NCT6775_REG_TEMP_OFFSET; in nct6775_probe()
3810 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
3811 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
3812 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3813 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3814 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3815 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3816 data->REG_ALARM = NCT6775_REG_ALARM; in nct6775_probe()
3817 data->REG_BEEP = NCT6776_REG_BEEP; in nct6775_probe()
3818 data->REG_TSI_TEMP = NCT6776_REG_TSI_TEMP; in nct6775_probe()
3834 data->in_num = 15; in nct6775_probe()
3835 data->pwm_num = 5; in nct6775_probe()
3836 data->auto_pwm_num = 4; in nct6775_probe()
3837 data->has_fan_div = false; in nct6775_probe()
3838 data->temp_fixed_num = 6; in nct6775_probe()
3839 data->num_temp_alarms = 2; in nct6775_probe()
3840 data->num_temp_beeps = 2; in nct6775_probe()
3842 data->ALARM_BITS = NCT6779_ALARM_BITS; in nct6775_probe()
3843 data->BEEP_BITS = NCT6779_BEEP_BITS; in nct6775_probe()
3845 data->fan_from_reg = fan_from_reg_rpm; in nct6775_probe()
3846 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3847 data->target_temp_mask = 0xff; in nct6775_probe()
3848 data->tolerance_mask = 0x07; in nct6775_probe()
3849 data->speed_tolerance_limit = 63; in nct6775_probe()
3851 data->temp_label = nct6779_temp_label; in nct6775_probe()
3852 data->temp_mask = NCT6779_TEMP_MASK; in nct6775_probe()
3853 data->virt_temp_mask = NCT6779_VIRT_TEMP_MASK; in nct6775_probe()
3855 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3856 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3857 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3858 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3859 data->REG_VIN = NCT6779_REG_IN; in nct6775_probe()
3860 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3861 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3862 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3863 data->REG_FAN = NCT6779_REG_FAN; in nct6775_probe()
3864 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3865 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
3866 data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; in nct6775_probe()
3867 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3868 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3869 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3870 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3871 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
3872 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3873 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3874 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3875 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3876 data->REG_PWM[6] = NCT6776_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3877 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3878 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
3879 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
3880 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3881 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3882 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3883 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3885 data->REG_CRITICAL_PWM_ENABLE = NCT6779_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3886 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
3888 data->REG_CRITICAL_PWM = NCT6779_REG_CRITICAL_PWM; in nct6775_probe()
3889 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; in nct6775_probe()
3890 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
3891 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
3892 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
3893 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
3894 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
3895 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
3896 data->REG_ALARM = NCT6779_REG_ALARM; in nct6775_probe()
3897 data->REG_BEEP = NCT6776_REG_BEEP; in nct6775_probe()
3898 data->REG_TSI_TEMP = NCT6776_REG_TSI_TEMP; in nct6775_probe()
3919 data->in_num = 15; in nct6775_probe()
3920 data->pwm_num = (data->kind == nct6796 || in nct6775_probe()
3921 data->kind == nct6797) ? 7 : 6; in nct6775_probe()
3922 data->auto_pwm_num = 4; in nct6775_probe()
3923 data->has_fan_div = false; in nct6775_probe()
3924 data->temp_fixed_num = 6; in nct6775_probe()
3925 data->num_temp_alarms = 2; in nct6775_probe()
3926 data->num_temp_beeps = 2; in nct6775_probe()
3928 data->ALARM_BITS = NCT6791_ALARM_BITS; in nct6775_probe()
3929 data->BEEP_BITS = NCT6779_BEEP_BITS; in nct6775_probe()
3931 data->fan_from_reg = fan_from_reg_rpm; in nct6775_probe()
3932 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
3933 data->target_temp_mask = 0xff; in nct6775_probe()
3934 data->tolerance_mask = 0x07; in nct6775_probe()
3935 data->speed_tolerance_limit = 63; in nct6775_probe()
3937 switch (data->kind) { in nct6775_probe()
3940 data->temp_label = nct6779_temp_label; in nct6775_probe()
3941 data->temp_mask = NCT6791_TEMP_MASK; in nct6775_probe()
3942 data->virt_temp_mask = NCT6791_VIRT_TEMP_MASK; in nct6775_probe()
3945 data->temp_label = nct6792_temp_label; in nct6775_probe()
3946 data->temp_mask = NCT6792_TEMP_MASK; in nct6775_probe()
3947 data->virt_temp_mask = NCT6792_VIRT_TEMP_MASK; in nct6775_probe()
3950 data->temp_label = nct6793_temp_label; in nct6775_probe()
3951 data->temp_mask = NCT6793_TEMP_MASK; in nct6775_probe()
3952 data->virt_temp_mask = NCT6793_VIRT_TEMP_MASK; in nct6775_probe()
3956 data->temp_label = nct6795_temp_label; in nct6775_probe()
3957 data->temp_mask = NCT6795_TEMP_MASK; in nct6775_probe()
3958 data->virt_temp_mask = NCT6795_VIRT_TEMP_MASK; in nct6775_probe()
3961 data->temp_label = nct6796_temp_label; in nct6775_probe()
3962 data->temp_mask = NCT6796_TEMP_MASK; in nct6775_probe()
3963 data->virt_temp_mask = NCT6796_VIRT_TEMP_MASK; in nct6775_probe()
3967 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
3968 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
3969 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
3970 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
3971 data->REG_VIN = NCT6779_REG_IN; in nct6775_probe()
3972 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
3973 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
3974 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
3975 data->REG_FAN = NCT6779_REG_FAN; in nct6775_probe()
3976 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
3977 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
3978 data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; in nct6775_probe()
3979 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
3980 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
3981 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
3982 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
3983 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
3984 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
3985 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
3986 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
3987 data->REG_PWM[5] = NCT6791_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
3988 data->REG_PWM[6] = NCT6791_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
3989 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
3990 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
3991 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
3992 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
3993 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
3994 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
3995 data->REG_CRITICAL_TEMP_TOLERANCE in nct6775_probe()
3997 data->REG_CRITICAL_PWM_ENABLE = NCT6779_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
3998 data->CRITICAL_PWM_ENABLE_MASK in nct6775_probe()
4000 data->REG_CRITICAL_PWM = NCT6779_REG_CRITICAL_PWM; in nct6775_probe()
4001 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; in nct6775_probe()
4002 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; in nct6775_probe()
4003 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
4004 data->REG_WEIGHT_TEMP_SEL = NCT6791_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
4005 data->REG_WEIGHT_TEMP[0] = NCT6791_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
4006 data->REG_WEIGHT_TEMP[1] = NCT6791_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
4007 data->REG_WEIGHT_TEMP[2] = NCT6791_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
4008 data->REG_ALARM = NCT6791_REG_ALARM; in nct6775_probe()
4009 if (data->kind == nct6791) in nct6775_probe()
4010 data->REG_BEEP = NCT6776_REG_BEEP; in nct6775_probe()
4012 data->REG_BEEP = NCT6792_REG_BEEP; in nct6775_probe()
4013 switch (data->kind) { in nct6775_probe()
4017 data->REG_TSI_TEMP = NCT6776_REG_TSI_TEMP; in nct6775_probe()
4023 data->REG_TSI_TEMP = NCT6796_REG_TSI_TEMP; in nct6775_probe()
4033 if (data->kind == nct6791) { in nct6775_probe()
4050 data->in_num = data->kind == nct6799 ? 18 : 15; in nct6775_probe()
4051 data->scale_in = scale_in_6798; in nct6775_probe()
4052 data->pwm_num = 7; in nct6775_probe()
4053 data->auto_pwm_num = 4; in nct6775_probe()
4054 data->has_fan_div = false; in nct6775_probe()
4055 data->temp_fixed_num = 6; in nct6775_probe()
4056 data->num_temp_alarms = 7; in nct6775_probe()
4057 data->num_temp_beeps = 8; in nct6775_probe()
4059 data->ALARM_BITS = NCT6799_ALARM_BITS; in nct6775_probe()
4060 data->BEEP_BITS = NCT6799_BEEP_BITS; in nct6775_probe()
4062 data->fan_from_reg = fan_from_reg_rpm; in nct6775_probe()
4063 data->fan_from_reg_min = fan_from_reg13; in nct6775_probe()
4064 data->target_temp_mask = 0xff; in nct6775_probe()
4065 data->tolerance_mask = 0x07; in nct6775_probe()
4066 data->speed_tolerance_limit = 63; in nct6775_probe()
4068 switch (data->kind) { in nct6775_probe()
4071 data->temp_label = nct6798_temp_label; in nct6775_probe()
4072 data->temp_mask = NCT6798_TEMP_MASK; in nct6775_probe()
4073 data->virt_temp_mask = NCT6798_VIRT_TEMP_MASK; in nct6775_probe()
4076 data->temp_label = nct6799_temp_label; in nct6775_probe()
4077 data->temp_mask = NCT6799_TEMP_MASK; in nct6775_probe()
4078 data->virt_temp_mask = NCT6799_VIRT_TEMP_MASK; in nct6775_probe()
4082 data->REG_CONFIG = NCT6775_REG_CONFIG; in nct6775_probe()
4083 data->REG_VBAT = NCT6775_REG_VBAT; in nct6775_probe()
4084 data->REG_DIODE = NCT6775_REG_DIODE; in nct6775_probe()
4085 data->DIODE_MASK = NCT6775_DIODE_MASK; in nct6775_probe()
4086 data->REG_VIN = NCT6779_REG_IN; in nct6775_probe()
4087 data->REG_IN_MINMAX[0] = NCT6775_REG_IN_MIN; in nct6775_probe()
4088 data->REG_IN_MINMAX[1] = NCT6775_REG_IN_MAX; in nct6775_probe()
4089 data->REG_TARGET = NCT6775_REG_TARGET; in nct6775_probe()
4090 data->REG_FAN = NCT6779_REG_FAN; in nct6775_probe()
4091 data->REG_FAN_MODE = NCT6775_REG_FAN_MODE; in nct6775_probe()
4092 data->REG_FAN_MIN = NCT6776_REG_FAN_MIN; in nct6775_probe()
4093 data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; in nct6775_probe()
4094 data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; in nct6775_probe()
4095 data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; in nct6775_probe()
4096 data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; in nct6775_probe()
4097 data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; in nct6775_probe()
4098 data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; in nct6775_probe()
4099 data->REG_PWM[0] = NCT6775_REG_PWM; in nct6775_probe()
4100 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; in nct6775_probe()
4101 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; in nct6775_probe()
4102 data->REG_PWM[5] = NCT6791_REG_WEIGHT_DUTY_STEP; in nct6775_probe()
4103 data->REG_PWM[6] = NCT6791_REG_WEIGHT_DUTY_BASE; in nct6775_probe()
4104 data->REG_PWM_READ = NCT6775_REG_PWM_READ; in nct6775_probe()
4105 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; in nct6775_probe()
4106 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; in nct6775_probe()
4107 data->REG_AUTO_TEMP = NCT6775_REG_AUTO_TEMP; in nct6775_probe()
4108 data->REG_AUTO_PWM = NCT6775_REG_AUTO_PWM; in nct6775_probe()
4109 data->REG_CRITICAL_TEMP = NCT6775_REG_CRITICAL_TEMP; in nct6775_probe()
4110 data->REG_CRITICAL_TEMP_TOLERANCE = NCT6775_REG_CRITICAL_TEMP_TOLERANCE; in nct6775_probe()
4111 data->REG_CRITICAL_PWM_ENABLE = NCT6779_REG_CRITICAL_PWM_ENABLE; in nct6775_probe()
4112 data->CRITICAL_PWM_ENABLE_MASK = NCT6779_CRITICAL_PWM_ENABLE_MASK; in nct6775_probe()
4113 data->REG_CRITICAL_PWM = NCT6779_REG_CRITICAL_PWM; in nct6775_probe()
4114 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; in nct6775_probe()
4115 data->REG_TEMP_SOURCE = NCT6798_REG_TEMP_SOURCE; in nct6775_probe()
4116 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; in nct6775_probe()
4117 data->REG_WEIGHT_TEMP_SEL = NCT6791_REG_WEIGHT_TEMP_SEL; in nct6775_probe()
4118 data->REG_WEIGHT_TEMP[0] = NCT6791_REG_WEIGHT_TEMP_STEP; in nct6775_probe()
4119 data->REG_WEIGHT_TEMP[1] = NCT6791_REG_WEIGHT_TEMP_STEP_TOL; in nct6775_probe()
4120 data->REG_WEIGHT_TEMP[2] = NCT6791_REG_WEIGHT_TEMP_BASE; in nct6775_probe()
4121 data->REG_ALARM = NCT6799_REG_ALARM; in nct6775_probe()
4122 data->REG_BEEP = NCT6792_REG_BEEP; in nct6775_probe()
4123 data->REG_TSI_TEMP = NCT6796_REG_TSI_TEMP; in nct6775_probe()
4141 data->have_in = BIT(data->in_num) - 1; in nct6775_probe()
4142 data->have_temp = 0; in nct6775_probe()
4158 err = nct6775_read_value(data, data->REG_TEMP_SOURCE[i], &src); in nct6775_probe()
4172 err = add_temp_sensors(data, data->REG_TEMP_SEL, &available, &mask); in nct6775_probe()
4175 err = add_temp_sensors(data, data->REG_WEIGHT_TEMP_SEL, &available, &mask); in nct6775_probe()
4185 err = nct6775_read_value(data, data->REG_TEMP_SOURCE[i], &src); in nct6775_probe()
4192 if (!(data->temp_mask & BIT(src))) { in nct6775_probe()
4195 src, i, data->REG_TEMP_SOURCE[i], reg_temp[i]); in nct6775_probe()
4202 if (src <= data->temp_fixed_num) { in nct6775_probe()
4203 data->have_temp |= BIT(src - 1); in nct6775_probe()
4204 data->have_temp_fixed |= BIT(src - 1); in nct6775_probe()
4205 data->reg_temp[0][src - 1] = reg_temp[i]; in nct6775_probe()
4206 data->reg_temp[1][src - 1] = reg_temp_over[i]; in nct6775_probe()
4207 data->reg_temp[2][src - 1] = reg_temp_hyst[i]; in nct6775_probe()
4209 data->reg_temp[3][src - 1] = reg_temp_crit_h[i]; in nct6775_probe()
4211 data->reg_temp[3][src - 1] in nct6775_probe()
4214 data->reg_temp[4][src - 1] = reg_temp_crit_l[i]; in nct6775_probe()
4216 data->reg_temp_config[src - 1] = reg_temp_config[i]; in nct6775_probe()
4217 data->temp_src[src - 1] = src; in nct6775_probe()
4225 data->have_temp |= BIT(s); in nct6775_probe()
4226 data->reg_temp[0][s] = reg_temp[i]; in nct6775_probe()
4227 data->reg_temp[1][s] = reg_temp_over[i]; in nct6775_probe()
4228 data->reg_temp[2][s] = reg_temp_hyst[i]; in nct6775_probe()
4230 data->reg_temp_config[s] = reg_temp_config[i]; in nct6775_probe()
4232 data->reg_temp[3][s] = reg_temp_crit_h[i]; in nct6775_probe()
4234 data->reg_temp[3][s] = reg_temp_crit[src - 1]; in nct6775_probe()
4236 data->reg_temp[4][s] = reg_temp_crit_l[i]; in nct6775_probe()
4238 data->temp_src[s] = src; in nct6775_probe()
4250 err = nct6775_read_value(data, data->REG_TEMP_SEL[i], &src); in nct6775_probe()
4257 if (!(data->temp_mask & BIT(src))) { in nct6775_probe()
4260 src, i, data->REG_TEMP_SEL[i], in nct6775_probe()
4270 if (!(data->virt_temp_mask & BIT(src))) { in nct6775_probe()
4277 if (src <= data->temp_fixed_num) { in nct6775_probe()
4278 if (data->have_temp & BIT(src - 1)) in nct6775_probe()
4280 data->have_temp |= BIT(src - 1); in nct6775_probe()
4281 data->have_temp_fixed |= BIT(src - 1); in nct6775_probe()
4282 data->reg_temp[0][src - 1] = reg_temp_mon[i]; in nct6775_probe()
4283 data->temp_src[src - 1] = src; in nct6775_probe()
4291 data->have_temp |= BIT(s); in nct6775_probe()
4292 data->reg_temp[0][s] = reg_temp_mon[i]; in nct6775_probe()
4293 data->temp_src[s] = src; in nct6775_probe()
4305 if (!(data->temp_mask & BIT(i + 1))) in nct6775_probe()
4311 if (i < data->temp_fixed_num) { in nct6775_probe()
4312 if (data->have_temp & BIT(i)) in nct6775_probe()
4314 data->have_temp |= BIT(i); in nct6775_probe()
4315 data->have_temp_fixed |= BIT(i); in nct6775_probe()
4316 data->reg_temp[0][i] = reg_temp_alternate[i]; in nct6775_probe()
4318 data->reg_temp[1][i] = reg_temp_over[i]; in nct6775_probe()
4319 data->reg_temp[2][i] = reg_temp_hyst[i]; in nct6775_probe()
4321 data->temp_src[i] = i + 1; in nct6775_probe()
4328 data->have_temp |= BIT(s); in nct6775_probe()
4329 data->reg_temp[0][s] = reg_temp_alternate[i]; in nct6775_probe()
4330 data->temp_src[s] = i + 1; in nct6775_probe()
4339 err = nct6775_read_value(data, data->REG_TSI_TEMP[i], &tmp); in nct6775_probe()
4343 data->have_tsi_temp |= BIT(i); in nct6775_probe()
4347 err = nct6775_init_device(data); in nct6775_probe()
4351 if (data->driver_init) { in nct6775_probe()
4352 err = data->driver_init(data); in nct6775_probe()
4358 err = nct6775_init_fan_common(dev, data); in nct6775_probe()
4363 err = nct6775_add_template_attr_group(dev, data, &nct6775_pwm_template_group, in nct6775_probe()
4364 data->pwm_num); in nct6775_probe()
4368 err = nct6775_add_template_attr_group(dev, data, &nct6775_in_template_group, in nct6775_probe()
4369 fls(data->have_in)); in nct6775_probe()
4373 err = nct6775_add_template_attr_group(dev, data, &nct6775_fan_template_group, in nct6775_probe()
4374 fls(data->has_fan)); in nct6775_probe()
4378 err = nct6775_add_template_attr_group(dev, data, &nct6775_temp_template_group, in nct6775_probe()
4379 fls(data->have_temp)); in nct6775_probe()
4383 if (data->have_tsi_temp) { in nct6775_probe()
4386 tsi_temp_tg.base = fls(data->have_temp) + 1; in nct6775_probe()
4387 err = nct6775_add_template_attr_group(dev, data, &tsi_temp_tg, in nct6775_probe()
4388 fls(data->have_tsi_temp)); in nct6775_probe()
4393 hwmon_dev = devm_hwmon_device_register_with_groups(dev, data->name, in nct6775_probe()
4394 data, data->groups); in nct6775_probe()