From: Guenter Roeck Date: Sat, 5 Aug 2017 17:57:05 +0000 (-0700) Subject: Improve fan6/pwm6 support X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=db6ab95430c90ff170cb36ea3b5d6339eded4d7e;p=groeck-nct6775 Improve fan6/pwm6 support Improve fan6/pwm6 detection. Add support for fan pulses for fans 4..6 and fan min limits for fan6. Signed-off-by: Guenter Roeck --- diff --git a/nct6775.c b/nct6775.c index 64855db..eae06cd 100644 --- a/nct6775.c +++ b/nct6775.c @@ -420,8 +420,10 @@ static const u16 NCT6776_REG_TOLERANCE_H[] = { static const u8 NCT6776_REG_PWM_MODE[] = { 0x04, 0, 0, 0, 0, 0 }; static const u8 NCT6776_PWM_MODE_MASK[] = { 0x01, 0, 0, 0, 0, 0 }; -static const u16 NCT6776_REG_FAN_MIN[] = { 0x63a, 0x63c, 0x63e, 0x640, 0x642 }; -static const u16 NCT6776_REG_FAN_PULSES[] = { 0x644, 0x645, 0x646, 0, 0 }; +static const u16 NCT6776_REG_FAN_MIN[] = { + 0x63a, 0x63c, 0x63e, 0x640, 0x642, 0x64a }; +static const u16 NCT6776_REG_FAN_PULSES[] = { + 0x644, 0x645, 0x646, 0x647, 0x648, 0x649 }; static const u16 NCT6776_REG_WEIGHT_DUTY_BASE[] = { 0x13e, 0x23e, 0x33e, 0x83e, 0x93e, 0xa3e }; @@ -1322,7 +1324,7 @@ static bool is_word_sized(struct nct6775_data *data, u16 reg) ((reg & 0xfff0) == 0x4b0 && (reg & 0x000f) < 0x0b) || reg == 0x402 || reg == 0x63a || reg == 0x63c || reg == 0x63e || - reg == 0x640 || reg == 0x642 || + reg == 0x640 || reg == 0x642 || reg == 0x64a || reg == 0x73 || reg == 0x75 || reg == 0x77 || reg == 0x79 || reg == 0x7b || reg == 0x7d; } @@ -3540,7 +3542,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm5pin = false; pwm6pin = false; } else { /* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D */ - int regval_1b, regval_2a, regval_eb; + int regval_1b, regval_2a, regval_2f, regval_eb; + bool dsw_en; regval = superio_inb(sioreg, 0x1c); @@ -3563,14 +3566,22 @@ nct6775_check_fan_inputs(struct nct6775_data *data) case nct6795: regval_1b = superio_inb(sioreg, 0x1b); regval_2a = superio_inb(sioreg, 0x2a); + regval_2f = superio_inb(sioreg, 0x2f); + dsw_en = regval_2f & BIT(3); if (!pwm5pin) pwm5pin = regval & BIT(7); - fan6pin = regval & BIT(1); - pwm6pin = regval & BIT(0); + if (!fan5pin) fan5pin = regval_1b & BIT(5); + fan6pin = false; + pwm6pin = false; + if (!dsw_en) { + fan6pin = regval & BIT(1); + pwm6pin = regval & BIT(0); + } + superio_select(sioreg, NCT6775_LD_12); regval_eb = superio_inb(sioreg, 0xeb); if (!fan5pin) @@ -3582,6 +3593,18 @@ nct6775_check_fan_inputs(struct nct6775_data *data) fan6pin = regval_eb & BIT(3); if (!pwm6pin) pwm6pin = regval_eb & BIT(2); + + if (data->kind == nct6795) { + int regval_ed = superio_inb(sioreg, 0xed); + + if (!fan6pin) + fan6pin = (regval_2a & BIT(4)) && + (!dsw_en || + (dsw_en && (regval_ed & BIT(4)))); + if (!pwm6pin) + pwm6pin = (regval_2a & BIT(3)) && + (regval_ed & BIT(2)); + } break; default: /* NCT6779D */ fan6pin = false; @@ -3596,7 +3619,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) data->has_fan = 0x03 | (fan3pin << 2) | (fan4pin << 3) | (fan5pin << 4) | (fan6pin << 5); data->has_fan_min = 0x03 | (fan3pin << 2) | (fan4min << 3) | - (fan5pin << 4); + (fan5pin << 4) | (fan6pin << 5); data->has_pwm = 0x03 | (pwm3pin << 2) | (pwm4pin << 3) | (pwm5pin << 4) | (pwm6pin << 5); }