]> git.sur5r.net Git - groeck-nct6775/commitdiff
nct6775: NCT6791 supports weight control only for CPUFAN
authorGuenter Roeck <linux@roeck-us.net>
Wed, 13 Nov 2013 06:14:19 +0000 (22:14 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 13 Nov 2013 06:14:19 +0000 (22:14 -0800)
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
nct6775.c

index 64a2362a0e65b6f4c787b0f622875c6c5a7cf538..ee3ba04318fc2bdc42f312de2179a71a31060398 100644 (file)
--- a/nct6775.c
+++ b/nct6775.c
@@ -511,6 +511,13 @@ static const u16 NCT6779_REG_TEMP_CRIT[ARRAY_SIZE(nct6779_temp_label) - 1]
 
 #define NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE    0x28
 
+static const u16 NCT6791_REG_WEIGHT_TEMP_SEL[6] = { 0, 0x239 };
+static const u16 NCT6791_REG_WEIGHT_TEMP_STEP[6] = { 0, 0x23a };
+static const u16 NCT6791_REG_WEIGHT_TEMP_STEP_TOL[6] = { 0, 0x23b };
+static const u16 NCT6791_REG_WEIGHT_DUTY_STEP[6] = { 0, 0x23c };
+static const u16 NCT6791_REG_WEIGHT_TEMP_BASE[6] = { 0, 0x23d };
+static const u16 NCT6791_REG_WEIGHT_DUTY_BASE[6] = { 0, 0x23e };
+
 static const u16 NCT6791_REG_ALARM[NUM_REG_ALARM] = {
        0x459, 0x45A, 0x45B, 0x568, 0x45D };
 
@@ -1319,17 +1326,19 @@ static void nct6775_update_pwm(struct device *dev)
                if (reg & 0x80)
                        data->pwm[2][i] = 0;
 
-               reg = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[i]);
-               data->pwm_weight_temp_sel[i] = reg & 0x1f;
-               /* If weight is disabled, report weight source as 0 */
-               if (j == 1 && !(reg & 0x80))
-                       data->pwm_weight_temp_sel[i] = 0;
-
-               /* Weight temp data */
-               for (j = 0; j < ARRAY_SIZE(data->weight_temp); j++) {
-                       data->weight_temp[j][i]
-                         = nct6775_read_value(data,
-                                              data->REG_WEIGHT_TEMP[j][i]);
+               if (data->REG_WEIGHT_TEMP_SEL[i]) {
+                       reg = nct6775_read_value(data, data->REG_WEIGHT_TEMP_SEL[i]);
+                       data->pwm_weight_temp_sel[i] = reg & 0x1f;
+                       /* If weight is disabled, report weight source as 0 */
+                       if (j == 1 && !(reg & 0x80))
+                               data->pwm_weight_temp_sel[i] = 0;
+
+                       /* Weight temp data */
+                       for (j = 0; j < ARRAY_SIZE(data->weight_temp); j++) {
+                               data->weight_temp[j][i]
+                                 = nct6775_read_value(data,
+                                               data->REG_WEIGHT_TEMP[j][i]);
+                       }
                }
        }
 }
@@ -2873,6 +2882,9 @@ static umode_t nct6775_pwm_is_visible(struct kobject *kobj,
        if (!(data->has_pwm & (1 << pwm)))
                return 0;
 
+       if ((nr >= 14 && nr <= 18) || nr == 21)   /* weight */
+               if (!data->REG_WEIGHT_TEMP_SEL[pwm])
+                       return 0;
        if (nr == 19 && data->REG_PWM[3] == NULL) /* pwm_max */
                return 0;
        if (nr == 20 && data->REG_PWM[4] == NULL) /* pwm_step */
@@ -2966,11 +2978,11 @@ static struct sensor_device_template *nct6775_attributes_pwm_template[] = {
        &sensor_dev_template_pwm_step_down_time,
        &sensor_dev_template_pwm_start,
        &sensor_dev_template_pwm_floor,
-       &sensor_dev_template_pwm_weight_temp_sel,
+       &sensor_dev_template_pwm_weight_temp_sel,       /* 14 */
        &sensor_dev_template_pwm_weight_temp_step,
        &sensor_dev_template_pwm_weight_temp_step_tol,
        &sensor_dev_template_pwm_weight_temp_step_base,
-       &sensor_dev_template_pwm_weight_duty_step,
+       &sensor_dev_template_pwm_weight_duty_step,      /* 18 */
        &sensor_dev_template_pwm_max,                   /* 19 */
        &sensor_dev_template_pwm_step,                  /* 20 */
        &sensor_dev_template_pwm_weight_duty_base,      /* 21 */
@@ -3653,8 +3665,8 @@ static int nct6775_probe(struct platform_device *pdev)
                data->REG_PWM[0] = NCT6775_REG_PWM;
                data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT;
                data->REG_PWM[2] = NCT6775_REG_FAN_STOP_OUTPUT;
-               data->REG_PWM[5] = NCT6775_REG_WEIGHT_DUTY_STEP;
-               data->REG_PWM[6] = NCT6776_REG_WEIGHT_DUTY_BASE;
+               data->REG_PWM[5] = NCT6791_REG_WEIGHT_DUTY_STEP;
+               data->REG_PWM[6] = NCT6791_REG_WEIGHT_DUTY_BASE;
                data->REG_PWM_READ = NCT6775_REG_PWM_READ;
                data->REG_PWM_MODE = NCT6776_REG_PWM_MODE;
                data->PWM_MODE_MASK = NCT6776_PWM_MODE_MASK;
@@ -3670,10 +3682,10 @@ static int nct6775_probe(struct platform_device *pdev)
                data->REG_TEMP_OFFSET = NCT6779_REG_TEMP_OFFSET;
                data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE;
                data->REG_TEMP_SEL = NCT6775_REG_TEMP_SEL;
-               data->REG_WEIGHT_TEMP_SEL = NCT6775_REG_WEIGHT_TEMP_SEL;
-               data->REG_WEIGHT_TEMP[0] = NCT6775_REG_WEIGHT_TEMP_STEP;
-               data->REG_WEIGHT_TEMP[1] = NCT6775_REG_WEIGHT_TEMP_STEP_TOL;
-               data->REG_WEIGHT_TEMP[2] = NCT6775_REG_WEIGHT_TEMP_BASE;
+               data->REG_WEIGHT_TEMP_SEL = NCT6791_REG_WEIGHT_TEMP_SEL;
+               data->REG_WEIGHT_TEMP[0] = NCT6791_REG_WEIGHT_TEMP_STEP;
+               data->REG_WEIGHT_TEMP[1] = NCT6791_REG_WEIGHT_TEMP_STEP_TOL;
+               data->REG_WEIGHT_TEMP[2] = NCT6791_REG_WEIGHT_TEMP_BASE;
                data->REG_ALARM = NCT6791_REG_ALARM;
                data->REG_BEEP = NCT6776_REG_BEEP;