Home | History | Annotate | Line # | Download | only in pci
sio.c revision 1.4
      1  1.4  thorpej /*	$NetBSD: sio.c,v 1.4 1996/03/17 01:06:35 thorpej 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.3      cgd #include <dev/isa/isavar.h>
     36  1.3      cgd #include <dev/eisa/eisavar.h>
     37  1.3      cgd 
     38  1.1      cgd #include <dev/pci/pcireg.h>
     39  1.1      cgd #include <dev/pci/pcivar.h>
     40  1.1      cgd #include <dev/pci/pcidevs.h>
     41  1.1      cgd 
     42  1.3      cgd #include <alpha/pci/siovar.h>
     43  1.1      cgd 
     44  1.1      cgd int	siomatch __P((struct device *, void *, void *));
     45  1.1      cgd void	sioattach __P((struct device *, struct device *, void *));
     46  1.1      cgd 
     47  1.4  thorpej struct cfattach sio_ca = {
     48  1.4  thorpej 	sizeof(struct device), siomatch, sioattach
     49  1.4  thorpej };
     50  1.4  thorpej 
     51  1.4  thorpej struct cfdriver sio_cd = {
     52  1.4  thorpej 	NULL, "sio", DV_DULL
     53  1.1      cgd };
     54  1.1      cgd 
     55  1.3      cgd int	pcebmatch __P((struct device *, void *, void *));
     56  1.3      cgd 
     57  1.4  thorpej struct cfattach pceb_ca = {
     58  1.4  thorpej 	sizeof(struct device), pcebmatch, sioattach
     59  1.4  thorpej };
     60  1.4  thorpej 
     61  1.4  thorpej struct cfdriver pceb_cd = {
     62  1.4  thorpej 	NULL, "pceb", DV_DULL
     63  1.3      cgd };
     64  1.3      cgd 
     65  1.1      cgd static int	sioprint __P((void *, char *pnp));
     66  1.1      cgd 
     67  1.1      cgd int
     68  1.1      cgd siomatch(parent, match, aux)
     69  1.1      cgd 	struct device *parent;
     70  1.1      cgd 	void *match, *aux;
     71  1.1      cgd {
     72  1.1      cgd 	struct cfdata *cf = match;
     73  1.3      cgd 	struct pcidev_attach_args *pda = aux;
     74  1.3      cgd 
     75  1.3      cgd 	if (PCI_VENDOR(pda->pda_id) != PCI_VENDOR_INTEL ||
     76  1.3      cgd 	    PCI_PRODUCT(pda->pda_id) != PCI_PRODUCT_INTEL_SIO)
     77  1.3      cgd 		return (0);
     78  1.3      cgd 
     79  1.3      cgd 	return (1);
     80  1.3      cgd }
     81  1.3      cgd 
     82  1.3      cgd int
     83  1.3      cgd pcebmatch(parent, match, aux)
     84  1.3      cgd 	struct device *parent;
     85  1.3      cgd 	void *match, *aux;
     86  1.3      cgd {
     87  1.3      cgd 	struct cfdata *cf = match;
     88  1.3      cgd 	struct pcidev_attach_args *pda = aux;
     89  1.1      cgd 
     90  1.3      cgd 	if (PCI_VENDOR(pda->pda_id) != PCI_VENDOR_INTEL ||
     91  1.3      cgd 	    PCI_PRODUCT(pda->pda_id) != PCI_PRODUCT_INTEL_PCEB)
     92  1.1      cgd 		return (0);
     93  1.1      cgd 
     94  1.1      cgd 	return (1);
     95  1.1      cgd }
     96  1.1      cgd 
     97  1.1      cgd void
     98  1.1      cgd sioattach(parent, self, aux)
     99  1.1      cgd 	struct device *parent, *self;
    100  1.1      cgd 	void *aux;
    101  1.1      cgd {
    102  1.3      cgd 	struct pcidev_attach_args *pda = aux;
    103  1.3      cgd 	struct isa_attach_args ia;
    104  1.3      cgd 	struct eisa_attach_args ea;
    105  1.3      cgd 	int sio, haseisa;
    106  1.3      cgd 	char devinfo[256];
    107  1.3      cgd 
    108  1.3      cgd 	sio = (PCI_PRODUCT(pda->pda_id) == PCI_PRODUCT_INTEL_SIO);
    109  1.3      cgd 	haseisa = (PCI_PRODUCT(pda->pda_id) == PCI_PRODUCT_INTEL_PCEB);
    110  1.3      cgd 
    111  1.3      cgd 	pci_devinfo(pda->pda_id, pda->pda_class, 0, devinfo);
    112  1.3      cgd 	printf(": %s (rev. 0x%02x)\n", devinfo,
    113  1.3      cgd 	    PCI_REVISION(pda->pda_class));
    114  1.3      cgd 
    115  1.3      cgd 	if (sio) {
    116  1.3      cgd 		pci_revision_t rev;
    117  1.3      cgd 
    118  1.3      cgd 		rev = PCI_REVISION(pda->pda_class);
    119  1.3      cgd 
    120  1.3      cgd 		if (rev < 3)
    121  1.3      cgd 			printf("%s: WARNING: SIO I SUPPORT UNTESTED\n",
    122  1.3      cgd 			    self->dv_xname);
    123  1.3      cgd 	}
    124  1.3      cgd 
    125  1.3      cgd #ifdef EVCNT_COUNTERS
    126  1.3      cgd 	evcnt_attach(self, "intr", &sio_intr_evcnt);
    127  1.3      cgd #endif
    128  1.3      cgd 
    129  1.3      cgd 	ia.ia_bus = BUS_ISA;
    130  1.3      cgd 	ia.ia_dmafns = pda->pda_dmafns;
    131  1.3      cgd 	ia.ia_dmaarg = pda->pda_dmaarg;
    132  1.3      cgd 	ia.ia_intrfns = &sio_isa_intr_fns;
    133  1.3      cgd 	ia.ia_intrarg = NULL;			/* XXX needs nothing */
    134  1.3      cgd 	ia.ia_memfns = pda->pda_memfns;
    135  1.3      cgd 	ia.ia_memarg = pda->pda_memarg;
    136  1.3      cgd 	ia.ia_piofns = pda->pda_piofns;
    137  1.3      cgd 	ia.ia_pioarg = pda->pda_pioarg;
    138  1.3      cgd 	config_found(self, &ia, sioprint);
    139  1.3      cgd 
    140  1.3      cgd 	if (haseisa) {
    141  1.3      cgd 		ea.ea_bus = BUS_EISA;
    142  1.3      cgd 		ea.ea_dmafns = pda->pda_dmafns;
    143  1.3      cgd 		ea.ea_dmaarg = pda->pda_dmaarg;
    144  1.3      cgd 		ea.ea_intrfns = &sio_isa_intr_fns;
    145  1.3      cgd 		ea.ea_intrarg = NULL;		/* XXX needs nothing */
    146  1.3      cgd 		ea.ea_memfns = pda->pda_memfns;
    147  1.3      cgd 		ea.ea_memarg = pda->pda_memarg;
    148  1.3      cgd 		ea.ea_piofns = pda->pda_piofns;
    149  1.3      cgd 		ea.ea_pioarg = pda->pda_pioarg;
    150  1.3      cgd 		config_found(self, &ea, sioprint);
    151  1.1      cgd 	}
    152  1.1      cgd }
    153  1.1      cgd 
    154  1.1      cgd static int
    155  1.1      cgd sioprint(aux, pnp)
    156  1.1      cgd 	void *aux;
    157  1.1      cgd 	char *pnp;
    158  1.1      cgd {
    159  1.3      cgd         register struct isa_attach_args *ia = aux;
    160  1.3      cgd 
    161  1.3      cgd 	/*
    162  1.3      cgd 	 * XXX Assumes that the first fields of 'struct isa_attach_args'
    163  1.3      cgd 	 * XXX and 'struct eisa_attach_args' are the same.
    164  1.3      cgd 	 */
    165  1.1      cgd 
    166  1.1      cgd         if (pnp)
    167  1.3      cgd                 printf("%s at %s", isa_bustype_name(ia->ia_bus), pnp);
    168  1.1      cgd         return (UNCONF);
    169  1.1      cgd }
    170