pci_machdep.c revision 1.25 1 1.25 thorpej /* $NetBSD: pci_machdep.c,v 1.25 2020/09/22 15:24:02 thorpej Exp $ */
2 1.25 thorpej
3 1.25 thorpej /*-
4 1.25 thorpej * Copyright (c) 2020 The NetBSD Foundation, Inc.
5 1.25 thorpej * All rights reserved.
6 1.25 thorpej *
7 1.25 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.25 thorpej * by Jason R. Thorpe.
9 1.25 thorpej *
10 1.25 thorpej * Redistribution and use in source and binary forms, with or without
11 1.25 thorpej * modification, are permitted provided that the following conditions
12 1.25 thorpej * are met:
13 1.25 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.25 thorpej * notice, this list of conditions and the following disclaimer.
15 1.25 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.25 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.25 thorpej * documentation and/or other materials provided with the distribution.
18 1.25 thorpej *
19 1.25 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.25 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.25 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.25 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.25 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.25 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.25 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.25 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.25 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.25 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.25 thorpej * POSSIBILITY OF SUCH DAMAGE.
30 1.25 thorpej */
31 1.1 cgd
32 1.1 cgd /*
33 1.5 cgd * Copyright (c) 1995, 1996 Carnegie-Mellon University.
34 1.3 cgd * All rights reserved.
35 1.1 cgd *
36 1.3 cgd * Author: Chris G. Demetriou
37 1.19 matt *
38 1.3 cgd * Permission to use, copy, modify and distribute this software and
39 1.3 cgd * its documentation is hereby granted, provided that both the copyright
40 1.3 cgd * notice and this permission notice appear in all copies of the
41 1.3 cgd * software, derivative works or modified versions, and any portions
42 1.3 cgd * thereof, and that both notices appear in supporting documentation.
43 1.19 matt *
44 1.19 matt * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 1.19 matt * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
46 1.3 cgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 1.19 matt *
48 1.3 cgd * Carnegie Mellon requests users of this software to return to
49 1.1 cgd *
50 1.3 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
51 1.3 cgd * School of Computer Science
52 1.3 cgd * Carnegie Mellon University
53 1.3 cgd * Pittsburgh PA 15213-3890
54 1.3 cgd *
55 1.3 cgd * any improvements or extensions that they make and grant Carnegie the
56 1.3 cgd * rights to redistribute these changes.
57 1.1 cgd */
58 1.1 cgd
59 1.1 cgd /*
60 1.1 cgd * Machine-specific functions for PCI autoconfiguration.
61 1.1 cgd */
62 1.9 cgd
63 1.10 cgd #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
64 1.10 cgd
65 1.25 thorpej __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.25 2020/09/22 15:24:02 thorpej Exp $");
66 1.1 cgd
67 1.1 cgd #include <sys/types.h>
68 1.1 cgd #include <sys/param.h>
69 1.1 cgd #include <sys/time.h>
70 1.1 cgd #include <sys/systm.h>
71 1.1 cgd #include <sys/errno.h>
72 1.1 cgd #include <sys/device.h>
73 1.14 mrg
74 1.1 cgd #include <dev/isa/isavar.h>
75 1.3 cgd #include <dev/pci/pcireg.h>
76 1.1 cgd #include <dev/pci/pcivar.h>
77 1.2 cgd #include <dev/pci/pcidevs.h>
78 1.1 cgd
79 1.7 cgd #include "vga_pci.h"
80 1.7 cgd #if NVGA_PCI
81 1.13 drochner #include <dev/ic/mc6845reg.h>
82 1.13 drochner #include <dev/ic/pcdisplayvar.h>
83 1.12 drochner #include <dev/pci/vga_pcivar.h>
84 1.3 cgd #endif
85 1.3 cgd
86 1.2 cgd #include "tga.h"
87 1.3 cgd #if NTGA
88 1.12 drochner #include <dev/pci/tgavar.h>
89 1.3 cgd #endif
90 1.1 cgd
91 1.20 tsutsui #include <machine/rpb.h>
92 1.20 tsutsui
93 1.1 cgd void
94 1.17 dsl pci_display_console(bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc, int bus, int device, int function)
95 1.1 cgd {
96 1.23 uebayasi #if NVGA_PCI || NTGA
97 1.4 cgd pcitag_t tag;
98 1.24 rin pcireg_t id;
99 1.4 cgd int match, nmatch;
100 1.23 uebayasi #endif
101 1.24 rin #if NVGA_PCI
102 1.24 rin pcireg_t class;
103 1.24 rin #endif
104 1.16 dsl int (*fn)(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
105 1.16 dsl int, int, int);
106 1.1 cgd
107 1.23 uebayasi #if NVGA_PCI || NTGA
108 1.4 cgd tag = pci_make_tag(pc, bus, device, function);
109 1.4 cgd id = pci_conf_read(pc, tag, PCI_ID_REG);
110 1.2 cgd if (id == 0 || id == 0xffffffff)
111 1.2 cgd panic("pci_display_console: no device at %d/%d/%d",
112 1.2 cgd bus, device, function);
113 1.24 rin # if NVGA_PCI
114 1.4 cgd class = pci_conf_read(pc, tag, PCI_CLASS_REG);
115 1.24 rin # endif
116 1.4 cgd
117 1.23 uebayasi match = 0;
118 1.23 uebayasi #endif
119 1.4 cgd fn = NULL;
120 1.2 cgd
121 1.7 cgd #if NVGA_PCI
122 1.7 cgd nmatch = DEVICE_IS_VGA_PCI(class, id);
123 1.4 cgd if (nmatch > match) {
124 1.4 cgd match = nmatch;
125 1.12 drochner fn = vga_pci_cnattach;
126 1.2 cgd }
127 1.3 cgd #endif
128 1.2 cgd #if NTGA
129 1.4 cgd nmatch = DEVICE_IS_TGA(class, id);
130 1.15 elric if (nmatch > match)
131 1.15 elric nmatch = tga_cnmatch(iot, memt, pc, tag);
132 1.4 cgd if (nmatch > match) {
133 1.4 cgd match = nmatch;
134 1.12 drochner fn = tga_cnattach;
135 1.2 cgd }
136 1.3 cgd #endif
137 1.2 cgd
138 1.4 cgd if (fn != NULL)
139 1.6 cgd (*fn)(iot, memt, pc, bus, device, function);
140 1.4 cgd else
141 1.4 cgd panic("pci_display_console: unconfigured device at %d/%d/%d",
142 1.2 cgd bus, device, function);
143 1.1 cgd }
144 1.20 tsutsui
145 1.20 tsutsui void
146 1.20 tsutsui device_pci_register(device_t dev, void *aux)
147 1.20 tsutsui {
148 1.20 tsutsui struct pci_attach_args *pa = aux;
149 1.20 tsutsui struct ctb *ctb;
150 1.20 tsutsui prop_dictionary_t dict;
151 1.20 tsutsui
152 1.20 tsutsui /* set properties for PCI framebuffers */
153 1.20 tsutsui ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);
154 1.20 tsutsui if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY &&
155 1.20 tsutsui ctb->ctb_term_type == CTB_GRAPHICS) {
156 1.20 tsutsui /* XXX should consider multiple displays? */
157 1.20 tsutsui dict = device_properties(dev);
158 1.20 tsutsui prop_dictionary_set_bool(dict, "is_console", true);
159 1.20 tsutsui }
160 1.20 tsutsui }
161 1.25 thorpej
162 1.25 thorpej int
163 1.25 thorpej alpha_pci_generic_intr_map(const struct pci_attach_args * const pa,
164 1.25 thorpej pci_intr_handle_t * const ihp)
165 1.25 thorpej {
166 1.25 thorpej pcitag_t const bustag = pa->pa_intrtag;
167 1.25 thorpej int const buspin = pa->pa_intrpin;
168 1.25 thorpej int const line = pa->pa_intrline;
169 1.25 thorpej pci_chipset_tag_t const pc = pa->pa_pc;
170 1.25 thorpej int bus, device, function;
171 1.25 thorpej
172 1.25 thorpej if (buspin == 0) {
173 1.25 thorpej /* No IRQ used. */
174 1.25 thorpej return 1;
175 1.25 thorpej }
176 1.25 thorpej if (buspin < 0 || buspin > 4) {
177 1.25 thorpej printf("%s: bad interrupt pin %d\n", __func__, buspin);
178 1.25 thorpej return 1;
179 1.25 thorpej }
180 1.25 thorpej
181 1.25 thorpej pci_decompose_tag(pc, bustag, &bus, &device, &function);
182 1.25 thorpej
183 1.25 thorpej /*
184 1.25 thorpej * The console firmware places the interrupt mapping in the "line"
185 1.25 thorpej * value. A valaue of (char)-1 indicates there is no mapping.
186 1.25 thorpej */
187 1.25 thorpej if (line == 0xff) {
188 1.25 thorpej printf("%s: no mapping for %d/%d/%d\n", __func__,
189 1.25 thorpej bus, device, function);
190 1.25 thorpej return 1;
191 1.25 thorpej }
192 1.25 thorpej
193 1.25 thorpej if (line < 0 || line >= pc->pc_nirq) {
194 1.25 thorpej printf("%s: bad line %d for %d/%d/%d\n", __func__,
195 1.25 thorpej line, bus, device, function);
196 1.25 thorpej return 1;
197 1.25 thorpej }
198 1.25 thorpej
199 1.25 thorpej alpha_pci_intr_handle_init(ihp, line, 0);
200 1.25 thorpej return 0;
201 1.25 thorpej }
202 1.25 thorpej
203 1.25 thorpej const char *
204 1.25 thorpej alpha_pci_generic_intr_string(pci_chipset_tag_t const pc,
205 1.25 thorpej pci_intr_handle_t const ih, char * const buf, size_t const len)
206 1.25 thorpej {
207 1.25 thorpej const u_int irq = alpha_pci_intr_handle_get_irq(&ih);
208 1.25 thorpej
209 1.25 thorpej KASSERT(irq < pc->pc_nirq);
210 1.25 thorpej
211 1.25 thorpej snprintf(buf, len, "%s %u", pc->pc_intr_desc, irq);
212 1.25 thorpej return buf;
213 1.25 thorpej }
214 1.25 thorpej
215 1.25 thorpej const struct evcnt *
216 1.25 thorpej alpha_pci_generic_intr_evcnt(pci_chipset_tag_t const pc,
217 1.25 thorpej pci_intr_handle_t const ih)
218 1.25 thorpej {
219 1.25 thorpej const u_int irq = alpha_pci_intr_handle_get_irq(&ih);
220 1.25 thorpej
221 1.25 thorpej KASSERT(irq < pc->pc_nirq);
222 1.25 thorpej
223 1.25 thorpej return alpha_shared_intr_evcnt(pc->pc_shared_intrs, irq);
224 1.25 thorpej }
225 1.25 thorpej
226 1.25 thorpej void *
227 1.25 thorpej alpha_pci_generic_intr_establish(pci_chipset_tag_t const pc,
228 1.25 thorpej pci_intr_handle_t const ih, int const level,
229 1.25 thorpej int (*func)(void *), void *arg)
230 1.25 thorpej {
231 1.25 thorpej const u_int irq = alpha_pci_intr_handle_get_irq(&ih);
232 1.25 thorpej const u_int flags = alpha_pci_intr_handle_get_flags(&ih);
233 1.25 thorpej void *cookie;
234 1.25 thorpej
235 1.25 thorpej KASSERT(irq < pc->pc_nirq);
236 1.25 thorpej
237 1.25 thorpej cookie = alpha_shared_intr_establish(pc->pc_shared_intrs,
238 1.25 thorpej irq, IST_LEVEL, level, flags, func, arg, pc->pc_intr_desc);
239 1.25 thorpej
240 1.25 thorpej if (cookie != NULL &&
241 1.25 thorpej alpha_shared_intr_firstactive(pc->pc_shared_intrs, irq)) {
242 1.25 thorpej scb_set(pc->pc_vecbase + SCB_IDXTOVEC(irq),
243 1.25 thorpej alpha_pci_generic_iointr, pc);
244 1.25 thorpej pc->pc_intr_enable(pc, irq);
245 1.25 thorpej }
246 1.25 thorpej return cookie;
247 1.25 thorpej }
248 1.25 thorpej
249 1.25 thorpej void
250 1.25 thorpej alpha_pci_generic_intr_disestablish(pci_chipset_tag_t const pc,
251 1.25 thorpej void * const cookie)
252 1.25 thorpej {
253 1.25 thorpej struct alpha_shared_intrhand * const ih = cookie;
254 1.25 thorpej const u_int irq = ih->ih_num;
255 1.25 thorpej int s;
256 1.25 thorpej
257 1.25 thorpej s = splhigh();
258 1.25 thorpej
259 1.25 thorpej alpha_shared_intr_disestablish(pc->pc_shared_intrs, cookie,
260 1.25 thorpej pc->pc_intr_desc);
261 1.25 thorpej if (alpha_shared_intr_isactive(pc->pc_shared_intrs, irq) == 0) {
262 1.25 thorpej pc->pc_intr_disable(pc, irq);
263 1.25 thorpej alpha_shared_intr_set_dfltsharetype(pc->pc_shared_intrs,
264 1.25 thorpej irq, IST_NONE);
265 1.25 thorpej scb_free(pc->pc_vecbase + SCB_IDXTOVEC(irq));
266 1.25 thorpej }
267 1.25 thorpej
268 1.25 thorpej splx(s);
269 1.25 thorpej }
270 1.25 thorpej
271 1.25 thorpej void
272 1.25 thorpej alpha_pci_generic_iointr(void * const arg, unsigned long const vec)
273 1.25 thorpej {
274 1.25 thorpej pci_chipset_tag_t const pc = arg;
275 1.25 thorpej const u_int irq = SCB_VECTOIDX(vec - pc->pc_vecbase);
276 1.25 thorpej
277 1.25 thorpej if (!alpha_shared_intr_dispatch(pc->pc_shared_intrs, irq)) {
278 1.25 thorpej alpha_shared_intr_stray(pc->pc_shared_intrs, irq,
279 1.25 thorpej pc->pc_intr_desc);
280 1.25 thorpej if (ALPHA_SHARED_INTR_DISABLE(pc->pc_shared_intrs, irq)) {
281 1.25 thorpej pc->pc_intr_disable(pc, irq);
282 1.25 thorpej }
283 1.25 thorpej } else {
284 1.25 thorpej alpha_shared_intr_reset_strays(pc->pc_shared_intrs, irq);
285 1.25 thorpej }
286 1.25 thorpej }
287 1.25 thorpej
288 1.25 thorpej #define ALPHA_PCI_INTR_HANDLE_IRQ __BITS(0,31)
289 1.25 thorpej #define ALPHA_PCI_INTR_HANDLE_FLAGS __BITS(32,63)
290 1.25 thorpej
291 1.25 thorpej void
292 1.25 thorpej alpha_pci_intr_handle_init(pci_intr_handle_t * const ihp, u_int const irq,
293 1.25 thorpej u_int const flags)
294 1.25 thorpej {
295 1.25 thorpej ihp->value = __SHIFTIN(irq, ALPHA_PCI_INTR_HANDLE_IRQ) |
296 1.25 thorpej __SHIFTIN(flags, ALPHA_PCI_INTR_HANDLE_FLAGS);
297 1.25 thorpej }
298 1.25 thorpej
299 1.25 thorpej void
300 1.25 thorpej alpha_pci_intr_handle_set_irq(pci_intr_handle_t * const ihp, u_int const irq)
301 1.25 thorpej {
302 1.25 thorpej ihp->value = (ihp->value & ALPHA_PCI_INTR_HANDLE_FLAGS) |
303 1.25 thorpej __SHIFTIN(irq, ALPHA_PCI_INTR_HANDLE_IRQ);
304 1.25 thorpej }
305 1.25 thorpej
306 1.25 thorpej u_int
307 1.25 thorpej alpha_pci_intr_handle_get_irq(const pci_intr_handle_t * const ihp)
308 1.25 thorpej {
309 1.25 thorpej return __SHIFTOUT(ihp->value, ALPHA_PCI_INTR_HANDLE_IRQ);
310 1.25 thorpej }
311 1.25 thorpej
312 1.25 thorpej void
313 1.25 thorpej alpha_pci_intr_handle_set_flags(pci_intr_handle_t * const ihp,
314 1.25 thorpej u_int const flags)
315 1.25 thorpej {
316 1.25 thorpej ihp->value = (ihp->value & ALPHA_PCI_INTR_HANDLE_IRQ) |
317 1.25 thorpej __SHIFTIN(flags, ALPHA_PCI_INTR_HANDLE_FLAGS);
318 1.25 thorpej }
319 1.25 thorpej
320 1.25 thorpej u_int
321 1.25 thorpej alpha_pci_intr_handle_get_flags(const pci_intr_handle_t * const ihp)
322 1.25 thorpej {
323 1.25 thorpej return __SHIFTOUT(ihp->value, ALPHA_PCI_INTR_HANDLE_FLAGS);
324 1.25 thorpej }
325 1.25 thorpej
326 1.25 thorpej /*
327 1.25 thorpej * MI PCI back-end entry points.
328 1.25 thorpej */
329 1.25 thorpej
330 1.25 thorpej void
331 1.25 thorpej pci_attach_hook(device_t const parent, device_t const self,
332 1.25 thorpej struct pcibus_attach_args * const pba)
333 1.25 thorpej {
334 1.25 thorpej pci_chipset_tag_t const pc = pba->pba_pc;
335 1.25 thorpej
336 1.25 thorpej KASSERT(pc->pc_attach_hook != NULL);
337 1.25 thorpej pc->pc_attach_hook(parent, self, pba);
338 1.25 thorpej }
339 1.25 thorpej
340 1.25 thorpej int
341 1.25 thorpej pci_bus_maxdevs(pci_chipset_tag_t const pc, int const busno)
342 1.25 thorpej {
343 1.25 thorpej KASSERT(pc->pc_bus_maxdevs != NULL);
344 1.25 thorpej return pc->pc_bus_maxdevs(pc->pc_conf_v, busno);
345 1.25 thorpej }
346 1.25 thorpej
347 1.25 thorpej pcitag_t
348 1.25 thorpej pci_make_tag(pci_chipset_tag_t const pc, int const bus, int const dev,
349 1.25 thorpej int const func)
350 1.25 thorpej {
351 1.25 thorpej KASSERT(pc->pc_make_tag != NULL);
352 1.25 thorpej return pc->pc_make_tag(pc->pc_conf_v, bus, dev, func);
353 1.25 thorpej }
354 1.25 thorpej
355 1.25 thorpej void
356 1.25 thorpej pci_decompose_tag(pci_chipset_tag_t const pc, pcitag_t const tag,
357 1.25 thorpej int * const busp, int * const devp, int * const funcp)
358 1.25 thorpej {
359 1.25 thorpej KASSERT(pc->pc_decompose_tag != NULL);
360 1.25 thorpej pc->pc_decompose_tag(pc->pc_conf_v, tag, busp, devp, funcp);
361 1.25 thorpej }
362 1.25 thorpej
363 1.25 thorpej pcireg_t
364 1.25 thorpej pci_conf_read(pci_chipset_tag_t const pc, pcitag_t const tag, int const reg)
365 1.25 thorpej {
366 1.25 thorpej KASSERT(pc->pc_conf_read != NULL);
367 1.25 thorpej return pc->pc_conf_read(pc->pc_conf_v, tag, reg);
368 1.25 thorpej }
369 1.25 thorpej
370 1.25 thorpej void
371 1.25 thorpej pci_conf_write(pci_chipset_tag_t const pc, pcitag_t const tag, int const reg,
372 1.25 thorpej pcireg_t const val)
373 1.25 thorpej {
374 1.25 thorpej KASSERT(pc->pc_conf_write != NULL);
375 1.25 thorpej pc->pc_conf_write(pc->pc_conf_v, tag, reg, val);
376 1.25 thorpej }
377 1.25 thorpej
378 1.25 thorpej int
379 1.25 thorpej pci_intr_map(const struct pci_attach_args * const pa,
380 1.25 thorpej pci_intr_handle_t * const ihp)
381 1.25 thorpej {
382 1.25 thorpej pci_chipset_tag_t const pc = pa->pa_pc;
383 1.25 thorpej
384 1.25 thorpej KASSERT(pc->pc_intr_map != NULL);
385 1.25 thorpej return pc->pc_intr_map(pa, ihp);
386 1.25 thorpej }
387 1.25 thorpej
388 1.25 thorpej const char *
389 1.25 thorpej pci_intr_string(pci_chipset_tag_t const pc, pci_intr_handle_t const ih,
390 1.25 thorpej char * const buf, size_t const len)
391 1.25 thorpej {
392 1.25 thorpej KASSERT(pc->pc_intr_string != NULL);
393 1.25 thorpej return pc->pc_intr_string(pc, ih, buf, len);
394 1.25 thorpej }
395 1.25 thorpej
396 1.25 thorpej const struct evcnt *
397 1.25 thorpej pci_intr_evcnt(pci_chipset_tag_t const pc, pci_intr_handle_t const ih)
398 1.25 thorpej {
399 1.25 thorpej KASSERT(pc->pc_intr_evcnt != NULL);
400 1.25 thorpej return pc->pc_intr_evcnt(pc, ih);
401 1.25 thorpej }
402 1.25 thorpej
403 1.25 thorpej void *
404 1.25 thorpej pci_intr_establish(pci_chipset_tag_t const pc, pci_intr_handle_t const ih,
405 1.25 thorpej int const ipl, int (*func)(void *), void *arg)
406 1.25 thorpej {
407 1.25 thorpej KASSERT(pc->pc_intr_establish != NULL);
408 1.25 thorpej return pc->pc_intr_establish(pc, ih, ipl, func, arg);
409 1.25 thorpej }
410 1.25 thorpej
411 1.25 thorpej void
412 1.25 thorpej pci_intr_disestablish(pci_chipset_tag_t const pc, void * const cookie)
413 1.25 thorpej {
414 1.25 thorpej KASSERT(pc->pc_intr_disestablish != NULL);
415 1.25 thorpej pc->pc_intr_disestablish(pc, cookie);
416 1.25 thorpej }
417 1.25 thorpej
418 1.25 thorpej int
419 1.25 thorpej pci_intr_setattr(pci_chipset_tag_t const pc __unused,
420 1.25 thorpej pci_intr_handle_t * const ihp, int const attr, uint64_t const data)
421 1.25 thorpej {
422 1.25 thorpej u_int flags = alpha_pci_intr_handle_get_flags(ihp);
423 1.25 thorpej
424 1.25 thorpej switch (attr) {
425 1.25 thorpej case PCI_INTR_MPSAFE:
426 1.25 thorpej if (data)
427 1.25 thorpej flags |= ALPHA_INTR_MPSAFE;
428 1.25 thorpej else
429 1.25 thorpej flags &= ~ALPHA_INTR_MPSAFE;
430 1.25 thorpej break;
431 1.25 thorpej
432 1.25 thorpej default:
433 1.25 thorpej return ENODEV;
434 1.25 thorpej }
435 1.25 thorpej
436 1.25 thorpej alpha_pci_intr_handle_set_flags(ihp, flags);
437 1.25 thorpej return 0;
438 1.25 thorpej }
439