summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAlexander Yurchenko <grange@cvs.openbsd.org>2005-07-26 19:08:10 +0000
committerAlexander Yurchenko <grange@cvs.openbsd.org>2005-07-26 19:08:10 +0000
commit48b47de4040ce6463df01690107e4e2f4fd91386 (patch)
treec1460084b2f44fe6b6e5ade9bc3b06b3dd794942 /sys
parent848bacd75f9ef99525e933a18affed66bc3467e5 (diff)
Fan tachometers improvements from form@pdp-11.org.ru:
- correct rpm calculation - automatic devisor tuning - correct handling of fan being stopped and started again Thanks jsg@ for testing.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/isa/it.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/sys/dev/isa/it.c b/sys/dev/isa/it.c
index 6be0db7dfad..91ddf9c9384 100644
--- a/sys/dev/isa/it.c
+++ b/sys/dev/isa/it.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: it.c,v 1.14 2005/04/29 17:13:54 grange Exp $ */
+/* $OpenBSD: it.c,v 1.15 2005/07/26 19:08:09 grange Exp $ */
/*
* Copyright (c) 2003 Julien Bordet <zejames@greyhats.org>
@@ -283,31 +283,29 @@ it_generic_svolt(struct it_softc *sc, struct sensor *sensors)
void
it_generic_fanrpm(struct it_softc *sc, struct sensor *sensors)
{
- int i, sdata, divisor;
+ int i, sdata, divisor, odivisor, ndivisor;
- divisor = it_readreg(sc, ITD_FAN);
- for (i = 0; i < 3; i++) {
- sdata = it_readreg(sc, ITD_SENSORFANBASE + i);
- switch (i) {
- case 2:
- divisor = (divisor & 0x40) ? 3 : 1;
- break;
- case 1:
- divisor = (divisor >> 3) & 0x7;
- break;
- case 0:
- divisor = divisor & 0x7;
- break;
- }
-
- if (sdata == 0xff) {
+ odivisor = ndivisor = divisor = it_readreg(sc, ITD_FAN);
+ for (i = 0; i < 3; i++, divisor >>= 3) {
+ sensors[i].flags &= ~SENSOR_FINVALID;
+ if ((sdata = it_readreg(sc, ITD_SENSORFANBASE + i)) == 0xff) {
sensors[i].flags |= SENSOR_FINVALID;
+ if (i == 2)
+ ndivisor ^= 0x40;
+ else {
+ ndivisor &= ~(7 << (i * 3));
+ ndivisor |= ((divisor + 1) & 7) << (i * 3);
+ }
} else if (sdata == 0) {
sensors[i].value = 0;
} else {
- sensors[i].value = 1350000 / (sdata << divisor);
+ if (i == 2)
+ divisor = divisor & 1 ? 3 : 1;
+ sensors[i].value = 1350000 / (sdata << (divisor & 7));
}
}
+ if (ndivisor != odivisor)
+ it_writereg(sc, ITD_FAN, ndivisor);
}
/*