From: Guenter Roeck Date: Mon, 11 Jun 2012 21:01:18 +0000 (-0700) Subject: implement pwmX_step_enable X-Git-Tag: nct6775-v0.9~14 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5eff54fcf28cbc1541ea85de60e5a73d36c9b1aa;p=groeck-nct6775 implement pwmX_step_enable Signed-off-by: Guenter Roeck --- diff --git a/nct6775.c b/nct6775.c index fc65ad1..2864017 100644 --- a/nct6775.c +++ b/nct6775.c @@ -250,6 +250,8 @@ static const u16 NCT6775_REG_FAN_STOP_OUTPUT[] = { 0x105, 0x205, 0x305, 0x805, 0x905 }; static const u16 NCT6775_REG_FAN_START_OUTPUT[] = { 0x106, 0x206, 0x306, 0x806, 0x906 }; +static const u16 NCT6775_REG_FAN_STEP_ENABLE[] = { + 0x120, 0x220, 0x320, 0x820, 0x920 }; static const u16 NCT6775_REG_FAN_MAX_OUTPUT[] = { 0x10a, 0x20a, 0x30a }; static const u16 NCT6775_REG_FAN_STEP_OUTPUT[] = { 0x10b, 0x20b, 0x30b }; @@ -581,7 +583,9 @@ struct nct6775_data { const u16 *REG_CRITICAL_TEMP_TOLERANCE; const u16 *REG_TEMP_SOURCE; /* temp register sources */ - const u16 *REG_TEMP_SEL[2]; /* pwm temp, 0=base, 1=weight */ + const u16 *REG_TEMP_SEL[3]; /* pwm temp: + * 0=base, 1=weight, 2=step enable + */ const u16 *REG_WEIGHT_TEMP[3]; /* 0=base, 1=hyst, 2=step */ @@ -641,7 +645,7 @@ struct nct6775_data { u8 pwm_temp_sel[2][5]; - bool pwm_sel_enable[2][5];/* 0->stop_val, 1->weight; + bool pwm_sel_enable[3][5];/* 0->stop_val, 1->weight, 2->step; * false->off, true->on */ u8 weight_temp[3][5]; /* 0->temp_step, 1->temp_step_tol, @@ -870,6 +874,9 @@ static void nct6775_update_pwm(struct device *dev) data->pwm_sel_enable[1][i] = nct6775_read_value(data, data->REG_TEMP_SEL[1][i]) & 0x80; + data->pwm_sel_enable[2][i] = + nct6775_read_value(data, data->REG_TEMP_SEL[2][i]) + & 0x01; /* Weight data */ for (j = 0; j < 2; j++) { @@ -2125,6 +2132,8 @@ store_pwm_sel_enable(struct device *dev, struct device_attribute *attr, unsigned long val; int err; u8 reg; + static const u8 bit[] = { 0x80, 0x80, 0x01 }; + err = kstrtoul(buf, 10, &val); if (err < 0) @@ -2136,9 +2145,9 @@ store_pwm_sel_enable(struct device *dev, struct device_attribute *attr, mutex_lock(&data->update_lock); data->pwm_sel_enable[index][nr] = val; reg = nct6775_read_value(data, data->REG_TEMP_SEL[index][nr]); - reg &= 0x7f; + reg &= ~bit[index]; if (val) - reg |= 0x80; + reg |= bit[index]; nct6775_write_value(data, data->REG_TEMP_SEL[index][nr], reg); mutex_unlock(&data->update_lock); return count; @@ -2201,6 +2210,17 @@ static SENSOR_DEVICE_ATTR_2(pwm4_weight_enable, S_IWUSR | S_IRUGO, static SENSOR_DEVICE_ATTR_2(pwm5_weight_enable, S_IWUSR | S_IRUGO, show_pwm_sel_enable, store_pwm_sel_enable, 4, 1); +static SENSOR_DEVICE_ATTR_2(pwm1_step_enable, S_IWUSR | S_IRUGO, + show_pwm_sel_enable, store_pwm_sel_enable, 0, 2); +static SENSOR_DEVICE_ATTR_2(pwm2_step_enable, S_IWUSR | S_IRUGO, + show_pwm_sel_enable, store_pwm_sel_enable, 1, 2); +static SENSOR_DEVICE_ATTR_2(pwm3_step_enable, S_IWUSR | S_IRUGO, + show_pwm_sel_enable, store_pwm_sel_enable, 2, 2); +static SENSOR_DEVICE_ATTR_2(pwm4_step_enable, S_IWUSR | S_IRUGO, + show_pwm_sel_enable, store_pwm_sel_enable, 3, 2); +static SENSOR_DEVICE_ATTR_2(pwm5_step_enable, S_IWUSR | S_IRUGO, + show_pwm_sel_enable, store_pwm_sel_enable, 4, 2); + static SENSOR_DEVICE_ATTR_2(pwm1_weight_temp_sel, S_IWUSR | S_IRUGO, show_pwm_temp_sel, store_pwm_temp_sel, 0, 1); static SENSOR_DEVICE_ATTR_2(pwm2_weight_temp_sel, S_IWUSR | S_IRUGO, @@ -2399,13 +2419,14 @@ static struct sensor_device_attribute_2 sda_step_output[] = { 4, 4), }; -static struct attribute *nct6775_attributes_pwm[5][19] = { +static struct attribute *nct6775_attributes_pwm[5][20] = { { &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm1_mode.dev_attr.attr, &sensor_dev_attr_pwm1_enable.dev_attr.attr, &sensor_dev_attr_pwm1_stop_output_enable.dev_attr.attr, &sensor_dev_attr_pwm1_weight_enable.dev_attr.attr, + &sensor_dev_attr_pwm1_step_enable.dev_attr.attr, &sensor_dev_attr_pwm1_temp_sel.dev_attr.attr, &sensor_dev_attr_pwm1_target.dev_attr.attr, &sensor_dev_attr_pwm1_stop_time.dev_attr.attr, @@ -2426,6 +2447,7 @@ static struct attribute *nct6775_attributes_pwm[5][19] = { &sensor_dev_attr_pwm2_enable.dev_attr.attr, &sensor_dev_attr_pwm2_stop_output_enable.dev_attr.attr, &sensor_dev_attr_pwm2_weight_enable.dev_attr.attr, + &sensor_dev_attr_pwm2_step_enable.dev_attr.attr, &sensor_dev_attr_pwm2_temp_sel.dev_attr.attr, &sensor_dev_attr_pwm2_target.dev_attr.attr, &sensor_dev_attr_pwm2_stop_time.dev_attr.attr, @@ -2446,6 +2468,7 @@ static struct attribute *nct6775_attributes_pwm[5][19] = { &sensor_dev_attr_pwm3_enable.dev_attr.attr, &sensor_dev_attr_pwm3_stop_output_enable.dev_attr.attr, &sensor_dev_attr_pwm3_weight_enable.dev_attr.attr, + &sensor_dev_attr_pwm3_step_enable.dev_attr.attr, &sensor_dev_attr_pwm3_temp_sel.dev_attr.attr, &sensor_dev_attr_pwm3_target.dev_attr.attr, &sensor_dev_attr_pwm3_stop_time.dev_attr.attr, @@ -2466,6 +2489,7 @@ static struct attribute *nct6775_attributes_pwm[5][19] = { &sensor_dev_attr_pwm4_enable.dev_attr.attr, &sensor_dev_attr_pwm4_stop_output_enable.dev_attr.attr, &sensor_dev_attr_pwm4_weight_enable.dev_attr.attr, + &sensor_dev_attr_pwm4_step_enable.dev_attr.attr, &sensor_dev_attr_pwm4_temp_sel.dev_attr.attr, &sensor_dev_attr_pwm4_target.dev_attr.attr, &sensor_dev_attr_pwm4_stop_time.dev_attr.attr, @@ -2486,6 +2510,7 @@ static struct attribute *nct6775_attributes_pwm[5][19] = { &sensor_dev_attr_pwm5_enable.dev_attr.attr, &sensor_dev_attr_pwm5_stop_output_enable.dev_attr.attr, &sensor_dev_attr_pwm5_weight_enable.dev_attr.attr, + &sensor_dev_attr_pwm5_step_enable.dev_attr.attr, &sensor_dev_attr_pwm5_temp_sel.dev_attr.attr, &sensor_dev_attr_pwm5_target.dev_attr.attr, &sensor_dev_attr_pwm5_stop_time.dev_attr.attr, @@ -3172,6 +3197,7 @@ static int __devinit nct6775_probe(struct platform_device *pdev) data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; data->REG_TEMP_SEL[0] = NCT6775_REG_TEMP_SEL; data->REG_TEMP_SEL[1] = NCT6775_REG_WEIGHT_TEMP_SEL; + data->REG_TEMP_SEL[2] = NCT6775_REG_FAN_STEP_ENABLE; 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; @@ -3232,6 +3258,7 @@ static int __devinit nct6775_probe(struct platform_device *pdev) data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; data->REG_TEMP_SEL[0] = NCT6775_REG_TEMP_SEL; data->REG_TEMP_SEL[1] = NCT6775_REG_WEIGHT_TEMP_SEL; + data->REG_TEMP_SEL[2] = NCT6775_REG_FAN_STEP_ENABLE; 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; @@ -3292,6 +3319,7 @@ static int __devinit nct6775_probe(struct platform_device *pdev) data->REG_TEMP_SOURCE = NCT6775_REG_TEMP_SOURCE; data->REG_TEMP_SEL[0] = NCT6775_REG_TEMP_SEL; data->REG_TEMP_SEL[1] = NCT6775_REG_WEIGHT_TEMP_SEL; + data->REG_TEMP_SEL[2] = NCT6775_REG_FAN_STEP_ENABLE; 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;