Home | History | Annotate | Line # | Download | only in pci
sio.c revision 1.5
      1  1.4  thorpej /*	$NetBSD: sio.c,v 1.5 1996/04/12 02:11:22 cgd Exp $	*/
      2  1.1      cgd 
      3  1.1      cgd /*
      4  1.2      cgd  * Copyright (c) 1995 Carnegie-Mellon University.
      5  1.1      cgd  * All rights reserved.
      6  1.1      cgd  *
      7  1.1      cgd  * Author: Chris G. Demetriou
      8  1.1      cgd  *
      9  1.1      cgd  * Permission to use, copy, modify and distribute this software and
     10  1.1      cgd  * its documentation is hereby granted, provided that both the copyright
     11  1.1      cgd  * notice and this permission notice appear in all copies of the
     12  1.1      cgd  * software, derivative works or modified versions, and any portions
     13  1.1      cgd  * thereof, and that both notices appear in supporting documentation.
     14  1.1      cgd  *
     15  1.1      cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  1.1      cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  1.1      cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  1.1      cgd  *
     19  1.1      cgd  * Carnegie Mellon requests users of this software to return to
     20  1.1      cgd  *
     21  1.1      cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  1.1      cgd  *  School of Computer Science
     23  1.1      cgd  *  Carnegie Mellon University
     24  1.1      cgd  *  Pittsburgh PA 15213-3890
     25  1.1      cgd  *
     26  1.1      cgd  * any improvements or extensions that they make and grant Carnegie the
     27  1.1      cgd  * rights to redistribute these changes.
     28  1.1      cgd  */
     29  1.1      cgd 
     30  1.1      cgd #include <sys/param.h>
     31  1.1      cgd #include <sys/systm.h>
     32  1.1      cgd #include <sys/kernel.h>
     33  1.1      cgd #include <sys/device.h>
     34  1.1      cgd 
     35  1.5      cgd #include <machine/intr.h>
     36  1.5      cgd #include <machine/bus.h>
     37  1.5      cgd 
     38  1.3      cgd #include <dev/isa/isavar.h>
     39  1.3      cgd #include <dev/eisa/eisavar.h>
     40  1.3      cgd 
     41  1.1      cgd #include <dev/pci/pcireg.h>
     42  1.1      cgd #include <dev/pci/pcivar.h>
     43  1.1      cgd #include <dev/pci/pcidevs.h>
     44  1.1      cgd 
     45  1.3      cgd #include <alpha/pci/siovar.h>
     46  1.1      cgd 
     47  1.1      cgd int	siomatch __P((struct device *, void *, void *));
     48  1.1      cgd void	sioattach __P((struct device *, struct device *, void *));
     49  1.1      cgd 
     50  1.4  thorpej struct cfattach sio_ca = {
     51  1.5      cgd 	sizeof(struct device), siomatch, sioattach,
     52  1.4  thorpej };
     53  1.4  thorpej 
     54  1.4  thorpej struct cfdriver sio_cd = {
     55  1.5      cgd 	NULL, "sio", DV_DULL,
     56  1.1      cgd };
     57  1.1      cgd 
     58  1.3      cgd int	pcebmatch __P((struct device *, void *, void *));
     59  1.3      cgd 
     60  1.4  thorpej struct cfattach pceb_ca = {
     61  1.5      cgd 	sizeof(struct device), pcebmatch, sioattach,
     62  1.4  thorpej };
     63  1.4  thorpej 
     64  1.4  thorpej struct cfdriver pceb_cd = {
     65  1.5      cgd 	NULL, "pceb", DV_DULL,
     66  1.5      cgd };
     67  1.5      cgd 
     68  1.5      cgd union sio_attach_args {
     69  1.5      cgd 	const char *sa_name;			/* XXX should be common */
     70  1.5      cgd 	struct isabus_attach_args sa_iba;
     71  1.5      cgd 	struct eisabus_attach_args sa_eba;
     72  1.3      cgd };
     73  1.3      cgd 
     74  1.1      cgd static int	sioprint __P((void *, char *pnp));
     75  1.1      cgd 
     76  1.1      cgd int
     77  1.1      cgd siomatch(parent, match, aux)
     78  1.1      cgd 	struct device *parent;
     79  1.1      cgd 	void *match, *aux;
     80  1.1      cgd {
     81  1.1      cgd 	struct cfdata *cf = match;
     82  1.5      cgd 	struct pci_attach_args *pa = aux;
     83  1.3      cgd 
     84  1.5      cgd 	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
     85  1.5      cgd 	    PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_SIO)
     86  1.3      cgd 		return (0);
     87  1.3      cgd 
     88  1.3      cgd 	return (1);
     89  1.3      cgd }
     90  1.3      cgd 
     91  1.3      cgd int
     92  1.3      cgd pcebmatch(parent, match, aux)
     93  1.3      cgd 	struct device *parent;
     94  1.3      cgd 	void *match, *aux;
     95  1.3      cgd {
     96  1.3      cgd 	struct cfdata *cf = match;
     97  1.5      cgd 	struct pci_attach_args *pa = aux;
     98  1.1      cgd 
     99  1.5      cgd 	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
    100  1.5      cgd 	    PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_PCEB)
    101  1.1      cgd 		return (0);
    102  1.1      cgd 
    103  1.1      cgd 	return (1);
    104  1.1      cgd }
    105  1.1      cgd 
    106  1.1      cgd void
    107  1.1      cgd sioattach(parent, self, aux)
    108  1.1      cgd 	struct device *parent, *self;
    109  1.1      cgd 	void *aux;
    110  1.1      cgd {
    111  1.5      cgd 	struct pci_attach_args *pa = aux;
    112  1.5      cgd 	union sio_attach_args sa;
    113  1.3      cgd 	int sio, haseisa;
    114  1.3      cgd 	char devinfo[256];
    115  1.3      cgd 
    116  1.5      cgd 	sio = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_SIO);
    117  1.5      cgd 	haseisa = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB);
    118  1.3      cgd 
    119  1.5      cgd 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
    120  1.3      cgd 	printf(": %s (rev. 0x%02x)\n", devinfo,
    121  1.5      cgd 	    PCI_REVISION(pa->pa_class));
    122  1.3      cgd 
    123  1.3      cgd 	if (sio) {
    124  1.3      cgd 		pci_revision_t rev;
    125  1.3      cgd 
    126  1.5      cgd 		rev = PCI_REVISION(pa->pa_class);
    127  1.3      cgd 
    128  1.3      cgd 		if (rev < 3)
    129  1.3      cgd 			printf("%s: WARNING: SIO I SUPPORT UNTESTED\n",
    130  1.3      cgd 			    self->dv_xname);
    131  1.3      cgd 	}
    132  1.3      cgd 
    133  1.3      cgd #ifdef EVCNT_COUNTERS
    134  1.3      cgd 	evcnt_attach(self, "intr", &sio_intr_evcnt);
    135  1.3      cgd #endif
    136  1.3      cgd 
    137  1.3      cgd 	if (haseisa) {
    138  1.5      cgd 		sa.sa_eba.eba_busname = "eisa";
    139  1.5      cgd 		sa.sa_eba.eba_bc = pa->pa_bc;
    140  1.5      cgd 		config_found(self, &sa.sa_eba, sioprint);
    141  1.1      cgd 	}
    142  1.5      cgd 
    143  1.5      cgd 	sa.sa_iba.iba_busname = "isa";
    144  1.5      cgd 	sa.sa_iba.iba_bc = pa->pa_bc;
    145  1.5      cgd 	config_found(self, &sa.sa_iba, sioprint);
    146  1.1      cgd }
    147  1.1      cgd 
    148  1.1      cgd static int
    149  1.1      cgd sioprint(aux, pnp)
    150  1.1      cgd 	void *aux;
    151  1.1      cgd 	char *pnp;
    152  1.1      cgd {
    153  1.5      cgd         register union sio_attach_args *sa = aux;
    154  1.1      cgd 
    155  1.1      cgd         if (pnp)
    156  1.5      cgd                 printf("%s at %s", sa->sa_name, pnp);
    157  1.1      cgd         return (UNCONF);
    158  1.1      cgd }
    159