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