Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys Pull up (requested by thorpej):
details: https://anonhg.NetBSD.org/src/rev/39c79eb843b3
branches: netbsd-1-5
changeset: 488811:39c79eb843b3
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sun Jul 30 17:54:10 2000 +0000
description:
Pull up (requested by thorpej):
lm_pnpbios.c 1.2->1.3
files 1.374->1.375
nslm7x.c 1.3->1.4
nslm7xvar.h 1.2->1.3
lm_isa.c 1.2->1.3
files.pci 1.96->1.97
viaenv.c 1.2->1.3
sysmon.c 1.1
sysmonvar.h 1.1
Add a clearing-house pseudo-device for system monitoring devices
such as the LM78 and VT82C686A (and eventually ACPI). Multiple
sensor devices can be hooked registered with `sysmon', and eventually
sysmon will also handle hardware (and software) watchdog timers.
Convert the `lm' and `viaenv' drivers to the new interface.
diffstat:
sys/arch/i386/pnpbios/lm_pnpbios.c | 5 +-
sys/conf/files | 8 +-
sys/dev/ic/nslm7x.c | 258 ++++++++++--------------------
sys/dev/ic/nslm7xvar.h | 4 +-
sys/dev/isa/lm_isa.c | 6 +-
sys/dev/pci/files.pci | 4 +-
sys/dev/pci/viaenv.c | 161 ++++++-------------
sys/dev/sysmon/sysmon.c | 305 +++++++++++++++++++++++++++++++++++++
sys/dev/sysmon/sysmonvar.h | 65 +++++++
9 files changed, 527 insertions(+), 289 deletions(-)
diffs (truncated from 1049 to 300 lines):
diff -r 07dc1b7c321a -r 39c79eb843b3 sys/arch/i386/pnpbios/lm_pnpbios.c
--- a/sys/arch/i386/pnpbios/lm_pnpbios.c Sun Jul 30 16:45:36 2000 +0000
+++ b/sys/arch/i386/pnpbios/lm_pnpbios.c Sun Jul 30 17:54:10 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lm_pnpbios.c,v 1.2 2000/03/01 20:24:53 groo Exp $ */
+/* $NetBSD: lm_pnpbios.c,v 1.2.6.1 2000/07/30 17:54:10 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -51,7 +51,8 @@
#include <i386/pnpbios/pnpbiosvar.h>
-#include <sys/envsys.h>
+#include <dev/sysmon/sysmonvar.h>
+
#include <dev/ic/nslm7xvar.h>
diff -r 07dc1b7c321a -r 39c79eb843b3 sys/conf/files
--- a/sys/conf/files Sun Jul 30 16:45:36 2000 +0000
+++ b/sys/conf/files Sun Jul 30 17:54:10 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.373.2.2 2000/07/14 14:36:22 onoe Exp $
+# $NetBSD: files,v 1.373.2.3 2000/07/30 17:54:11 bouyer Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -190,6 +190,10 @@
define mii_bitbang
file dev/mii/mii_bitbang.c mii_bitbang
+# Central clearing house for system monitoring.
+define sysmon
+file dev/sysmon/sysmon.c sysmon needs-flag
+
# "Chipset" drivers. These are the bus-independent routines which
# contain the cfdrivers. Attachments are provided by files.<bus>
@@ -394,7 +398,7 @@
define i2c_eeprom
# National Semiconductor LM7[89]
-device lm
+device lm: sysmon
file dev/ic/nslm7x.c lm needs-flag
# Essential Communications Corp. HIPPI Interface
diff -r 07dc1b7c321a -r 39c79eb843b3 sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c Sun Jul 30 16:45:36 2000 +0000
+++ b/sys/dev/ic/nslm7x.c Sun Jul 30 17:54:10 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nslm7x.c,v 1.3 2000/03/09 04:20:58 groo Exp $ */
+/* $NetBSD: nslm7x.c,v 1.3.4.1 2000/07/30 17:54:14 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -49,13 +49,13 @@
#include <sys/conf.h>
#include <sys/time.h>
-#include <sys/envsys.h>
-
#include <machine/bus.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
+#include <dev/sysmon/sysmonvar.h>
+
#include <dev/ic/nslm7xvar.h>
#include <machine/intr.h>
@@ -67,8 +67,8 @@
#define DPRINTF(x)
#endif
-struct envsys_range ranges[] = { /* sc->sensors sub-intervals */
- /* for each unit type */
+const struct envsys_range lm_ranges[] = { /* sc->sensors sub-intervals */
+ /* for each unit type */
{ 7, 7, ENVSYS_STEMP },
{ 8, 10, ENVSYS_SFANRPM },
{ 1, 0, ENVSYS_SVOLTS_AC }, /* None */
@@ -79,19 +79,11 @@
};
-#define SCFLAG_OREAD 0x00000001
-#define SCFLAG_OWRITE 0x00000002
-#define SCFLAG_OPEN (SCFLAG_OREAD|SCFLAG_OWRITE)
-
u_int8_t lm_readreg __P((struct lm_softc *, int));
void lm_writereg __P((struct lm_softc *, int, int));
void lm_refresh_sensor_data __P((struct lm_softc *));
-
-cdev_decl(lm);
-
-extern struct cfdriver lm_cd;
-
-#define LMUNIT(x) (minor(x))
+int lm_gtredata __P((struct sysmon_envsys *, struct envsys_tre_data *));
+int lm_streinfo __P((struct sysmon_envsys *, struct envsys_basic_info *));
u_int8_t
lm_readreg(sc, reg)
@@ -212,184 +204,114 @@
lmsc->info[i].desc[4] = i - 7 + '0';
lmsc->info[i].desc[5] = 0;
}
-}
+ /*
+ * Hook into the System Monitor.
+ */
+ lmsc->sc_sysmon.sme_ranges = lm_ranges;
+ lmsc->sc_sysmon.sme_sensor_info = lmsc->info;
+ lmsc->sc_sysmon.sme_sensor_data = lmsc->sensors;
+ lmsc->sc_sysmon.sme_cookie = lmsc;
-int
-lmopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- int unit = LMUNIT(dev);
- struct lm_softc *sc;
-
- if (unit >= lm_cd.cd_ndevs)
- return (ENXIO);
- sc = lm_cd.cd_devs[unit];
- if (sc == 0)
- return (ENXIO);
+ lmsc->sc_sysmon.sme_gtredata = lm_gtredata;
+ lmsc->sc_sysmon.sme_streinfo = lm_streinfo;
- /* XXX - add spinlocks instead! */
- if (sc->sc_flags & SCFLAG_OPEN)
- return (EBUSY);
+ lmsc->sc_sysmon.sme_nsensors = LM_NUM_SENSORS;
+ lmsc->sc_sysmon.sme_envsys_version = 1000;
- sc->sc_flags |= SCFLAG_OPEN;
-
- return 0;
+ if (sysmon_envsys_register(&lmsc->sc_sysmon))
+ printf("%s: unable to register with sysmon\n",
+ lmsc->sc_dev.dv_xname);
}
int
-lmclose(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
+lm_gtredata(sme, tred)
+ struct sysmon_envsys *sme;
+ struct envsys_tre_data *tred;
{
- struct lm_softc *sc = lm_cd.cd_devs[LMUNIT(dev)];
-
- DPRINTF(("lmclose: pid %d flag %x mode %x\n", p->p_pid, flag, mode));
+ static const struct timeval onepointfive = { 1, 500000 };
+ struct timeval t;
+ struct lm_softc *sc = sme->sme_cookie;
+ int i, s;
- sc->sc_flags &= ~SCFLAG_OPEN;
+ /* read new values at most once every 1.5 seconds */
+ timeradd(&sc->lastread, &onepointfive, &t);
+ s = splclock();
+ i = timercmp(&mono_time, &t, >);
+ if (i) {
+ sc->lastread.tv_sec = mono_time.tv_sec;
+ sc->lastread.tv_usec = mono_time.tv_usec;
+ }
+ splx(s);
+
+ if (i)
+ lm_refresh_sensor_data(sc);
- return 0;
+ *tred = sc->sensors[tred->sensor];
+
+ return (0);
}
int
-lmioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct lm_softc *sc = lm_cd.cd_devs[LMUNIT(dev)];
- struct envsys_range *rng;
- struct envsys_tre_data *tred;
+lm_streinfo(sme, binfo)
+ struct sysmon_envsys *sme;
struct envsys_basic_info *binfo;
- struct timeval t, onepointfive = { 1, 500000 };
- u_int8_t sdata;
- int32_t *vers;
- int i, s;
+{
+ struct lm_softc *sc = sme->sme_cookie;
int divisor;
-
- switch (cmd) {
- case ENVSYS_VERSION:
- vers = (int32_t *)data;
- *vers = 1000;
-
- return (0);
+ u_int8_t sdata;
- case ENVSYS_GRANGE:
- rng = (struct envsys_range *)data;
- if ((rng->units < ENVSYS_STEMP) ||
- (rng->units > ENVSYS_SAMPS) ) {
- /* Return empty range for unsupp sensor types */
- rng->low = 1;
- rng->high = 0;
- } else {
- rng->low = ranges[rng->units].low;
- rng->high = ranges[rng->units].high;
- }
-
- return (0);
+ if (sc->info[binfo->sensor].units == ENVSYS_SVOLTS_DC)
+ sc->info[binfo->sensor].rfact = binfo->rfact;
+ else {
+ /* FAN1 and FAN2 can have divisors set, but not FAN3 */
+ if ((sc->info[binfo->sensor].units == ENVSYS_SFANRPM)
+ && (binfo->sensor != 10)) {
- case ENVSYS_GTREDATA:
- tred = (struct envsys_tre_data *)data;
- tred->validflags = 0;
-
- if (tred->sensor < LM_NUM_SENSORS) {
- /* read new values at most once every 1.5 seconds */
- s = splclock();
-
- timeradd(&sc->lastread, &onepointfive, &t);
-
- i = timercmp(&mono_time, &t, >);
- if (i) {
- sc->lastread.tv_sec = mono_time.tv_sec;
- sc->lastread.tv_usec = mono_time.tv_usec;
- }
- splx(s);
-
- if (i) {
- lm_refresh_sensor_data(sc);
+ if (binfo->rpms == 0) {
+ binfo->validflags = 0;
+ return (0);
}
- bcopy(&sc->sensors[tred->sensor], tred,
- sizeof(struct envsys_tre_data));
+ /* 153 is the nominal FAN speed value */
+ divisor = 1350000 / (binfo->rpms * 153);
+
+ /* ...but we need lg(divisor) */
+ if (divisor <= 1)
+ divisor = 0;
+ else if (divisor <= 2)
+ divisor = 1;
+ else if (divisor <= 4)
+ divisor = 2;
+ else
+ divisor = 3;
+
+ /*
+ * FAN1 div is in bits <5:4>, FAN2 div is
+ * in <7:6>
+ */
+ sdata = lm_readreg(sc, LMD_VIDFAN);
+ if ( binfo->sensor == 8 ) { /* FAN1 */
+ divisor <<= 4;
+ sdata = (sdata & 0xCF) | divisor;
+ } else { /* FAN2 */
+ divisor <<= 6;
+ sdata = (sdata & 0x3F) | divisor;
+ }
+
+ lm_writereg(sc, LMD_VIDFAN, sdata);
}
- return (0);
-
- case ENVSYS_GTREINFO:
- binfo = (struct envsys_basic_info *)data;
-
Home |
Main Index |
Thread Index |
Old Index