Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src VIA VT82C686A hardware monitor



details:   https://anonhg.NetBSD.org/src/rev/a4e43e2b4e46
branches:  trunk
changeset: 485893:a4e43e2b4e46
user:      joda <joda%NetBSD.org@localhost>
date:      Mon May 08 16:40:42 2000 +0000

description:
VIA VT82C686A hardware monitor

diffstat:

 share/man/man4/Makefile |    5 +-
 share/man/man4/viaenv.4 |   75 ++++++++
 sys/dev/pci/files.pci   |   12 +-
 sys/dev/pci/viaenv.c    |  421 ++++++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/pci/viapm.c     |  147 ++++++++++++++++
 sys/dev/pci/viapmvar.h  |   49 +++++
 6 files changed, 706 insertions(+), 3 deletions(-)

diffs (truncated from 757 to 300 lines):

diff -r 22977bafcb4e -r a4e43e2b4e46 share/man/man4/Makefile
--- a/share/man/man4/Makefile   Mon May 08 16:30:57 2000 +0000
+++ b/share/man/man4/Makefile   Mon May 08 16:40:42 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.151 2000/05/07 20:46:10 wiz Exp $
+#      $NetBSD: Makefile,v 1.152 2000/05/08 16:40:42 joda Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/18/93
 
 MAN=   adv.4 adw.4 ahb.4 ahc.4 aria.4 atalk.4 audio.4 auvia.4 awi.4 bba.4 \
@@ -29,7 +29,7 @@
 MAN+=  eisa.4 isa.4 isapnp.4 pci.4 pcmcia.4
 
 # machine-independent PCI devices
-MAN+=  epic.4 lmc.4
+MAN+=  epic.4 lmc.4 viaenv.4
 
 # machine-independent ISA devices
 MAN+=  aha.4 ai.4 aic.4 ast.4 ate.4 boca.4 cs.4 cy.4 ec.4 ef.4 eg.4 el.4 \
@@ -70,6 +70,7 @@
 MLINKS+=pcppi.4 spkr.4
 MLINKS+=pcppi.4 sysbeep.4
 MLINKS+=pss.4 sp.4
+MLINKS+=viaenv.4 viapm.4
 
 SUBDIR=        man4.amiga man4.arm32 man4.atari man4.hp300 man4.i386 \
        man4.mac68k man4.mvme68k man4.pc532 man4.pmax man4.sparc \
diff -r 22977bafcb4e -r a4e43e2b4e46 share/man/man4/viaenv.4
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/viaenv.4   Mon May 08 16:40:42 2000 +0000
@@ -0,0 +1,75 @@
+.\"    $NetBSD: viaenv.4,v 1.1 2000/05/08 16:40:42 joda Exp $
+.\"
+.\" Copyright (c) 2000 Johan Danielsson
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without 
+.\" modification, are permitted provided that the following conditions 
+.\" are met: 
+.\"
+.\" 1. Redistributions of source code must retain the above copyright 
+.\"    notice, this list of conditions and the following disclaimer. 
+.\"
+.\" 2. Redistributions in binary form must reproduce the above copyright 
+.\"    notice, this list of conditions and the following disclaimer in the 
+.\"    documentation and/or other materials provided with the distribution. 
+.\"
+.\" 3. Neither the name of author nor the names of any contributors may
+.\"    be used to endorse or promote products derived from this
+.\"    software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+
+.Dd May 8, 2000
+.Dt VIAENV 4
+.Os
+.Sh NAME
+.Nm viaenv
+.Nd VIA VT82C686A hardware monitor
+.Sh SYNOPSIS
+.Cd "viapm* at pci? dev ? function ?"
+.Cd "viaenv* at viapm?"
+.Sh DESCRIPTION
+The
+.Nm
+is an 
+.Xr envsys 4
+compatible driver for the hardware monitor in the
+.Tn VIA 
+VT82C686A South Bridge.
+.Pp
+The device has 10 sensors:
+.Bl -column "Sensor" "Units" "Typical" -offset indent
+.It Sy "Sensor" Ta Sy "Units" Ta Sy "Typical Use"
+.It Li "TSENS1" Ta "uK" Ta "CPU temperature"
+.It Li "TSENS2" Ta "uK" Ta "System temperature"
+.It Li "TSENS3" Ta "uK" Ta "?"
+.It Li "FAN1" Ta "RPM" Ta "CPU fan"
+.It Li "FAN2" Ta "RPM" Ta "System fan"
+.It Li "VSENS1" Ta "uV DC" Ta "CPU core voltage (2.0V)"
+.It Li "VSENS2" Ta "uV DC" Ta "North Bridge core voltage (2.5V)"
+.It Li "Vcore" Ta "uV DC" Ta "Internal core voltage (3.3V)"
+.It Li "VSENS3" Ta "uV DC" Ta "+5V"
+.It Li "VSENS4" Ta "uV DC" Ta "+12V"
+.El
+.Pp
+Sensor data is updated every 1.5 seconds.
+.Sh SEE ALSO
+.Xr envsys 4
+.Sh BUGS
+Interrupt support is unimplemented, as is support for setting values.
+.Sh HISTORY
+The
+.Nm
+device appeared in
+.Nx 1.5 .
diff -r 22977bafcb4e -r a4e43e2b4e46 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Mon May 08 16:30:57 2000 +0000
+++ b/sys/dev/pci/files.pci     Mon May 08 16:40:42 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pci,v 1.90 2000/05/07 00:25:58 wiz Exp $
+#      $NetBSD: files.pci,v 1.91 2000/05/08 16:40:44 joda Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -300,3 +300,13 @@
 device btvmeii: vmebus, univ_pci
 attach btvmeii at pci
 file dev/pci/btvmeii.c btvmeii
