psycho.c revision 1.4 1 1.4 mrg /* $NetBSD: psycho.c,v 1.4 2000/04/08 15:15:41 mrg Exp $ */
2 1.1 mrg
3 1.1 mrg /*
4 1.3 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 * 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.3 mrg int psycho_debug = 0x0;
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 char *model = getpropstring(ma->ma_node, "model");
144 1.1 mrg
145 1.1 mrg printf("\n");
146 1.1 mrg
147 1.1 mrg sc->sc_node = ma->ma_node;
148 1.1 mrg sc->sc_bustag = ma->ma_bustag;
149 1.1 mrg sc->sc_dmatag = ma->ma_dmatag;
150 1.1 mrg
151 1.1 mrg /*
152 1.1 mrg * pull in all the information about the psycho as we can.
153 1.1 mrg */
154 1.1 mrg
155 1.1 mrg /*
156 1.1 mrg * XXX use the prom address for the psycho registers? we do so far.
157 1.1 mrg */
158 1.1 mrg sc->sc_regs = (struct psychoreg *)(u_long)ma->ma_address[0];
159 1.1 mrg sc->sc_basepaddr = (paddr_t)ma->ma_reg[0].ur_paddr;
160 1.1 mrg
161 1.1 mrg /*
162 1.1 mrg * call the model-specific initialisation routine.
163 1.1 mrg */
164 1.1 mrg if (strcmp(model, ROM_SABRE_MODEL) == 0)
165 1.1 mrg sabre_init(sc, &pba);
166 1.1 mrg else if (strcmp(model, ROM_PSYCHO_MODEL) == 0)
167 1.1 mrg psycho_init(sc, &pba);
168 1.1 mrg #ifdef DIAGNOSTIC
169 1.1 mrg else
170 1.1 mrg panic("psycho_attach: unknown model %s?", model);
171 1.1 mrg #endif
172 1.1 mrg
173 1.1 mrg /*
174 1.1 mrg * attach the pci.. note we pass PCI A tags, etc., for the sabre here.
175 1.1 mrg */
176 1.1 mrg pba.pba_busname = "pci";
177 1.1 mrg pba.pba_flags = sc->sc_psycho_this->pp_flags;
178 1.1 mrg pba.pba_dmat = sc->sc_psycho_this->pp_dmat;
179 1.1 mrg pba.pba_iot = sc->sc_psycho_this->pp_iot;
180 1.1 mrg pba.pba_memt = sc->sc_psycho_this->pp_memt;
181 1.1 mrg
182 1.1 mrg config_found(self, &pba, psycho_print);
183 1.1 mrg }
184 1.1 mrg
185 1.1 mrg static int
186 1.1 mrg psycho_print(aux, p)
187 1.1 mrg void *aux;
188 1.1 mrg const char *p;
189 1.1 mrg {
190 1.1 mrg
191 1.1 mrg if (p == NULL)
192 1.1 mrg return (UNCONF);
193 1.1 mrg return (QUIET);
194 1.1 mrg }
195 1.1 mrg
196 1.1 mrg /*
197 1.1 mrg * SUNW,sabre initialisation ..
198 1.1 mrg * - get the sabre's ranges. this are used for both simba's.
199 1.1 mrg * - find the two SUNW,simba's underneath (a and b)
200 1.1 mrg * - work out which simba is which via the bus-range property
201 1.1 mrg * - get each simba's interrupt-map and interrupt-map-mask.
202 1.1 mrg * - turn on the iommu
203 1.1 mrg */
204 1.1 mrg static void
205 1.1 mrg sabre_init(sc, pba)
206 1.1 mrg struct psycho_softc *sc;
207 1.1 mrg struct pcibus_attach_args *pba;
208 1.1 mrg {
209 1.1 mrg struct psycho_pbm *pp;
210 1.3 mrg bus_space_handle_t bh;
211 1.1 mrg u_int64_t csr;
212 1.1 mrg int node;
213 1.1 mrg int sabre_br[2], simba_br[2];
214 1.1 mrg
215 1.1 mrg /* who? said a voice, incredulous */
216 1.1 mrg sc->sc_mode = PSYCHO_MODE_SABRE;
217 1.1 mrg printf("sabre: ");
218 1.1 mrg
219 1.1 mrg /* setup the PCI control register; there is only one for the sabre */
220 1.4 mrg csr = bus_space_read_8(sc->sc_bustag, (bus_space_handle_t)(u_long)&sc->sc_regs->psy_pcictl[0].pci_csr, 0);
221 1.1 mrg csr = PCICTL_SERR | PCICTL_ARB_PARK | PCICTL_ERRINTEN | PCICTL_4ENABLE;
222 1.1 mrg bus_space_write_8(sc->sc_bustag, &sc->sc_regs->psy_pcictl[0].pci_csr, 0, csr);
223 1.1 mrg
224 1.1 mrg /* allocate a pair of psycho_pbm's for our simba's */
225 1.1 mrg sc->sc_sabre = malloc(sizeof *pp, M_DEVBUF, M_NOWAIT);
226 1.1 mrg sc->sc_simba_a = malloc(sizeof *pp, M_DEVBUF, M_NOWAIT);
227 1.1 mrg sc->sc_simba_b = malloc(sizeof *pp, M_DEVBUF, M_NOWAIT);
228 1.1 mrg if (sc->sc_simba_a == NULL || sc->sc_simba_b == NULL)
229 1.1 mrg panic("could not allocate simba pbm's");
230 1.1 mrg
231 1.1 mrg memset(sc->sc_sabre, 0, sizeof *pp);
232 1.1 mrg memset(sc->sc_simba_a, 0, sizeof *pp);
233 1.1 mrg memset(sc->sc_simba_b, 0, sizeof *pp);
234 1.1 mrg
235 1.1 mrg /* grab the sabre ranges; use them for both simba's */
236 1.1 mrg psycho_get_ranges(sc->sc_node, &sc->sc_sabre->pp_range,
237 1.1 mrg &sc->sc_sabre->pp_nrange);
238 1.1 mrg sc->sc_simba_b->pp_range = sc->sc_simba_a->pp_range =
239 1.1 mrg sc->sc_sabre->pp_range;
240 1.1 mrg sc->sc_simba_b->pp_nrange = sc->sc_simba_a->pp_nrange =
241 1.1 mrg sc->sc_sabre->pp_nrange;
242 1.1 mrg
243 1.1 mrg /* get the bus-range for the sabre. we expect 0..2 */
244 1.1 mrg psycho_get_bus_range(sc->sc_node, sabre_br);
245 1.1 mrg
246 1.1 mrg pba->pba_bus = sabre_br[0];
247 1.1 mrg
248 1.1 mrg printf("bus range %u to %u", sabre_br[0], sabre_br[1]);
249 1.1 mrg
250 1.1 mrg for (node = firstchild(sc->sc_node); node; node = nextsibling(node)) {
251 1.1 mrg char *name = getpropstring(node, "name");
252 1.1 mrg char *model, who;
253 1.1 mrg
254 1.1 mrg if (strcmp(name, ROM_PCI_NAME) != 0)
255 1.1 mrg continue;
256 1.1 mrg
257 1.1 mrg model = getpropstring(node, "model");
258 1.1 mrg if (strcmp(model, ROM_SIMBA_MODEL) != 0)
259 1.1 mrg continue;
260 1.1 mrg
261 1.1 mrg psycho_get_bus_range(node, simba_br);
262 1.1 mrg
263 1.1 mrg if (simba_br[0] == 1) { /* PCI B */
264 1.1 mrg pp = sc->sc_simba_b;
265 1.1 mrg pp->pp_pcictl = &sc->sc_regs->psy_pcictl[1];
266 1.1 mrg pp->pp_sb_diag = &sc->sc_regs->psy_strbufdiag[1];
267 1.1 mrg who = 'b';
268 1.1 mrg } else { /* PCI A */
269 1.1 mrg pp = sc->sc_simba_a;
270 1.1 mrg pp->pp_pcictl = &sc->sc_regs->psy_pcictl[0];
271 1.1 mrg pp->pp_sb_diag = &sc->sc_regs->psy_strbufdiag[0];
272 1.1 mrg who = 'a';
273 1.1 mrg }
274 1.1 mrg /* link us in .. */
275 1.1 mrg pp->pp_sc = sc;
276 1.1 mrg
277 1.1 mrg printf("; simba %c, PCI bus %d", who, simba_br[0]);
278 1.1 mrg
279 1.1 mrg /* grab the simba registers, interrupt map and map mask */
280 1.1 mrg psycho_get_registers(node, &pp->pp_regs, &pp->pp_nregs);
281 1.1 mrg psycho_get_intmap(node, &pp->pp_intmap, &pp->pp_nintmap);
282 1.1 mrg psycho_get_intmapmask(node, &pp->pp_intmapmask);
283 1.1 mrg
284 1.1 mrg /* allocate our tags */
285 1.1 mrg pp->pp_memt = psycho_alloc_mem_tag(pp);
286 1.1 mrg pp->pp_iot = psycho_alloc_io_tag(pp);
287 1.1 mrg pp->pp_dmat = psycho_alloc_dma_tag(pp);
288 1.1 mrg pp->pp_flags = (pp->pp_memt ? PCI_FLAGS_MEM_ENABLED : 0) |
289 1.1 mrg (pp->pp_iot ? PCI_FLAGS_IO_ENABLED : 0);
290 1.1 mrg
291 1.1 mrg /* allocate a chipset for this */
292 1.1 mrg pp->pp_pc = psycho_alloc_chipset(pp, node, &_sparc_pci_chipset);
293 1.1 mrg }
294 1.1 mrg
295 1.1 mrg /* setup the rest of the sabre pbm */
296 1.1 mrg pp = sc->sc_sabre;
297 1.1 mrg pp->pp_sc = sc;
298 1.1 mrg pp->pp_memt = sc->sc_psycho_this->pp_memt;
299 1.1 mrg pp->pp_iot = sc->sc_psycho_this->pp_iot;
300 1.1 mrg pp->pp_dmat = sc->sc_psycho_this->pp_dmat;
301 1.1 mrg pp->pp_flags = sc->sc_psycho_this->pp_flags;
302 1.1 mrg pp->pp_intmap = NULL;
303 1.1 mrg pp->pp_regs = NULL;
304 1.1 mrg pp->pp_pcictl = sc->sc_psycho_this->pp_pcictl;
305 1.1 mrg pp->pp_sb_diag = sc->sc_psycho_this->pp_sb_diag;
306 1.1 mrg pba->pba_pc = psycho_alloc_chipset(pp, sc->sc_node,
307 1.1 mrg sc->sc_psycho_this->pp_pc);
308 1.1 mrg
309 1.1 mrg printf("\n");
310 1.1 mrg
311 1.1 mrg /* and finally start up the IOMMU ... */
312 1.1 mrg psycho_iommu_init(sc);
313 1.3 mrg
314 1.3 mrg /*
315 1.3 mrg * get us a config space tag, and punch in the physical address
316 1.3 mrg * of the PCI configuration space. note that we use unmapped
317 1.3 mrg * access to PCI configuration space, relying on the bus space
318 1.3 mrg * macros to provide the proper ASI based on the bus tag.
319 1.3 mrg */
320 1.3 mrg sc->sc_configtag = psycho_alloc_config_tag(sc->sc_simba_a);
321 1.3 mrg #if 0
322 1.3 mrg sc->sc_configaddr = (paddr_t)sc->sc_basepaddr + 0x01000000;
323 1.3 mrg #else
324 1.3 mrg if (bus_space_map2(sc->sc_bustag,
325 1.3 mrg PCI_CONFIG_BUS_SPACE,
326 1.3 mrg sc->sc_basepaddr + 0x01000000,
327 1.3 mrg 0x0100000,
328 1.3 mrg 0,
329 1.3 mrg 0,
330 1.3 mrg &bh))
331 1.3 mrg panic("could not map sabre PCI configuration space");
332 1.3 mrg sc->sc_configaddr = (paddr_t)bh;
333 1.3 mrg #endif
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.3 mrg #if 1
353 1.3 mrg panic("can't do SUNW,psycho yet");
354 1.3 mrg #else
355 1.1 mrg
356 1.1 mrg /*
357 1.3 mrg * OK, so the deal here is:
358 1.3 mrg * - given our base register address, search our sibling
359 1.3 mrg * devices for a match.
360 1.3 mrg * - if we find a match, we are attaching an almost
361 1.3 mrg * already setup PCI bus, the partner already done.
362 1.3 mrg * - otherwise, we are doing the hard slog.
363 1.1 mrg */
364 1.3 mrg for (n = 0; n < psycho_cd.cd_ndevs; n++) {
365 1.3 mrg psycho_softc *osc = &psycho_cd.cd_devs[n];
366 1.3 mrg
367 1.3 mrg /*
368 1.3 mrg * I am not myself.
369 1.3 mrg */
370 1.3 mrg if (osc == sc || osc->sc_regs != sc->sc_regs)
371 1.3 mrg continue;
372 1.3 mrg
373 1.3 mrg /*
374 1.3 mrg * OK, so we found a matching regs that wasn't me,
375 1.3 mrg * so that must make me partly attached. Finish it.
376 1.3 mrg */
377 1.3 mrg }
378 1.3 mrg
379 1.3 mrg /* Oh, dear. OK, lets get started */
380 1.3 mrg
381 1.3 mrg /* who? said a voice, incredulous */
382 1.3 mrg sc->sc_mode = PSYCHO_MODE_PSYCHO_A;
383 1.3 mrg printf("psycho: ");
384 1.3 mrg #endif
385 1.1 mrg }
386 1.1 mrg
387 1.1 mrg /*
388 1.1 mrg * PCI bus support
389 1.1 mrg */
390 1.1 mrg
391 1.1 mrg /*
392 1.1 mrg * allocate a PCI chipset tag and set it's cookie.
393 1.1 mrg */
394 1.1 mrg static pci_chipset_tag_t
395 1.1 mrg psycho_alloc_chipset(pp, node, pc)
396 1.1 mrg struct psycho_pbm *pp;
397 1.1 mrg int node;
398 1.1 mrg pci_chipset_tag_t pc;
399 1.1 mrg {
400 1.1 mrg pci_chipset_tag_t npc;
401 1.1 mrg
402 1.1 mrg npc = malloc(sizeof *npc, M_DEVBUF, M_NOWAIT);
403 1.1 mrg if (npc == NULL)
404 1.1 mrg panic("could not allocate pci_chipset_tag_t");
405 1.1 mrg memcpy(npc, pc, sizeof *pc);
406 1.1 mrg npc->cookie = pp;
407 1.1 mrg npc->node = node;
408 1.1 mrg
409 1.1 mrg return (npc);
410 1.1 mrg }
411 1.1 mrg
412 1.1 mrg /*
413 1.1 mrg * grovel the OBP for various psycho properties
414 1.1 mrg */
415 1.1 mrg static void
416 1.1 mrg psycho_get_bus_range(node, brp)
417 1.1 mrg int node;
418 1.1 mrg int *brp;
419 1.1 mrg {
420 1.1 mrg int n;
421 1.1 mrg
422 1.1 mrg if (getprop(node, "bus-range", sizeof(*brp), &n, (void **)&brp))
423 1.1 mrg panic("could not get psycho bus-range");
424 1.1 mrg if (n != 2)
425 1.1 mrg panic("broken psycho bus-range");
426 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `bus-range' for node %08x: %u - %u\n", node, brp[0], brp[1]));
427 1.1 mrg }
428 1.1 mrg
429 1.1 mrg static void
430 1.1 mrg psycho_get_ranges(node, rp, np)
431 1.1 mrg int node;
432 1.1 mrg struct psycho_ranges **rp;
433 1.1 mrg int *np;
434 1.1 mrg {
435 1.1 mrg
436 1.1 mrg if (getprop(node, "ranges", sizeof(**rp), np, (void **)rp))
437 1.1 mrg panic("could not get psycho ranges");
438 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `ranges' for node %08x: %d entries\n", node, *np));
439 1.1 mrg }
440 1.1 mrg
441 1.1 mrg static void
442 1.1 mrg psycho_get_registers(node, rp, np)
443 1.1 mrg int node;
444 1.1 mrg struct psycho_registers **rp;
445 1.1 mrg int *np;
446 1.1 mrg {
447 1.1 mrg
448 1.1 mrg if (getprop(node, "reg", sizeof(**rp), np, (void **)rp))
449 1.1 mrg panic("could not get psycho registers");
450 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `reg' for node %08x: %d entries\n", node, *np));
451 1.1 mrg }
452 1.1 mrg
453 1.1 mrg static void
454 1.1 mrg psycho_get_intmap(node, imp, np)
455 1.1 mrg int node;
456 1.1 mrg struct psycho_interrupt_map **imp;
457 1.1 mrg int *np;
458 1.1 mrg {
459 1.1 mrg
460 1.1 mrg if (getprop(node, "interrupt-map", sizeof(**imp), np, (void **)imp))
461 1.1 mrg panic("could not get psycho interrupt-map");
462 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `interupt-map' for node %08x\n", node));
463 1.1 mrg }
464 1.1 mrg
465 1.1 mrg static void
466 1.1 mrg psycho_get_intmapmask(node, immp)
467 1.1 mrg int node;
468 1.1 mrg struct psycho_interrupt_map_mask *immp;
469 1.1 mrg {
470 1.1 mrg int n;
471 1.1 mrg
472 1.1 mrg if (getprop(node, "interrupt-map-mask", sizeof(*immp), &n,
473 1.1 mrg (void **)&immp))
474 1.1 mrg panic("could not get psycho interrupt-map-mask");
475 1.1 mrg if (n != 1)
476 1.1 mrg panic("broken psycho interrupt-map-mask");
477 1.1 mrg DPRINTF(PDB_PROM, ("psycho debug: got `interrupt-map-mask' for node %08x\n", node));
478 1.1 mrg }
479 1.1 mrg
480 1.1 mrg /*
481 1.1 mrg * IOMMU code
482 1.1 mrg */
483 1.1 mrg
484 1.1 mrg /*
485 1.1 mrg * initialise the IOMMU..
486 1.1 mrg */
487 1.1 mrg void
488 1.1 mrg psycho_iommu_init(sc)
489 1.1 mrg struct psycho_softc *sc;
490 1.1 mrg {
491 1.1 mrg char *name;
492 1.1 mrg
493 1.1 mrg /* punch in our copies */
494 1.1 mrg sc->sc_is.is_bustag = sc->sc_bustag;
495 1.1 mrg sc->sc_is.is_iommu = &sc->sc_regs->psy_iommu;
496 1.1 mrg sc->sc_is.is_sb = &sc->sc_regs->psy_iommu_strbuf;
497 1.1 mrg
498 1.1 mrg /* give us a nice name.. */
499 1.1 mrg name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
500 1.1 mrg if (name == 0)
501 1.1 mrg panic("couldn't malloc iommu name");
502 1.1 mrg snprintf(name, 32, "%s dvma", sc->sc_dev.dv_xname);
503 1.1 mrg
504 1.1 mrg /* XXX XXX XXX FIX ME tsbsize XXX XXX XXX */
505 1.1 mrg iommu_init(name, &sc->sc_is, 0);
506 1.1 mrg }
507