Home | History | Annotate | Line # | Download | only in pci
sio.c revision 1.7
      1  1.7      cgd /*	$NetBSD: sio.c,v 1.7 1996/04/12 06:09:00 cgd Exp $	*/
      2  1.1      cgd 
      3  1.1      cgd /*
      4  1.7      cgd  * Copyright (c) 1995, 1996 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.6      cgd static void	sio_isa_attach_hook __P((struct device *, struct device *,
     76  1.6      cgd 		    struct isabus_attach_args *));
     77  1.1      cgd 
     78  1.1      cgd int
     79  1.1      cgd siomatch(parent, match, aux)
     80  1.1      cgd 	struct device *parent;
     81  1.1      cgd 	void *match, *aux;
     82  1.1      cgd {
     83  1.1      cgd 	struct cfdata *cf = match;
     84  1.5      cgd 	struct pci_attach_args *pa = aux;
     85  1.3      cgd 
     86  1.5      cgd 	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
     87  1.5      cgd 	    PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_SIO)
     88  1.3      cgd 		return (0);
     89  1.3      cgd 
     90  1.3      cgd 	return (1);
     91  1.3      cgd }
     92  1.3      cgd 
     93  1.3      cgd int
     94  1.3      cgd pcebmatch(parent, match, aux)
     95  1.3      cgd 	struct device *parent;
     96  1.3      cgd 	void *match, *aux;
     97  1.3      cgd {
     98  1.3      cgd 	struct cfdata *cf = match;
     99  1.5      cgd 	struct pci_attach_args *pa = aux;
    100  1.1      cgd 
    101  1.5      cgd 	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
    102  1.5      cgd 	    PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_PCEB)
    103  1.1      cgd 		return (0);
    104  1.1      cgd 
    105  1.1      cgd 	return (1);
    106  1.1      cgd }
    107  1.1      cgd 
    108  1.1      cgd void
    109  1.1      cgd sioattach(parent, self, aux)
    110  1.1      cgd 	struct device *parent, *self;
    111  1.1      cgd 	void *aux;
    112  1.1      cgd {
    113  1.5      cgd 	struct pci_attach_args *pa = aux;
    114  1.6      cgd 	struct alpha_isa_chipset ic;
    115  1.6      cgd 	struct alpha_eisa_chipset ec;
    116  1.5      cgd 	union sio_attach_args sa;
    117  1.3      cgd 	int sio, haseisa;
    118  1.3      cgd 	char devinfo[256];
    119  1.3      cgd 
    120  1.5      cgd 	sio = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_SIO);
    121  1.5      cgd 	haseisa = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB);
    122  1.3      cgd 
    123  1.5      cgd 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
    124  1.3      cgd 	printf(": %s (rev. 0x%02x)\n", devinfo,
    125  1.5      cgd 	    PCI_REVISION(pa->pa_class));
    126  1.3      cgd 
    127  1.3      cgd 	if (sio) {
    128  1.3      cgd 		pci_revision_t rev;
    129  1.3      cgd 
    130  1.5      cgd 		rev = PCI_REVISION(pa->pa_class);
    131  1.3      cgd 
    132  1.3      cgd 		if (rev < 3)
    133  1.3      cgd 			printf("%s: WARNING: SIO I SUPPORT UNTESTED\n",
    134  1.3      cgd 			    self->dv_xname);
    135  1.3      cgd 	}
    136  1.3      cgd 
    137  1.3      cgd #ifdef EVCNT_COUNTERS
    138  1.3      cgd 	evcnt_attach(self, "intr", &sio_intr_evcnt);
    139  1.3      cgd #endif
    140  1.3      cgd 
    141  1.3      cgd 	if (haseisa) {
    142  1.6      cgd 		/* XXX SET UP EISA CHIPSET */
    143  1.5      cgd 		sa.sa_eba.eba_busname = "eisa";
    144  1.5      cgd 		sa.sa_eba.eba_bc = pa->pa_bc;
    145  1.6      cgd 		sa.sa_eba.eba_ec = &ec;
    146  1.5      cgd 		config_found(self, &sa.sa_eba, sioprint);
    147  1.1      cgd 	}
    148  1.5      cgd 
    149  1.6      cgd 	ic.ic_v = NULL;
    150  1.6      cgd 	ic.ic_attach_hook = sio_isa_attach_hook;
    151  1.6      cgd 	ic.ic_intr_establish = sio_intr_establish;
    152  1.6      cgd 	ic.ic_intr_disestablish = sio_intr_disestablish;
    153  1.6      cgd 
    154  1.5      cgd 	sa.sa_iba.iba_busname = "isa";
    155  1.5      cgd 	sa.sa_iba.iba_bc = pa->pa_bc;
    156  1.6      cgd 	sa.sa_iba.iba_ic = &ic;
    157  1.5      cgd 	config_found(self, &sa.sa_iba, sioprint);
    158  1.1      cgd }
    159  1.1      cgd 
    160  1.1      cgd static int
    161  1.1      cgd sioprint(aux, pnp)
    162  1.1      cgd 	void *aux;
    163  1.1      cgd 	char *pnp;
    164  1.1      cgd {
    165  1.5      cgd         register union sio_attach_args *sa = aux;
    166  1.1      cgd 
    167  1.1      cgd         if (pnp)
    168  1.5      cgd                 printf("%s at %s", sa->sa_name, pnp);
    169  1.1      cgd         return (UNCONF);
    170  1.6      cgd }
    171  1.6      cgd 
    172  1.6      cgd static void
    173  1.6      cgd sio_isa_attach_hook(parent, self, iba)
    174  1.6      cgd 	struct device *parent, *self;
    175  1.6      cgd 	struct isabus_attach_args *iba;
    176  1.6      cgd {
    177  1.6      cgd 
    178  1.6      cgd 	/* Nothing to do. */
    179  1.1      cgd }
    180