1996-04-12 06:11:22 +04:00
|
|
|
/* $NetBSD: sio.c,v 1.5 1996/04/12 02:11:22 cgd Exp $ */
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
/*
|
1995-08-03 05:12:15 +04:00
|
|
|
* Copyright (c) 1995 Carnegie-Mellon University.
|
1995-06-28 05:24:50 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Chris G. Demetriou
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/eisa/eisavar.h>
|
|
|
|
|
1995-06-28 05:24:50 +04:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
#include <alpha/pci/siovar.h>
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
int siomatch __P((struct device *, void *, void *));
|
|
|
|
void sioattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-03-17 04:03:02 +03:00
|
|
|
struct cfattach sio_ca = {
|
1996-04-12 06:11:22 +04:00
|
|
|
sizeof(struct device), siomatch, sioattach,
|
1996-03-17 04:03:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver sio_cd = {
|
1996-04-12 06:11:22 +04:00
|
|
|
NULL, "sio", DV_DULL,
|
1995-06-28 05:24:50 +04:00
|
|
|
};
|
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
int pcebmatch __P((struct device *, void *, void *));
|
|
|
|
|
1996-03-17 04:03:02 +03:00
|
|
|
struct cfattach pceb_ca = {
|
1996-04-12 06:11:22 +04:00
|
|
|
sizeof(struct device), pcebmatch, sioattach,
|
1996-03-17 04:03:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver pceb_cd = {
|
1996-04-12 06:11:22 +04:00
|
|
|
NULL, "pceb", DV_DULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
union sio_attach_args {
|
|
|
|
const char *sa_name; /* XXX should be common */
|
|
|
|
struct isabus_attach_args sa_iba;
|
|
|
|
struct eisabus_attach_args sa_eba;
|
1995-11-23 05:33:17 +03:00
|
|
|
};
|
|
|
|
|
1995-06-28 05:24:50 +04:00
|
|
|
static int sioprint __P((void *, char *pnp));
|
|
|
|
|
|
|
|
int
|
|
|
|
siomatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match, *aux;
|
|
|
|
{
|
|
|
|
struct cfdata *cf = match;
|
1996-04-12 06:11:22 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_SIO)
|
1995-11-23 05:33:17 +03:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pcebmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match, *aux;
|
|
|
|
{
|
|
|
|
struct cfdata *cf = match;
|
1996-04-12 06:11:22 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_PCEB)
|
1995-06-28 05:24:50 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sioattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
1996-04-12 06:11:22 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
union sio_attach_args sa;
|
1995-11-23 05:33:17 +03:00
|
|
|
int sio, haseisa;
|
|
|
|
char devinfo[256];
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
sio = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_SIO);
|
|
|
|
haseisa = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB);
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
|
1995-11-23 05:33:17 +03:00
|
|
|
printf(": %s (rev. 0x%02x)\n", devinfo,
|
1996-04-12 06:11:22 +04:00
|
|
|
PCI_REVISION(pa->pa_class));
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
if (sio) {
|
|
|
|
pci_revision_t rev;
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
rev = PCI_REVISION(pa->pa_class);
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
if (rev < 3)
|
|
|
|
printf("%s: WARNING: SIO I SUPPORT UNTESTED\n",
|
|
|
|
self->dv_xname);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EVCNT_COUNTERS
|
|
|
|
evcnt_attach(self, "intr", &sio_intr_evcnt);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (haseisa) {
|
1996-04-12 06:11:22 +04:00
|
|
|
sa.sa_eba.eba_busname = "eisa";
|
|
|
|
sa.sa_eba.eba_bc = pa->pa_bc;
|
|
|
|
config_found(self, &sa.sa_eba, sioprint);
|
1995-06-28 05:24:50 +04:00
|
|
|
}
|
1996-04-12 06:11:22 +04:00
|
|
|
|
|
|
|
sa.sa_iba.iba_busname = "isa";
|
|
|
|
sa.sa_iba.iba_bc = pa->pa_bc;
|
|
|
|
config_found(self, &sa.sa_iba, sioprint);
|
1995-06-28 05:24:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sioprint(aux, pnp)
|
|
|
|
void *aux;
|
|
|
|
char *pnp;
|
|
|
|
{
|
1996-04-12 06:11:22 +04:00
|
|
|
register union sio_attach_args *sa = aux;
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
if (pnp)
|
1996-04-12 06:11:22 +04:00
|
|
|
printf("%s at %s", sa->sa_name, pnp);
|
1995-06-28 05:24:50 +04:00
|
|
|
return (UNCONF);
|
|
|
|
}
|