pci_550.c revision 1.22.2.3 1 1.22.2.3 nathanw /* $NetBSD: pci_550.c,v 1.22.2.3 2002/10/18 02:34:22 nathanw Exp $ */
2 1.22.2.2 nathanw
3 1.22.2.2 nathanw /*-
4 1.22.2.2 nathanw * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
5 1.22.2.2 nathanw * All rights reserved.
6 1.22.2.2 nathanw *
7 1.22.2.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.22.2.2 nathanw * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.22.2.2 nathanw * NASA Ames Research Center, and by Andrew Gallatin.
10 1.22.2.2 nathanw *
11 1.22.2.2 nathanw * Redistribution and use in source and binary forms, with or without
12 1.22.2.2 nathanw * modification, are permitted provided that the following conditions
13 1.22.2.2 nathanw * are met:
14 1.22.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
15 1.22.2.2 nathanw * notice, this list of conditions and the following disclaimer.
16 1.22.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
17 1.22.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
18 1.22.2.2 nathanw * documentation and/or other materials provided with the distribution.
19 1.22.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
20 1.22.2.2 nathanw * must display the following acknowledgement:
21 1.22.2.2 nathanw * This product includes software developed by the NetBSD
22 1.22.2.2 nathanw * Foundation, Inc. and its contributors.
23 1.22.2.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.22.2.2 nathanw * contributors may be used to endorse or promote products derived
25 1.22.2.2 nathanw * from this software without specific prior written permission.
26 1.22.2.2 nathanw *
27 1.22.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.22.2.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.22.2.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.22.2.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.22.2.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.22.2.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.22.2.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.22.2.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.22.2.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.22.2.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.22.2.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
38 1.22.2.2 nathanw */
39 1.22.2.2 nathanw
40 1.22.2.2 nathanw /*
41 1.22.2.2 nathanw * Copyright (c) 1995, 1996 Carnegie-Mellon University.
42 1.22.2.2 nathanw * All rights reserved.
43 1.22.2.2 nathanw *
44 1.22.2.2 nathanw * Author: Chris G. Demetriou
45 1.22.2.2 nathanw *
46 1.22.2.2 nathanw * Permission to use, copy, modify and distribute this software and
47 1.22.2.2 nathanw * its documentation is hereby granted, provided that both the copyright
48 1.22.2.2 nathanw * notice and this permission notice appear in all copies of the
49 1.22.2.2 nathanw * software, derivative works or modified versions, and any portions
50 1.22.2.2 nathanw * thereof, and that both notices appear in supporting documentation.
51 1.22.2.2 nathanw *
52 1.22.2.2 nathanw * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
53 1.22.2.2 nathanw * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
54 1.22.2.2 nathanw * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
55 1.22.2.2 nathanw *
56 1.22.2.2 nathanw * Carnegie Mellon requests users of this software to return to
57 1.22.2.2 nathanw *
58 1.22.2.2 nathanw * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
59 1.22.2.2 nathanw * School of Computer Science
60 1.22.2.2 nathanw * Carnegie Mellon University
61 1.22.2.2 nathanw * Pittsburgh PA 15213-3890
62 1.22.2.2 nathanw *
63 1.22.2.2 nathanw * any improvements or extensions that they make and grant Carnegie the
64 1.22.2.2 nathanw * rights to redistribute these changes.
65 1.22.2.2 nathanw */
66 1.22.2.2 nathanw
67 1.22.2.2 nathanw #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
68 1.22.2.2 nathanw
69 1.22.2.3 nathanw __KERNEL_RCSID(0, "$NetBSD: pci_550.c,v 1.22.2.3 2002/10/18 02:34:22 nathanw Exp $");
70 1.22.2.2 nathanw
71 1.22.2.2 nathanw #include <sys/types.h>
72 1.22.2.2 nathanw #include <sys/param.h>
73 1.22.2.2 nathanw #include <sys/time.h>
74 1.22.2.2 nathanw #include <sys/systm.h>
75 1.22.2.2 nathanw #include <sys/errno.h>
76 1.22.2.2 nathanw #include <sys/malloc.h>
77 1.22.2.2 nathanw #include <sys/device.h>
78 1.22.2.2 nathanw #include <sys/syslog.h>
79 1.22.2.2 nathanw
80 1.22.2.2 nathanw #include <uvm/uvm_extern.h>
81 1.22.2.2 nathanw
82 1.22.2.2 nathanw #include <machine/autoconf.h>
83 1.22.2.2 nathanw #include <machine/rpb.h>
84 1.22.2.2 nathanw
85 1.22.2.2 nathanw #include <dev/pci/pcireg.h>
86 1.22.2.2 nathanw #include <dev/pci/pcivar.h>
87 1.22.2.2 nathanw #include <dev/pci/pciidereg.h>
88 1.22.2.2 nathanw #include <dev/pci/pciidevar.h>
89 1.22.2.2 nathanw
90 1.22.2.2 nathanw #include <alpha/pci/ciareg.h>
91 1.22.2.2 nathanw #include <alpha/pci/ciavar.h>
92 1.22.2.2 nathanw
93 1.22.2.2 nathanw #include <alpha/pci/pci_550.h>
94 1.22.2.2 nathanw
95 1.22.2.2 nathanw #include "sio.h"
96 1.22.2.2 nathanw #if NSIO
97 1.22.2.2 nathanw #include <alpha/pci/siovar.h>
98 1.22.2.2 nathanw #endif
99 1.22.2.2 nathanw
100 1.22.2.2 nathanw int dec_550_intr_map __P((struct pci_attach_args *,
101 1.22.2.2 nathanw pci_intr_handle_t *));
102 1.22.2.2 nathanw const char *dec_550_intr_string __P((void *, pci_intr_handle_t));
103 1.22.2.2 nathanw const struct evcnt *dec_550_intr_evcnt __P((void *, pci_intr_handle_t));
104 1.22.2.2 nathanw void *dec_550_intr_establish __P((void *, pci_intr_handle_t,
105 1.22.2.2 nathanw int, int (*func)(void *), void *));
106 1.22.2.2 nathanw void dec_550_intr_disestablish __P((void *, void *));
107 1.22.2.2 nathanw
108 1.22.2.2 nathanw void *dec_550_pciide_compat_intr_establish __P((void *, struct device *,
109 1.22.2.2 nathanw struct pci_attach_args *, int, int (*)(void *), void *));
110 1.22.2.2 nathanw
111 1.22.2.2 nathanw #define DEC_550_PCI_IRQ_BEGIN 8
112 1.22.2.2 nathanw #define DEC_550_MAX_IRQ (64 - DEC_550_PCI_IRQ_BEGIN)
113 1.22.2.2 nathanw
114 1.22.2.2 nathanw /*
115 1.22.2.2 nathanw * The Miata has a Pyxis, which seems to have problems with stray
116 1.22.2.2 nathanw * interrupts. Work around this by just ignoring strays.
117 1.22.2.2 nathanw */
118 1.22.2.2 nathanw #define PCI_STRAY_MAX 0
119 1.22.2.2 nathanw
120 1.22.2.2 nathanw /*
121 1.22.2.2 nathanw * Some Miata models, notably models with a Cypress PCI-ISA bridge, have
122 1.22.2.2 nathanw * a PCI device (the OHCI USB controller) with interrupts tied to ISA IRQ
123 1.22.2.2 nathanw * lines. This IRQ is encoded as: line = FLAG | isa_irq. Usually FLAG
124 1.22.2.2 nathanw * is 0xe0, however, it can be 0xf0. We don't allow 0xf0 | irq15.
125 1.22.2.2 nathanw */
126 1.22.2.2 nathanw #define DEC_550_LINE_IS_ISA(line) ((line) >= 0xe0 && (line) <= 0xfe)
127 1.22.2.2 nathanw #define DEC_550_LINE_ISA_IRQ(line) ((line) & 0x0f)
128 1.22.2.2 nathanw
129 1.22.2.2 nathanw struct alpha_shared_intr *dec_550_pci_intr;
130 1.22.2.2 nathanw
131 1.22.2.2 nathanw void dec_550_iointr __P((void *arg, unsigned long vec));
132 1.22.2.2 nathanw void dec_550_intr_enable __P((int irq));
133 1.22.2.2 nathanw void dec_550_intr_disable __P((int irq));
134 1.22.2.2 nathanw
135 1.22.2.2 nathanw void
136 1.22.2.2 nathanw pci_550_pickintr(ccp)
137 1.22.2.2 nathanw struct cia_config *ccp;
138 1.22.2.2 nathanw {
139 1.22.2.2 nathanw bus_space_tag_t iot = &ccp->cc_iot;
140 1.22.2.2 nathanw pci_chipset_tag_t pc = &ccp->cc_pc;
141 1.22.2.2 nathanw char *cp;
142 1.22.2.2 nathanw int i;
143 1.22.2.2 nathanw
144 1.22.2.2 nathanw pc->pc_intr_v = ccp;
145 1.22.2.2 nathanw pc->pc_intr_map = dec_550_intr_map;
146 1.22.2.2 nathanw pc->pc_intr_string = dec_550_intr_string;
147 1.22.2.2 nathanw pc->pc_intr_evcnt = dec_550_intr_evcnt;
148 1.22.2.2 nathanw pc->pc_intr_establish = dec_550_intr_establish;
149 1.22.2.2 nathanw pc->pc_intr_disestablish = dec_550_intr_disestablish;
150 1.22.2.2 nathanw
151 1.22.2.2 nathanw pc->pc_pciide_compat_intr_establish =
152 1.22.2.2 nathanw dec_550_pciide_compat_intr_establish;
153 1.22.2.2 nathanw
154 1.22.2.2 nathanw /*
155 1.22.2.2 nathanw * DEC 550's interrupts are enabled via the Pyxis interrupt
156 1.22.2.2 nathanw * mask register. Nothing to map.
157 1.22.2.2 nathanw */
158 1.22.2.2 nathanw
159 1.22.2.2 nathanw for (i = 0; i < DEC_550_MAX_IRQ; i++)
160 1.22.2.2 nathanw dec_550_intr_disable(i);
161 1.22.2.2 nathanw
162 1.22.2.2 nathanw dec_550_pci_intr = alpha_shared_intr_alloc(DEC_550_MAX_IRQ, 8);
163 1.22.2.2 nathanw for (i = 0; i < DEC_550_MAX_IRQ; i++) {
164 1.22.2.2 nathanw alpha_shared_intr_set_maxstrays(dec_550_pci_intr, i,
165 1.22.2.2 nathanw PCI_STRAY_MAX);
166 1.22.2.2 nathanw alpha_shared_intr_set_private(dec_550_pci_intr, i, ccp);
167 1.22.2.2 nathanw
168 1.22.2.2 nathanw cp = alpha_shared_intr_string(dec_550_pci_intr, i);
169 1.22.2.2 nathanw sprintf(cp, "irq %d", i);
170 1.22.2.2 nathanw evcnt_attach_dynamic(alpha_shared_intr_evcnt(
171 1.22.2.2 nathanw dec_550_pci_intr, i), EVCNT_TYPE_INTR, NULL,
172 1.22.2.2 nathanw "dec_550", cp);
173 1.22.2.2 nathanw }
174 1.22.2.2 nathanw
175 1.22.2.2 nathanw #if NSIO
176 1.22.2.2 nathanw sio_intr_setup(pc, iot);
177 1.22.2.2 nathanw #endif
178 1.22.2.2 nathanw }
179 1.22.2.2 nathanw
180 1.22.2.2 nathanw int
181 1.22.2.2 nathanw dec_550_intr_map(pa, ihp)
182 1.22.2.2 nathanw struct pci_attach_args *pa;
183 1.22.2.2 nathanw pci_intr_handle_t *ihp;
184 1.22.2.2 nathanw {
185 1.22.2.2 nathanw pcitag_t bustag = pa->pa_intrtag;
186 1.22.2.2 nathanw int buspin = pa->pa_intrpin, line = pa->pa_intrline;
187 1.22.2.2 nathanw pci_chipset_tag_t pc = pa->pa_pc;
188 1.22.2.2 nathanw int bus, device, function;
189 1.22.2.2 nathanw
190 1.22.2.2 nathanw if (buspin == 0) {
191 1.22.2.2 nathanw /* No IRQ used. */
192 1.22.2.2 nathanw return 1;
193 1.22.2.2 nathanw }
194 1.22.2.2 nathanw if (buspin > 4) {
195 1.22.2.2 nathanw printf("dec_550_intr_map: bad interrupt pin %d\n", buspin);
196 1.22.2.2 nathanw return 1;
197 1.22.2.2 nathanw }
198 1.22.2.2 nathanw
199 1.22.2.2 nathanw pci_decompose_tag(pc, bustag, &bus, &device, &function);
200 1.22.2.2 nathanw
201 1.22.2.2 nathanw /*
202 1.22.2.2 nathanw * There are two main variants of Miata: Miata 1 (Intel SIO)
203 1.22.2.2 nathanw * and Miata {1.5,2} (Cypress).
204 1.22.2.2 nathanw *
205 1.22.2.2 nathanw * The Miata 1 has a CMD PCI IDE wired to compatibility mode at
206 1.22.2.2 nathanw * device 4 of bus 0. This variant apparently also has the
207 1.22.2.2 nathanw * Pyxis DMA bug.
208 1.22.2.2 nathanw *
209 1.22.2.2 nathanw * On the Miata 1.5 and Miata 2, the Cypress PCI-ISA bridge lives
210 1.22.2.2 nathanw * on device 7 of bus 0. This device has PCI IDE wired to
211 1.22.2.2 nathanw * compatibility mode on functions 1 and 2.
212 1.22.2.2 nathanw *
213 1.22.2.2 nathanw * There will be no interrupt mapping for these devices, so just
214 1.22.2.2 nathanw * bail out now.
215 1.22.2.2 nathanw */
216 1.22.2.2 nathanw if (bus == 0) {
217 1.22.2.2 nathanw if ((hwrpb->rpb_variation & SV_ST_MASK) < SV_ST_MIATA_1_5) {
218 1.22.2.2 nathanw /* Miata 1 */
219 1.22.2.2 nathanw if (device == 7)
220 1.22.2.2 nathanw panic("dec_550_intr_map: SIO device");
221 1.22.2.2 nathanw else if (device == 4)
222 1.22.2.2 nathanw return (1);
223 1.22.2.2 nathanw } else {
224 1.22.2.2 nathanw /* Miata 1.5 or Miata 2 */
225 1.22.2.2 nathanw if (device == 7) {
226 1.22.2.2 nathanw if (function == 0)
227 1.22.2.2 nathanw panic("dec_550_intr_map: SIO device");
228 1.22.2.2 nathanw if (function == 1 || function == 2)
229 1.22.2.2 nathanw return (1);
230 1.22.2.2 nathanw }
231 1.22.2.2 nathanw }
232 1.22.2.2 nathanw }
233 1.22.2.2 nathanw
234 1.22.2.2 nathanw /*
235 1.22.2.2 nathanw * The console places the interrupt mapping in the "line" value.
236 1.22.2.2 nathanw * A value of (char)-1 indicates there is no mapping.
237 1.22.2.2 nathanw */
238 1.22.2.2 nathanw if (line == 0xff) {
239 1.22.2.2 nathanw printf("dec_550_intr_map: no mapping for %d/%d/%d\n",
240 1.22.2.2 nathanw bus, device, function);
241 1.22.2.2 nathanw return (1);
242 1.22.2.2 nathanw }
243 1.22.2.2 nathanw
244 1.22.2.2 nathanw #if NSIO == 0
245 1.22.2.2 nathanw if (DEC_550_LINE_IS_ISA(line)) {
246 1.22.2.2 nathanw printf("dec_550_intr_map: ISA IRQ %d for %d/%d/%d\n",
247 1.22.2.2 nathanw DEC_550_LINE_ISA_IRQ(line), bus, device, function);
248 1.22.2.2 nathanw return (1);
249 1.22.2.2 nathanw }
250 1.22.2.2 nathanw #endif
251 1.22.2.2 nathanw
252 1.22.2.2 nathanw if (DEC_550_LINE_IS_ISA(line) == 0 && line >= DEC_550_MAX_IRQ) {
253 1.22.2.2 nathanw printf("dec_550_intr_map: irq %d out of range %d/%d/%d\n",
254 1.22.2.2 nathanw line, bus, device, function);
255 1.22.2.2 nathanw return (1);
256 1.22.2.2 nathanw }
257 1.22.2.2 nathanw *ihp = line;
258 1.22.2.2 nathanw return (0);
259 1.22.2.2 nathanw }
260 1.22.2.2 nathanw
261 1.22.2.2 nathanw const char *
262 1.22.2.2 nathanw dec_550_intr_string(ccv, ih)
263 1.22.2.2 nathanw void *ccv;
264 1.22.2.2 nathanw pci_intr_handle_t ih;
265 1.22.2.2 nathanw {
266 1.22.2.2 nathanw #if 0
267 1.22.2.2 nathanw struct cia_config *ccp = ccv;
268 1.22.2.2 nathanw #endif
269 1.22.2.2 nathanw static char irqstr[16]; /* 12 + 2 + NULL + sanity */
270 1.22.2.2 nathanw
271 1.22.2.2 nathanw #if NSIO
272 1.22.2.2 nathanw if (DEC_550_LINE_IS_ISA(ih))
273 1.22.2.2 nathanw return (sio_intr_string(NULL /*XXX*/,
274 1.22.2.2 nathanw DEC_550_LINE_ISA_IRQ(ih)));
275 1.22.2.2 nathanw #endif
276 1.22.2.2 nathanw
277 1.22.2.2 nathanw if (ih >= DEC_550_MAX_IRQ)
278 1.22.2.3 nathanw panic("dec_550_intr_string: bogus 550 IRQ 0x%lx", ih);
279 1.22.2.2 nathanw sprintf(irqstr, "dec 550 irq %ld", ih);
280 1.22.2.2 nathanw return (irqstr);
281 1.22.2.2 nathanw }
282 1.22.2.2 nathanw
283 1.22.2.2 nathanw const struct evcnt *
284 1.22.2.2 nathanw dec_550_intr_evcnt(ccv, ih)
285 1.22.2.2 nathanw void *ccv;
286 1.22.2.2 nathanw pci_intr_handle_t ih;
287 1.22.2.2 nathanw {
288 1.22.2.2 nathanw #if 0
289 1.22.2.2 nathanw struct cia_config *ccp = ccv;
290 1.22.2.2 nathanw #endif
291 1.22.2.2 nathanw
292 1.22.2.2 nathanw #if NSIO
293 1.22.2.2 nathanw if (DEC_550_LINE_IS_ISA(ih))
294 1.22.2.2 nathanw return (sio_intr_evcnt(NULL /*XXX*/,
295 1.22.2.2 nathanw DEC_550_LINE_ISA_IRQ(ih)));
296 1.22.2.2 nathanw #endif
297 1.22.2.2 nathanw
298 1.22.2.2 nathanw if (ih >= DEC_550_MAX_IRQ)
299 1.22.2.3 nathanw panic("dec_550_intr_evcnt: bogus 550 IRQ 0x%lx", ih);
300 1.22.2.2 nathanw
301 1.22.2.2 nathanw return (alpha_shared_intr_evcnt(dec_550_pci_intr, ih));
302 1.22.2.2 nathanw }
303 1.22.2.2 nathanw
304 1.22.2.2 nathanw void *
305 1.22.2.2 nathanw dec_550_intr_establish(ccv, ih, level, func, arg)
306 1.22.2.2 nathanw void *ccv, *arg;
307 1.22.2.2 nathanw pci_intr_handle_t ih;
308 1.22.2.2 nathanw int level;
309 1.22.2.2 nathanw int (*func) __P((void *));
310 1.22.2.2 nathanw {
311 1.22.2.2 nathanw #if 0
312 1.22.2.2 nathanw struct cia_config *ccp = ccv;
313 1.22.2.2 nathanw #endif
314 1.22.2.2 nathanw void *cookie;
315 1.22.2.2 nathanw
316 1.22.2.2 nathanw #if NSIO
317 1.22.2.2 nathanw if (DEC_550_LINE_IS_ISA(ih))
318 1.22.2.2 nathanw return (sio_intr_establish(NULL /*XXX*/,
319 1.22.2.2 nathanw DEC_550_LINE_ISA_IRQ(ih), IST_LEVEL, level, func, arg));
320 1.22.2.2 nathanw #endif
321 1.22.2.2 nathanw
322 1.22.2.2 nathanw if (ih >= DEC_550_MAX_IRQ)
323 1.22.2.3 nathanw panic("dec_550_intr_establish: bogus dec 550 IRQ 0x%lx", ih);
324 1.22.2.2 nathanw
325 1.22.2.2 nathanw cookie = alpha_shared_intr_establish(dec_550_pci_intr, ih, IST_LEVEL,
326 1.22.2.2 nathanw level, func, arg, "dec 550 irq");
327 1.22.2.2 nathanw
328 1.22.2.2 nathanw if (cookie != NULL &&
329 1.22.2.2 nathanw alpha_shared_intr_firstactive(dec_550_pci_intr, ih)) {
330 1.22.2.2 nathanw scb_set(0x900 + SCB_IDXTOVEC(ih), dec_550_iointr, NULL);
331 1.22.2.2 nathanw dec_550_intr_enable(ih);
332 1.22.2.2 nathanw }
333 1.22.2.2 nathanw return (cookie);
334 1.22.2.2 nathanw }
335 1.22.2.2 nathanw
336 1.22.2.2 nathanw void
337 1.22.2.2 nathanw dec_550_intr_disestablish(ccv, cookie)
338 1.22.2.2 nathanw void *ccv, *cookie;
339 1.22.2.2 nathanw {
340 1.22.2.2 nathanw struct cia_config *ccp = ccv;
341 1.22.2.2 nathanw struct alpha_shared_intrhand *ih = cookie;
342 1.22.2.2 nathanw unsigned int irq = ih->ih_num;
343 1.22.2.2 nathanw int s;
344 1.22.2.2 nathanw
345 1.22.2.2 nathanw #if NSIO
346 1.22.2.2 nathanw /*
347 1.22.2.2 nathanw * We have to determine if this is an ISA IRQ or not! We do this
348 1.22.2.2 nathanw * by checking to see if the intrhand points back to an intrhead
349 1.22.2.2 nathanw * that points to our cia_config. If not, it's an ISA IRQ. Pretty
350 1.22.2.2 nathanw * disgusting, eh?
351 1.22.2.2 nathanw */
352 1.22.2.2 nathanw if (ih->ih_intrhead->intr_private != ccp) {
353 1.22.2.2 nathanw sio_intr_disestablish(NULL /*XXX*/, cookie);
354 1.22.2.2 nathanw return;
355 1.22.2.2 nathanw }
356 1.22.2.2 nathanw #endif
357 1.22.2.2 nathanw
358 1.22.2.2 nathanw s = splhigh();
359 1.22.2.2 nathanw
360 1.22.2.2 nathanw alpha_shared_intr_disestablish(dec_550_pci_intr, cookie,
361 1.22.2.2 nathanw "dec 550 irq");
362 1.22.2.2 nathanw if (alpha_shared_intr_isactive(dec_550_pci_intr, irq) == 0) {
363 1.22.2.2 nathanw dec_550_intr_disable(irq);
364 1.22.2.2 nathanw alpha_shared_intr_set_dfltsharetype(dec_550_pci_intr, irq,
365 1.22.2.2 nathanw IST_NONE);
366 1.22.2.2 nathanw scb_free(0x900 + SCB_IDXTOVEC(irq));
367 1.22.2.2 nathanw }
368 1.22.2.2 nathanw
369 1.22.2.2 nathanw splx(s);
370 1.22.2.2 nathanw }
371 1.22.2.2 nathanw
372 1.22.2.2 nathanw void *
373 1.22.2.2 nathanw dec_550_pciide_compat_intr_establish(v, dev, pa, chan, func, arg)
374 1.22.2.2 nathanw void *v;
375 1.22.2.2 nathanw struct device *dev;
376 1.22.2.2 nathanw struct pci_attach_args *pa;
377 1.22.2.2 nathanw int chan;
378 1.22.2.2 nathanw int (*func) __P((void *));
379 1.22.2.2 nathanw void *arg;
380 1.22.2.2 nathanw {
381 1.22.2.2 nathanw pci_chipset_tag_t pc = pa->pa_pc;
382 1.22.2.2 nathanw void *cookie = NULL;
383 1.22.2.2 nathanw int bus, irq;
384 1.22.2.2 nathanw
385 1.22.2.2 nathanw pci_decompose_tag(pc, pa->pa_tag, &bus, NULL, NULL);
386 1.22.2.2 nathanw
387 1.22.2.2 nathanw /*
388 1.22.2.2 nathanw * If this isn't PCI bus #0, all bets are off.
389 1.22.2.2 nathanw */
390 1.22.2.2 nathanw if (bus != 0)
391 1.22.2.2 nathanw return (NULL);
392 1.22.2.2 nathanw
393 1.22.2.2 nathanw irq = PCIIDE_COMPAT_IRQ(chan);
394 1.22.2.2 nathanw #if NSIO
395 1.22.2.2 nathanw cookie = sio_intr_establish(NULL /*XXX*/, irq, IST_EDGE, IPL_BIO,
396 1.22.2.2 nathanw func, arg);
397 1.22.2.2 nathanw if (cookie == NULL)
398 1.22.2.2 nathanw return (NULL);
399 1.22.2.2 nathanw printf("%s: %s channel interrupting at %s\n", dev->dv_xname,
400 1.22.2.2 nathanw PCIIDE_CHANNEL_NAME(chan), sio_intr_string(NULL /*XXX*/, irq));
401 1.22.2.2 nathanw #endif
402 1.22.2.2 nathanw return (cookie);
403 1.22.2.2 nathanw }
404 1.22.2.2 nathanw
405 1.22.2.2 nathanw void
406 1.22.2.2 nathanw dec_550_iointr(arg, vec)
407 1.22.2.2 nathanw void *arg;
408 1.22.2.2 nathanw unsigned long vec;
409 1.22.2.2 nathanw {
410 1.22.2.2 nathanw int irq;
411 1.22.2.2 nathanw
412 1.22.2.2 nathanw irq = SCB_VECTOIDX(vec - 0x900);
413 1.22.2.2 nathanw
414 1.22.2.2 nathanw if (irq >= DEC_550_MAX_IRQ)
415 1.22.2.3 nathanw panic("550_iointr: vec 0x%lx out of range", vec);
416 1.22.2.2 nathanw
417 1.22.2.2 nathanw if (!alpha_shared_intr_dispatch(dec_550_pci_intr, irq)) {
418 1.22.2.2 nathanw alpha_shared_intr_stray(dec_550_pci_intr, irq,
419 1.22.2.2 nathanw "dec 550 irq");
420 1.22.2.2 nathanw if (ALPHA_SHARED_INTR_DISABLE(dec_550_pci_intr, irq))
421 1.22.2.2 nathanw dec_550_intr_disable(irq);
422 1.22.2.2 nathanw }
423 1.22.2.2 nathanw }
424 1.22.2.2 nathanw
425 1.22.2.2 nathanw void
426 1.22.2.2 nathanw dec_550_intr_enable(irq)
427 1.22.2.2 nathanw int irq;
428 1.22.2.2 nathanw {
429 1.22.2.2 nathanw
430 1.22.2.2 nathanw cia_pyxis_intr_enable(irq + DEC_550_PCI_IRQ_BEGIN, 1);
431 1.22.2.2 nathanw }
432 1.22.2.2 nathanw
433 1.22.2.2 nathanw void
434 1.22.2.2 nathanw dec_550_intr_disable(irq)
435 1.22.2.2 nathanw int irq;
436 1.22.2.2 nathanw {
437 1.22.2.2 nathanw
438 1.22.2.2 nathanw cia_pyxis_intr_enable(irq + DEC_550_PCI_IRQ_BEGIN, 0);
439 1.22.2.2 nathanw }
440