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