Updated viaenv(4) driver:
* Support for the VIA VT8231 Hardware monitor. * Power Management Timer available for timecounters in both VT86C686A and VT8231 (code simplified thanks to dev/ic/acpipmtimer). * Remove viapm(4) code and manpage (which was a link to viaenv.4 anyway). From OpenBSD, tested by some users.
This commit is contained in:
parent
af41d0fea7
commit
a4423f177a
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.968 2007/01/15 21:49:17 tron Exp $
|
||||
# $NetBSD: mi,v 1.969 2007/01/20 18:44:26 xtraeme Exp $
|
||||
./etc/mtree/set.man man-sys-root
|
||||
./usr/share/info/am-utils.info man-amd-info info
|
||||
./usr/share/info/as.info man-computil-info bfd,info
|
||||
|
@ -1490,7 +1490,7 @@
|
|||
./usr/share/man/cat4/vge.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/viaenv.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/viaide.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/viapm.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/viapm.0 man-sys-catman obsolete
|
||||
./usr/share/man/cat4/vinum.0 man-obsolete obsolete
|
||||
./usr/share/man/cat4/vlan.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/vmmon.0 man-sys-catman .cat
|
||||
|
@ -3901,7 +3901,7 @@
|
|||
./usr/share/man/man4/vge.4 man-sys-man .man
|
||||
./usr/share/man/man4/viaenv.4 man-sys-man .man
|
||||
./usr/share/man/man4/viaide.4 man-sys-man .man
|
||||
./usr/share/man/man4/viapm.4 man-sys-man .man
|
||||
./usr/share/man/man4/viapm.4 man-sys-man obsolete
|
||||
./usr/share/man/man4/vinum.4 man-obsolete obsolete
|
||||
./usr/share/man/man4/vlan.4 man-sys-man .man
|
||||
./usr/share/man/man4/vmmon.4 man-sys-man .man
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.418 2007/01/07 03:14:09 xtraeme Exp $
|
||||
# $NetBSD: Makefile,v 1.419 2007/01/20 18:44:26 xtraeme Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/18/93
|
||||
|
||||
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 adc.4 adt7467c.4 adv.4 \
|
||||
|
@ -150,7 +150,6 @@ MLINKS+=tty.4 dty.4
|
|||
MLINKS+=url.4 urlphy.4
|
||||
MLINKS+=usb.4 uhub.4
|
||||
MLINKS+=usb.4 usbtask.4
|
||||
MLINKS+=viaenv.4 viapm.4
|
||||
MLINKS+=zstty.4 zs.4 zstty.4 zsc.4
|
||||
|
||||
# This is a hack
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: viaenv.4,v 1.5 2001/09/11 23:18:55 wiz Exp $
|
||||
.\" $NetBSD: viaenv.4,v 1.6 2007/01/20 18:44:26 xtraeme Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2000 Johan Danielsson
|
||||
.\" All rights reserved.
|
||||
|
@ -29,23 +29,23 @@
|
|||
.\" 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
|
||||
.Dd January 20, 2007
|
||||
.Dt VIAENV 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm viaenv
|
||||
.Nd VIA VT82C686A hardware monitor
|
||||
.Nd VIA VT82C686A/VT8231 Hardware Monitor and Power Management Timer
|
||||
.Sh SYNOPSIS
|
||||
.Cd "viapm* at pci? dev ? function ?"
|
||||
.Cd "viaenv* at viapm?"
|
||||
.Cd "viaenv* at pci? dev ? function ?"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
is an
|
||||
.Xr envsys 4
|
||||
compatible driver for the hardware monitor in the
|
||||
compatible driver for the Hardware Monitor and the Power Management
|
||||
timer in the
|
||||
.Tn VIA
|
||||
VT82C686A South Bridge.
|
||||
VT82C686A and VT8231 South Bridge.
|
||||
.Pp
|
||||
The device has 10 sensors:
|
||||
.Bl -column "Sensor" "Units" "Typical" -offset indent
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.pci,v 1.275 2006/12/17 23:02:06 bouyer Exp $
|
||||
# $NetBSD: files.pci,v 1.276 2007/01/20 18:44:26 xtraeme Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent PCI code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -660,15 +660,10 @@ 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: sysmon_envsys
|
||||
attach viaenv at viapm
|
||||
file dev/pci/viaenv.c viaenv needs-flag
|
||||
# VIA VT82C686A/VT8231 PM Timer and Hardware Monitor
|
||||
device viaenv: acpipmtimer, sysmon_envsys
|
||||
attach viaenv at pci
|
||||
file dev/pci/viaenv.c viaenv
|
||||
|
||||
# Intel PIIX4 power management controller
|
||||
device piixpm: i2cbus, acpipmtimer
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: viaenv.c,v 1.17 2006/11/16 01:33:10 christos Exp $ */
|
||||
/* $NetBSD: viaenv.c,v 1.18 2007/01/20 18:44:26 xtraeme Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Johan Danielsson
|
||||
|
@ -32,30 +32,33 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* driver for the hardware monitoring part of the VIA VT82C686A */
|
||||
/*
|
||||
* Driver for the hardware monitoring and power management timer
|
||||
* in the VIA VT82C686A and VT8231 South Bridges.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: viaenv.c,v 1.17 2006/11/16 01:33:10 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: viaenv.c,v 1.18 2007/01/20 18:44:26 xtraeme Exp $");
|
||||
|
||||
#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>
|
||||
|
||||
#ifdef __HAVE_TIMECOUNTER
|
||||
#include <machine/bus.h>
|
||||
#include <dev/ic/acpipmtimer.h>
|
||||
#endif
|
||||
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
||||
#include <dev/pci/viapmvar.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
|
||||
#include <dev/sysmon/sysmonvar.h>
|
||||
|
||||
#ifdef VIAENV_DEBUG
|
||||
unsigned int viaenv_debug = 0;
|
||||
#define DPRINTF(X) do { if(viaenv_debug) printf X ; } while(0)
|
||||
#define DPRINTF(X) do { if (viaenv_debug) printf X ; } while(0)
|
||||
#else
|
||||
#define DPRINTF(X)
|
||||
#endif
|
||||
|
@ -66,11 +69,12 @@ struct viaenv_softc {
|
|||
struct device sc_dev;
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
bus_space_handle_t sc_pm_ioh;
|
||||
|
||||
int sc_fan_div[2]; /* fan RPM divisor */
|
||||
|
||||
struct envsys_tre_data sc_data[VIANUMSENSORS];
|
||||
struct envsys_basic_info sc_info[VIANUMSENSORS];
|
||||
envsys_tre_data_t sc_data[VIANUMSENSORS];
|
||||
envsys_basic_info_t sc_info[VIANUMSENSORS];
|
||||
|
||||
struct simplelock sc_slock;
|
||||
struct timeval sc_lastread;
|
||||
|
@ -88,20 +92,36 @@ static const struct envsys_range viaenv_ranges[] = {
|
|||
{ 1, 0, ENVSYS_SAMPS }, /* none */
|
||||
};
|
||||
|
||||
static int viaenv_gtredata(struct sysmon_envsys *,
|
||||
struct envsys_tre_data *);
|
||||
static int viaenv_streinfo(struct sysmon_envsys *,
|
||||
struct envsys_basic_info *);
|
||||
/* autoconf(9) glue */
|
||||
static int viaenv_match(struct device *, struct cfdata *, void *);
|
||||
static void viaenv_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(viaenv, sizeof(struct viaenv_softc),
|
||||
viaenv_match, viaenv_attach, NULL, NULL);
|
||||
|
||||
/* envsys(4) glue */
|
||||
static int viaenv_gtredata(struct sysmon_envsys *, envsys_tre_data_t *);
|
||||
static int viaenv_streinfo(struct sysmon_envsys *, envsys_basic_info_t *);
|
||||
|
||||
static int val_to_uK(unsigned int);
|
||||
static int val_to_rpm(unsigned int, int);
|
||||
static long val_to_uV(unsigned int, int);
|
||||
|
||||
static int
|
||||
viaenv_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
viaenv_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct viapm_attach_args *va = aux;
|
||||
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
|
||||
|
||||
if (va->va_type == VIAPM_HWMON)
|
||||
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_VIATECH)
|
||||
return 0;
|
||||
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_VIATECH_VT82C686A_SMB:
|
||||
case PCI_PRODUCT_VIATECH_VT8231_PWR:
|
||||
return 1;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -198,13 +218,21 @@ val_to_uV(unsigned int val, int index)
|
|||
#define VIAENV_TLOW 0x49 /* temperature low order value */
|
||||
#define VIAENV_TIRQ 0x4b /* temperature interrupt configuration */
|
||||
|
||||
#define VIAENV_GENCFG 0x40 /* general configuration */
|
||||
#define VIAENV_GENCFG_TMR32 (1 << 11) /* 32-bit PM timer */
|
||||
#define VIAENV_GENCFG_PMEN (1 << 15) /* enable PM I/O space */
|
||||
#define VIAENV_PMBASE 0x48 /* power management I/O space base */
|
||||
#define VIAENV_PMSIZE 128 /* HWM and power management I/O space size */
|
||||
#define VIAENV_PM_TMR 0x08 /* PM timer */
|
||||
#define VIAENV_HWMON_CONF 0x70 /* HWMon I/O base */
|
||||
#define VIAENV_HWMON_CTL 0x74 /* HWMon control register */
|
||||
|
||||
static void
|
||||
viaenv_refresh_sensor_data(struct viaenv_softc *sc)
|
||||
{
|
||||
static const struct timeval onepointfive = { 1, 500000 };
|
||||
struct timeval t, utv;
|
||||
u_int8_t v, v2;
|
||||
uint8_t v, v2;
|
||||
int i;
|
||||
|
||||
/* Read new values at most once every 1.5 seconds. */
|
||||
|
@ -267,30 +295,44 @@ viaenv_refresh_sensor_data(struct viaenv_softc *sc)
|
|||
static void
|
||||
viaenv_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct viapm_attach_args *va = aux;
|
||||
struct viaenv_softc *sc = (struct viaenv_softc *) self;
|
||||
struct viaenv_softc *sc = (struct viaenv_softc *)self;
|
||||
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
|
||||
pcireg_t iobase, control;
|
||||
int i;
|
||||
|
||||
iobase = pci_conf_read(va->va_pc, va->va_tag, va->va_offset);
|
||||
if ((iobase & 0xff80) == 0) {
|
||||
printf(": disabled\n");
|
||||
return;
|
||||
aprint_naive("\n");
|
||||
aprint_normal(": VIA Technologies ");
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_VIATECH_VT82C686A_SMB:
|
||||
aprint_normal("VT82C686A Hardware Monitor\n");
|
||||
break;
|
||||
case PCI_PRODUCT_VIATECH_VT8231_PWR:
|
||||
aprint_normal("VT8231 Hardware Monitor\n");
|
||||
break;
|
||||
default:
|
||||
aprint_normal("Unknown Hardware Monitor\n");
|
||||
break;
|
||||
}
|
||||
control = pci_conf_read(va->va_pc, va->va_tag, va->va_offset + 4);
|
||||
/* If the device is disabled, turn it on */
|
||||
if ((control & 1) == 0)
|
||||
pci_conf_write(va->va_pc, va->va_tag, va->va_offset + 4,
|
||||
control | 1);
|
||||
|
||||
sc->sc_iot = va->va_iot;
|
||||
if (bus_space_map(sc->sc_iot, iobase & 0xff80, 128, 0, &sc->sc_ioh)) {
|
||||
printf(": failed to map i/o\n");
|
||||
return;
|
||||
iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAENV_HWMON_CONF);
|
||||
DPRINTF(("%s: iobase 0x%x\n", sc->sc_dev.dv_xname, iobase));
|
||||
control = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAENV_HWMON_CTL);
|
||||
|
||||
/* Check if the Hardware Monitor enable bit is set */
|
||||
if ((control & 1) == 0) {
|
||||
aprint_normal("%s : Hardware Monitor disabled\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto nohwm;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
simple_lock_init(&sc->sc_slock);
|
||||
/* Map Hardware Monitor I/O space */
|
||||
sc->sc_iot = pa->pa_iot;
|
||||
if (bus_space_map(sc->sc_iot, iobase & 0xff80,
|
||||
VIAENV_PMSIZE, 0, &sc->sc_ioh)) {
|
||||
aprint_error("%s: failed to map I/O space\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto nohwm;
|
||||
}
|
||||
|
||||
/* Initialize sensors */
|
||||
for (i = 0; i < VIANUMSENSORS; ++i) {
|
||||
|
@ -300,33 +342,38 @@ viaenv_attach(struct device *parent, struct device *self, void *aux)
|
|||
sc->sc_data[i].warnflags = ENVSYS_WARN_OK;
|
||||
}
|
||||
|
||||
for (i = 0; i <= 2; i++) {
|
||||
for (i = 0; i <= 2; i++)
|
||||
sc->sc_data[i].units = sc->sc_info[i].units = ENVSYS_STEMP;
|
||||
}
|
||||
strcpy(sc->sc_info[0].desc, "TSENS1");
|
||||
strcpy(sc->sc_info[1].desc, "TSENS2");
|
||||
strcpy(sc->sc_info[2].desc, "TSENS3");
|
||||
|
||||
for (i = 3; i <= 4; i++) {
|
||||
#define COPYDESCR(x, y) \
|
||||
do { \
|
||||
strlcpy((x), (y), sizeof(x)); \
|
||||
} while (0)
|
||||
|
||||
COPYDESCR(sc->sc_info[0].desc, "TSENS1");
|
||||
COPYDESCR(sc->sc_info[1].desc, "TSENS2");
|
||||
COPYDESCR(sc->sc_info[2].desc, "TSENS3");
|
||||
|
||||
for (i = 3; i <= 4; i++)
|
||||
sc->sc_data[i].units = sc->sc_info[i].units = ENVSYS_SFANRPM;
|
||||
}
|
||||
strcpy(sc->sc_info[3].desc, "FAN1");
|
||||
strcpy(sc->sc_info[4].desc, "FAN2");
|
||||
|
||||
COPYDESCR(sc->sc_info[3].desc, "FAN1");
|
||||
COPYDESCR(sc->sc_info[4].desc, "FAN2");
|
||||
|
||||
for (i = 5; i <= 9; ++i) {
|
||||
sc->sc_data[i].units = sc->sc_info[i].units =
|
||||
ENVSYS_SVOLTS_DC;
|
||||
sc->sc_info[i].rfact = 1; /* what is this used for? */
|
||||
}
|
||||
strcpy(sc->sc_info[5].desc, "VSENS1"); /* CPU core (2V) */
|
||||
strcpy(sc->sc_info[6].desc, "VSENS2"); /* NB core? (2.5V) */
|
||||
strcpy(sc->sc_info[7].desc, "Vcore"); /* Vcore (3.3V) */
|
||||
strcpy(sc->sc_info[8].desc, "VSENS3"); /* VSENS3 (5V) */
|
||||
strcpy(sc->sc_info[9].desc, "VSENS4"); /* VSENS4 (12V) */
|
||||
for (i = 5; i <= 9; ++i)
|
||||
sc->sc_data[i].units = sc->sc_info[i].units = ENVSYS_SVOLTS_DC;
|
||||
|
||||
COPYDESCR(sc->sc_info[5].desc, "VSENS1"); /* CPU core (2V) */
|
||||
COPYDESCR(sc->sc_info[6].desc, "VSENS2"); /* NB core? (2.5V) */
|
||||
COPYDESCR(sc->sc_info[7].desc, "Vcore"); /* Vcore (3.3V) */
|
||||
COPYDESCR(sc->sc_info[8].desc, "VSENS3"); /* VSENS3 (5V) */
|
||||
COPYDESCR(sc->sc_info[9].desc, "VSENS4"); /* VSENS4 (12V) */
|
||||
|
||||
/* Get initial set of sensor values. */
|
||||
viaenv_refresh_sensor_data(sc);
|
||||
|
||||
#undef COPYDESCR
|
||||
|
||||
/*
|
||||
* Hook into the System Monitor.
|
||||
*/
|
||||
|
@ -344,13 +391,38 @@ viaenv_attach(struct device *parent, struct device *self, void *aux)
|
|||
if (sysmon_envsys_register(&sc->sc_sysmon))
|
||||
printf("%s: unable to register with sysmon\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
|
||||
nohwm:
|
||||
#ifdef __HAVE_TIMECOUNTER
|
||||
/* Check if power management I/O space is enabled */
|
||||
control = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAENV_GENCFG);
|
||||
if ((control & VIAENV_GENCFG_PMEN) == 0) {
|
||||
aprint_normal("%s: Power Managament controller disabled\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto nopm;
|
||||
}
|
||||
|
||||
/* Map power management I/O space */
|
||||
iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAENV_PMBASE);
|
||||
if (bus_space_map(sc->sc_iot, PCI_MAPREG_IO_ADDR(iobase),
|
||||
VIAENV_PMSIZE, 0, &sc->sc_pm_ioh)) {
|
||||
aprint_error("%s: failed to map PM I/O space\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto nopm;
|
||||
}
|
||||
|
||||
/* Attach our PM timer with the generic acpipmtimer function */
|
||||
acpipmtimer_attach(&sc->sc_dev, sc->sc_iot, sc->sc_pm_ioh,
|
||||
VIAENV_PM_TMR,
|
||||
((control & VIAENV_GENCFG_TMR32) ? ACPIPMT_32BIT : 0));
|
||||
|
||||
nopm:
|
||||
#endif /* __HAVE_TIMECOUNTER */
|
||||
return;
|
||||
}
|
||||
|
||||
CFATTACH_DECL(viaenv, sizeof(struct viaenv_softc),
|
||||
viaenv_match, viaenv_attach, NULL, NULL);
|
||||
|
||||
static int
|
||||
viaenv_gtredata(struct sysmon_envsys *sme, struct envsys_tre_data *tred)
|
||||
viaenv_gtredata(struct sysmon_envsys *sme, envsys_tre_data_t *tred)
|
||||
{
|
||||
struct viaenv_softc *sc = sme->sme_cookie;
|
||||
|
||||
|
@ -361,16 +433,14 @@ viaenv_gtredata(struct sysmon_envsys *sme, struct envsys_tre_data *tred)
|
|||
|
||||
simple_unlock(&sc->sc_slock);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
viaenv_streinfo(struct sysmon_envsys *sme,
|
||||
struct envsys_basic_info *binfo)
|
||||
viaenv_streinfo(struct sysmon_envsys *sme, envsys_basic_info_t *binfo)
|
||||
{
|
||||
|
||||
/* XXX Not implemented */
|
||||
/* Not implemented */
|
||||
binfo->validflags = 0;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
/* $NetBSD: viapm.c,v 1.16 2006/11/16 01:33:10 christos 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* frontend for the power management device in the VIA VT82C686a South
|
||||
* Bridge. It (the chip) has three functions, power management, hardware
|
||||
* monitoring, and an SMBus controller. A driver for the hardware monitoring
|
||||
* is provided by the viaenv driver
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: viapm.c,v 1.16 2006/11/16 01:33:10 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
|
||||
#include <dev/pci/viapmvar.h>
|
||||
|
||||
struct viapm_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
pci_chipset_tag_t sc_pc;
|
||||
pcitag_t sc_tag;
|
||||
bus_space_tag_t sc_iot;
|
||||
};
|
||||
|
||||
static int
|
||||
viapm_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_VIATECH)
|
||||
return 0;
|
||||
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_VIATECH_VT82C686A_SMB:
|
||||
#ifdef notyet
|
||||
case PCI_PRODUCT_VIATECH_VT8231_PWR:
|
||||
#endif
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
viapm_device_name(enum vapm_devtype type)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case VIAPM_POWER:
|
||||
return "power management";
|
||||
case VIAPM_HWMON:
|
||||
return "hardware monitor";
|
||||
case VIAPM_SMBUS:
|
||||
return "SMBus controller";
|
||||
default:
|
||||
panic("viapm_device_name: unknown type");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
viapm_print(void *aux, const char *pnp)
|
||||
{
|
||||
struct viapm_attach_args *vaa = aux;
|
||||
|
||||
if (pnp)
|
||||
aprint_normal("%s at %s", viapm_device_name(vaa->va_type), pnp);
|
||||
return UNCONF;
|
||||
}
|
||||
|
||||
static void
|
||||
viapm_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct viapm_softc *sc = (struct viapm_softc *) self;
|
||||
struct pci_attach_args *pa = aux;
|
||||
struct viapm_attach_args vaa;
|
||||
|
||||
printf("\n");
|
||||
|
||||
sc->sc_pc = pa->pa_pc;
|
||||
sc->sc_tag = pa->pa_tag;
|
||||
sc->sc_iot = pa->pa_iot;
|
||||
|
||||
vaa.va_pc = sc->sc_pc;
|
||||
vaa.va_tag = sc->sc_tag;
|
||||
vaa.va_iot = sc->sc_iot;
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* no point in confusing people with these until there are drivers for
|
||||
* them
|
||||
*/
|
||||
vaa.va_type = VIAPM_POWER;
|
||||
vaa.va_offset = 0x40;
|
||||
config_found_ia(self, "viapm", &vaa, viapm_print);
|
||||
#endif
|
||||
|
||||
vaa.va_type = VIAPM_HWMON;
|
||||
vaa.va_offset = 0x70;
|
||||
config_found_ia(self, "viapm", &vaa, viapm_print);
|
||||
|
||||
#if 0
|
||||
vaa.va_type = VIAPM_SMBUS;
|
||||
vaa.va_offset = 0x93;
|
||||
config_found_ia(self, "viapm", &vaa, viapm_print);
|
||||
#endif
|
||||
}
|
||||
|
||||
CFATTACH_DECL(viapm, sizeof(struct viapm_softc),
|
||||
viapm_match, viapm_attach, NULL, NULL);
|
|
@ -1,48 +0,0 @@
|
|||
/* $NetBSD: viapmvar.h,v 1.4 2005/12/11 12:22:51 christos 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.
|
||||
*/
|
||||
|
||||
#ifndef _DEV_PCI_VIAPMVAR_H_
|
||||
#define _DEV_PCI_VIAPMVAR_H_
|
||||
|
||||
enum vapm_devtype { VIAPM_POWER, VIAPM_HWMON, VIAPM_SMBUS };
|
||||
|
||||
struct viapm_attach_args {
|
||||
enum vapm_devtype va_type;
|
||||
pci_chipset_tag_t va_pc;
|
||||
pcitag_t va_tag;
|
||||
int va_offset;
|
||||
bus_space_tag_t va_iot;
|
||||
};
|
||||
|
||||
#endif /* _DEV_PCI_VIAPMVAR_H_ */
|
Loading…
Reference in New Issue