2003-01-01 03:10:15 +03:00
|
|
|
/* $NetBSD: viapm.c,v 1.9 2003/01/01 00:10:23 thorpej Exp $ */
|
2000-05-08 20:40:42 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Johan Danielsson
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2000-05-12 20:42:41 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2000-05-08 20:40:42 +04:00
|
|
|
*
|
2000-05-12 20:42:41 +04:00
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2000-05-08 20:40:42 +04:00
|
|
|
*
|
2000-05-12 20:42:41 +04:00
|
|
|
* 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.
|
2000-05-08 20:40:42 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2000-05-12 20:42:41 +04:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2000-05-08 20:40:42 +04:00
|
|
|
|
2001-11-13 10:48:40 +03:00
|
|
|
#include <sys/cdefs.h>
|
2003-01-01 03:10:15 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: viapm.c,v 1.9 2003/01/01 00:10:23 thorpej Exp $");
|
2001-11-13 10:48:40 +03:00
|
|
|
|
2000-05-08 20:40:42 +04:00
|
|
|
#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 {
|
2000-05-12 20:42:41 +04:00
|
|
|
struct device sc_dev;
|
2000-05-08 20:40:42 +04:00
|
|
|
|
2000-05-12 20:42:41 +04:00
|
|
|
pci_chipset_tag_t sc_pc;
|
|
|
|
pcitag_t sc_tag;
|
|
|
|
bus_space_tag_t sc_iot;
|
2000-05-08 20:40:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2000-05-12 20:42:41 +04:00
|
|
|
viapm_match(struct device * parent, struct cfdata * match, void *aux)
|
2000-05-08 20:40:42 +04:00
|
|
|
{
|
2000-05-12 20:42:41 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
|
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_VIATECH &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_VIATECH_VT82C686A_SMB)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
2000-05-08 20:40:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
viapm_device_name(enum vapm_devtype type)
|
|
|
|
{
|
2000-05-12 20:42:41 +04:00
|
|
|
|
|
|
|
switch (type) {
|
2002-03-26 00:29:58 +03:00
|
|
|
case VIAPM_POWER:
|
2000-05-12 20:42:41 +04:00
|
|
|
return "power management";
|
|
|
|
case VIAPM_HWMON:
|
|
|
|
return "hardware monitor";
|
|
|
|
case VIAPM_SMBUS:
|
|
|
|
return "SMBus controller";
|
|
|
|
default:
|
|
|
|
panic("viapm_device_name: unknown type");
|
|
|
|
}
|
2000-05-08 20:40:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
viapm_print(void *aux, const char *pnp)
|
|
|
|
{
|
2000-05-12 20:42:41 +04:00
|
|
|
struct viapm_attach_args *vaa = aux;
|
|
|
|
|
|
|
|
if (pnp)
|
2003-01-01 03:10:15 +03:00
|
|
|
aprint_normal("%s at %s", viapm_device_name(vaa->va_type), pnp);
|
2000-05-12 20:42:41 +04:00
|
|
|
return UNCONF;
|
2000-05-08 20:40:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-05-12 20:42:41 +04:00
|
|
|
viapm_submatch(struct device * parent, struct cfdata * cf, void *aux)
|
2000-05-08 20:40:42 +04:00
|
|
|
{
|
2000-05-12 20:42:41 +04:00
|
|
|
|
2002-09-27 07:17:40 +04:00
|
|
|
return config_match(parent, cf, aux);
|
2000-05-08 20:40:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-26 00:29:58 +03:00
|
|
|
viapm_attach(struct device * parent, struct device * self, void *aux)
|
2000-05-08 20:40:42 +04:00
|
|
|
{
|
2000-05-12 20:42:41 +04:00
|
|
|
struct viapm_softc *sc = (struct viapm_softc *) self;
|
2002-03-26 00:29:58 +03:00
|
|
|
struct pci_attach_args *pa = aux;
|
2000-05-12 20:42:41 +04:00
|
|
|
struct viapm_attach_args vaa;
|
|
|
|
|
2002-03-26 00:29:58 +03:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
sc->sc_pc = pa->pa_pc;
|
|
|
|
sc->sc_tag = pa->pa_tag;
|
|
|
|
sc->sc_iot = pa->pa_iot;
|
|
|
|
|
2000-05-12 20:42:41 +04:00
|
|
|
vaa.va_pc = sc->sc_pc;
|
|
|
|
vaa.va_tag = sc->sc_tag;
|
|
|
|
vaa.va_iot = sc->sc_iot;
|
2000-05-08 20:40:42 +04:00
|
|
|
|
|
|
|
#if 0
|
2000-05-12 20:42:41 +04:00
|
|
|
/*
|
|
|
|
* no point in confusing people with these until there are drivers for
|
|
|
|
* them
|
|
|
|
*/
|
|
|
|
vaa.va_type = VIAPM_POWER;
|
|
|
|
vaa.va_offset = 0x40;
|
|
|
|
config_found_sm(self, &vaa, viapm_print, viapm_submatch);
|
2000-05-08 20:40:42 +04:00
|
|
|
#endif
|
|
|
|
|
2000-05-12 20:42:41 +04:00
|
|
|
vaa.va_type = VIAPM_HWMON;
|
|
|
|
vaa.va_offset = 0x70;
|
|
|
|
config_found_sm(self, &vaa, viapm_print, viapm_submatch);
|
2000-05-08 20:40:42 +04:00
|
|
|
|
|
|
|
#if 0
|
2000-05-12 20:42:41 +04:00
|
|
|
vaa.va_type = VIAPM_SMBUS;
|
|
|
|
vaa.va_offset = 0x93;
|
|
|
|
config_found_sm(self, &vaa, viapm_print, viapm_submatch);
|
2000-05-08 20:40:42 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-10-01 00:37:04 +04:00
|
|
|
CFATTACH_DECL(viapm, sizeof(struct viapm_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
viapm_match, viapm_attach, NULL, NULL);
|