diff --git a/sys/dev/it/it.c b/sys/dev/it/it.c index 3ccf328..30a31e2 100644 --- a/sys/dev/it/it.c +++ b/sys/dev/it/it.c @@ -141,6 +141,7 @@ static int it_attach(struct device *dev) { struct it_softc *sc = device_get_softc(dev); + int fancount; int i; u_int8_t cr; @@ -155,16 +156,22 @@ it_attach(struct device *dev) sc->numsensors = IT_NUM_SENSORS; cr = it_readreg(sc, ITD_COREID); - if (cr == IT_COREID_12) { /* XXX perhaps >= ? */ + if (cr >= IT_COREID_12) { /* Force use of 16-bit fan counters. */ cr = it_readreg(sc, ITD_FAN_CTL16); it_writereg(sc, ITD_FAN_CTL16, cr | IT_FAN16_MASK); sc->fan16bit = 1; } - it_setup_fan(sc, 0, 3); - it_setup_volt(sc, 3, 9); - it_setup_temp(sc, 12, 3); + fancount = 5; + if (!sc->fan16bit) { + fancount -= 2; + sc->numsensors -= 2; + } + + it_setup_fan(sc, 0, fancount); + it_setup_volt(sc, fancount, 9); + it_setup_temp(sc, fancount + 9, 3); if (sensor_task_register(sc, it_refresh, 5)) { device_printf(sc->sc_dev, "unable to register update task\n"); @@ -344,6 +351,17 @@ it_16bit_fanrpm(struct it_softc *sc, struct ksensor *sensors) else sensors[i].flags |= SENSOR_FINVALID; } + for (i = 0; i < 2; i++) { + sdata = it_readreg(sc, ITD_SENSORFANBASE2 + 2 * i + 1); + sdata <<= 8; + sdata |= it_readreg(sc, ITD_SENSORFANBASE2 + 2 * i); + if (sdata != 0xffff && sdata != 0) { + sensors[3 + i].flags &= ~SENSOR_FINVALID; + sensors[3 + i].value = (1350000 / 2) / sdata; + } + else + sensors[3 + i].flags |= SENSOR_FINVALID; + } } /* @@ -354,12 +372,15 @@ static void it_refresh_sensor_data(struct it_softc *sc) { /* Refresh our stored data for every sensor */ - it_generic_stemp(sc, &sc->sensors[12]); - it_generic_svolt(sc, &sc->sensors[3]); - if (sc->fan16bit) + if (sc->fan16bit) { it_16bit_fanrpm(sc, &sc->sensors[0]); - else + it_generic_svolt(sc, &sc->sensors[5]); + it_generic_svolt(sc, &sc->sensors[14]); + } else { it_generic_fanrpm(sc, &sc->sensors[0]); + it_generic_svolt(sc, &sc->sensors[3]); + it_generic_stemp(sc, &sc->sensors[12]); + } } static void diff --git a/sys/dev/it/itvar.h b/sys/dev/it/itvar.h index d50f6e3..ba10316 100644 --- a/sys/dev/it/itvar.h +++ b/sys/dev/it/itvar.h @@ -29,7 +29,7 @@ #ifndef _DEV_ISA_ITVAR_H #define _DEV_ISA_ITVAR_H -#define IT_NUM_SENSORS 15 +#define IT_NUM_SENSORS 17 /* chip ids */ #define IT_ID_IT87 0x90 @@ -62,6 +62,7 @@ #define ITD_SENSORFANBASE 0x0d /* Fan from 0x0d to 0x0f */ #define ITD_SENSORFANBASE_EXT 0x18 /* Extended fan (upper 8 bits) from 0x18 to 0x1a */ +#define ITD_SENSORFANBASE2 0x80 /* 16-bit: 81:80, 83:82 */ #define ITD_SENSORVOLTBASE 0x20 /* VIN from 0x20 to 0x28 */ #define ITD_SENSORTEMPBASE 0x29 /* Temperature from 0x29 to 0x2b */