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