pci_machdep.c revision 1.83 1 1.83 riastrad /* $NetBSD: pci_machdep.c,v 1.83 2024/06/23 00:53:34 riastradh Exp $ */
2 1.1 mrg
3 1.1 mrg /*
4 1.5 mrg * Copyright (c) 1999, 2000 Matthew R. Green
5 1.1 mrg * All rights reserved.
6 1.1 mrg *
7 1.1 mrg * Redistribution and use in source and binary forms, with or without
8 1.1 mrg * modification, are permitted provided that the following conditions
9 1.1 mrg * are met:
10 1.1 mrg * 1. Redistributions of source code must retain the above copyright
11 1.1 mrg * notice, this list of conditions and the following disclaimer.
12 1.1 mrg * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 mrg * notice, this list of conditions and the following disclaimer in the
14 1.1 mrg * documentation and/or other materials provided with the distribution.
15 1.1 mrg *
16 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 mrg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 mrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 mrg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 mrg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 mrg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 mrg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 mrg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 mrg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 mrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 mrg * SUCH DAMAGE.
27 1.1 mrg */
28 1.1 mrg
29 1.1 mrg /*
30 1.1 mrg * functions expected by the MI PCI code.
31 1.1 mrg */
32 1.38 lukem
33 1.38 lukem #include <sys/cdefs.h>
34 1.83 riastrad __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.83 2024/06/23 00:53:34 riastradh Exp $");
35 1.1 mrg
36 1.1 mrg #include <sys/types.h>
37 1.1 mrg #include <sys/param.h>
38 1.1 mrg #include <sys/time.h>
39 1.1 mrg #include <sys/systm.h>
40 1.1 mrg #include <sys/errno.h>
41 1.1 mrg #include <sys/device.h>
42 1.1 mrg
43 1.1 mrg #define _SPARC_BUS_DMA_PRIVATE
44 1.73 dyoung #include <sys/bus.h>
45 1.1 mrg #include <machine/autoconf.h>
46 1.22 eeh #include <machine/openfirm.h>
47 1.1 mrg #include <dev/pci/pcivar.h>
48 1.1 mrg #include <dev/pci/pcireg.h>
49 1.1 mrg
50 1.19 mrg #include <dev/ofw/ofw_pci.h>
51 1.19 mrg
52 1.1 mrg #include <sparc64/dev/iommureg.h>
53 1.37 martin #include <sparc64/sparc64/cache.h>
54 1.39 petrov
55 1.49 drochner #include "locators.h"
56 1.49 drochner
57 1.39 petrov #ifdef DEBUG
58 1.39 petrov #define SPDB_CONF 0x01
59 1.39 petrov #define SPDB_INTR 0x04
60 1.39 petrov #define SPDB_INTMAP 0x08
61 1.39 petrov #define SPDB_PROBE 0x20
62 1.61 mrg #define SPDB_TAG 0x40
63 1.39 petrov int sparc_pci_debug = 0x0;
64 1.39 petrov #define DPRINTF(l, s) do { if (sparc_pci_debug & l) printf s; } while (0)
65 1.39 petrov #else
66 1.39 petrov #define DPRINTF(l, s)
67 1.39 petrov #endif
68 1.1 mrg
69 1.1 mrg /* this is a base to be copied */
70 1.1 mrg struct sparc_pci_chipset _sparc_pci_chipset = {
71 1.52 martin .cookie = NULL,
72 1.1 mrg };
73 1.2 mrg
74 1.30 thorpej static pcitag_t
75 1.30 thorpej ofpci_make_tag(pci_chipset_tag_t pc, int node, int b, int d, int f)
76 1.30 thorpej {
77 1.30 thorpej pcitag_t tag;
78 1.61 mrg pcireg_t reg;
79 1.30 thorpej
80 1.30 thorpej tag = PCITAG_CREATE(node, b, d, f);
81 1.30 thorpej
82 1.61 mrg DPRINTF(SPDB_TAG,
83 1.69 mrg ("%s: creating tag for node %x bus %d dev %d fn %d\n",
84 1.61 mrg __func__, node, b, d, f));
85 1.61 mrg
86 1.30 thorpej /* Enable all the different spaces for this device */
87 1.61 mrg reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
88 1.61 mrg reg |= PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE|
89 1.61 mrg PCI_COMMAND_IO_ENABLE;
90 1.61 mrg pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, reg);
91 1.61 mrg
92 1.30 thorpej return (tag);
93 1.30 thorpej }
94 1.30 thorpej
95 1.1 mrg /*
96 1.1 mrg * functions provided to the MI code.
97 1.1 mrg */
98 1.1 mrg
99 1.1 mrg void
100 1.75 chs pci_attach_hook(device_t parent, device_t self,
101 1.75 chs struct pcibus_attach_args *pba)
102 1.1 mrg {
103 1.1 mrg }
104 1.1 mrg
105 1.1 mrg int
106 1.51 cdi pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
107 1.1 mrg {
108 1.1 mrg
109 1.1 mrg return 32;
110 1.1 mrg }
111 1.19 mrg
112 1.1 mrg pcitag_t
113 1.51 cdi pci_make_tag(pci_chipset_tag_t pc, int b, int d, int f)
114 1.1 mrg {
115 1.46 nakayama struct ofw_pci_register reg;
116 1.22 eeh pcitag_t tag;
117 1.51 cdi int (*valid)(void *);
118 1.79 charlott int node, new_node, len;
119 1.22 eeh #ifdef DEBUG
120 1.22 eeh char name[80];
121 1.40 martin memset(name, 0, sizeof(name));
122 1.22 eeh #endif
123 1.1 mrg
124 1.35 nakayama /*
125 1.35 nakayama * Refer to the PCI/CardBus bus node first.
126 1.35 nakayama * It returns a tag if node is present and bus is valid.
127 1.35 nakayama */
128 1.35 nakayama if (0 <= b && b < 256) {
129 1.62 nakayama KASSERT(pc->spc_busnode != NULL);
130 1.60 mrg node = (*pc->spc_busnode)[b].node;
131 1.60 mrg valid = (*pc->spc_busnode)[b].valid;
132 1.35 nakayama if (node != 0 && d == 0 &&
133 1.60 mrg (valid == NULL || (*valid)((*pc->spc_busnode)[b].arg)))
134 1.35 nakayama return ofpci_make_tag(pc, node, b, d, f);
135 1.35 nakayama }
136 1.35 nakayama
137 1.22 eeh /*
138 1.22 eeh * Hunt for the node that corresponds to this device
139 1.22 eeh *
140 1.22 eeh * We could cache this info in an array in the parent
141 1.22 eeh * device... except then we have problems with devices
142 1.22 eeh * attached below pci-pci bridges, and we would need to
143 1.22 eeh * add special code to the pci-pci bridge to cache this
144 1.22 eeh * info.
145 1.22 eeh */
146 1.1 mrg
147 1.22 eeh tag = PCITAG_CREATE(-1, b, d, f);
148 1.22 eeh node = pc->rootnode;
149 1.22 eeh /*
150 1.22 eeh * First make sure we're on the right bus. If our parent
151 1.22 eeh * has a bus-range property and we're not in the range,
152 1.22 eeh * then we're obviously on the wrong bus. So go up one
153 1.22 eeh * level.
154 1.22 eeh */
155 1.74 mrg DPRINTF(SPDB_PROBE, ("curnode %x %s\n", node,
156 1.74 mrg prom_getpropstringA(node, "name", name, sizeof(name))));
157 1.22 eeh #if 0
158 1.22 eeh while ((OF_getprop(OF_parent(node), "bus-range", (void *)&busrange,
159 1.22 eeh sizeof(busrange)) == sizeof(busrange)) &&
160 1.22 eeh (b < busrange[0] || b > busrange[1])) {
161 1.22 eeh /* Out of range, go up one */
162 1.22 eeh node = OF_parent(node);
163 1.74 mrg DPRINTF(SPDB_PROBE, printf("going up to node %x %s\n",
164 1.74 mrg node,
165 1.74 mrg prom_getpropstringA(node, "name", name, sizeof(name))));
166 1.22 eeh }
167 1.22 eeh #endif
168 1.72 macallan node = prom_firstchild(node);
169 1.22 eeh /*
170 1.22 eeh * Now traverse all peers until we find the node or we find
171 1.22 eeh * the right bridge.
172 1.22 eeh *
173 1.22 eeh * XXX We go up one and down one to make sure nobody's missed.
174 1.22 eeh * but this should not be necessary.
175 1.22 eeh */
176 1.42 pk for (node = ((node)); node; node = prom_nextsibling(node)) {
177 1.1 mrg
178 1.74 mrg DPRINTF(SPDB_PROBE, ("checking node %x %s\n", node,
179 1.74 mrg prom_getpropstringA(node, "name", name, sizeof(name))));
180 1.1 mrg
181 1.22 eeh #if 1
182 1.1 mrg /*
183 1.22 eeh * Check for PCI-PCI bridges. If the device we want is
184 1.22 eeh * in the bus-range for that bridge, work our way down.
185 1.1 mrg */
186 1.44 pk while (1) {
187 1.44 pk int busrange[2], *brp;
188 1.44 pk len = 2;
189 1.44 pk brp = busrange;
190 1.45 nakayama if (prom_getprop(node, "bus-range", sizeof(*brp),
191 1.45 nakayama &len, &brp) != 0)
192 1.44 pk break;
193 1.44 pk if (len != 2 || b < busrange[0] || b > busrange[1])
194 1.44 pk break;
195 1.79 charlott /* Go down 1 level, as long as we're able */
196 1.79 charlott new_node = prom_firstchild(node);
197 1.79 charlott if (new_node == 0)
198 1.79 charlott break;
199 1.79 charlott node = new_node;
200 1.74 mrg DPRINTF(SPDB_PROBE, ("going down to node %x %s\n", node,
201 1.74 mrg prom_getpropstringA(node, "name", name,
202 1.74 mrg sizeof(name))));
203 1.1 mrg }
204 1.44 pk #endif /*1*/
205 1.22 eeh /*
206 1.22 eeh * We only really need the first `reg' property.
207 1.22 eeh *
208 1.22 eeh * For simplicity, we'll query the `reg' when we
209 1.22 eeh * need it. Otherwise we could malloc() it, but
210 1.22 eeh * that gets more complicated.
211 1.22 eeh */
212 1.46 nakayama len = prom_getproplen(node, "reg");
213 1.46 nakayama if (len < sizeof(reg))
214 1.46 nakayama continue;
215 1.46 nakayama if (OF_getprop(node, "reg", (void *)®, sizeof(reg)) != len)
216 1.44 pk panic("pci_probe_bus: OF_getprop len botch");
217 1.22 eeh
218 1.22 eeh if (b != OFW_PCI_PHYS_HI_BUS(reg.phys_hi))
219 1.22 eeh continue;
220 1.22 eeh if (d != OFW_PCI_PHYS_HI_DEVICE(reg.phys_hi))
221 1.22 eeh continue;
222 1.22 eeh if (f != OFW_PCI_PHYS_HI_FUNCTION(reg.phys_hi))
223 1.22 eeh continue;
224 1.22 eeh
225 1.22 eeh /* Got a match */
226 1.27 eeh tag = ofpci_make_tag(pc, node, b, d, f);
227 1.22 eeh
228 1.22 eeh return (tag);
229 1.1 mrg }
230 1.22 eeh /* No device found -- return a dead tag */
231 1.27 eeh return (tag);
232 1.28 thorpej }
233 1.28 thorpej
234 1.28 thorpej void
235 1.51 cdi pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp)
236 1.28 thorpej {
237 1.28 thorpej
238 1.28 thorpej if (bp != NULL)
239 1.28 thorpej *bp = PCITAG_BUS(tag);
240 1.28 thorpej if (dp != NULL)
241 1.28 thorpej *dp = PCITAG_DEV(tag);
242 1.28 thorpej if (fp != NULL)
243 1.28 thorpej *fp = PCITAG_FUN(tag);
244 1.27 eeh }
245 1.27 eeh
246 1.30 thorpej int
247 1.83 riastrad sparc64_pci_enumerate_bus1(struct pci_softc *sc, const int *locators,
248 1.83 riastrad int (*match)(void *, const struct pci_attach_args *), void *cookie,
249 1.83 riastrad struct pci_attach_args *pap)
250 1.27 eeh {
251 1.30 thorpej struct ofw_pci_register reg;
252 1.30 thorpej pci_chipset_tag_t pc = sc->sc_pc;
253 1.27 eeh pcitag_t tag;
254 1.35 nakayama pcireg_t class, csr, bhlc, ic;
255 1.30 thorpej int node, b, d, f, ret;
256 1.37 martin int bus_frequency, lt, cl, cacheline;
257 1.30 thorpej char name[30];
258 1.69 mrg #if 0
259 1.32 eeh extern int pci_config_dump;
260 1.69 mrg #endif
261 1.30 thorpej
262 1.31 eeh if (sc->sc_bridgetag)
263 1.31 eeh node = PCITAG_NODE(*sc->sc_bridgetag);
264 1.31 eeh else
265 1.31 eeh node = pc->rootnode;
266 1.31 eeh
267 1.42 pk bus_frequency =
268 1.42 pk prom_getpropint(node, "clock-frequency", 33000000) / 1000000;
269 1.35 nakayama
270 1.37 martin /*
271 1.37 martin * Make sure the cache line size is at least as big as the
272 1.37 martin * ecache line and the streaming cache (64 byte).
273 1.37 martin */
274 1.78 riastrad cacheline = uimax(ecache_min_line_size, 64);
275 1.37 martin KASSERT((cacheline/64)*64 == cacheline &&
276 1.53 mrg (cacheline/ecache_min_line_size)*ecache_min_line_size == cacheline &&
277 1.37 martin (cacheline/4)*4 == cacheline);
278 1.37 martin
279 1.69 mrg #if 0
280 1.69 mrg /*
281 1.69 mrg * XXX this faults on Fire PCIe controllers.
282 1.69 mrg * XXX move into the psycho and schizo driver front ends.
283 1.69 mrg */
284 1.32 eeh /* Turn on parity for the bus. */
285 1.32 eeh tag = ofpci_make_tag(pc, node, sc->sc_bus, 0, 0);
286 1.32 eeh csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
287 1.32 eeh csr |= PCI_COMMAND_PARITY_ENABLE;
288 1.32 eeh pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr);
289 1.32 eeh
290 1.35 nakayama /*
291 1.35 nakayama * Initialize the latency timer register.
292 1.35 nakayama * The value 0x40 is from Solaris.
293 1.35 nakayama */
294 1.35 nakayama bhlc = pci_conf_read(pc, tag, PCI_BHLC_REG);
295 1.35 nakayama bhlc &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
296 1.35 nakayama bhlc |= 0x40 << PCI_LATTIMER_SHIFT;
297 1.35 nakayama pci_conf_write(pc, tag, PCI_BHLC_REG, bhlc);
298 1.35 nakayama
299 1.69 mrg if (pci_config_dump)
300 1.69 mrg pci_conf_print(pc, tag, NULL);
301 1.69 mrg #endif
302 1.32 eeh
303 1.42 pk for (node = prom_firstchild(node); node != 0 && node != -1;
304 1.42 pk node = prom_nextsibling(node)) {
305 1.30 thorpej name[0] = name[29] = 0;
306 1.42 pk prom_getpropstringA(node, "name", name, sizeof(name));
307 1.27 eeh
308 1.30 thorpej if (OF_getprop(node, "class-code", &class, sizeof(class)) !=
309 1.30 thorpej sizeof(class))
310 1.30 thorpej continue;
311 1.83 riastrad if (OF_getprop(node, "reg", ®, sizeof(reg)) < sizeof(reg)) {
312 1.83 riastrad panic("pci_enumerate_bus1: \"%s\" regs too small",
313 1.83 riastrad name);
314 1.83 riastrad }
315 1.27 eeh
316 1.30 thorpej b = OFW_PCI_PHYS_HI_BUS(reg.phys_hi);
317 1.30 thorpej d = OFW_PCI_PHYS_HI_DEVICE(reg.phys_hi);
318 1.30 thorpej f = OFW_PCI_PHYS_HI_FUNCTION(reg.phys_hi);
319 1.30 thorpej
320 1.30 thorpej if (sc->sc_bus != b) {
321 1.57 cube aprint_error_dev(sc->sc_dev, "WARNING: incorrect "
322 1.57 cube "bus # for \"%s\" (%d/%d/%d)\n", name, b, d, f);
323 1.30 thorpej continue;
324 1.30 thorpej }
325 1.49 drochner if ((locators[PCICF_DEV] != PCICF_DEV_DEFAULT) &&
326 1.49 drochner (locators[PCICF_DEV] != d))
327 1.49 drochner continue;
328 1.49 drochner if ((locators[PCICF_FUNCTION] != PCICF_FUNCTION_DEFAULT) &&
329 1.49 drochner (locators[PCICF_FUNCTION] != f))
330 1.49 drochner continue;
331 1.27 eeh
332 1.30 thorpej tag = ofpci_make_tag(pc, node, b, d, f);
333 1.32 eeh
334 1.32 eeh /*
335 1.32 eeh * Turn on parity and fast-back-to-back for the device.
336 1.32 eeh */
337 1.32 eeh csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
338 1.32 eeh if (csr & PCI_STATUS_BACKTOBACK_SUPPORT)
339 1.32 eeh csr |= PCI_COMMAND_BACKTOBACK_ENABLE;
340 1.32 eeh csr |= PCI_COMMAND_PARITY_ENABLE;
341 1.32 eeh pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr);
342 1.32 eeh
343 1.35 nakayama /*
344 1.35 nakayama * Initialize the latency timer register for busmaster
345 1.35 nakayama * devices to work properly.
346 1.35 nakayama * latency-timer = min-grant * bus-freq / 4 (from FreeBSD)
347 1.35 nakayama * Also initialize the cache line size register.
348 1.35 nakayama * Solaris anytime sets this register to the value 0x10.
349 1.35 nakayama */
350 1.35 nakayama bhlc = pci_conf_read(pc, tag, PCI_BHLC_REG);
351 1.35 nakayama ic = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
352 1.35 nakayama
353 1.78 riastrad lt = uimin(PCI_MIN_GNT(ic) * bus_frequency / 4, 255);
354 1.35 nakayama if (lt == 0 || lt < PCI_LATTIMER(bhlc))
355 1.35 nakayama lt = PCI_LATTIMER(bhlc);
356 1.35 nakayama
357 1.35 nakayama cl = PCI_CACHELINE(bhlc);
358 1.35 nakayama if (cl == 0)
359 1.37 martin cl = cacheline;
360 1.35 nakayama
361 1.35 nakayama bhlc &= ~((PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT) |
362 1.35 nakayama (PCI_CACHELINE_MASK << PCI_CACHELINE_SHIFT));
363 1.35 nakayama bhlc |= (lt << PCI_LATTIMER_SHIFT) |
364 1.35 nakayama (cl << PCI_CACHELINE_SHIFT);
365 1.35 nakayama pci_conf_write(pc, tag, PCI_BHLC_REG, bhlc);
366 1.35 nakayama
367 1.83 riastrad ret = pci_probe_device1(sc, tag, match, cookie, pap);
368 1.30 thorpej if (match != NULL && ret != 0)
369 1.30 thorpej return (ret);
370 1.30 thorpej }
371 1.30 thorpej return (0);
372 1.1 mrg }
373 1.1 mrg
374 1.1 mrg const char *
375 1.77 christos pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf,
376 1.77 christos size_t len)
377 1.1 mrg {
378 1.77 christos snprintf(buf, len, "ivec %x", ih);
379 1.77 christos DPRINTF(SPDB_INTR, ("pci_intr_string: returning %s\n", buf));
380 1.1 mrg
381 1.77 christos return buf;
382 1.8 cgd }
383 1.8 cgd
384 1.8 cgd const struct evcnt *
385 1.51 cdi pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
386 1.8 cgd {
387 1.8 cgd
388 1.8 cgd /* XXX for now, no evcnt parent reported */
389 1.8 cgd return NULL;
390 1.1 mrg }
391 1.1 mrg
392 1.59 ad int
393 1.59 ad pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih,
394 1.59 ad int attr, uint64_t data)
395 1.59 ad {
396 1.59 ad
397 1.59 ad switch (attr) {
398 1.59 ad case PCI_INTR_MPSAFE:
399 1.59 ad return 0;
400 1.59 ad default:
401 1.59 ad return ENODEV;
402 1.59 ad }
403 1.59 ad }
404 1.59 ad
405 1.66 mrg /*
406 1.66 mrg * interrupt mapping foo.
407 1.66 mrg * XXX: how does this deal with multiple interrupts for a device?
408 1.66 mrg */
409 1.66 mrg int
410 1.71 dyoung pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
411 1.66 mrg {
412 1.66 mrg pcitag_t tag = pa->pa_tag;
413 1.67 jdc int interrupts[4], *intp, int_used;
414 1.66 mrg int len, node = PCITAG_NODE(tag);
415 1.66 mrg char devtype[30];
416 1.66 mrg
417 1.67 jdc intp = &interrupts[0];
418 1.67 jdc len = prom_getproplen(node, "interrupts");
419 1.67 jdc if (len > sizeof(interrupts)) {
420 1.67 jdc DPRINTF(SPDB_INTMAP,
421 1.67 jdc ("pci_intr_map: too many available interrupts\n"));
422 1.67 jdc return (ENODEV);
423 1.67 jdc }
424 1.67 jdc if (prom_getprop(node, "interrupts", len,
425 1.66 mrg &len, &intp) != 0 || len != 1) {
426 1.66 mrg DPRINTF(SPDB_INTMAP,
427 1.66 mrg ("pci_intr_map: could not read interrupts\n"));
428 1.66 mrg return (ENODEV);
429 1.66 mrg }
430 1.66 mrg
431 1.67 jdc /* XXX We pick the first interrupt, but should do better */
432 1.67 jdc int_used = interrupts[0];
433 1.67 jdc if (OF_mapintr(node, &int_used, sizeof(int_used),
434 1.67 jdc sizeof(int_used)) < 0) {
435 1.66 mrg printf("OF_mapintr failed\n");
436 1.68 mrg if (pa->pa_pc->spc_find_ino)
437 1.68 mrg pa->pa_pc->spc_find_ino(pa, &int_used);
438 1.66 mrg }
439 1.67 jdc DPRINTF(SPDB_INTMAP, ("OF_mapintr() gave %x\n", int_used));
440 1.66 mrg
441 1.66 mrg /* Try to find an IPL for this type of device. */
442 1.66 mrg prom_getpropstringA(node, "device_type", devtype, sizeof(devtype));
443 1.66 mrg for (len = 0; intrmap[len].in_class != NULL; len++)
444 1.66 mrg if (strcmp(intrmap[len].in_class, devtype) == 0) {
445 1.67 jdc int_used |= INTLEVENCODE(intrmap[len].in_lev);
446 1.67 jdc DPRINTF(SPDB_INTMAP, ("reset to %x\n", int_used));
447 1.66 mrg break;
448 1.66 mrg }
449 1.66 mrg
450 1.67 jdc *ihp = int_used;
451 1.66 mrg
452 1.66 mrg /* Call the sub-driver is necessary */
453 1.66 mrg if (pa->pa_pc->spc_intr_map)
454 1.66 mrg (*pa->pa_pc->spc_intr_map)(pa, ihp);
455 1.66 mrg
456 1.66 mrg return (0);
457 1.66 mrg }
458 1.66 mrg
459 1.1 mrg void
460 1.51 cdi pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
461 1.1 mrg {
462 1.1 mrg
463 1.1 mrg DPRINTF(SPDB_INTR, ("pci_intr_disestablish: cookie %p\n", cookie));
464 1.1 mrg
465 1.1 mrg /* XXX */
466 1.55 martin /* panic("can't disestablish PCI interrupts yet"); */
467 1.1 mrg }
468 1.61 mrg
469 1.61 mrg int
470 1.61 mrg sparc_pci_childspace(int type)
471 1.61 mrg {
472 1.61 mrg int ss;
473 1.61 mrg
474 1.61 mrg switch (type) {
475 1.61 mrg case PCI_CONFIG_BUS_SPACE:
476 1.61 mrg ss = 0x00;
477 1.61 mrg break;
478 1.61 mrg case PCI_IO_BUS_SPACE:
479 1.61 mrg ss = 0x01;
480 1.61 mrg break;
481 1.61 mrg case PCI_MEMORY_BUS_SPACE:
482 1.61 mrg ss = 0x02;
483 1.61 mrg break;
484 1.61 mrg #if 0
485 1.61 mrg /* we don't do 64 bit memory space */
486 1.61 mrg case PCI_MEMORY64_BUS_SPACE:
487 1.61 mrg ss = 0x03;
488 1.61 mrg break;
489 1.61 mrg #endif
490 1.61 mrg default:
491 1.69 mrg panic("get_childspace: unknown bus type: %d", type);
492 1.61 mrg }
493 1.61 mrg
494 1.61 mrg return (ss);
495 1.61 mrg }
496