diff options
author | 2008-10-22 05:38:17 +0000 | |
---|---|---|
committer | 2008-10-22 05:38:17 +0000 | |
commit | 1e5c1a8761ad506b28dca94ae55dd3266f71c46d (patch) | |
tree | 93d8992e7fadfaf02b0e8235a0e939f833d495ce /sys/dev/isa/it.c | |
parent | Re-add support TX VLAN tag insertion and RX VLAN tag stripping. (diff) | |
download | wireguard-openbsd-1e5c1a8761ad506b28dca94ae55dd3266f71c46d.tar.xz wireguard-openbsd-1e5c1a8761ad506b28dca94ae55dd3266f71c46d.zip |
o add FAN4 and FAN5 sensors for IT8716/8718/8726
o always use 16-bit FAN counters for IT8716/8718/8726
o do not try to poll sensors disabled by BIOS
o sync VIN5 & VIN6 sensors description w/ ITE docs
tested by naddy@ weerd@
Diffstat (limited to 'sys/dev/isa/it.c')
-rw-r--r-- | sys/dev/isa/it.c | 139 |
1 files changed, 97 insertions, 42 deletions
diff --git a/sys/dev/isa/it.c b/sys/dev/isa/it.c index 84700ca25f5..74560168977 100644 --- a/sys/dev/isa/it.c +++ b/sys/dev/isa/it.c @@ -1,4 +1,4 @@ -/* $OpenBSD: it.c,v 1.36 2008/10/11 20:31:50 miod Exp $ */ +/* $OpenBSD: it.c,v 1.37 2008/10/22 05:38:17 form Exp $ */ /* * Copyright (c) 2007-2008 Oleg Safiullin <form@pdp-11.org.ru> @@ -71,8 +71,8 @@ int it_wdog_cb(void *, int); struct { - int type; - const char *desc; + enum sensor_type type; + const char *desc; } it_sensors[IT_EC_NUMSENSORS] = { #define IT_TEMP_BASE 0 #define IT_TEMP_COUNT 3 @@ -81,20 +81,22 @@ struct { { SENSOR_TEMP, NULL }, #define IT_FAN_BASE 3 -#define IT_FAN_COUNT 3 +#define IT_FAN_COUNT 5 + { SENSOR_FANRPM, NULL }, + { SENSOR_FANRPM, NULL }, { SENSOR_FANRPM, NULL }, { SENSOR_FANRPM, NULL }, { SENSOR_FANRPM, NULL }, -#define IT_VOLT_BASE 6 +#define IT_VOLT_BASE 8 #define IT_VOLT_COUNT 9 { SENSOR_VOLTS_DC, "VCORE_A" }, { SENSOR_VOLTS_DC, "VCORE_B" }, { SENSOR_VOLTS_DC, "+3.3V" }, { SENSOR_VOLTS_DC, "+5V" }, { SENSOR_VOLTS_DC, "+12V" }, - { SENSOR_VOLTS_DC, "-5V" }, { SENSOR_VOLTS_DC, "-12V" }, + { SENSOR_VOLTS_DC, "-5V" }, { SENSOR_VOLTS_DC, "+5VSB" }, { SENSOR_VOLTS_DC, "VBAT" } }; @@ -106,12 +108,22 @@ int it_vrfact[IT_VOLT_COUNT] = { RFACT_NONE, /* +3.3V */ RFACT(68, 100), /* +5V */ RFACT(30, 10), /* +12V */ - RFACT(21, 10), /* -5V */ RFACT(83, 20), /* -12V */ + RFACT(21, 10), /* -5V */ RFACT(68, 100), /* +5VSB */ RFACT_NONE /* VBAT */ }; +int it_fan_regs[] = { + IT_EC_FAN_TAC1, IT_EC_FAN_TAC2, IT_EC_FAN_TAC3, + IT_EC_FAN_TAC4_LSB, IT_EC_FAN_TAC5_LSB +}; + +int it_fan_ext_regs[] = { + IT_EC_FAN_EXT_TAC1, IT_EC_FAN_EXT_TAC2, IT_EC_FAN_EXT_TAC3, + IT_EC_FAN_TAC4_MSB, IT_EC_FAN_TAC5_MSB +}; + LIST_HEAD(, it_softc) it_softc_list = LIST_HEAD_INITIALIZER(&it_softc_list); @@ -222,7 +234,7 @@ it_attach(struct device *parent, struct device *self, void *aux) it_exit(sc->sc_iot, sc->sc_ioh); LIST_INSERT_HEAD(&it_softc_list, sc, sc_list); - printf(": IT%xF rev 0x%x", sc->sc_chipid, sc->sc_chiprev); + printf(": IT%xF rev %X", sc->sc_chipid, sc->sc_chiprev); if (sc->sc_ec_iobase == 0) { printf(", EC disabled\n"); @@ -256,9 +268,14 @@ it_attach(struct device *parent, struct device *self, void *aux) return; } + /* use 16-bit FAN tachometer registers for newer chips */ + if (sc->sc_chipid != IT_ID_8705 && sc->sc_chipid != IT_ID_8712) + it_ec_writereg(sc, IT_EC_FAN_ECER, + it_ec_readreg(sc, IT_EC_FAN_ECER) | 0x07); + /* activate monitoring */ it_ec_writereg(sc, IT_EC_CFG, - it_ec_readreg(sc, IT_EC_CFG) | IT_EC_CFG_START | IT_EC_INT_CLEAR); + it_ec_readreg(sc, IT_EC_CFG) | IT_EC_CFG_START | IT_EC_CFG_INTCLR); /* initialize sensors */ strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, @@ -319,10 +336,22 @@ void it_ec_refresh(void *arg) { struct it_softc *sc = arg; - int i, sdata, mode, divisor, odivisor, ndivisor; + int i, sdata, divisor, odivisor, ndivisor; + u_int8_t cr, ecr; /* refresh temp sensors */ + cr = it_ec_readreg(sc, IT_EC_ADC_TEMPER); + for (i = 0; i < IT_TEMP_COUNT; i++) { + sc->sc_sensors[IT_TEMP_BASE + i].flags &= + SENSOR_FINVALID; + + if (!(cr & (1 << i)) && !(cr & (1 << (i + 3)))) { + sc->sc_sensors[IT_TEMP_BASE + i].flags |= + SENSOR_FINVALID; + continue; + } + sdata = it_ec_readreg(sc, IT_EC_TEMPBASE + i); /* convert to degF */ sc->sc_sensors[IT_TEMP_BASE + i].value = @@ -330,7 +359,18 @@ it_ec_refresh(void *arg) } /* refresh volt sensors */ + cr = it_ec_readreg(sc, IT_EC_ADC_VINER); + for (i = 0; i < IT_VOLT_COUNT; i++) { + sc->sc_sensors[IT_VOLT_BASE + i].flags &= + SENSOR_FINVALID; + + if ((i < 8) && !(cr & (1 << i))) { + sc->sc_sensors[IT_VOLT_BASE + i].flags |= + SENSOR_FINVALID; + continue; + } + sdata = it_ec_readreg(sc, IT_EC_VOLTBASE + i); /* voltage returned as (mV >> 4) */ sc->sc_sensors[IT_VOLT_BASE + i].value = sdata << 4; @@ -347,25 +387,55 @@ it_ec_refresh(void *arg) } /* refresh fan sensors */ - if (sc->sc_chipid == IT_ID_8705 || sc->sc_chipid == IT_ID_8712) + cr = it_ec_readreg(sc, IT_EC_FAN_MCR); + + if (sc->sc_chipid != IT_ID_8705 && sc->sc_chipid != IT_ID_8712) { + /* use 16-bit FAN tachometer registers */ + ecr = it_ec_readreg(sc, IT_EC_FAN_ECER); + + for (i = 0; i < IT_FAN_COUNT; i++) { + sc->sc_sensors[IT_FAN_BASE + i].flags &= + ~SENSOR_FINVALID; + + if (i < 3 && !(cr & (1 << (i + 4)))) { + sc->sc_sensors[IT_FAN_BASE + i].flags |= + SENSOR_FINVALID; + continue; + } else if (i > 2 && !(ecr & (1 << (i + 1)))) { + sc->sc_sensors[IT_FAN_BASE + i].flags |= + SENSOR_FINVALID; + continue; + } + + sdata = it_ec_readreg(sc, it_fan_regs[i]); + sdata |= it_ec_readreg(sc, it_fan_ext_regs[i]) << 8; + + if (sdata == 0 || sdata == 0xffff) + sc->sc_sensors[IT_FAN_BASE + i].value = 0; + else + sc->sc_sensors[IT_FAN_BASE + i].value = + 675000 / sdata; + } + } else { + /* use 8-bit FAN tachometer & FAN divisor registers */ odivisor = ndivisor = divisor = it_ec_readreg(sc, IT_EC_FAN_DIV); - else { - mode = it_ec_readreg(sc, IT_EC_FAN_ECR); - divisor = -1; - } - - for (i = 0; i < IT_FAN_COUNT; i++) { - sc->sc_sensors[IT_FAN_BASE + i].flags &= ~SENSOR_FINVALID; - sdata = it_ec_readreg(sc, IT_EC_FANBASE + i); - if (divisor != -1) { - /* - * Use 8-bit FAN Tachometer & FAN Divisor registers - */ - if (sdata == 0xff) { + for (i = 0; i < IT_FAN_COUNT; i++) { + if (i > 2 || !(cr & (1 << (i + 4)))) { sc->sc_sensors[IT_FAN_BASE + i].flags |= SENSOR_FINVALID; + continue; + } + + sc->sc_sensors[IT_FAN_BASE + i].flags &= + ~SENSOR_FINVALID; + + sdata = it_ec_readreg(sc, it_fan_regs[i]); + + if (sdata == 0xff) { + sc->sc_sensors[IT_FAN_BASE + i].value = 0; + if (i == 2) ndivisor ^= 0x40; else { @@ -380,25 +450,10 @@ it_ec_refresh(void *arg) 1350000 / (sdata << (divisor & 7)); } else sc->sc_sensors[IT_FAN_BASE + i].value = 0; - - if (ndivisor != odivisor) - it_ec_writereg(sc, IT_EC_FAN_DIV, ndivisor); - } else { - /* - * Use 16-bit FAN tachometer register - */ - if (mode & (1 << i)) - sdata |= it_ec_readreg(sc, - IT_EC_FANEXTBASE + i) << 8; - if (sdata == ((mode & (1 << i)) ? 0xffff : 0xff)) - sc->sc_sensors[IT_FAN_BASE + i].flags |= - SENSOR_FINVALID; - else if (sdata != 0) - sc->sc_sensors[IT_FAN_BASE + i].value = - 675000 / sdata; - else - sc->sc_sensors[IT_FAN_BASE + i].value = 0; } + + if (ndivisor != odivisor) + it_ec_writereg(sc, IT_EC_FAN_DIV, ndivisor); } } |