Lines Matching refs:data
392 static inline void w83627ehf_set_bank(struct w83627ehf_data *data, u16 reg) in w83627ehf_set_bank() argument
395 if (data->bank != bank) { in w83627ehf_set_bank()
396 outb_p(W83627EHF_REG_BANK, data->addr + ADDR_REG_OFFSET); in w83627ehf_set_bank()
397 outb_p(bank, data->addr + DATA_REG_OFFSET); in w83627ehf_set_bank()
398 data->bank = bank; in w83627ehf_set_bank()
402 static u16 w83627ehf_read_value(struct w83627ehf_data *data, u16 reg) in w83627ehf_read_value() argument
406 mutex_lock(&data->lock); in w83627ehf_read_value()
408 w83627ehf_set_bank(data, reg); in w83627ehf_read_value()
409 outb_p(reg & 0xff, data->addr + ADDR_REG_OFFSET); in w83627ehf_read_value()
410 res = inb_p(data->addr + DATA_REG_OFFSET); in w83627ehf_read_value()
413 data->addr + ADDR_REG_OFFSET); in w83627ehf_read_value()
414 res = (res << 8) + inb_p(data->addr + DATA_REG_OFFSET); in w83627ehf_read_value()
417 mutex_unlock(&data->lock); in w83627ehf_read_value()
421 static int w83627ehf_write_value(struct w83627ehf_data *data, u16 reg, in w83627ehf_write_value() argument
426 mutex_lock(&data->lock); in w83627ehf_write_value()
428 w83627ehf_set_bank(data, reg); in w83627ehf_write_value()
429 outb_p(reg & 0xff, data->addr + ADDR_REG_OFFSET); in w83627ehf_write_value()
431 outb_p(value >> 8, data->addr + DATA_REG_OFFSET); in w83627ehf_write_value()
433 data->addr + ADDR_REG_OFFSET); in w83627ehf_write_value()
435 outb_p(value & 0xff, data->addr + DATA_REG_OFFSET); in w83627ehf_write_value()
437 mutex_unlock(&data->lock); in w83627ehf_write_value()
442 static u16 w83627ehf_read_temp(struct w83627ehf_data *data, u16 reg) in w83627ehf_read_temp() argument
446 res = w83627ehf_read_value(data, reg); in w83627ehf_read_temp()
453 static int w83627ehf_write_temp(struct w83627ehf_data *data, u16 reg, in w83627ehf_write_temp() argument
458 return w83627ehf_write_value(data, reg, value); in w83627ehf_write_temp()
462 static void w83627ehf_write_fan_div(struct w83627ehf_data *data, int nr) in w83627ehf_write_fan_div() argument
468 reg = (w83627ehf_read_value(data, W83627EHF_REG_FANDIV1) & 0xcf) in w83627ehf_write_fan_div()
469 | ((data->fan_div[0] & 0x03) << 4); in w83627ehf_write_fan_div()
471 reg |= (data->has_fan & (1 << 4)) ? 1 : 0; in w83627ehf_write_fan_div()
472 w83627ehf_write_value(data, W83627EHF_REG_FANDIV1, reg); in w83627ehf_write_fan_div()
473 reg = (w83627ehf_read_value(data, W83627EHF_REG_VBAT) & 0xdf) in w83627ehf_write_fan_div()
474 | ((data->fan_div[0] & 0x04) << 3); in w83627ehf_write_fan_div()
475 w83627ehf_write_value(data, W83627EHF_REG_VBAT, reg); in w83627ehf_write_fan_div()
478 reg = (w83627ehf_read_value(data, W83627EHF_REG_FANDIV1) & 0x3f) in w83627ehf_write_fan_div()
479 | ((data->fan_div[1] & 0x03) << 6); in w83627ehf_write_fan_div()
481 reg |= (data->has_fan & (1 << 4)) ? 1 : 0; in w83627ehf_write_fan_div()
482 w83627ehf_write_value(data, W83627EHF_REG_FANDIV1, reg); in w83627ehf_write_fan_div()
483 reg = (w83627ehf_read_value(data, W83627EHF_REG_VBAT) & 0xbf) in w83627ehf_write_fan_div()
484 | ((data->fan_div[1] & 0x04) << 4); in w83627ehf_write_fan_div()
485 w83627ehf_write_value(data, W83627EHF_REG_VBAT, reg); in w83627ehf_write_fan_div()
488 reg = (w83627ehf_read_value(data, W83627EHF_REG_FANDIV2) & 0x3f) in w83627ehf_write_fan_div()
489 | ((data->fan_div[2] & 0x03) << 6); in w83627ehf_write_fan_div()
490 w83627ehf_write_value(data, W83627EHF_REG_FANDIV2, reg); in w83627ehf_write_fan_div()
491 reg = (w83627ehf_read_value(data, W83627EHF_REG_VBAT) & 0x7f) in w83627ehf_write_fan_div()
492 | ((data->fan_div[2] & 0x04) << 5); in w83627ehf_write_fan_div()
493 w83627ehf_write_value(data, W83627EHF_REG_VBAT, reg); in w83627ehf_write_fan_div()
496 reg = (w83627ehf_read_value(data, W83627EHF_REG_DIODE) & 0xfc) in w83627ehf_write_fan_div()
497 | (data->fan_div[3] & 0x03); in w83627ehf_write_fan_div()
498 w83627ehf_write_value(data, W83627EHF_REG_DIODE, reg); in w83627ehf_write_fan_div()
499 reg = (w83627ehf_read_value(data, W83627EHF_REG_SMI_OVT) & 0x7f) in w83627ehf_write_fan_div()
500 | ((data->fan_div[3] & 0x04) << 5); in w83627ehf_write_fan_div()
501 w83627ehf_write_value(data, W83627EHF_REG_SMI_OVT, reg); in w83627ehf_write_fan_div()
504 reg = (w83627ehf_read_value(data, W83627EHF_REG_DIODE) & 0x73) in w83627ehf_write_fan_div()
505 | ((data->fan_div[4] & 0x03) << 2) in w83627ehf_write_fan_div()
506 | ((data->fan_div[4] & 0x04) << 5); in w83627ehf_write_fan_div()
507 w83627ehf_write_value(data, W83627EHF_REG_DIODE, reg); in w83627ehf_write_fan_div()
512 static void w83627ehf_update_fan_div(struct w83627ehf_data *data) in w83627ehf_update_fan_div() argument
516 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV1); in w83627ehf_update_fan_div()
517 data->fan_div[0] = (i >> 4) & 0x03; in w83627ehf_update_fan_div()
518 data->fan_div[1] = (i >> 6) & 0x03; in w83627ehf_update_fan_div()
519 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV2); in w83627ehf_update_fan_div()
520 data->fan_div[2] = (i >> 6) & 0x03; in w83627ehf_update_fan_div()
521 i = w83627ehf_read_value(data, W83627EHF_REG_VBAT); in w83627ehf_update_fan_div()
522 data->fan_div[0] |= (i >> 3) & 0x04; in w83627ehf_update_fan_div()
523 data->fan_div[1] |= (i >> 4) & 0x04; in w83627ehf_update_fan_div()
524 data->fan_div[2] |= (i >> 5) & 0x04; in w83627ehf_update_fan_div()
525 if (data->has_fan & ((1 << 3) | (1 << 4))) { in w83627ehf_update_fan_div()
526 i = w83627ehf_read_value(data, W83627EHF_REG_DIODE); in w83627ehf_update_fan_div()
527 data->fan_div[3] = i & 0x03; in w83627ehf_update_fan_div()
528 data->fan_div[4] = ((i >> 2) & 0x03) in w83627ehf_update_fan_div()
531 if (data->has_fan & (1 << 3)) { in w83627ehf_update_fan_div()
532 i = w83627ehf_read_value(data, W83627EHF_REG_SMI_OVT); in w83627ehf_update_fan_div()
533 data->fan_div[3] |= (i >> 5) & 0x04; in w83627ehf_update_fan_div()
537 static void w83627ehf_update_pwm(struct w83627ehf_data *data) in w83627ehf_update_pwm() argument
542 for (i = 0; i < data->pwm_num; i++) { in w83627ehf_update_pwm()
543 if (!(data->has_fan & (1 << i))) in w83627ehf_update_pwm()
548 pwmcfg = w83627ehf_read_value(data, in w83627ehf_update_pwm()
550 tolerance = w83627ehf_read_value(data, in w83627ehf_update_pwm()
553 data->pwm_mode[i] = in w83627ehf_update_pwm()
555 data->pwm_enable[i] = ((pwmcfg >> W83627EHF_PWM_ENABLE_SHIFT[i]) in w83627ehf_update_pwm()
557 data->pwm[i] = w83627ehf_read_value(data, W83627EHF_REG_PWM[i]); in w83627ehf_update_pwm()
559 data->tolerance[i] = (tolerance >> (i == 1 ? 4 : 0)) & 0x0f; in w83627ehf_update_pwm()
565 struct w83627ehf_data *data = dev_get_drvdata(dev); in w83627ehf_update_device() local
568 mutex_lock(&data->update_lock); in w83627ehf_update_device()
570 if (time_after(jiffies, data->last_updated + HZ + HZ/2) in w83627ehf_update_device()
571 || !data->valid) { in w83627ehf_update_device()
573 w83627ehf_update_fan_div(data); in w83627ehf_update_device()
576 for (i = 0; i < data->in_num; i++) { in w83627ehf_update_device()
577 if ((i == 6) && data->in6_skip) in w83627ehf_update_device()
580 data->in[i] = w83627ehf_read_value(data, in w83627ehf_update_device()
582 data->in_min[i] = w83627ehf_read_value(data, in w83627ehf_update_device()
584 data->in_max[i] = w83627ehf_read_value(data, in w83627ehf_update_device()
592 if (!(data->has_fan & (1 << i))) in w83627ehf_update_device()
595 reg = w83627ehf_read_value(data, W83627EHF_REG_FAN[i]); in w83627ehf_update_device()
596 data->rpm[i] = fan_from_reg8(reg, data->fan_div[i]); in w83627ehf_update_device()
598 if (data->has_fan_min & (1 << i)) in w83627ehf_update_device()
599 data->fan_min[i] = w83627ehf_read_value(data, in w83627ehf_update_device()
607 if (reg >= 0xff && data->fan_div[i] < 0x07) { in w83627ehf_update_device()
610 i + 1, div_from_reg(data->fan_div[i]), in w83627ehf_update_device()
611 div_from_reg(data->fan_div[i] + 1)); in w83627ehf_update_device()
612 data->fan_div[i]++; in w83627ehf_update_device()
613 w83627ehf_write_fan_div(data, i); in w83627ehf_update_device()
615 if ((data->has_fan_min & (1 << i)) in w83627ehf_update_device()
616 && data->fan_min[i] >= 2 in w83627ehf_update_device()
617 && data->fan_min[i] != 255) in w83627ehf_update_device()
618 w83627ehf_write_value(data, in w83627ehf_update_device()
620 (data->fan_min[i] /= 2)); in w83627ehf_update_device()
624 w83627ehf_update_pwm(data); in w83627ehf_update_device()
626 for (i = 0; i < data->pwm_num; i++) { in w83627ehf_update_device()
627 if (!(data->has_fan & (1 << i))) in w83627ehf_update_device()
630 data->fan_start_output[i] = in w83627ehf_update_device()
631 w83627ehf_read_value(data, in w83627ehf_update_device()
633 data->fan_stop_output[i] = in w83627ehf_update_device()
634 w83627ehf_read_value(data, in w83627ehf_update_device()
636 data->fan_stop_time[i] = in w83627ehf_update_device()
637 w83627ehf_read_value(data, in w83627ehf_update_device()
640 if (data->REG_FAN_MAX_OUTPUT && in w83627ehf_update_device()
641 data->REG_FAN_MAX_OUTPUT[i] != 0xff) in w83627ehf_update_device()
642 data->fan_max_output[i] = in w83627ehf_update_device()
643 w83627ehf_read_value(data, in w83627ehf_update_device()
644 data->REG_FAN_MAX_OUTPUT[i]); in w83627ehf_update_device()
646 if (data->REG_FAN_STEP_OUTPUT && in w83627ehf_update_device()
647 data->REG_FAN_STEP_OUTPUT[i] != 0xff) in w83627ehf_update_device()
648 data->fan_step_output[i] = in w83627ehf_update_device()
649 w83627ehf_read_value(data, in w83627ehf_update_device()
650 data->REG_FAN_STEP_OUTPUT[i]); in w83627ehf_update_device()
652 data->target_temp[i] = in w83627ehf_update_device()
653 w83627ehf_read_value(data, in w83627ehf_update_device()
655 (data->pwm_mode[i] == 1 ? 0x7f : 0xff); in w83627ehf_update_device()
660 if (!(data->have_temp & (1 << i))) in w83627ehf_update_device()
662 data->temp[i] = w83627ehf_read_temp(data, in w83627ehf_update_device()
663 data->reg_temp[i]); in w83627ehf_update_device()
664 if (data->reg_temp_over[i]) in w83627ehf_update_device()
665 data->temp_max[i] in w83627ehf_update_device()
666 = w83627ehf_read_temp(data, in w83627ehf_update_device()
667 data->reg_temp_over[i]); in w83627ehf_update_device()
668 if (data->reg_temp_hyst[i]) in w83627ehf_update_device()
669 data->temp_max_hyst[i] in w83627ehf_update_device()
670 = w83627ehf_read_temp(data, in w83627ehf_update_device()
671 data->reg_temp_hyst[i]); in w83627ehf_update_device()
674 if (data->have_temp_offset & (1 << i)) in w83627ehf_update_device()
675 data->temp_offset[i] in w83627ehf_update_device()
676 = w83627ehf_read_value(data, in w83627ehf_update_device()
680 data->alarms = w83627ehf_read_value(data, in w83627ehf_update_device()
682 (w83627ehf_read_value(data, in w83627ehf_update_device()
684 (w83627ehf_read_value(data, in w83627ehf_update_device()
687 data->caseopen = w83627ehf_read_value(data, in w83627ehf_update_device()
690 data->last_updated = jiffies; in w83627ehf_update_device()
691 data->valid = true; in w83627ehf_update_device()
694 mutex_unlock(&data->update_lock); in w83627ehf_update_device()
695 return data; in w83627ehf_update_device()
700 store_in_##reg(struct device *dev, struct w83627ehf_data *data, int channel, \
705 mutex_lock(&data->update_lock); \
706 data->in_##reg[channel] = in_to_reg(val, channel, data->scale_in); \
707 w83627ehf_write_value(data, W83627EHF_REG_IN_##REG(channel), \
708 data->in_##reg[channel]); \
709 mutex_unlock(&data->update_lock); \
717 store_fan_min(struct device *dev, struct w83627ehf_data *data, int channel, in store_in_reg()
726 mutex_lock(&data->update_lock); in store_in_reg()
729 data->fan_min[channel] = 255; in store_in_reg()
730 new_div = data->fan_div[channel]; /* No change */ in store_in_reg()
738 data->fan_min[channel] = 254; in store_in_reg()
748 data->fan_min[channel] = 1; in store_in_reg()
764 data->fan_min[channel] = reg; in store_in_reg()
771 if (new_div != data->fan_div[channel]) { in store_in_reg()
773 channel + 1, div_from_reg(data->fan_div[channel]), in store_in_reg()
775 data->fan_div[channel] = new_div; in store_in_reg()
776 w83627ehf_write_fan_div(data, channel); in store_in_reg()
778 data->last_updated = jiffies; in store_in_reg()
781 w83627ehf_write_value(data, W83627EHF_REG_FAN_MIN[channel], in store_in_reg()
782 data->fan_min[channel]); in store_in_reg()
783 mutex_unlock(&data->update_lock); in store_in_reg()
790 store_##reg(struct device *dev, struct w83627ehf_data *data, int channel, \
793 mutex_lock(&data->update_lock); \
794 data->reg[channel] = LM75_TEMP_TO_REG(val); \
795 w83627ehf_write_temp(data, data->addr[channel], data->reg[channel]); \
796 mutex_unlock(&data->update_lock); \
803 store_temp_offset(struct device *dev, struct w83627ehf_data *data, int channel, in store_temp_offset() argument
808 mutex_lock(&data->update_lock); in store_temp_offset()
809 data->temp_offset[channel] = val; in store_temp_offset()
810 w83627ehf_write_value(data, W83627EHF_REG_TEMP_OFFSET[channel], val); in store_temp_offset()
811 mutex_unlock(&data->update_lock); in store_temp_offset()
816 store_pwm_mode(struct device *dev, struct w83627ehf_data *data, int channel, in store_pwm_mode() argument
824 mutex_lock(&data->update_lock); in store_pwm_mode()
825 reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[channel]); in store_pwm_mode()
826 data->pwm_mode[channel] = val; in store_pwm_mode()
830 w83627ehf_write_value(data, W83627EHF_REG_PWM_ENABLE[channel], reg); in store_pwm_mode()
831 mutex_unlock(&data->update_lock); in store_pwm_mode()
836 store_pwm(struct device *dev, struct w83627ehf_data *data, int channel, in store_pwm() argument
841 mutex_lock(&data->update_lock); in store_pwm()
842 data->pwm[channel] = val; in store_pwm()
843 w83627ehf_write_value(data, W83627EHF_REG_PWM[channel], val); in store_pwm()
844 mutex_unlock(&data->update_lock); in store_pwm()
849 store_pwm_enable(struct device *dev, struct w83627ehf_data *data, int channel, in store_pwm_enable() argument
855 (val > 4 && val != data->pwm_enable_orig[channel])) in store_pwm_enable()
858 mutex_lock(&data->update_lock); in store_pwm_enable()
859 data->pwm_enable[channel] = val; in store_pwm_enable()
860 reg = w83627ehf_read_value(data, in store_pwm_enable()
864 w83627ehf_write_value(data, W83627EHF_REG_PWM_ENABLE[channel], in store_pwm_enable()
866 mutex_unlock(&data->update_lock); in store_pwm_enable()
874 struct w83627ehf_data *data = w83627ehf_update_device(dev->parent); \
878 return sprintf(buf, "%d\n", data->reg[nr] * 1000); \
888 struct w83627ehf_data *data = dev_get_drvdata(dev); in show_tol_temp() local
900 mutex_lock(&data->update_lock); in show_tol_temp()
901 data->target_temp[nr] = val; in show_tol_temp()
902 w83627ehf_write_value(data, W83627EHF_REG_TARGET[nr], val); in show_tol_temp()
903 mutex_unlock(&data->update_lock); in show_tol_temp()
911 struct w83627ehf_data *data = dev_get_drvdata(dev); in store_tolerance() local
925 mutex_lock(&data->update_lock); in store_tolerance()
926 reg = w83627ehf_read_value(data, W83627EHF_REG_TOLERANCE[nr]); in store_tolerance()
931 w83627ehf_write_value(data, W83627EHF_REG_TOLERANCE[nr], reg); in store_tolerance()
932 data->tolerance[nr] = val; in store_tolerance()
933 mutex_unlock(&data->update_lock); in store_tolerance()
961 struct w83627ehf_data *data = w83627ehf_update_device(dev->parent); \
965 return sprintf(buf, "%d\n", data->reg[nr]); \
971 struct w83627ehf_data *data = dev_get_drvdata(dev); \
981 mutex_lock(&data->update_lock); \
982 data->reg[nr] = val; \
983 w83627ehf_write_value(data, REG[nr], val); \
984 mutex_unlock(&data->update_lock); \
990 fan_functions(fan_max_output, data->REG_FAN_MAX_OUTPUT)
991 fan_functions(fan_step_output, data->REG_FAN_STEP_OUTPUT)
997 struct w83627ehf_data *data = w83627ehf_update_device(dev->parent); \
1002 step_time_from_reg(data->reg[nr], \
1003 data->pwm_mode[nr])); \
1010 struct w83627ehf_data *data = dev_get_drvdata(dev); \
1019 val = step_time_to_reg(val, data->pwm_mode[nr]); \
1020 mutex_lock(&data->update_lock); \
1021 data->reg[nr] = val; \
1022 w83627ehf_write_value(data, REG[nr], val); \
1023 mutex_unlock(&data->update_lock); \
1081 struct w83627ehf_data *data = dev_get_drvdata(dev); in cpu0_vid_show() local
1082 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); in cpu0_vid_show()
1089 clear_caseopen(struct device *dev, struct w83627ehf_data *data, int channel, in clear_caseopen() argument
1098 mutex_lock(&data->update_lock); in clear_caseopen()
1099 reg = w83627ehf_read_value(data, W83627EHF_REG_CASEOPEN_CLR); in clear_caseopen()
1100 w83627ehf_write_value(data, W83627EHF_REG_CASEOPEN_CLR, reg | mask); in clear_caseopen()
1101 w83627ehf_write_value(data, W83627EHF_REG_CASEOPEN_CLR, reg & ~mask); in clear_caseopen()
1102 data->valid = false; /* Force cache refresh */ in clear_caseopen()
1103 mutex_unlock(&data->update_lock); in clear_caseopen()
1112 struct w83627ehf_data *data = dev_get_drvdata(dev); in w83627ehf_attrs_visible() local
1119 if (devattr->show == cpu0_vid_show && data->have_vid) in w83627ehf_attrs_visible()
1133 data->REG_FAN_STEP_OUTPUT && in w83627ehf_attrs_visible()
1134 data->REG_FAN_STEP_OUTPUT[sda->index] != 0xff) in w83627ehf_attrs_visible()
1139 (data->has_fan & (1 << 2)) && data->pwm_num >= 3 && in w83627ehf_attrs_visible()
1146 (data->has_fan & (1 << 3)) && data->pwm_num >= 4 && in w83627ehf_attrs_visible()
1156 (data->has_fan & (1 << sda->index)) && in w83627ehf_attrs_visible()
1157 sda->index < data->pwm_num) in w83627ehf_attrs_visible()
1217 static inline void w83627ehf_init_device(struct w83627ehf_data *data, in w83627ehf_init_device() argument
1224 tmp = w83627ehf_read_value(data, W83627EHF_REG_CONFIG); in w83627ehf_init_device()
1226 w83627ehf_write_value(data, W83627EHF_REG_CONFIG, in w83627ehf_init_device()
1231 if (!(data->have_temp & (1 << i))) in w83627ehf_init_device()
1233 if (!data->reg_temp_config[i]) in w83627ehf_init_device()
1235 tmp = w83627ehf_read_value(data, in w83627ehf_init_device()
1236 data->reg_temp_config[i]); in w83627ehf_init_device()
1238 w83627ehf_write_value(data, in w83627ehf_init_device()
1239 data->reg_temp_config[i], in w83627ehf_init_device()
1244 tmp = w83627ehf_read_value(data, W83627EHF_REG_VBAT); in w83627ehf_init_device()
1246 w83627ehf_write_value(data, W83627EHF_REG_VBAT, tmp | 0x01); in w83627ehf_init_device()
1251 diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE); in w83627ehf_init_device()
1262 if (data->temp_label) in w83627ehf_init_device()
1263 label = data->temp_label[data->temp_src[i]]; in w83627ehf_init_device()
1267 data->temp_type[i] = 6; in w83627ehf_init_device()
1269 data->temp_type[i] = 5; in w83627ehf_init_device()
1271 data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3; in w83627ehf_init_device()
1273 data->temp_type[i] = 4; /* thermistor */ in w83627ehf_init_device()
1278 w83627ehf_set_temp_reg_ehf(struct w83627ehf_data *data, int n_temp) in w83627ehf_set_temp_reg_ehf() argument
1283 data->reg_temp[i] = W83627EHF_REG_TEMP[i]; in w83627ehf_set_temp_reg_ehf()
1284 data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i]; in w83627ehf_set_temp_reg_ehf()
1285 data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i]; in w83627ehf_set_temp_reg_ehf()
1286 data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i]; in w83627ehf_set_temp_reg_ehf()
1292 struct w83627ehf_data *data) in w83627ehf_check_fan_inputs() argument
1298 data->has_fan = 0x03; /* fan1 and fan2 */ in w83627ehf_check_fan_inputs()
1299 data->has_fan_min = 0x03; in w83627ehf_check_fan_inputs()
1314 data->has_fan = data->has_fan_min = 0x03; /* fan1 and fan2 */ in w83627ehf_check_fan_inputs()
1315 data->has_fan |= (fan3pin << 2); in w83627ehf_check_fan_inputs()
1316 data->has_fan_min |= (fan3pin << 2); in w83627ehf_check_fan_inputs()
1325 regval = w83627ehf_read_value(data, W83627EHF_REG_FANDIV1); in w83627ehf_check_fan_inputs()
1327 data->has_fan |= (1 << 3); in w83627ehf_check_fan_inputs()
1328 data->has_fan_min |= (1 << 3); in w83627ehf_check_fan_inputs()
1331 data->has_fan |= (1 << 4); in w83627ehf_check_fan_inputs()
1332 data->has_fan_min |= (1 << 4); in w83627ehf_check_fan_inputs()
1340 const struct w83627ehf_data *data = drvdata; in w83627ehf_is_visible() local
1345 if (!(data->have_temp & (1 << channel))) in w83627ehf_is_visible()
1350 if (data->temp_label) in w83627ehf_is_visible()
1354 if (channel == 2 && data->temp3_val_only) in w83627ehf_is_visible()
1357 if (data->reg_temp_over[channel]) in w83627ehf_is_visible()
1363 if (data->reg_temp_hyst[channel]) in w83627ehf_is_visible()
1373 if (data->have_temp_offset & (1 << channel)) in w83627ehf_is_visible()
1382 if (!(data->has_fan & (1 << channel))) in w83627ehf_is_visible()
1390 if (data->has_fan_min & (1 << channel)) in w83627ehf_is_visible()
1399 if (channel >= data->in_num) in w83627ehf_is_visible()
1401 if (channel == 6 && data->in6_skip) in w83627ehf_is_visible()
1411 if (!(data->has_fan & (1 << channel)) || in w83627ehf_is_visible()
1412 channel >= data->pwm_num) in w83627ehf_is_visible()
1430 w83627ehf_do_read_temp(struct w83627ehf_data *data, u32 attr, in w83627ehf_do_read_temp() argument
1435 *val = LM75_TEMP_FROM_REG(data->temp[channel]); in w83627ehf_do_read_temp()
1438 *val = LM75_TEMP_FROM_REG(data->temp_max[channel]); in w83627ehf_do_read_temp()
1441 *val = LM75_TEMP_FROM_REG(data->temp_max_hyst[channel]); in w83627ehf_do_read_temp()
1444 *val = data->temp_offset[channel] * 1000; in w83627ehf_do_read_temp()
1447 *val = (int)data->temp_type[channel]; in w83627ehf_do_read_temp()
1452 *val = (data->alarms >> bit[channel]) & 1; in w83627ehf_do_read_temp()
1465 w83627ehf_do_read_in(struct w83627ehf_data *data, u32 attr, in w83627ehf_do_read_in() argument
1470 *val = in_from_reg(data->in[channel], channel, data->scale_in); in w83627ehf_do_read_in()
1473 *val = in_from_reg(data->in_min[channel], channel, in w83627ehf_do_read_in()
1474 data->scale_in); in w83627ehf_do_read_in()
1477 *val = in_from_reg(data->in_max[channel], channel, in w83627ehf_do_read_in()
1478 data->scale_in); in w83627ehf_do_read_in()
1483 *val = (data->alarms >> bit[channel]) & 1; in w83627ehf_do_read_in()
1494 w83627ehf_do_read_fan(struct w83627ehf_data *data, u32 attr, in w83627ehf_do_read_fan() argument
1499 *val = data->rpm[channel]; in w83627ehf_do_read_fan()
1502 *val = fan_from_reg8(data->fan_min[channel], in w83627ehf_do_read_fan()
1503 data->fan_div[channel]); in w83627ehf_do_read_fan()
1506 *val = div_from_reg(data->fan_div[channel]); in w83627ehf_do_read_fan()
1511 *val = (data->alarms >> bit[channel]) & 1; in w83627ehf_do_read_fan()
1522 w83627ehf_do_read_pwm(struct w83627ehf_data *data, u32 attr, in w83627ehf_do_read_pwm() argument
1527 *val = data->pwm[channel]; in w83627ehf_do_read_pwm()
1530 *val = data->pwm_enable[channel]; in w83627ehf_do_read_pwm()
1533 *val = data->pwm_enable[channel]; in w83627ehf_do_read_pwm()
1542 w83627ehf_do_read_intrusion(struct w83627ehf_data *data, u32 attr, in w83627ehf_do_read_intrusion() argument
1548 *val = !!(data->caseopen & 0x10); in w83627ehf_do_read_intrusion()
1556 struct w83627ehf_data *data = w83627ehf_update_device(dev->parent); in w83627ehf_read() local
1560 return w83627ehf_do_read_fan(data, attr, channel, val); in w83627ehf_read()
1563 return w83627ehf_do_read_in(data, attr, channel, val); in w83627ehf_read()
1566 return w83627ehf_do_read_pwm(data, attr, channel, val); in w83627ehf_read()
1569 return w83627ehf_do_read_temp(data, attr, channel, val); in w83627ehf_read()
1572 return w83627ehf_do_read_intrusion(data, attr, channel, val); in w83627ehf_read()
1585 struct w83627ehf_data *data = dev_get_drvdata(dev); in w83627ehf_read_string() local
1590 *str = data->temp_label[data->temp_src[channel]]; in w83627ehf_read_string()
1606 struct w83627ehf_data *data = dev_get_drvdata(dev); in w83627ehf_write() local
1609 return store_in_min(dev, data, channel, val); in w83627ehf_write()
1611 return store_in_max(dev, data, channel, val); in w83627ehf_write()
1614 return store_fan_min(dev, data, channel, val); in w83627ehf_write()
1617 return store_temp_max(dev, data, channel, val); in w83627ehf_write()
1619 return store_temp_max_hyst(dev, data, channel, val); in w83627ehf_write()
1621 return store_temp_offset(dev, data, channel, val); in w83627ehf_write()
1624 return store_pwm_mode(dev, data, channel, val); in w83627ehf_write()
1626 return store_pwm_enable(dev, data, channel, val); in w83627ehf_write()
1628 return store_pwm(dev, data, channel, val); in w83627ehf_write()
1631 return clear_caseopen(dev, data, channel, val); in w83627ehf_write()
1699 struct w83627ehf_data *data; in w83627ehf_probe() local
1709 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); in w83627ehf_probe()
1710 if (!data) in w83627ehf_probe()
1713 data->addr = res->start; in w83627ehf_probe()
1714 mutex_init(&data->lock); in w83627ehf_probe()
1715 mutex_init(&data->update_lock); in w83627ehf_probe()
1716 data->name = w83627ehf_device_names[sio_data->kind]; in w83627ehf_probe()
1717 data->bank = 0xff; /* Force initial bank selection */ in w83627ehf_probe()
1718 platform_set_drvdata(pdev, data); in w83627ehf_probe()
1721 data->in_num = (sio_data->kind == w83627ehf) ? 10 : 9; in w83627ehf_probe()
1725 data->pwm_num = 4; in w83627ehf_probe()
1729 data->pwm_num = 3; in w83627ehf_probe()
1732 data->pwm_num = 2; in w83627ehf_probe()
1737 data->have_temp = 0x07; in w83627ehf_probe()
1743 w83627ehf_set_temp_reg_ehf(data, 4); in w83627ehf_probe()
1749 reg = w83627ehf_read_value(data, 0x4a); in w83627ehf_probe()
1750 data->temp_src[0] = reg >> 5; in w83627ehf_probe()
1751 reg = w83627ehf_read_value(data, 0x49); in w83627ehf_probe()
1752 data->temp_src[1] = reg & 0x07; in w83627ehf_probe()
1753 data->temp_src[2] = (reg >> 4) & 0x07; in w83627ehf_probe()
1761 reg = w83627ehf_read_value(data, 0x7d); in w83627ehf_probe()
1763 if (reg != data->temp_src[0] && reg != data->temp_src[1] in w83627ehf_probe()
1764 && reg != data->temp_src[2]) { in w83627ehf_probe()
1765 data->temp_src[3] = reg; in w83627ehf_probe()
1766 data->have_temp |= 1 << 3; in w83627ehf_probe()
1773 reg = w83627ehf_read_value(data, W83627EHF_REG_TEMP_CONFIG[2]); in w83627ehf_probe()
1774 if (data->temp_src[2] == 2 && (reg & 0x01)) in w83627ehf_probe()
1775 data->have_temp &= ~(1 << 2); in w83627ehf_probe()
1777 if ((data->temp_src[2] == 2 && (data->have_temp & (1 << 2))) in w83627ehf_probe()
1778 || (data->temp_src[3] == 2 && (data->have_temp & (1 << 3)))) in w83627ehf_probe()
1779 data->in6_skip = 1; in w83627ehf_probe()
1781 data->temp_label = w83667hg_b_temp_label; in w83627ehf_probe()
1782 data->have_temp_offset = data->have_temp & 0x07; in w83627ehf_probe()
1784 if (data->temp_src[i] > 2) in w83627ehf_probe()
1785 data->have_temp_offset &= ~(1 << i); in w83627ehf_probe()
1790 w83627ehf_set_temp_reg_ehf(data, 3); in w83627ehf_probe()
1796 data->temp_src[0] = 0; /* SYSTIN */ in w83627ehf_probe()
1797 reg = w83627ehf_read_value(data, 0x49) & 0x07; in w83627ehf_probe()
1800 data->temp_src[1] = 1; in w83627ehf_probe()
1802 data->temp_src[1] = reg + 2; in w83627ehf_probe()
1804 data->have_temp &= ~(1 << 1); in w83627ehf_probe()
1805 reg = w83627ehf_read_value(data, 0x4a); in w83627ehf_probe()
1806 data->temp_src[2] = reg >> 5; in w83627ehf_probe()
1812 if (data->temp_src[2] == 2 || data->temp_src[2] == 3 || in w83627ehf_probe()
1813 data->temp_src[2] == data->temp_src[0] || in w83627ehf_probe()
1814 ((data->have_temp & (1 << 1)) && in w83627ehf_probe()
1815 data->temp_src[2] == data->temp_src[1])) in w83627ehf_probe()
1816 data->have_temp &= ~(1 << 2); in w83627ehf_probe()
1818 data->temp3_val_only = 1; /* No limit regs */ in w83627ehf_probe()
1820 data->in6_skip = 1; /* No VIN3 */ in w83627ehf_probe()
1822 data->temp_label = w83667hg_b_temp_label; in w83627ehf_probe()
1823 data->have_temp_offset = data->have_temp & 0x03; in w83627ehf_probe()
1825 if (data->temp_src[i] > 1) in w83627ehf_probe()
1826 data->have_temp_offset &= ~(1 << i); in w83627ehf_probe()
1829 w83627ehf_set_temp_reg_ehf(data, 3); in w83627ehf_probe()
1840 reg = w83627ehf_read_value(data, in w83627ehf_probe()
1843 data->have_temp &= ~(1 << 2); in w83627ehf_probe()
1845 data->in6_skip = 1; in w83627ehf_probe()
1847 data->have_temp_offset = data->have_temp & 0x07; in w83627ehf_probe()
1851 data->REG_FAN_MAX_OUTPUT = in w83627ehf_probe()
1853 data->REG_FAN_STEP_OUTPUT = in w83627ehf_probe()
1856 data->REG_FAN_MAX_OUTPUT = in w83627ehf_probe()
1858 data->REG_FAN_STEP_OUTPUT = in w83627ehf_probe()
1864 data->scale_in = scale_in_w83627uhg; in w83627ehf_probe()
1866 data->scale_in = scale_in_common; in w83627ehf_probe()
1869 w83627ehf_init_device(data, sio_data->kind); in w83627ehf_probe()
1871 data->vrm = vid_which_vrm(); in w83627ehf_probe()
1885 data->vid = superio_inb(sio_data->sioreg, 0xe3); in w83627ehf_probe()
1886 data->have_vid = true; in w83627ehf_probe()
1900 if ((en_vrm10 & 0x08) && data->vrm == 90) { in w83627ehf_probe()
1907 && data->vrm == 100) { in w83627ehf_probe()
1916 data->vid = superio_inb(sio_data->sioreg, in w83627ehf_probe()
1919 data->vid &= 0x3f; in w83627ehf_probe()
1920 data->have_vid = true; in w83627ehf_probe()
1927 w83627ehf_check_fan_inputs(sio_data, data); in w83627ehf_probe()
1932 w83627ehf_update_fan_div(data); in w83627ehf_probe()
1935 w83627ehf_update_pwm(data); in w83627ehf_probe()
1936 for (i = 0; i < data->pwm_num; i++) in w83627ehf_probe()
1937 data->pwm_enable_orig[i] = data->pwm_enable[i]; in w83627ehf_probe()
1940 data->name, in w83627ehf_probe()
1941 data, in w83627ehf_probe()
1949 struct w83627ehf_data *data = w83627ehf_update_device(dev); in w83627ehf_suspend() local
1951 mutex_lock(&data->update_lock); in w83627ehf_suspend()
1952 data->vbat = w83627ehf_read_value(data, W83627EHF_REG_VBAT); in w83627ehf_suspend()
1953 mutex_unlock(&data->update_lock); in w83627ehf_suspend()
1960 struct w83627ehf_data *data = dev_get_drvdata(dev); in w83627ehf_resume() local
1963 mutex_lock(&data->update_lock); in w83627ehf_resume()
1964 data->bank = 0xff; /* Force initial bank selection */ in w83627ehf_resume()
1967 for (i = 0; i < data->in_num; i++) { in w83627ehf_resume()
1968 if ((i == 6) && data->in6_skip) in w83627ehf_resume()
1971 w83627ehf_write_value(data, W83627EHF_REG_IN_MIN(i), in w83627ehf_resume()
1972 data->in_min[i]); in w83627ehf_resume()
1973 w83627ehf_write_value(data, W83627EHF_REG_IN_MAX(i), in w83627ehf_resume()
1974 data->in_max[i]); in w83627ehf_resume()
1978 if (!(data->has_fan_min & (1 << i))) in w83627ehf_resume()
1981 w83627ehf_write_value(data, W83627EHF_REG_FAN_MIN[i], in w83627ehf_resume()
1982 data->fan_min[i]); in w83627ehf_resume()
1986 if (!(data->have_temp & (1 << i))) in w83627ehf_resume()
1989 if (data->reg_temp_over[i]) in w83627ehf_resume()
1990 w83627ehf_write_temp(data, data->reg_temp_over[i], in w83627ehf_resume()
1991 data->temp_max[i]); in w83627ehf_resume()
1992 if (data->reg_temp_hyst[i]) in w83627ehf_resume()
1993 w83627ehf_write_temp(data, data->reg_temp_hyst[i], in w83627ehf_resume()
1994 data->temp_max_hyst[i]); in w83627ehf_resume()
1997 if (data->have_temp_offset & (1 << i)) in w83627ehf_resume()
1998 w83627ehf_write_value(data, in w83627ehf_resume()
2000 data->temp_offset[i]); in w83627ehf_resume()
2004 w83627ehf_write_value(data, W83627EHF_REG_VBAT, data->vbat); in w83627ehf_resume()
2007 data->valid = false; in w83627ehf_resume()
2008 mutex_unlock(&data->update_lock); in w83627ehf_resume()