sio.c revision 1.7 1 /* $NetBSD: sio.c,v 1.7 1996/04/12 06:09:00 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1995, 1996 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 <machine/intr.h>
36 #include <machine/bus.h>
37
38 #include <dev/isa/isavar.h>
39 #include <dev/eisa/eisavar.h>
40
41 #include <dev/pci/pcireg.h>
42 #include <dev/pci/pcivar.h>
43 #include <dev/pci/pcidevs.h>
44
45 #include <alpha/pci/siovar.h>
46
47 int siomatch __P((struct device *, void *, void *));
48 void sioattach __P((struct device *, struct device *, void *));
49
50 struct cfattach sio_ca = {
51 sizeof(struct device), siomatch, sioattach,
52 };
53
54 struct cfdriver sio_cd = {
55 NULL, "sio", DV_DULL,
56 };
57
58 int pcebmatch __P((struct device *, void *, void *));
59
60 struct cfattach pceb_ca = {
61 sizeof(struct device), pcebmatch, sioattach,
62 };
63
64 struct cfdriver pceb_cd = {
65 NULL, "pceb", DV_DULL,
66 };
67
68 union sio_attach_args {
69 const char *sa_name; /* XXX should be common */
70 struct isabus_attach_args sa_iba;
71 struct eisabus_attach_args sa_eba;
72 };
73
74 static int sioprint __P((void *, char *pnp));
75 static void sio_isa_attach_hook __P((struct device *, struct device *,
76 struct isabus_attach_args *));
77
78 int
79 siomatch(parent, match, aux)
80 struct device *parent;
81 void *match, *aux;
82 {
83 struct cfdata *cf = match;
84 struct pci_attach_args *pa = aux;
85
86 if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
87 PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_SIO)
88 return (0);
89
90 return (1);
91 }
92
93 int
94 pcebmatch(parent, match, aux)
95 struct device *parent;
96 void *match, *aux;
97 {
98 struct cfdata *cf = match;
99 struct pci_attach_args *pa = aux;
100
101 if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
102 PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_PCEB)
103 return (0);
104
105 return (1);
106 }
107
108 void
109 sioattach(parent, self, aux)
110 struct device *parent, *self;
111 void *aux;
112 {
113 struct pci_attach_args *pa = aux;
114 struct alpha_isa_chipset ic;
115 struct alpha_eisa_chipset ec;
116 union sio_attach_args sa;
117 int sio, haseisa;
118 char devinfo[256];
119
120 sio = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_SIO);
121 haseisa = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB);
122
123 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
124 printf(": %s (rev. 0x%02x)\n", devinfo,
125 PCI_REVISION(pa->pa_class));
126
127 if (sio) {
128 pci_revision_t rev;
129
130 rev = PCI_REVISION(pa->pa_class);
131
132 if (rev < 3)
133 printf("%s: WARNING: SIO I SUPPORT UNTESTED\n",
134 self->dv_xname);
135 }
136
137 #ifdef EVCNT_COUNTERS
138 evcnt_attach(self, "intr", &sio_intr_evcnt);
139 #endif
140
141 if (haseisa) {
142 /* XXX SET UP EISA CHIPSET */
143 sa.sa_eba.eba_busname = "eisa";
144 sa.sa_eba.eba_bc = pa->pa_bc;
145 sa.sa_eba.eba_ec = &ec;
146 config_found(self, &sa.sa_eba, sioprint);
147 }
148
149 ic.ic_v = NULL;
150 ic.ic_attach_hook = sio_isa_attach_hook;
151 ic.ic_intr_establish = sio_intr_establish;
152 ic.ic_intr_disestablish = sio_intr_disestablish;
153
154 sa.sa_iba.iba_busname = "isa";
155 sa.sa_iba.iba_bc = pa->pa_bc;
156 sa.sa_iba.iba_ic = ⁣
157 config_found(self, &sa.sa_iba, sioprint);
158 }
159
160 static int
161 sioprint(aux, pnp)
162 void *aux;
163 char *pnp;
164 {
165 register union sio_attach_args *sa = aux;
166
167 if (pnp)
168 printf("%s at %s", sa->sa_name, pnp);
169 return (UNCONF);
170 }
171
172 static void
173 sio_isa_attach_hook(parent, self, iba)
174 struct device *parent, *self;
175 struct isabus_attach_args *iba;
176 {
177
178 /* Nothing to do. */
179 }
180