psycho.c revision 1.1 1 1.1 mrg /* $NetBSD: psycho.c,v 1.1 1999/06/04 13:42:14 mrg Exp $ */
2 1.1 mrg
3 1.1 mrg /*
4 1.1 mrg * Copyright (c) 1999 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 * 3. The name of the author may not be used to endorse or promote products
16 1.1 mrg * derived from this software without specific prior written permission.
17 1.1 mrg *
18 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 mrg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 mrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 mrg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 mrg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 1.1 mrg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 1.1 mrg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 1.1 mrg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 1.1 mrg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.1 mrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.1 mrg * SUCH DAMAGE.
29 1.1 mrg */
30 1.1 mrg
31 1.1 mrg /*
32 1.1 mrg * PCI support for UltraSPARC `psycho'
33 1.1 mrg */
34 1.1 mrg
35 1.1 mrg #undef DEBUG
36 1.1 mrg #define DEBUG
37 1.1 mrg
38 1.1 mrg #ifdef DEBUG
39 1.1 mrg #define PDB_PROM 0x1
40 1.1 mrg #define PDB_IOMMU 0x2
41 1.1 mrg int psycho_debug = 0;
42 1.1 mrg #define DPRINTF(l, s) do { if (psycho_debug & l) printf s; } while (0)
43 1.1 mrg #else
44 1.1 mrg #define DPRINTF(l, s)
45 1.1 mrg #endif
46 1.1 mrg
47 1.1 mrg #include <sys/param.h>
48 1.1 mrg #include <sys/extent.h>
49 1.1 mrg #include <sys/time.h>
50 1.1 mrg #include <sys/systm.h>
51 1.1 mrg #include <sys/errno.h>
52 1.1 mrg #include <sys/device.h>
53 1.1 mrg #include <sys/malloc.h>
54 1.1 mrg
55 1.1 mrg #include <vm/vm.h>
56 1.1 mrg #include <vm/vm_kern.h>
57 1.1 mrg
58 1.1 mrg #define _SPARC_BUS_DMA_PRIVATE
59 1.1 mrg #include <machine/bus.h>
60 1.1 mrg #include <machine/autoconf.h>
61 1.1 mrg
62 1.1 mrg #include <dev/pci/pcivar.h>
63 1.1 mrg #include <dev/pci/pcireg.h>
64 1.1 mrg
65 1.1 mrg #include <sparc64/dev/iommureg.h>
66 1.1 mrg #include <sparc64/dev/iommuvar.h>
67 1.1 mrg #include <sparc64/dev/psychoreg.h>
68 1.1 mrg #include <sparc64/dev/psychovar.h>
69 1.1 mrg
70 1.1 mrg static pci_chipset_tag_t psycho_alloc_chipset __P((struct psycho_pbm *, int,
71 1.1 mrg pci_chipset_tag_t));
72 1.1 mrg static void psycho_get_bus_range __P((int, int *));
73 1.1 mrg static void psycho_get_ranges __P((int, struct psycho_ranges **, int *));
74 1.1 mrg static void psycho_get_registers __P((int, struct psycho_registers **, int *));
75 1.1 mrg static void psycho_get_intmap __P((int, struct psycho_interrupt_map **, int *));
76 1.1 mrg static void psycho_get_intmapmask __P((int, struct psycho_interrupt_map_mask *));
77 1.1 mrg
78 1.1 mrg /* IOMMU support */
79 1.1 mrg static void psycho_iommu_init __P((struct psycho_softc *));
80 1.1 mrg
81 1.1 mrg extern struct sparc_pci_chipset _sparc_pci_chipset;
82 1.1 mrg
83 1.1 mrg /*
84 1.1 mrg * autoconfiguration
85 1.1 mrg */
86 1.1 mrg static int psycho_match __P((struct device *, struct cfdata *, void *));
87 1.1 mrg static void psycho_attach __P((struct device *, struct device *, void *));
88 1.1 mrg static int psycho_print __P((void *aux, const char *p));
89 1.1 mrg
90 1.1 mrg static void sabre_init __P((struct psycho_softc *, struct pcibus_attach_args *));
91 1.1 mrg static void psycho_init __P((struct psycho_softc *, struct pcibus_attach_args *));
92 1.1 mrg
93 1.1 mrg struct cfattach psycho_ca = {
94 1.1 mrg sizeof(struct psycho_softc), psycho_match, psycho_attach
95 1.1 mrg };
96 1.1 mrg
97 1.1 mrg /*
98 1.1 mrg * "sabre" is the UltraSPARC IIi onboard PCI interface, normally connected to
99 1.1 mrg * an APB (advanced PCI bridge), which was designed specifically for the IIi.
100 1.1 mrg * the APB appears as two "simba"'s underneath the sabre. real devices
101 1.1 mrg * typically appear on the "simba"'s only.
102 1.1 mrg *
103 1.1 mrg * a pair of "psycho"s sit on the mainbus and have real devices attached to
104 1.1 mrg * them. they implemented in the U2P (UPA to PCI). these two devices share
105 1.1 mrg * register space and as such need to be configured together, even though the
106 1.1 mrg * autoconfiguration will attach them separately.
107 1.1 mrg *
108 1.1 mrg * each of these appears as two usable PCI busses, though the sabre itself
109 1.1 mrg * takes pci0 in this case, leaving real devices on pci1 and pci2. there can
110 1.1 mrg * be multiple pairs of psycho's, however, in multi-board machines.
111 1.1 mrg */
112 1.1 mrg #define ROM_PCI_NAME "pci"
113 1.1 mrg #define ROM_SABRE_MODEL "SUNW,sabre"
114 1.1 mrg #define ROM_SIMBA_MODEL "SUNW,simba"
115 1.1 mrg #define ROM_PSYCHO_MODEL "SUNW,psycho"
116 1.1 mrg
117 1.1 mrg static int
118 1.1 mrg psycho_match(parent, match, aux)
119 1.1 mrg struct device *parent;
120 1.1 mrg struct cfdata *match;
121 1.1 mrg void *aux;
122 1.1 mrg {
123 1.1 mrg struct mainbus_attach_args *ma = aux;
124 1.1 mrg char *model = getpropstring(ma->ma_node, "model");
125 1.1 mrg
126 1.1 mrg /* match on a name of "pci" and a sabre or a psycho */
127 1.1 mrg if (strcmp(ma->ma_name, ROM_PCI_NAME) == 0 &&
128 1.1 mrg (strcmp(model, ROM_SABRE_MODEL) == 0 ||
129 1.1 mrg strcmp(model, ROM_PSYCHO_MODEL) == 0))
130 1.1 mrg return (1);
131 1.1 mrg
132 1.1 mrg return (0);
133 1.1 mrg }
134 1.1 mrg
135 1.1 mrg static void
136 1.1 mrg psycho_attach(parent, self, aux)
137 1.1 mrg struct device *parent, *self;
138 1.1 mrg void *aux;
139 1.1 mrg {
140 1.1 mrg struct psycho_softc *sc = (struct psycho_softc *)self;
141 1.1 mrg struct pcibus_attach_args pba;
142 1.1 mrg struct mainbus_attach_args *ma = aux;
143 1.1 mrg bus_space_handle_t bh;
144 1.1 mrg char *model = getpropstring(ma->ma_node, "model");
145 1.1 mrg
146 1.1 mrg printf("\n");
147 1.1 mrg
148 1.1 mrg sc->sc_node = ma->ma_node;
149 1.1 mrg sc->sc_bustag = ma->ma_bustag;
150 1.1 mrg sc->sc_dmatag = ma->ma_dmatag;
151 1.1 mrg
152 1.1 mrg /*
153 1.1 mrg * pull in all the information about the psycho as we can.
154 1.1 mrg */
155 1.1 mrg
156 1.1 mrg /*
157 1.1 mrg * XXX use the prom address for the psycho registers? we do so far.
158 1.1 mrg */
159 1.1 mrg sc->sc_regs = (struct psychoreg *)(u_long)ma->ma_address[0];
160 1.1 mrg sc->sc_basepaddr = (paddr_t)ma->ma_reg[0].ur_paddr;
161 1.1 mrg
162 1.1 mrg /*
163 1.1 mrg * call the model-specific initialisation routine.
164 1.1 mrg */
165 1.1 mrg if (strcmp(model, ROM_SABRE_MODEL) == 0)
166 1.1 mrg sabre_init(sc, &pba);
167 1.1 mrg else if (strcmp(model, ROM_PSYCHO_MODEL) == 0)
168 1.1 mrg psycho_init(sc, &pba);
169 1.1 mrg #ifdef DIAGNOSTIC
170 1.1 mrg else
171 1.1 mrg panic("psycho_attach: unknown model %s?", model);
172 1.1 mrg #endif
173 1.1 mrg
174 1.1 mrg /*
175 1.1 mrg * get us a config space tag, and punch in the physical address
176 1.1 mrg * of the PCI configuration space. note that we use unmapped
177 1.1 mrg * access to PCI configuration space, relying on the bus space
178 1.1 mrg * macros to provide the proper ASI based on the bus tag.
179 1.1 mrg */
180 1.1 mrg sc->sc_configtag = psycho_alloc_config_tag(sc->sc_simba_a);
181 1.1 mrg #if 0
182 1.1 mrg sc->sc_configaddr = (paddr_t)sc->sc_basepaddr + 0x01000000;
183 1.1 mrg #else
184 1.1 mrg if (bus_space_map2(ma->ma_bustag,
185 1.1 mrg PCI_CONFIG_BUS_SPACE,
186 1.1 mrg sc->sc_basepaddr + 0x01000000,
187 1.1 mrg 0x0100000,
188 1.1 mrg 0,
189 1.1 mrg 0,
190 1.1 mrg &bh))
191 1.1 mrg panic("could not map sabre PCI configuration space");
192 1.1 mrg sc->sc_configaddr = (paddr_t)bh;
193 1.1 mrg #endif
194 1.1 mrg
195 1.1 mrg /*
196 1.1 mrg * attach the pci.. note we pass PCI A tags, etc., for the sabre here.
197 1.1 mrg */
198 1.1 mrg pba.pba_busname = "pci";
199 1.1 mrg pba.pba_flags = sc->sc_psycho_this->pp_flags;
200 1.1 mrg pba.pba_dmat = sc->sc_psycho_this->pp_dmat;
201 1.1 mrg pba.pba_iot = sc->sc_psycho_this->pp_iot;
202 1.1 mrg pba.pba_memt = sc->sc_psycho_this->pp_memt;
203 1.1 mrg
204 1.1 mrg config_found(self, &pba, psycho_print);
205 1.1 mrg }
206 1.1 mrg
207 1.1 mrg static int
208 1.1 mrg psycho_print(aux, p)
209 1.1 mrg void *aux;
210 1.1 mrg const char *p;
211 1.1 mrg {
212 1.1 mrg
213 1.1 mrg if (p == NULL)
214 1.1 mrg return (UNCONF);
215 1.1 mrg return (QUIET);
216 1.1 mrg }
217 1.1 mrg
218 1.1 mrg /*
219 1.1 mrg * SUNW,sabre initialisation ..
220 1.1 mrg * - get the sabre's ranges. this are used for both simba's.
221 1.1 mrg * - find the two SUNW,simba's underneath (a and b)
222 1.1 mrg * - work out which simba is which via the bus-range property
223 1.1 mrg * - get each simba's interrupt-map and interrupt-map-mask.
224 1.1 mrg * - turn on the iommu
225 1.1 mrg */
226 1.1 mrg static void
227 1.1 mrg sabre_init(sc, pba)
228 1.1 mrg struct psycho_softc *sc;
229 1.1 mrg struct pcibus_attach_args *pba;
230 1.1 mrg {
231 1.1 mrg struct psycho_pbm *pp;
232 1.1 mrg u_int64_t csr;
233 1.1 mrg int node;
234 1.1 mrg int sabre_br[2], simba_br[2];
235 1.1 mrg
236 1.1 mrg /* who? said a voice, incredulous */
237 1.1 mrg sc->sc_mode = PSYCHO_MODE_SABRE;
238 1.1 mrg printf("sabre: ");
239 1.1 mrg
240 1.1 mrg /* setup the PCI control register; there is only one for the sabre */
241 1.1 mrg csr = bus_space_read_8(sc->sc_bustag, &sc->sc_regs->psy_pcictl[0].pci_csr, 0);
242 1.1 mrg csr = PCICTL_SERR | PCICTL_ARB_PARK | PCICTL_ERRINTEN | PCICTL_4ENABLE;
243 1.1 mrg bus_space_write_8(sc->sc_bustag, &sc->sc_regs->psy_pcictl[0].pci_csr, 0, csr);
244 1.1 mrg
245 1.1 mrg /* allocate a pair of psycho_pbm's for our simba's */
246 1.1 mrg sc->sc_sabre = malloc(sizeof *pp, M_DEVBUF, M_NOWAIT);
247 1.1 mrg sc->sc_simba_a = malloc(sizeof *pp, M_DEVBUF, M_NOWAIT);
248 1.1 mrg sc->sc_simba_b = malloc(sizeof *pp, M_DEVBUF, M_NOWAIT);
249 1.1 mrg if (sc->sc_simba_a == NULL || sc->sc_simba_b == NULL)
250 1.1 mrg panic("could not allocate simba pbm's");
251 1.1 mrg
252 1.1 mrg memset(sc->sc_sabre, 0, sizeof *pp);
253 1.1 mrg memset(sc->sc_simba_a, 0, sizeof *pp);
254 1.1 mrg memset(sc->sc_simba_b, 0, sizeof *pp);
255 1.1 mrg
256 1.1 mrg /* grab the sabre ranges; use them for both simba's */
257 1.1 mrg psycho_get_ranges(sc->sc_node, &sc->sc_sabre->pp_range,
258 1.1 mrg &sc->sc_sabre->pp_nrange);
259 1.1 mrg sc->sc_simba_b->pp_range = sc->sc_simba_a->pp_range =
260 1.1 mrg sc->sc_sabre->pp_range;
261 1.1 mrg sc->sc_simba_b->pp_nrange = sc->sc_simba_a->pp_nrange =
262 1.1 mrg sc->sc_sabre->pp_nrange;
263 1.1 mrg
264 1.1 mrg /* get the bus-range for the sabre. we expect 0..2 */
265 1.1 mrg psycho_get_bus_range(sc->sc_node, sabre_br);
266 1.1 mrg
267 1.1 mrg pba->pba_bus = sabre_br[0];
268 1.1 mrg
269 1.1 mrg printf("bus range %u to %u", sabre_br[0], sabre_br[1]);
270 1.1 mrg
271 1.1 mrg for (node = firstchild(sc->sc_node); node; node = nextsibling(node)) {
272 1.1 mrg char *name = getpropstring(node, "name");
273 1.1 mrg char *model, who;
274 1.1 mrg
275 1.1 mrg if (strcmp(name, ROM_PCI_NAME) != 0)
276 1.1 mrg continue;
277 1.1 mrg
278 1.1 mrg model = getpropstring(node, "model");
279 1.1 mrg if (strcmp(model, ROM_SIMBA_MODEL) != 0)
280 1.1 mrg continue;
281 1.1 mrg
282 1.1 mrg psycho_get_bus_range(node, simba_br);
283 1.1 mrg
284 1.1 mrg if (simba_br[0] == 1) { /* PCI B */
285 1.1 mrg pp = sc->sc_simba_b;
286 1.1 mrg pp->pp_pcictl = &sc->sc_regs->psy_pcictl[1];
287 1.1 mrg pp->pp_sb_diag = &sc->sc_regs->psy_strbufdiag[1];
288 1.1 mrg who = 'b';
289 1.1 mrg } else { /* PCI A */
290 1.1 mrg pp = sc->sc_simba_a;
291 1.1 mrg pp->pp_pcictl = &sc->sc_regs->psy_pcictl[0];
292 1.1 mrg pp->pp_sb_diag = &sc->sc_regs->psy_strbufdiag[0];
293 1.1 mrg who = 'a';
294 1.1 mrg }
295 1.1 mrg /* link us in .. */
296 1.1 mrg pp->pp_sc = sc;
297 1.1 mrg
298 1.1 mrg printf("; simba %c, PCI bus %d", who, simba_br[0]);
299 1.1 mrg
300 1.1 mrg /* grab the simba registers, interrupt map and map mask */
301 1.1 mrg psycho_get_registers(node, &pp->pp_regs, &pp->pp_nregs);
302 1.1 mrg psycho_get_intmap(node, &pp->pp_intmap, &pp->pp_nintmap);
303 1.1 mrg psycho_get_intmapmask(node, &pp->pp_intmapmask);
304 1.1 mrg
305 1.1 mrg /* allocate our tags */
306 1.1 mrg pp->pp_memt = psycho_alloc_mem_tag(pp);
307 1.1 mrg pp->pp_iot = psycho_alloc_io_tag(pp);
308 1.1 mrg pp->pp_dmat = psycho_alloc_dma_tag(pp);
309 1.1 mrg pp->pp_flags = (pp->pp_memt ? PCI_FLAGS_MEM_ENABLED : 0) |
310 1.1 mrg (pp->pp_iot ? PCI_FLAGS_IO_ENABLED : 0);
311 1.1 mrg
312 1.1 mrg /* allocate a chipset for this */
313 1.1 mrg pp->pp_pc = psycho_alloc_chipset(pp, node, &_sparc_pci_chipset);
314 1.1 mrg }
315 1.1 mrg
316 1.1 mrg /* setup the rest of the sabre pbm */
317 1.1 mrg pp = sc->sc_sabre;
318 1.1 mrg pp->pp_sc = sc;
319 1.1 mrg pp->pp_memt = sc->sc_psycho_this->pp_memt;
320 1.1 mrg pp->pp_iot = sc->sc_psycho_this->pp_iot;
321 1.1 mrg pp->pp_dmat = sc->sc_psycho_this->pp_dmat;
322 1.1 mrg pp->pp_flags = sc->sc_psycho_this->pp_flags;
323 1.1 mrg pp->pp_intmap = NULL;
324 1.1 mrg pp->pp_regs = NULL;
325 1.1 mrg pp->pp_pcictl = sc->sc_psycho_this->pp_pcictl;
326 1.1 mrg pp->pp_sb_diag = sc->sc_psycho_this->pp_sb_diag;
327 1.1 mrg pba->pba_pc = psycho_alloc_chipset(pp, sc->sc_node,
328 1.1 mrg sc->sc_psycho_this->pp_pc);
329 1.1 mrg
330 1.1 mrg printf("\n");
331 1.1 mrg
332 1.1 mrg /* and finally start up the IOMMU ... */
333 1.1 mrg psycho_iommu_init(sc);
334 1.1 mrg }
335 1.1 mrg
336 1.1 mrg /*
337 1.1 mrg * SUNW,psycho initialisation ..
338 1.1 mrg * - XXX what do we do here?
339 1.1 mrg *
340 1.1 mrg * i think that an attaching psycho should here find it's partner psycho
341 1.1 mrg * and if they haven't been attached yet, allocate both psycho_pbm's and
342 1.1 mrg * fill them both in here, and when the partner attaches, there is little
343 1.1 mrg * to do... perhaps keep a static array of what psycho have been found so
344 1.1 mrg * far (or perhaps those that have not yet been finished). .mrg.
345 1.1 mrg * note that the partner can be found via matching `ranges' properties.
346 1.1 mrg */
347 1.1 mrg static void
348 1.1 mrg psycho_init(sc, pba)
349 1.1 mrg struct psycho_softc *sc;
350 1.1 mrg struct pcibus_attach_args *pba;
351 1.1 mrg {
352 1.1 mrg
353 1.1 mrg /*
354 1.1 mrg * ok, we are a psycho.
355 1.1 mrg */
356 1.1 mrg panic("can't do SUNW,psycho yet");
357 1.1 mrg }
358 1.1 mrg
359 1.1 mrg /*
360 1.1 mrg * PCI bus support
361 1.1 mrg */
362 1.1 mrg
363 1.1 mrg /*
364 1.1 mrg * allocate a PCI chipset tag and set it's cookie.
365 1.1 mrg */
366 1.1 mrg static pci_chipset_tag_t
367 1.1 mrg psycho_alloc_chipset(pp, node, pc)
368 1.1 mrg struct psycho_pbm *pp;
369 1.1 mrg int node;
370 1.1 mrg pci_chipset_tag_t pc;
371 1.1 mrg {
372 1.1 mrg pci_chipset_tag_t npc;
373 1.1 mrg
374 1.1 mrg npc = malloc(sizeof *npc, M_DEVBUF, M_NOWAIT);
375 1.1 mrg if (npc == NULL)
376 1.1 mrg panic("could not allocate pci_chipset_tag_t");
377 1.1 mrg memcpy(npc, pc, sizeof *pc);
378 1.1 mrg npc->cookie = pp;
379 1.1 mrg npc->node = node;
380 1.1 mrg
381 1.1 mrg return (npc);
382 1.1 mrg }
383 1.1 mrg
384 1.1 mrg /*
385 1.1 mrg * grovel the OBP for various psycho properties
386 1.1 mrg */
387 1.1 mrg static void
388 1.1 mrg psycho_get_bus_range(node, brp)
389 1.1 mrg int node;
390 1.1 mrg int *brp;
391 1.1 mrg {
392 1.1 mrg int n;
393 1.1 mrg
394 1.1 mrg if (getprop(node, "bus-range", sizeof(*brp), &n, (void **)&brp))
395 1.1 mrg panic("could not get psycho bus-range");
396 1.1 mrg if (n != 2)
397 1.1 mrg panic("broken psycho bus-range");
398 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `bus-range' for node %08x: %u - %u\n", node, brp[0], brp[1]));
399 1.1 mrg }
400 1.1 mrg
401 1.1 mrg static void
402 1.1 mrg psycho_get_ranges(node, rp, np)
403 1.1 mrg int node;
404 1.1 mrg struct psycho_ranges **rp;
405 1.1 mrg int *np;
406 1.1 mrg {
407 1.1 mrg
408 1.1 mrg if (getprop(node, "ranges", sizeof(**rp), np, (void **)rp))
409 1.1 mrg panic("could not get psycho ranges");
410 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `ranges' for node %08x: %d entries\n", node, *np));
411 1.1 mrg }
412 1.1 mrg
413 1.1 mrg static void
414 1.1 mrg psycho_get_registers(node, rp, np)
415 1.1 mrg int node;
416 1.1 mrg struct psycho_registers **rp;
417 1.1 mrg int *np;
418 1.1 mrg {
419 1.1 mrg
420 1.1 mrg if (getprop(node, "reg", sizeof(**rp), np, (void **)rp))
421 1.1 mrg panic("could not get psycho registers");
422 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `reg' for node %08x: %d entries\n", node, *np));
423 1.1 mrg }
424 1.1 mrg
425 1.1 mrg static void
426 1.1 mrg psycho_get_intmap(node, imp, np)
427 1.1 mrg int node;
428 1.1 mrg struct psycho_interrupt_map **imp;
429 1.1 mrg int *np;
430 1.1 mrg {
431 1.1 mrg
432 1.1 mrg if (getprop(node, "interrupt-map", sizeof(**imp), np, (void **)imp))
433 1.1 mrg panic("could not get psycho interrupt-map");
434 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `interupt-map' for node %08x\n", node));
435 1.1 mrg }
436 1.1 mrg
437 1.1 mrg static void
438 1.1 mrg psycho_get_intmapmask(node, immp)
439 1.1 mrg int node;
440 1.1 mrg struct psycho_interrupt_map_mask *immp;
441 1.1 mrg {
442 1.1 mrg int n;
443 1.1 mrg
444 1.1 mrg if (getprop(node, "interrupt-map-mask", sizeof(*immp), &n,
445 1.1 mrg (void **)&immp))
446 1.1 mrg panic("could not get psycho interrupt-map-mask");
447 1.1 mrg if (n != 1)
448 1.1 mrg panic("broken psycho interrupt-map-mask");
449 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `interrupt-map-mask' for node %08x\n", node));
450 1.1 mrg }
451 1.1 mrg
452 1.1 mrg /*
453 1.1 mrg * IOMMU code
454 1.1 mrg */
455 1.1 mrg
456 1.1 mrg /*
457 1.1 mrg * initialise the IOMMU..
458 1.1 mrg */
459 1.1 mrg void
460 1.1 mrg psycho_iommu_init(sc)
461 1.1 mrg struct psycho_softc *sc;
462 1.1 mrg {
463 1.1 mrg char *name;
464 1.1 mrg
465 1.1 mrg /* punch in our copies */
466 1.1 mrg sc->sc_is.is_bustag = sc->sc_bustag;
467 1.1 mrg sc->sc_is.is_iommu = &sc->sc_regs->psy_iommu;
468 1.1 mrg sc->sc_is.is_sb = &sc->sc_regs->psy_iommu_strbuf;
469 1.1 mrg
470 1.1 mrg /* give us a nice name.. */
471 1.1 mrg name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
472 1.1 mrg if (name == 0)
473 1.1 mrg panic("couldn't malloc iommu name");
474 1.1 mrg snprintf(name, 32, "%s dvma", sc->sc_dev.dv_xname);
475 1.1 mrg
476 1.1 mrg DPRINTF(PDB_IOMMU, ("psycho base %p phys %p\n", (long)sc->sc_regs, (long)pmap_extract(pmap_kernel(), (vaddr_t)sc->sc_regs)));
477 1.1 mrg
478 1.1 mrg /* XXX XXX XXX FIX ME tsbsize XXX XXX XXX */
479 1.1 mrg iommu_init(name, &sc->sc_is, 0);
480 1.1 mrg }
481