aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/nct6775.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/nct6775.c')
-rw-r--r--drivers/hwmon/nct6775.c91
1 files changed, 81 insertions, 10 deletions
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index d17325db0ea3..cf811c1a1475 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -274,6 +274,8 @@ static const u16 NCT6775_FAN_PULSE_SHIFT[] = { 0, 0, 0, 0, 0, 0 };
274static const u16 NCT6775_REG_TEMP[] = { 274static const u16 NCT6775_REG_TEMP[] = {
275 0x27, 0x150, 0x250, 0x62b, 0x62c, 0x62d }; 275 0x27, 0x150, 0x250, 0x62b, 0x62c, 0x62d };
276 276
277static const u16 NCT6775_REG_TEMP_MON[] = { 0x73, 0x75, 0x77 };
278
277static const u16 NCT6775_REG_TEMP_CONFIG[ARRAY_SIZE(NCT6775_REG_TEMP)] = { 279static const u16 NCT6775_REG_TEMP_CONFIG[ARRAY_SIZE(NCT6775_REG_TEMP)] = {
278 0, 0x152, 0x252, 0x628, 0x629, 0x62A }; 280 0, 0x152, 0x252, 0x628, 0x629, 0x62A };
279static const u16 NCT6775_REG_TEMP_HYST[ARRAY_SIZE(NCT6775_REG_TEMP)] = { 281static const u16 NCT6775_REG_TEMP_HYST[ARRAY_SIZE(NCT6775_REG_TEMP)] = {
@@ -454,6 +456,7 @@ static const u16 NCT6779_REG_CRITICAL_PWM[] = {
454 0x137, 0x237, 0x337, 0x837, 0x937, 0xa37 }; 456 0x137, 0x237, 0x337, 0x837, 0x937, 0xa37 };
455 457
456static const u16 NCT6779_REG_TEMP[] = { 0x27, 0x150 }; 458static const u16 NCT6779_REG_TEMP[] = { 0x27, 0x150 };
459static const u16 NCT6779_REG_TEMP_MON[] = { 0x73, 0x75, 0x77, 0x79, 0x7b };
457static const u16 NCT6779_REG_TEMP_CONFIG[ARRAY_SIZE(NCT6779_REG_TEMP)] = { 460static const u16 NCT6779_REG_TEMP_CONFIG[ARRAY_SIZE(NCT6779_REG_TEMP)] = {
458 0x18, 0x152 }; 461 0x18, 0x152 };
459static const u16 NCT6779_REG_TEMP_HYST[ARRAY_SIZE(NCT6779_REG_TEMP)] = { 462static const u16 NCT6779_REG_TEMP_HYST[ARRAY_SIZE(NCT6779_REG_TEMP)] = {
@@ -507,6 +510,13 @@ static const u16 NCT6779_REG_TEMP_CRIT[ARRAY_SIZE(nct6779_temp_label) - 1]
507 510
508#define NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE 0x28 511#define NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE 0x28
509 512
513static const u16 NCT6791_REG_WEIGHT_TEMP_SEL[6] = { 0, 0x239 };
514static const u16 NCT6791_REG_WEIGHT_TEMP_STEP[6] = { 0, 0x23a };
515static const u16 NCT6791_REG_WEIGHT_TEMP_STEP_TOL[6] = { 0, 0x23b };
516static const u16 NCT6791_REG_WEIGHT_DUTY_STEP[6] = { 0, 0x23c };
517static const u16 NCT6791_REG_WEIGHT_TEMP_BASE[6] = { 0, 0x23d };
518static const u16 NCT6791_REG_WEIGHT_DUTY_BASE[6] = { 0, 0x23e };
519
510static const u16 NCT6791_REG_ALARM[NUM_REG_ALARM] = { 520static const u16 NCT6791_REG_ALARM[NUM_REG_ALARM] = {
511 0x459, 0x45A, 0x45B, 0x568, 0x45D }; 521 0x459, 0x45A, 0x45B, 0x568, 0x45D };
512 522
@@ -534,6 +544,7 @@ static const u16 NCT6106_REG_IN[] = {
534 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x09 }; 544 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x09 };
535 545
536static const u16 NCT6106_REG_TEMP[] = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15 }; 546static const u16 NCT6106_REG_TEMP[] = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15 };
547static const u16 NCT6106_REG_TEMP_MON[] = { 0x18, 0x19, 0x1a };
537static const u16 NCT6106_REG_TEMP_HYST[] = { 548static const u16 NCT6106_REG_TEMP_HYST[] = {
538 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7 }; 549 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7 };
539static const u16 NCT6106_REG_TEMP_OVER[] = { 550static const u16 NCT6106_REG_TEMP_OVER[] = {
@@ -1307,6 +1318,9 @@ static void nct6775_update_pwm(struct device *dev)
1307 if (reg & 0x80) 1318 if (reg & 0x80)
1308 data->pwm[2][i] = 0; 1319 data->pwm[2][i] = 0;
1309 1320
1321 if (!data->REG_WEIGHT_TEMP_SEL[i])
1322 continue;
1323
1310 reg = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[i]); 1324 reg = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[i]);
1311 data->pwm_weight_temp_sel[i] = reg & 0x1f; 1325 data->pwm_weight_temp_sel[i] = reg & 0x1f;
1312 /* If weight is disabled, report weight source as 0 */ 1326 /* If weight is disabled, report weight source as 0 */
@@ -2852,6 +2866,9 @@ static umode_t nct6775_pwm_is_visible(struct kobject *kobj,
2852 if (!(data->has_pwm & (1 << pwm))) 2866 if (!(data->has_pwm & (1 << pwm)))
2853 return 0; 2867 return 0;
2854 2868
2869 if ((nr >= 14 && nr <= 18) || nr == 21) /* weight */
2870 if (!data->REG_WEIGHT_TEMP_SEL[pwm])
2871 return 0;
2855 if (nr == 19 && data->REG_PWM[3] == NULL) /* pwm_max */ 2872 if (nr == 19 && data->REG_PWM[3] == NULL) /* pwm_max */
2856 return 0; 2873 return 0;
2857 if (nr == 20 && data->REG_PWM[4] == NULL) /* pwm_step */ 2874 if (nr == 20 && data->REG_PWM[4] == NULL) /* pwm_step */
@@ -2945,11 +2962,11 @@ static struct sensor_device_template *nct6775_attributes_pwm_template[] = {
2945 &sensor_dev_template_pwm_step_down_time, 2962 &sensor_dev_template_pwm_step_down_time,
2946 &sensor_dev_template_pwm_start, 2963 &sensor_dev_template_pwm_start,
2947 &sensor_dev_template_pwm_floor, 2964 &sensor_dev_template_pwm_floor,
2948 &sensor_dev_template_pwm_weight_temp_sel, 2965 &sensor_dev_template_pwm_weight_temp_sel, /* 14 */
2949 &sensor_dev_template_pwm_weight_temp_step, 2966 &sensor_dev_template_pwm_weight_temp_step,
2950 &sensor_dev_template_pwm_weight_temp_step_tol, 2967 &sensor_dev_template_pwm_weight_temp_step_tol,
2951 &sensor_dev_template_pwm_weight_temp_step_base, 2968 &sensor_dev_template_pwm_weight_temp_step_base,
2952 &sensor_dev_template_pwm_weight_duty_step, 2969 &sensor_dev_template_pwm_weight_duty_step, /* 18 */
2953 &sensor_dev_template_pwm_max, /* 19 */ 2970 &sensor_dev_template_pwm_max, /* 19 */
2954 &sensor_dev_template_pwm_step, /* 20 */ 2971 &sensor_dev_template_pwm_step, /* 20 */
2955 &sensor_dev_template_pwm_weight_duty_base, /* 21 */ 2972 &sensor_dev_template_pwm_weight_duty_base, /* 21 */
@@ -3253,9 +3270,9 @@ static int nct6775_probe(struct platform_device *pdev)
3253 int i, s, err = 0; 3270 int i, s, err = 0;
3254 int src, mask, available; 3271 int src, mask, available;
3255 const u16 *reg_temp, *reg_temp_over, *reg_temp_hyst, *reg_temp_config; 3272 const u16 *reg_temp, *reg_temp_over, *reg_temp_hyst, *reg_temp_config;
3256 const u16 *reg_temp_alternate, *reg_temp_crit; 3273 const u16 *reg_temp_mon, *reg_temp_alternate, *reg_temp_crit;
3257 const u16 *reg_temp_crit_l = NULL, *reg_temp_crit_h = NULL; 3274 const u16 *reg_temp_crit_l = NULL, *reg_temp_crit_h = NULL;
3258 int num_reg_temp; 3275 int num_reg_temp, num_reg_temp_mon;
3259 u8 cr2a; 3276 u8 cr2a;
3260 struct attribute_group *group; 3277 struct attribute_group *group;
3261 struct device *hwmon_dev; 3278 struct device *hwmon_dev;
@@ -3338,7 +3355,9 @@ static int nct6775_probe(struct platform_device *pdev)
3338 data->BEEP_BITS = NCT6106_BEEP_BITS; 3355 data->BEEP_BITS = NCT6106_BEEP_BITS;
3339 3356
3340 reg_temp = NCT6106_REG_TEMP; 3357 reg_temp = NCT6106_REG_TEMP;
3358 reg_temp_mon = NCT6106_REG_TEMP_MON;
3341 num_reg_temp = ARRAY_SIZE(NCT6106_REG_TEMP); 3359 num_reg_temp = ARRAY_SIZE(NCT6106_REG_TEMP);
3360 num_reg_temp_mon = ARRAY_SIZE(NCT6106_REG_TEMP_MON);
3342 reg_temp_over = NCT6106_REG_TEMP_OVER; 3361 reg_temp_over = NCT6106_REG_TEMP_OVER;
3343 reg_temp_hyst = NCT6106_REG_TEMP_HYST; 3362 reg_temp_hyst = NCT6106_REG_TEMP_HYST;
3344 reg_temp_config = NCT6106_REG_TEMP_CONFIG; 3363 reg_temp_config = NCT6106_REG_TEMP_CONFIG;
@@ -3410,7 +3429,9 @@ static int nct6775_probe(struct platform_device *pdev)
3410 data->REG_BEEP = NCT6775_REG_BEEP; 3429 data->REG_BEEP = NCT6775_REG_BEEP;
3411 3430
3412 reg_temp = NCT6775_REG_TEMP; 3431 reg_temp = NCT6775_REG_TEMP;
3432 reg_temp_mon = NCT6775_REG_TEMP_MON;
3413 num_reg_temp = ARRAY_SIZE(NCT6775_REG_TEMP); 3433 num_reg_temp = ARRAY_SIZE(NCT6775_REG_TEMP);
3434 num_reg_temp_mon = ARRAY_SIZE(NCT6775_REG_TEMP_MON);
3414 reg_temp_over = NCT6775_REG_TEMP_OVER; 3435 reg_temp_over = NCT6775_REG_TEMP_OVER;
3415 reg_temp_hyst = NCT6775_REG_TEMP_HYST; 3436 reg_temp_hyst = NCT6775_REG_TEMP_HYST;
3416 reg_temp_config = NCT6775_REG_TEMP_CONFIG; 3437 reg_temp_config = NCT6775_REG_TEMP_CONFIG;
@@ -3480,7 +3501,9 @@ static int nct6775_probe(struct platform_device *pdev)
3480 data->REG_BEEP = NCT6776_REG_BEEP; 3501 data->REG_BEEP = NCT6776_REG_BEEP;
3481 3502
3482 reg_temp = NCT6775_REG_TEMP; 3503 reg_temp = NCT6775_REG_TEMP;
3504 reg_temp_mon = NCT6775_REG_TEMP_MON;
3483 num_reg_temp = ARRAY_SIZE(NCT6775_REG_TEMP); 3505 num_reg_temp = ARRAY_SIZE(NCT6775_REG_TEMP);
3506 num_reg_temp_mon = ARRAY_SIZE(NCT6775_REG_TEMP_MON);
3484 reg_temp_over = NCT6775_REG_TEMP_OVER; 3507 reg_temp_over = NCT6775_REG_TEMP_OVER;
3485 reg_temp_hyst = NCT6775_REG_TEMP_HYST; 3508 reg_temp_hyst = NCT6775_REG_TEMP_HYST;
3486 reg_temp_config = NCT6776_REG_TEMP_CONFIG; 3509 reg_temp_config = NCT6776_REG_TEMP_CONFIG;
@@ -3554,7 +3577,9 @@ static int nct6775_probe(struct platform_device *pdev)
3554 data->REG_BEEP = NCT6776_REG_BEEP; 3577 data->REG_BEEP = NCT6776_REG_BEEP;
3555 3578
3556 reg_temp = NCT6779_REG_TEMP; 3579 reg_temp = NCT6779_REG_TEMP;
3580 reg_temp_mon = NCT6779_REG_TEMP_MON;
3557 num_reg_temp = ARRAY_SIZE(NCT6779_REG_TEMP); 3581 num_reg_temp = ARRAY_SIZE(NCT6779_REG_TEMP);
3582 num_reg_temp_mon = ARRAY_SIZE(NCT6779_REG_TEMP_MON);
3558 reg_temp_over = NCT6779_REG_TEMP_OVER; 3583 reg_temp_over = NCT6779_REG_TEMP_OVER;
3559 reg_temp_hyst = NCT6779_REG_TEMP_HYST; 3584 reg_temp_hyst = NCT6779_REG_TEMP_HYST;
3560 reg_temp_config = NCT6779_REG_TEMP_CONFIG; 3585 reg_temp_config = NCT6779_REG_TEMP_CONFIG;
@@ -3603,8 +3628,8 @@ static int nct6775_probe(struct platform_device *pdev)
3603 data->REG_PWM[0] = NCT6775_REG_PWM; 3628 data->REG_PWM[0] = NCT6775_REG_PWM;
3604 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; 3629 data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT;
3605 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT; 3630 data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT;
3606 data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP; 3631 data->REG_PWM[5] = NCT6791_REG_WEIGHT_DUTY_STEP;
3607 data->REG_PWM[6] = NCT6776_REG_WEIGHT_DUTY_BASE; 3632 data->REG_PWM[6] = NCT6791_REG_WEIGHT_DUTY_BASE;
3608 data->REG_PWM_READ = NCT6775_REG_PWM_READ; 3633 data->REG_PWM_READ = NCT6775_REG_PWM_READ;
3609 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE; 3634 data->REG_PWM_MODE = NCT6776_REG_PWM_MODE;
3610 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK; 3635 data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK;
@@ -3620,15 +3645,17 @@ static int nct6775_probe(struct platform_device *pdev)
3620 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET; 3645 data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET;
3621 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; 3646 data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE;
3622 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL; 3647 data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL;
3623 data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL; 3648 data->REG_WEIGHT_TEMP_SEL = NCT6791_REG_WEIGHT_TEMP_SEL;
3624 data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP; 3649 data->REG_WEIGHT_TEMP[0] = NCT6791_REG_WEIGHT_TEMP_STEP;
3625 data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL; 3650 data->REG_WEIGHT_TEMP[1] = NCT6791_REG_WEIGHT_TEMP_STEP_TOL;
3626 data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE; 3651 data->REG_WEIGHT_TEMP[2] = NCT6791_REG_WEIGHT_TEMP_BASE;
3627 data->REG_ALARM = NCT6791_REG_ALARM; 3652 data->REG_ALARM = NCT6791_REG_ALARM;
3628 data->REG_BEEP = NCT6776_REG_BEEP; 3653 data->REG_BEEP = NCT6776_REG_BEEP;
3629 3654
3630 reg_temp = NCT6779_REG_TEMP; 3655 reg_temp = NCT6779_REG_TEMP;
3656 reg_temp_mon = NCT6779_REG_TEMP_MON;
3631 num_reg_temp = ARRAY_SIZE(NCT6779_REG_TEMP); 3657 num_reg_temp = ARRAY_SIZE(NCT6779_REG_TEMP);
3658 num_reg_temp_mon = ARRAY_SIZE(NCT6779_REG_TEMP_MON);
3632 reg_temp_over = NCT6779_REG_TEMP_OVER; 3659 reg_temp_over = NCT6779_REG_TEMP_OVER;
3633 reg_temp_hyst = NCT6779_REG_TEMP_HYST; 3660 reg_temp_hyst = NCT6779_REG_TEMP_HYST;
3634 reg_temp_config = NCT6779_REG_TEMP_CONFIG; 3661 reg_temp_config = NCT6779_REG_TEMP_CONFIG;
@@ -3729,6 +3756,50 @@ static int nct6775_probe(struct platform_device *pdev)
3729 s++; 3756 s++;
3730 } 3757 }
3731 3758
3759 /*
3760 * Repeat with temperatures used for fan control.
3761 * This set of registers does not support limits.
3762 */
3763 for (i = 0; i < num_reg_temp_mon; i++) {
3764 if (reg_temp_mon[i] == 0)
3765 continue;
3766
3767 src = nct6775_read_value(data, data->REG_TEMP_SEL[i]) & 0x1f;
3768 if (!src || (mask & (1 << src)))
3769 continue;
3770
3771 if (src >= data->temp_label_num ||
3772 !strlen(data->temp_label[src])) {
3773 dev_info(dev,
3774 "Invalid temperature source %d at index %d, source register 0x%x, temp register 0x%x\n",
3775 src, i, data->REG_TEMP_SEL[i],
3776 reg_temp_mon[i]);
3777 continue;
3778 }
3779
3780 mask |= 1 << src;
3781
3782 /* Use fixed index for SYSTIN(1), CPUTIN(2), AUXTIN(3) */
3783 if (src <= data->temp_fixed_num) {
3784 if (data->have_temp & (1 << (src - 1)))
3785 continue;
3786 data->have_temp |= 1 << (src - 1);
3787 data->have_temp_fixed |= 1 << (src - 1);
3788 data->reg_temp[0][src - 1] = reg_temp_mon[i];
3789 data->temp_src[src - 1] = src;
3790 continue;
3791 }
3792
3793 if (s >= NUM_TEMP)
3794 continue;
3795
3796 /* Use dynamic index for other sources */
3797 data->have_temp |= 1 << s;
3798 data->reg_temp[0][s] = reg_temp_mon[i];
3799 data->temp_src[s] = src;
3800 s++;
3801 }
3802
3732#ifdef USE_ALTERNATE 3803#ifdef USE_ALTERNATE
3733 /* 3804 /*
3734 * Go through the list of alternate temp registers and enable 3805 * Go through the list of alternate temp registers and enable