Add feature flag FEAT_FANCTL_ONOFF
Several recent chips don't support configuration bits to turn fan control off entirely for the first three fans. Handle all of them with a configuration flag. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
58
it87.c
58
it87.c
@@ -331,31 +331,34 @@ struct it87_devices {
|
|||||||
#define FEAT_FOUR_PWM BIT(20) /* Supports four fan controls */
|
#define FEAT_FOUR_PWM BIT(20) /* Supports four fan controls */
|
||||||
#define FEAT_BANK_SEL BIT(21) /* Chip has multi-bank support */
|
#define FEAT_BANK_SEL BIT(21) /* Chip has multi-bank support */
|
||||||
#define FEAT_SCALING BIT(22) /* Internal voltage scaling */
|
#define FEAT_SCALING BIT(22) /* Internal voltage scaling */
|
||||||
|
#define FEAT_FANCTL_ONOFF BIT(23) /* chip has FAN_CTL ON/OFF */
|
||||||
|
|
||||||
static const struct it87_devices it87_devices[] = {
|
static const struct it87_devices it87_devices[] = {
|
||||||
[it87] = {
|
[it87] = {
|
||||||
.name = "it87",
|
.name = "it87",
|
||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_OLD_AUTOPWM, /* may need to overwrite */
|
.features = FEAT_OLD_AUTOPWM | FEAT_FANCTL_ONOFF,
|
||||||
|
/* may need to overwrite */
|
||||||
},
|
},
|
||||||
[it8712] = {
|
[it8712] = {
|
||||||
.name = "it8712",
|
.name = "it8712",
|
||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_OLD_AUTOPWM | FEAT_VID,
|
.features = FEAT_OLD_AUTOPWM | FEAT_VID | FEAT_FANCTL_ONOFF,
|
||||||
/* may need to overwrite */
|
/* may need to overwrite */
|
||||||
},
|
},
|
||||||
[it8716] = {
|
[it8716] = {
|
||||||
.name = "it8716",
|
.name = "it8716",
|
||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID
|
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID
|
||||||
| FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_PWM_FREQ2,
|
| FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_PWM_FREQ2
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
},
|
},
|
||||||
[it8718] = {
|
[it8718] = {
|
||||||
.name = "it8718",
|
.name = "it8718",
|
||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID
|
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID
|
||||||
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS
|
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS
|
||||||
| FEAT_PWM_FREQ2,
|
| FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF,
|
||||||
.old_peci_mask = 0x4,
|
.old_peci_mask = 0x4,
|
||||||
},
|
},
|
||||||
[it8720] = {
|
[it8720] = {
|
||||||
@@ -363,7 +366,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID
|
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID
|
||||||
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS
|
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS
|
||||||
| FEAT_PWM_FREQ2,
|
| FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF,
|
||||||
.old_peci_mask = 0x4,
|
.old_peci_mask = 0x4,
|
||||||
},
|
},
|
||||||
[it8721] = {
|
[it8721] = {
|
||||||
@@ -372,7 +375,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI
|
||||||
| FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_IN7_INTERNAL
|
| FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_IN7_INTERNAL
|
||||||
| FEAT_PWM_FREQ2 | FEAT_SCALING,
|
| FEAT_PWM_FREQ2 | FEAT_SCALING | FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x05,
|
.peci_mask = 0x05,
|
||||||
.old_peci_mask = 0x02, /* Actually reports PCH */
|
.old_peci_mask = 0x02, /* Actually reports PCH */
|
||||||
},
|
},
|
||||||
@@ -381,7 +384,8 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_FIVE_FANS
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_FIVE_FANS
|
||||||
| FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 | FEAT_SCALING,
|
| FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 | FEAT_SCALING
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8732] = {
|
[it8732] = {
|
||||||
@@ -390,7 +394,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI
|
||||||
| FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_FOUR_FANS
|
| FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_FOUR_FANS
|
||||||
| FEAT_FOUR_PWM,
|
| FEAT_FOUR_PWM | FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
.old_peci_mask = 0x02, /* Actually reports PCH */
|
.old_peci_mask = 0x02, /* Actually reports PCH */
|
||||||
},
|
},
|
||||||
@@ -399,7 +403,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "E",
|
.suffix = "E",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
||||||
| FEAT_PWM_FREQ2 | FEAT_SCALING,
|
| FEAT_PWM_FREQ2 | FEAT_SCALING | FEAT_FANCTL_ONOFF,
|
||||||
/* PECI: guesswork */
|
/* PECI: guesswork */
|
||||||
/* 12mV ADC (OHM) */
|
/* 12mV ADC (OHM) */
|
||||||
/* 16 bit fans (OHM) */
|
/* 16 bit fans (OHM) */
|
||||||
@@ -411,7 +415,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "E",
|
.suffix = "E",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
||||||
| FEAT_PWM_FREQ2 | FEAT_SCALING,
|
| FEAT_PWM_FREQ2 | FEAT_SCALING | FEAT_FANCTL_ONOFF,
|
||||||
/* PECI (coreboot) */
|
/* PECI (coreboot) */
|
||||||
/* 12mV ADC (HWSensors4, OHM) */
|
/* 12mV ADC (HWSensors4, OHM) */
|
||||||
/* 16 bit fans (HWSensors4, OHM) */
|
/* 16 bit fans (HWSensors4, OHM) */
|
||||||
@@ -422,21 +426,24 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.name = "it8781",
|
.name = "it8781",
|
||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
|
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
|
||||||
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2,
|
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.old_peci_mask = 0x4,
|
.old_peci_mask = 0x4,
|
||||||
},
|
},
|
||||||
[it8782] = {
|
[it8782] = {
|
||||||
.name = "it8782",
|
.name = "it8782",
|
||||||
.suffix = "F",
|
.suffix = "F",
|
||||||
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
|
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
|
||||||
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2,
|
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.old_peci_mask = 0x4,
|
.old_peci_mask = 0x4,
|
||||||
},
|
},
|
||||||
[it8783] = {
|
[it8783] = {
|
||||||
.name = "it8783",
|
.name = "it8783",
|
||||||
.suffix = "E/F",
|
.suffix = "E/F",
|
||||||
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
|
.features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
|
||||||
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2,
|
| FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.old_peci_mask = 0x4,
|
.old_peci_mask = 0x4,
|
||||||
},
|
},
|
||||||
[it8786] = {
|
[it8786] = {
|
||||||
@@ -444,7 +451,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "E",
|
.suffix = "E",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
||||||
| FEAT_PWM_FREQ2,
|
| FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8790] = {
|
[it8790] = {
|
||||||
@@ -452,7 +459,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "E",
|
.suffix = "E",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_10_9MV_ADC | FEAT_SCALING
|
.features = FEAT_NEWER_AUTOPWM | FEAT_10_9MV_ADC | FEAT_SCALING
|
||||||
| FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI
|
| FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI
|
||||||
| FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2,
|
| FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8792] = {
|
[it8792] = {
|
||||||
@@ -460,7 +467,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "E",
|
.suffix = "E",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_10_9MV_ADC | FEAT_SCALING
|
.features = FEAT_NEWER_AUTOPWM | FEAT_10_9MV_ADC | FEAT_SCALING
|
||||||
| FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI
|
| FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI
|
||||||
| FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2,
|
| FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8603] = {
|
[it8603] = {
|
||||||
@@ -476,7 +483,8 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.suffix = "E",
|
.suffix = "E",
|
||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL
|
||||||
| FEAT_AVCC3 | FEAT_PWM_FREQ2 | FEAT_SCALING,
|
| FEAT_AVCC3 | FEAT_PWM_FREQ2 | FEAT_SCALING
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8620] = {
|
[it8620] = {
|
||||||
@@ -485,7 +493,8 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_SIX_FANS
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_SIX_FANS
|
||||||
| FEAT_IN7_INTERNAL | FEAT_SIX_PWM | FEAT_PWM_FREQ2
|
| FEAT_IN7_INTERNAL | FEAT_SIX_PWM | FEAT_PWM_FREQ2
|
||||||
| FEAT_SIX_TEMP | FEAT_VIN3_5V | FEAT_SCALING,
|
| FEAT_SIX_TEMP | FEAT_VIN3_5V | FEAT_SCALING
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8622] = {
|
[it8622] = {
|
||||||
@@ -503,7 +512,8 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
|
||||||
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_SIX_FANS
|
| FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_SIX_FANS
|
||||||
| FEAT_IN7_INTERNAL | FEAT_SIX_PWM | FEAT_PWM_FREQ2
|
| FEAT_IN7_INTERNAL | FEAT_SIX_PWM | FEAT_PWM_FREQ2
|
||||||
| FEAT_SIX_TEMP | FEAT_SCALING | FEAT_AVCC3,
|
| FEAT_SIX_TEMP | FEAT_SCALING | FEAT_AVCC3
|
||||||
|
| FEAT_FANCTL_ONOFF,
|
||||||
.peci_mask = 0x07,
|
.peci_mask = 0x07,
|
||||||
},
|
},
|
||||||
[it8655] = {
|
[it8655] = {
|
||||||
@@ -566,6 +576,7 @@ static const struct it87_devices it87_devices[] = {
|
|||||||
| FEAT_SIX_PWM))
|
| FEAT_SIX_PWM))
|
||||||
#define has_bank_sel(data) ((data)->features & FEAT_BANK_SEL)
|
#define has_bank_sel(data) ((data)->features & FEAT_BANK_SEL)
|
||||||
#define has_scaling(data) ((data)->features & FEAT_SCALING)
|
#define has_scaling(data) ((data)->features & FEAT_SCALING)
|
||||||
|
#define has_fanctl_onoff(data) ((data)->features & FEAT_FANCTL_ONOFF)
|
||||||
|
|
||||||
struct it87_sio_data {
|
struct it87_sio_data {
|
||||||
enum chips type;
|
enum chips type;
|
||||||
@@ -1203,11 +1214,12 @@ static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR, show_temp_type,
|
|||||||
|
|
||||||
static int pwm_mode(const struct it87_data *data, int nr)
|
static int pwm_mode(const struct it87_data *data, int nr)
|
||||||
{
|
{
|
||||||
if (data->type != it8603 && nr < 3 && !(data->fan_main_ctrl & BIT(nr)))
|
if (has_fanctl_onoff(data) && nr < 3 &&
|
||||||
|
!(data->fan_main_ctrl & BIT(nr)))
|
||||||
return 0; /* Full speed */
|
return 0; /* Full speed */
|
||||||
if (data->pwm_ctrl[nr] & 0x80)
|
if (data->pwm_ctrl[nr] & 0x80)
|
||||||
return 2; /* Automatic mode */
|
return 2; /* Automatic mode */
|
||||||
if ((data->type == it8603 || nr >= 3) &&
|
if ((!has_fanctl_onoff(data) || nr >= 3) &&
|
||||||
data->pwm_duty[nr] == pwm_to_reg(data, 0xff))
|
data->pwm_duty[nr] == pwm_to_reg(data, 0xff))
|
||||||
return 0; /* Full speed */
|
return 0; /* Full speed */
|
||||||
|
|
||||||
@@ -1420,7 +1432,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
|
|||||||
mutex_lock(&data->update_lock);
|
mutex_lock(&data->update_lock);
|
||||||
|
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
if (nr < 3 && data->type != it8603) {
|
if (nr < 3 && has_fanctl_onoff(data)) {
|
||||||
int tmp;
|
int tmp;
|
||||||
/* make sure the fan is on when in on/off mode */
|
/* make sure the fan is on when in on/off mode */
|
||||||
tmp = it87_read_value(data, IT87_REG_FAN_CTL);
|
tmp = it87_read_value(data, IT87_REG_FAN_CTL);
|
||||||
@@ -1460,7 +1472,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
|
|||||||
data->pwm_ctrl[nr] = ctrl;
|
data->pwm_ctrl[nr] = ctrl;
|
||||||
it87_write_value(data, data->REG_PWM[nr], ctrl);
|
it87_write_value(data, data->REG_PWM[nr], ctrl);
|
||||||
|
|
||||||
if (data->type != it8603 && nr < 3) {
|
if (has_fanctl_onoff(data) && nr < 3) {
|
||||||
/* set SmartGuardian mode */
|
/* set SmartGuardian mode */
|
||||||
data->fan_main_ctrl |= BIT(nr);
|
data->fan_main_ctrl |= BIT(nr);
|
||||||
it87_write_value(data, IT87_REG_FAN_MAIN_CTRL,
|
it87_write_value(data, IT87_REG_FAN_MAIN_CTRL,
|
||||||
|
Reference in New Issue
Block a user