+
+# VT86C686A power management
+device viapm {}
+attach viapm at pci
+file dev/pci/viapm.c   viapm
+
+# hardware monitoring part of viapm
+device viaenv
+attach viaenv at viapm
+file dev/pci/viaenv.c  viaenv needs-flag
diff -r 22977bafcb4e -r a4e43e2b4e46 sys/dev/pci/viaenv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/viaenv.c      Mon May 08 16:40:42 2000 +0000
@@ -0,0 +1,421 @@
+/* $NetBSD: viaenv.c,v 1.1 2000/05/08 16:40:43 joda Exp $ */
+
+/*
+ * Copyright (c) 2000 Johan Danielsson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ *
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ *
+ * 3. Neither the name of author nor the names of any contributors may
+ *    be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* driver for the hardware monitoring part of the VIA VT82C686A */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/ioctl.h>
+#include <sys/kthread.h>
+#include <sys/lock.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/envsys.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+
+#include <dev/pci/viapmvar.h>
+
+#ifdef VIAENV_DEBUG
+unsigned int viaenv_debug = 0;
+#define DPRINTF(X) do { if(viaenv_debug) printf X ; } while(0)
+#else
+#define DPRINTF(X)
+#endif
+
+#define VIANUMSENSORS 10 /* three temp, two fan, five voltage */
+
+struct viaenv_softc {
+    struct device              sc_dev;
+    bus_space_tag_t            sc_iot;
+    bus_space_handle_t         sc_ioh;
+    struct callout             sc_callout;
+    unsigned int               sc_flags;
+
+    int                                sc_fan_div[2]; /* fan RPM divisor */
+
+    struct envsys_tre_data     sc_data[VIANUMSENSORS];
+    struct envsys_basic_info   sc_info[VIANUMSENSORS];
+
+    struct proc *sc_thread;
+
+    struct lock                        sc_lock;
+    struct simplelock          sc_interlock;
+};
+
+#define SCFLAG_OPEN 1
+
+static int
+viaenv_match(struct device *parent, struct cfdata *match, void *aux);
+static void
+viaenv_attach(struct device *parent, struct device *self, void *aux);
+
+struct cfattach viaenv_ca = {
+       sizeof(struct viaenv_softc), viaenv_match, viaenv_attach
+};
+
+static int
+viaenv_match(struct device *parent, struct cfdata *match, void *aux)
+{
+    struct viapm_attach_args *va = aux;
+    
+    if (va->va_type == VIAPM_HWMON)
+      return 1;
+    return 0;
+}
+
+/* XXX there doesn't seem to exist much hard documentation on how to
+   convert the raw values to usable units, this code is more or less
+   stolen from the Linux driver, but changed to suit our conditions */
+
+/* lookup-table to translate raw values to uK, this is the same table
+used by the Linux driver (modulo units); there is a fifth degree
+polynomial that supposedly been used to generate this table, but I
+haven't been able to figure out how -- it doesn't give the same values */
+
+static long val_to_temp[] = { 
+    20225, 20435, 20645, 20855, 21045, 21245, 21425, 21615, 21785, 21955,
+    22125, 22285, 22445, 22605, 22755, 22895, 23035, 23175, 23315, 23445,
+    23565, 23695, 23815, 23925, 24045, 24155, 24265, 24365, 24465, 24565,
+    24665, 24765, 24855, 24945, 25025, 25115, 25195, 25275, 25355, 25435,
+    25515, 25585, 25655, 25725, 25795, 25865, 25925, 25995, 26055, 26115,
+    26175, 26235, 26295, 26355, 26405, 26465, 26515, 26575, 26625, 26675,
+    26725, 26775, 26825, 26875, 26925, 26975, 27025, 27065, 27115, 27165,
+    27205, 27255, 27295, 27345, 27385, 27435, 27475, 27515, 27565, 27605,
+    27645, 27685, 27735, 27775, 27815, 27855, 27905, 27945, 27985, 28025,
+    28065, 28105, 28155, 28195, 28235, 28275, 28315, 28355, 28405, 28445,
+    28485, 28525, 28565, 28615, 28655, 28695, 28735, 28775, 28825, 28865,
+    28905, 28945, 28995, 29035, 29075, 29125, 29165, 29205, 29245, 29295,
+    29335, 29375, 29425, 29465, 29505, 29555, 29595, 29635, 29685, 29725,
+    29765, 29815, 29855, 29905, 29945, 29985, 30035, 30075, 30125, 30165,
+    30215, 30255, 30305, 30345, 30385, 30435, 30475, 30525, 30565, 30615,
+    30655, 30705, 30755, 30795, 30845, 30885, 30935, 30975, 31025, 31075,
+    31115, 31165, 31215, 31265, 31305, 31355, 31405, 31455, 31505, 31545,
+    31595, 31645, 31695, 31745, 31805, 31855, 31905, 31955, 32005, 32065,
+    32115, 32175, 32225, 32285, 32335, 32395, 32455, 32515, 32575, 32635,
+    32695, 32755, 32825, 32885, 32955, 33025, 33095, 33155, 33235, 33305,
+    33375, 33455, 33525, 33605, 33685, 33765, 33855, 33935, 34025, 34115,
+    34205, 34295, 34395, 34495, 34595, 34695, 34805, 34905, 35015, 35135,
+    35245, 35365, 35495, 35615, 35745, 35875, 36015, 36145, 36295, 36435,
+    36585, 36745, 36895, 37065, 37225, 37395, 37575, 37755, 37935, 38125,
+    38325, 38525, 38725, 38935, 39155, 39375, 39605, 39835, 40075, 40325,
+    40575, 40835, 41095, 41375, 41655, 41935,
+};
+
+/* use above table to convert values to temperatures in micro-Kelvins */
+static int
+val_to_uK(unsigned int val)
+{
+    int i = val / 4;
+    int j = val % 4;
+    assert(i >= 0 && i <= 255);
+    if(j == 0 || i == 255)
+       return val_to_temp[i] * 10000;
+    /* is linear interpolation ok? */
+    return (val_to_temp[i] * (4 - j) + 
+           val_to_temp[i+1] * j) * 2500 /* really: / 4 * 10000 */;
+}
+
+static int
+val_to_rpm(unsigned int val, int div)
+{
+    if(val == 0)
+       return 0;
+    return 1350000 / val / div;
+}
+
+static long
+val_to_uV(unsigned int val, int index)
+{
+    long mult[] = { 1250000, 1250000, 1670000, 2600000, 6300000 };
+    assert(index >= 0 && index <= 4);
+    return (25LL * val + 133) * mult[index] / 2628;
+}
+
+#define VIAENV_TSENS3  0x1f



Home | Main Index | Thread Index | Old Index