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