diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-05-07 07:00:47 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-05-07 07:00:47 +0000 |
commit | 3196b51f3bb745b5c03b15a522a2a7c50c6e528c (patch) | |
tree | 966040720678b7be96d71a4559ef93d10707da67 /sys/dev/ic/nslm7x.c | |
parent | 89255557b5a4c39041e926b80a1128b71f69a59b (diff) |
LM7x models improvements:
- correct divisor for fan3 (2 means 2^1, so the divisor is actually 1, not 2)
- fan1 and fan2 have adjastable divisors, use this feature to
dynamically correct divisors for slow fans
- fix SENSOR_FINVALID usage
Based on the diff from Alexander Bluhm <alexander.bluhm@gmx.net> in
PR 3719.
Diffstat (limited to 'sys/dev/ic/nslm7x.c')
-rw-r--r-- | sys/dev/ic/nslm7x.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c index 0991ffa1600..30866f69603 100644 --- a/sys/dev/ic/nslm7x.c +++ b/sys/dev/ic/nslm7x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nslm7x.c,v 1.6 2004/02/10 19:58:16 grange Exp $ */ +/* $OpenBSD: nslm7x.c,v 1.7 2004/05/07 07:00:46 grange Exp $ */ /* $NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $ */ /*- @@ -645,25 +645,34 @@ generic_svolt(struct lm_softc *sc, struct sensor *sensors) void generic_fanrpm(struct lm_softc *sc, struct sensor *sensors) { - int i, sdata, divisor; + int i, sdata, divisor, vidfan; for (i = 0; i < 3; i++) { sdata = (*sc->lm_readreg)(sc, LMD_SENSORBASE + 8 + i); - DPRINTF(("sdata[fan%d] 0x%x\n", i, sdata)); + vidfan = (*sc->lm_readreg)(sc, LMD_VIDFAN); + DPRINTF(("sdata[fan%d] 0x%x", i, sdata)); if (i == 2) - divisor = 2; /* Fixed divisor for FAN3 */ + divisor = 1; /* Fixed divisor for FAN3 */ else if (i == 1) /* Bits 7 & 6 of VID/FAN */ - divisor = ((*sc->lm_readreg)(sc, - LMD_VIDFAN) >> 6) & 0x3; + divisor = (vidfan >> 6) & 0x3; else - divisor = ((*sc->lm_readreg)(sc, - LMD_VIDFAN) >> 4) & 0x3; + divisor = (vidfan >> 4) & 0x3; + DPRINTF((", divisor %d\n", 2 << divisor)); if (sdata == 0xff) { - sensors[i].flags |= SENSOR_FINVALID; + /* Fan can be too slow, try to adjust the divisor */ + if (i < 2 && divisor < 3) { + divisor++; + vidfan &= ~(0x3 << (i == 0 ? 4 : 6)); + vidfan |= (divisor & 0x3) << (i == 0 ? 4 : 6); + (*sc->lm_writereg)(sc, LMD_VIDFAN, vidfan); + } + sensors[i].value = 0; } else if (sdata == 0x00) { + sensors[i].flags |= SENSOR_FINVALID; sensors[i].value = 0; } else { + sensors[i].flags &= ~SENSOR_FINVALID; sensors[i].value = 1350000 / (sdata << divisor); } } |