schizo.c revision 1.3 1 1.3 nakayama /* $NetBSD: schizo.c,v 1.3 2008/12/10 12:17:02 nakayama Exp $ */
2 1.1 mrg /* $OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $ */
3 1.1 mrg
4 1.1 mrg /*
5 1.1 mrg * Copyright (c) 2002 Jason L. Wright (jason (at) thought.net)
6 1.1 mrg * Copyright (c) 2003 Henric Jungheim
7 1.1 mrg * All rights reserved.
8 1.1 mrg *
9 1.1 mrg * Redistribution and use in source and binary forms, with or without
10 1.1 mrg * modification, are permitted provided that the following conditions
11 1.1 mrg * are met:
12 1.1 mrg * 1. Redistributions of source code must retain the above copyright
13 1.1 mrg * notice, this list of conditions and the following disclaimer.
14 1.1 mrg * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 mrg * notice, this list of conditions and the following disclaimer in the
16 1.1 mrg * documentation and/or other materials provided with the distribution.
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
20 1.1 mrg * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 1.1 mrg * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22 1.1 mrg * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 1.1 mrg * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 1.1 mrg * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 1.1 mrg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 1.1 mrg * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 1.1 mrg * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 1.1 mrg * POSSIBILITY OF SUCH DAMAGE.
29 1.1 mrg */
30 1.1 mrg
31 1.1 mrg #include <sys/param.h>
32 1.1 mrg #include <sys/device.h>
33 1.1 mrg #include <sys/errno.h>
34 1.1 mrg #include <sys/extent.h>
35 1.1 mrg #include <sys/malloc.h>
36 1.1 mrg #include <sys/systm.h>
37 1.1 mrg #include <sys/time.h>
38 1.1 mrg #include <sys/reboot.h>
39 1.1 mrg
40 1.1 mrg #define _SPARC_BUS_DMA_PRIVATE
41 1.1 mrg #include <machine/bus.h>
42 1.1 mrg #include <machine/autoconf.h>
43 1.1 mrg #include <machine/psl.h>
44 1.1 mrg
45 1.1 mrg #include <dev/pci/pcivar.h>
46 1.1 mrg #include <dev/pci/pcireg.h>
47 1.1 mrg
48 1.1 mrg #include <sparc64/dev/iommureg.h>
49 1.1 mrg #include <sparc64/dev/iommuvar.h>
50 1.1 mrg #include <sparc64/dev/schizoreg.h>
51 1.1 mrg #include <sparc64/dev/schizovar.h>
52 1.1 mrg #include <sparc64/sparc64/cache.h>
53 1.1 mrg
54 1.1 mrg #ifdef DEBUG
55 1.1 mrg #define SDB_PROM 0x01
56 1.1 mrg #define SDB_BUSMAP 0x02
57 1.1 mrg #define SDB_INTR 0x04
58 1.2 mrg #define SDB_INTMAP 0x08
59 1.2 mrg #define SDB_CONF 0x10
60 1.2 mrg int schizo_debug = 0x0f;
61 1.1 mrg #define DPRINTF(l, s) do { if (schizo_debug & l) printf s; } while (0)
62 1.1 mrg #else
63 1.1 mrg #define DPRINTF(l, s)
64 1.1 mrg #endif
65 1.1 mrg
66 1.1 mrg extern struct sparc_pci_chipset _sparc_pci_chipset;
67 1.1 mrg
68 1.2 mrg static int schizo_match(struct device *, struct cfdata *, void *);
69 1.2 mrg static void schizo_attach(struct device *, struct device *, void *);
70 1.2 mrg static int schizo_print(void *aux, const char *p);
71 1.2 mrg
72 1.2 mrg CFATTACH_DECL(schizo, sizeof(struct schizo_softc),
73 1.2 mrg schizo_match, schizo_attach, NULL, NULL);
74 1.2 mrg
75 1.2 mrg void schizo_init(struct schizo_softc *, int, struct mainbus_attach_args *);
76 1.1 mrg void schizo_init_iommu(struct schizo_softc *, struct schizo_pbm *);
77 1.1 mrg
78 1.1 mrg void schizo_set_intr(struct schizo_softc *, struct schizo_pbm *, int,
79 1.2 mrg int (*handler)(void *), void *, int, const char *);
80 1.1 mrg int schizo_ue(void *);
81 1.1 mrg int schizo_ce(void *);
82 1.1 mrg int schizo_safari_error(void *);
83 1.1 mrg int schizo_pci_error(void *);
84 1.1 mrg
85 1.1 mrg pci_chipset_tag_t schizo_alloc_chipset(struct schizo_pbm *, int,
86 1.1 mrg pci_chipset_tag_t);
87 1.1 mrg bus_space_tag_t schizo_alloc_mem_tag(struct schizo_pbm *);
88 1.1 mrg bus_space_tag_t schizo_alloc_io_tag(struct schizo_pbm *);
89 1.1 mrg bus_space_tag_t schizo_alloc_config_tag(struct schizo_pbm *);
90 1.1 mrg bus_space_tag_t schizo_alloc_bus_tag(struct schizo_pbm *, const char *,
91 1.2 mrg int);
92 1.1 mrg bus_dma_tag_t schizo_alloc_dma_tag(struct schizo_pbm *);
93 1.1 mrg
94 1.1 mrg pcireg_t schizo_conf_read(pci_chipset_tag_t, pcitag_t, int);
95 1.1 mrg void schizo_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
96 1.1 mrg
97 1.1 mrg int schizo_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
98 1.2 mrg int schizo_bus_map(bus_space_tag_t t, bus_addr_t offset, bus_size_t size,
99 1.2 mrg int flags, vaddr_t unused, bus_space_handle_t *hp);
100 1.2 mrg static paddr_t schizo_bus_mmap(bus_space_tag_t t, bus_addr_t paddr,
101 1.2 mrg off_t off, int prot, int flags);
102 1.2 mrg static void *schizo_intr_establish(bus_space_tag_t, int, int, int (*)(void *),
103 1.2 mrg void *, void(*)(void));
104 1.2 mrg static void *schizo_pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
105 1.2 mrg int, int (*)(void *), void *);
106 1.2 mrg static int schizo_pci_find_ino(struct pci_attach_args *, pci_intr_handle_t *);
107 1.1 mrg
108 1.1 mrg int
109 1.2 mrg schizo_match(struct device *parent, struct cfdata *match, void *aux)
110 1.1 mrg {
111 1.1 mrg struct mainbus_attach_args *ma = aux;
112 1.1 mrg char *str;
113 1.1 mrg
114 1.1 mrg if (strcmp(ma->ma_name, "pci") != 0)
115 1.1 mrg return (0);
116 1.1 mrg
117 1.2 mrg str = prom_getpropstring(ma->ma_node, "model");
118 1.1 mrg if (strcmp(str, "schizo") == 0)
119 1.1 mrg return (1);
120 1.1 mrg
121 1.2 mrg str = prom_getpropstring(ma->ma_node, "compatible");
122 1.1 mrg if (strcmp(str, "pci108e,8001") == 0)
123 1.1 mrg return (1);
124 1.1 mrg if (strcmp(str, "pci108e,8002") == 0) /* XMITS */
125 1.1 mrg return (1);
126 1.1 mrg if (strcmp(str, "pci108e,a801") == 0) /* Tomatillo */
127 1.1 mrg return (1);
128 1.1 mrg
129 1.1 mrg return (0);
130 1.1 mrg }
131 1.1 mrg
132 1.1 mrg void
133 1.1 mrg schizo_attach(struct device *parent, struct device *self, void *aux)
134 1.1 mrg {
135 1.1 mrg struct schizo_softc *sc = (struct schizo_softc *)self;
136 1.1 mrg struct mainbus_attach_args *ma = aux;
137 1.2 mrg uint64_t eccctrl;
138 1.1 mrg int busa;
139 1.1 mrg char *str;
140 1.1 mrg
141 1.2 mrg printf(": addr %lx ", ma->ma_reg[0].ur_paddr);
142 1.2 mrg str = prom_getpropstring(ma->ma_node, "compatible");
143 1.1 mrg if (strcmp(str, "pci108e,a801") == 0)
144 1.1 mrg sc->sc_tomatillo = 1;
145 1.1 mrg
146 1.1 mrg sc->sc_node = ma->ma_node;
147 1.1 mrg sc->sc_dmat = ma->ma_dmatag;
148 1.2 mrg sc->sc_bustag = ma->ma_bustag;
149 1.1 mrg sc->sc_ctrl = ma->ma_reg[1].ur_paddr - 0x10000UL;
150 1.1 mrg sc->sc_ign = INTIGN(ma->ma_upaid << INTMAP_IGN_SHIFT);
151 1.1 mrg
152 1.1 mrg if ((ma->ma_reg[0].ur_paddr & 0x00700000) == 0x00600000)
153 1.1 mrg busa = 1;
154 1.1 mrg else
155 1.1 mrg busa = 0;
156 1.1 mrg
157 1.2 mrg printf("bustag->type = %d\n", sc->sc_bustag->type);
158 1.2 mrg if (bus_space_map(sc->sc_bustag, sc->sc_ctrl,
159 1.2 mrg sizeof(struct schizo_regs), 0,
160 1.2 mrg &sc->sc_ctrlh)) {
161 1.1 mrg printf(": failed to map registers\n");
162 1.1 mrg return;
163 1.1 mrg }
164 1.2 mrg printf("mapped regs len %zx, sc_ctrl = %lx sc_ctrlh._ptr = %lx ._asi = %x ._sasi = %x\n", sizeof(struct schizo_regs), (uint64_t)sc->sc_ctrl, sc->sc_ctrlh._ptr, sc->sc_ctrlh._asi, sc->sc_ctrlh._sasi);
165 1.1 mrg
166 1.1 mrg /* enable schizo ecc error interrupts */
167 1.2 mrg eccctrl = schizo_read(sc, SCZ_ECCCTRL);
168 1.2 mrg eccctrl |= SCZ_ECCCTRL_EE_INTEN |
169 1.2 mrg SCZ_ECCCTRL_UE_INTEN |
170 1.2 mrg SCZ_ECCCTRL_CE_INTEN;
171 1.2 mrg schizo_write(sc, SCZ_ECCCTRL, eccctrl);
172 1.1 mrg
173 1.2 mrg schizo_init(sc, busa, ma);
174 1.1 mrg }
175 1.1 mrg
176 1.1 mrg void
177 1.2 mrg schizo_init(struct schizo_softc *sc, int busa, struct mainbus_attach_args *ma)
178 1.1 mrg {
179 1.1 mrg struct schizo_pbm *pbm;
180 1.1 mrg struct pcibus_attach_args pba;
181 1.1 mrg int *busranges = NULL, nranges;
182 1.2 mrg u_int64_t /*match,*/ reg;
183 1.1 mrg
184 1.1 mrg pbm = malloc(sizeof(*pbm), M_DEVBUF, M_NOWAIT | M_ZERO);
185 1.1 mrg if (pbm == NULL)
186 1.1 mrg panic("schizo: can't alloc schizo pbm");
187 1.1 mrg
188 1.1 mrg pbm->sp_sc = sc;
189 1.1 mrg pbm->sp_bus_a = busa;
190 1.2 mrg pbm->sp_regt = sc->sc_bustag;
191 1.1 mrg
192 1.2 mrg if (prom_getprop(sc->sc_node, "ranges", sizeof(struct schizo_range),
193 1.1 mrg &pbm->sp_nrange, (void **)&pbm->sp_range))
194 1.1 mrg panic("schizo: can't get ranges");
195 1.1 mrg
196 1.2 mrg if (prom_getprop(sc->sc_node, "bus-range", sizeof(int), &nranges,
197 1.1 mrg (void **)&busranges))
198 1.1 mrg panic("schizo: can't get bus-range");
199 1.1 mrg
200 1.1 mrg printf(": \"%s\", version %d, ign %x, bus %c %d to %d\n",
201 1.1 mrg sc->sc_tomatillo ? "Tomatillo" : "Schizo",
202 1.2 mrg prom_getpropint(sc->sc_node, "version#", 0), sc->sc_ign,
203 1.2 mrg pbm->sp_bus_a ? 'A' : 'B', busranges[0], busranges[1]);
204 1.1 mrg
205 1.1 mrg if (bus_space_subregion(pbm->sp_regt, sc->sc_ctrlh,
206 1.2 mrg pbm->sp_bus_a ? offsetof(struct schizo_regs, pbm_a) :
207 1.1 mrg offsetof(struct schizo_regs, pbm_b),
208 1.1 mrg sizeof(struct schizo_pbm_regs),
209 1.1 mrg &pbm->sp_regh)) {
210 1.1 mrg panic("schizo: unable to create PBM handle");
211 1.1 mrg }
212 1.2 mrg printf("mapped regs, sp_regh._ptr = %lx ._asi = %x ._sasi = %x\n", pbm->sp_regh._ptr, pbm->sp_regh._asi, pbm->sp_regh._sasi);
213 1.1 mrg
214 1.1 mrg printf("%s: ", sc->sc_dv.dv_xname);
215 1.1 mrg schizo_init_iommu(sc, pbm);
216 1.1 mrg
217 1.1 mrg pbm->sp_memt = schizo_alloc_mem_tag(pbm);
218 1.1 mrg pbm->sp_iot = schizo_alloc_io_tag(pbm);
219 1.1 mrg pbm->sp_cfgt = schizo_alloc_config_tag(pbm);
220 1.1 mrg pbm->sp_dmat = schizo_alloc_dma_tag(pbm);
221 1.2 mrg pbm->sp_flags = (pbm->sp_memt ? PCI_FLAGS_MEM_ENABLED : 0) |
222 1.2 mrg (pbm->sp_iot ? PCI_FLAGS_IO_ENABLED : 0);
223 1.1 mrg
224 1.1 mrg if (bus_space_map(pbm->sp_cfgt, 0, 0x1000000, 0, &pbm->sp_cfgh))
225 1.1 mrg panic("schizo: could not map config space");
226 1.2 mrg printf("mapped regs, sp_cfgh._ptr = %lx ._asi = %x ._sasi = %x\n", pbm->sp_cfgh._ptr, pbm->sp_cfgh._asi, pbm->sp_cfgh._sasi);
227 1.1 mrg
228 1.1 mrg pbm->sp_pc = schizo_alloc_chipset(pbm, sc->sc_node,
229 1.1 mrg &_sparc_pci_chipset);
230 1.3 nakayama pbm->sp_pc->spc_busmax = busranges[1];
231 1.3 nakayama pbm->sp_pc->spc_busnode = malloc(sizeof(*pbm->sp_pc->spc_busnode),
232 1.3 nakayama M_DEVBUF, M_NOWAIT | M_ZERO);
233 1.3 nakayama if (pbm->sp_pc->spc_busnode == NULL)
234 1.3 nakayama panic("schizo: malloc busnode");
235 1.1 mrg
236 1.1 mrg pba.pba_bus = busranges[0];
237 1.1 mrg pba.pba_bridgetag = NULL;
238 1.1 mrg pba.pba_pc = pbm->sp_pc;
239 1.1 mrg pba.pba_flags = pbm->sp_flags;
240 1.1 mrg pba.pba_dmat = pbm->sp_dmat;
241 1.2 mrg pba.pba_dmat64 = NULL; /* XXX */
242 1.1 mrg pba.pba_memt = pbm->sp_memt;
243 1.1 mrg pba.pba_iot = pbm->sp_iot;
244 1.2 mrg #if 0
245 1.1 mrg pba.pba_pc->intr_map = schizo_intr_map;
246 1.2 mrg #endif
247 1.1 mrg
248 1.1 mrg free(busranges, M_DEVBUF);
249 1.1 mrg
250 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_INTR_RETRY, 5);
251 1.1 mrg
252 1.1 mrg /* clear out the bus errors */
253 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_CTRL, schizo_pbm_read(pbm, SCZ_PCI_CTRL));
254 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_AFSR, schizo_pbm_read(pbm, SCZ_PCI_AFSR));
255 1.1 mrg schizo_cfg_write(pbm, PCI_COMMAND_STATUS_REG,
256 1.1 mrg schizo_cfg_read(pbm, PCI_COMMAND_STATUS_REG));
257 1.1 mrg
258 1.1 mrg reg = schizo_pbm_read(pbm, SCZ_PCI_CTRL);
259 1.1 mrg /* enable/disable error interrupts and arbiter */
260 1.1 mrg reg |= SCZ_PCICTRL_EEN | SCZ_PCICTRL_MMU_INT | SCZ_PCICTRL_ARB;
261 1.1 mrg reg &= ~SCZ_PCICTRL_SBH_INT;
262 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_CTRL, reg);
263 1.1 mrg
264 1.1 mrg reg = schizo_pbm_read(pbm, SCZ_PCI_DIAG);
265 1.1 mrg reg &= ~(SCZ_PCIDIAG_D_RTRYARB | SCZ_PCIDIAG_D_RETRY |
266 1.1 mrg SCZ_PCIDIAG_D_INTSYNC);
267 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_DIAG, reg);
268 1.1 mrg
269 1.2 mrg if (pbm->sp_bus_a)
270 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_pci_error,
271 1.1 mrg pbm, SCZ_PCIERR_A_INO, "pci_a");
272 1.1 mrg else
273 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_pci_error,
274 1.1 mrg pbm, SCZ_PCIERR_B_INO, "pci_b");
275 1.1 mrg
276 1.1 mrg /* double mapped */
277 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ue, sc, SCZ_UE_INO,
278 1.1 mrg "ue");
279 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ce, sc, SCZ_CE_INO,
280 1.1 mrg "ce");
281 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_safari_error, sc,
282 1.1 mrg SCZ_SERR_INO, "safari");
283 1.1 mrg
284 1.1 mrg config_found(&sc->sc_dv, &pba, schizo_print);
285 1.1 mrg }
286 1.1 mrg
287 1.1 mrg int
288 1.1 mrg schizo_ue(void *vsc)
289 1.1 mrg {
290 1.1 mrg struct schizo_softc *sc = vsc;
291 1.1 mrg
292 1.1 mrg panic("%s: uncorrectable error", sc->sc_dv.dv_xname);
293 1.1 mrg return (1);
294 1.1 mrg }
295 1.1 mrg
296 1.1 mrg int
297 1.1 mrg schizo_ce(void *vsc)
298 1.1 mrg {
299 1.1 mrg struct schizo_softc *sc = vsc;
300 1.1 mrg
301 1.1 mrg panic("%s: correctable error", sc->sc_dv.dv_xname);
302 1.1 mrg return (1);
303 1.1 mrg }
304 1.1 mrg
305 1.1 mrg int
306 1.1 mrg schizo_pci_error(void *vpbm)
307 1.1 mrg {
308 1.1 mrg struct schizo_pbm *sp = vpbm;
309 1.1 mrg struct schizo_softc *sc = sp->sp_sc;
310 1.2 mrg u_int64_t afsr, afar, ctrl, tfar;
311 1.1 mrg u_int32_t csr;
312 1.2 mrg char bits[128];
313 1.1 mrg
314 1.1 mrg afsr = schizo_pbm_read(sp, SCZ_PCI_AFSR);
315 1.1 mrg afar = schizo_pbm_read(sp, SCZ_PCI_AFAR);
316 1.1 mrg ctrl = schizo_pbm_read(sp, SCZ_PCI_CTRL);
317 1.1 mrg csr = schizo_cfg_read(sp, PCI_COMMAND_STATUS_REG);
318 1.1 mrg
319 1.1 mrg printf("%s: pci bus %c error\n", sc->sc_dv.dv_xname,
320 1.1 mrg sp->sp_bus_a ? 'A' : 'B');
321 1.1 mrg
322 1.2 mrg printf("PCIAFSR=%s\n", bitmask_snprintf(afsr, SCZ_PCIAFSR_BITS,
323 1.2 mrg bits, sizeof(bits)));
324 1.1 mrg printf("PCIAFAR=%lx\n", afar);
325 1.2 mrg printf("PCICTRL=%s\n", bitmask_snprintf(ctrl, SCZ_PCICTRL_BITS,
326 1.2 mrg bits, sizeof(bits)));
327 1.2 mrg #ifdef PCI_COMMAND_STATUS_BITS
328 1.2 mrg printf("PCICSR=%s\n", bitmask_snprintf(csr, PCI_COMMAND_STATUS_BITS,
329 1.2 mrg bits, sizeof(bits)));
330 1.2 mrg #endif
331 1.1 mrg
332 1.1 mrg if (ctrl & SCZ_PCICTRL_MMU_ERR) {
333 1.1 mrg ctrl = schizo_pbm_read(sp, SCZ_PCI_IOMMU_CTRL);
334 1.1 mrg printf("IOMMUCTRL=%lx\n", ctrl);
335 1.1 mrg
336 1.1 mrg if ((ctrl & TOM_IOMMU_ERR) == 0)
337 1.1 mrg goto clear_error;
338 1.1 mrg
339 1.1 mrg if (sc->sc_tomatillo) {
340 1.1 mrg tfar = schizo_pbm_read(sp, TOM_PCI_IOMMU_TFAR);
341 1.1 mrg printf("IOMMUTFAR=%lx\n", tfar);
342 1.1 mrg }
343 1.1 mrg
344 1.1 mrg /* These are non-fatal if target abort was signalled. */
345 1.1 mrg if ((ctrl & TOM_IOMMU_ERR_MASK) == TOM_IOMMU_INV_ERR ||
346 1.1 mrg ctrl & TOM_IOMMU_ILLTSBTBW_ERR ||
347 1.1 mrg ctrl & TOM_IOMMU_BADVA_ERR) {
348 1.1 mrg if (csr & PCI_STATUS_TARGET_TARGET_ABORT) {
349 1.1 mrg schizo_pbm_write(sp, SCZ_PCI_IOMMU_CTRL, ctrl);
350 1.1 mrg goto clear_error;
351 1.1 mrg }
352 1.1 mrg }
353 1.1 mrg }
354 1.1 mrg
355 1.1 mrg panic("%s: fatal", sc->sc_dv.dv_xname);
356 1.1 mrg
357 1.1 mrg clear_error:
358 1.1 mrg schizo_cfg_write(sp, PCI_COMMAND_STATUS_REG, csr);
359 1.1 mrg schizo_pbm_write(sp, SCZ_PCI_CTRL, ctrl);
360 1.1 mrg schizo_pbm_write(sp, SCZ_PCI_AFSR, afsr);
361 1.1 mrg return (1);
362 1.1 mrg }
363 1.1 mrg
364 1.1 mrg int
365 1.1 mrg schizo_safari_error(void *vsc)
366 1.1 mrg {
367 1.1 mrg struct schizo_softc *sc = vsc;
368 1.1 mrg
369 1.1 mrg printf("%s: safari error\n", sc->sc_dv.dv_xname);
370 1.1 mrg
371 1.1 mrg printf("ERRLOG=%lx\n", schizo_read(sc, SCZ_SAFARI_ERRLOG));
372 1.1 mrg printf("UE_AFSR=%lx\n", schizo_read(sc, SCZ_UE_AFSR));
373 1.1 mrg printf("UE_AFAR=%lx\n", schizo_read(sc, SCZ_UE_AFAR));
374 1.1 mrg printf("CE_AFSR=%lx\n", schizo_read(sc, SCZ_CE_AFSR));
375 1.1 mrg printf("CE_AFAR=%lx\n", schizo_read(sc, SCZ_CE_AFAR));
376 1.1 mrg
377 1.1 mrg panic("%s: fatal", sc->sc_dv.dv_xname);
378 1.1 mrg return (1);
379 1.1 mrg }
380 1.1 mrg
381 1.1 mrg void
382 1.1 mrg schizo_init_iommu(struct schizo_softc *sc, struct schizo_pbm *pbm)
383 1.1 mrg {
384 1.1 mrg struct iommu_state *is = &pbm->sp_is;
385 1.1 mrg int *vdma = NULL, nitem, tsbsize = 7;
386 1.1 mrg u_int32_t iobase = -1;
387 1.1 mrg vaddr_t va;
388 1.1 mrg char *name;
389 1.1 mrg
390 1.1 mrg va = (vaddr_t)pbm->sp_flush[0x40];
391 1.1 mrg
392 1.1 mrg is->is_bustag = pbm->sp_regt;
393 1.1 mrg
394 1.1 mrg if (bus_space_subregion(is->is_bustag, pbm->sp_regh,
395 1.1 mrg offsetof(struct schizo_pbm_regs, iommu),
396 1.1 mrg sizeof(struct iommureg), &is->is_iommu)) {
397 1.1 mrg panic("schizo: unable to create iommu handle");
398 1.1 mrg }
399 1.1 mrg
400 1.1 mrg is->is_sb[0] = &pbm->sp_sb;
401 1.2 mrg // XXXSCHIZO?
402 1.2 mrg //is->is_sb[0]->sb_bustag = is->is_bustag;
403 1.1 mrg is->is_sb[0]->sb_flush = (void *)(va & ~0x3f);
404 1.1 mrg
405 1.1 mrg if (bus_space_subregion(is->is_bustag, pbm->sp_regh,
406 1.1 mrg offsetof(struct schizo_pbm_regs, strbuf),
407 1.1 mrg sizeof(struct iommu_strbuf), &is->is_sb[0]->sb_sb)) {
408 1.1 mrg panic("schizo: unable to create streaming buffer handle");
409 1.1 mrg is->is_sb[0]->sb_flush = NULL;
410 1.1 mrg }
411 1.1 mrg
412 1.1 mrg #if 1
413 1.1 mrg /* XXX disable the streaming buffers for now */
414 1.1 mrg bus_space_write_8(is->is_bustag, is->is_sb[0]->sb_sb,
415 1.1 mrg STRBUFREG(strbuf_ctl),
416 1.1 mrg bus_space_read_8(is->is_bustag, is->is_sb[0]->sb_sb,
417 1.1 mrg STRBUFREG(strbuf_ctl)) & ~STRBUF_EN);
418 1.1 mrg is->is_sb[0]->sb_flush = NULL;
419 1.1 mrg #endif
420 1.1 mrg
421 1.1 mrg name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
422 1.1 mrg if (name == NULL)
423 1.1 mrg panic("couldn't malloc iommu name");
424 1.1 mrg snprintf(name, 32, "%s dvma", sc->sc_dv.dv_xname);
425 1.1 mrg
426 1.1 mrg /*
427 1.1 mrg * Separate the men from the boys. If the `virtual-dma'
428 1.1 mrg * property exists, use it.
429 1.1 mrg */
430 1.2 mrg if (!prom_getprop(sc->sc_node, "virtual-dma", sizeof(vdma), &nitem,
431 1.1 mrg (void **)&vdma)) {
432 1.1 mrg /* Damn. Gotta use these values. */
433 1.1 mrg iobase = vdma[0];
434 1.1 mrg #define TSBCASE(x) case 1 << ((x) + 23): tsbsize = (x); break
435 1.1 mrg switch (vdma[1]) {
436 1.1 mrg TSBCASE(1); TSBCASE(2); TSBCASE(3);
437 1.1 mrg TSBCASE(4); TSBCASE(5); TSBCASE(6);
438 1.1 mrg default:
439 1.1 mrg printf("bogus tsb size %x, using 7\n", vdma[1]);
440 1.1 mrg TSBCASE(7);
441 1.1 mrg }
442 1.1 mrg #undef TSBCASE
443 1.2 mrg DPRINTF(SDB_BUSMAP, ("schizo_init_iommu: iobase=0x%x\n", iobase));
444 1.1 mrg free(vdma, M_DEVBUF);
445 1.1 mrg } else {
446 1.2 mrg DPRINTF(SDB_BUSMAP, ("schizo_init_iommu: getprop failed, "
447 1.1 mrg "using iobase=0x%x, tsbsize=%d\n", iobase, tsbsize));
448 1.1 mrg }
449 1.1 mrg
450 1.1 mrg iommu_init(name, is, tsbsize, iobase);
451 1.1 mrg }
452 1.1 mrg
453 1.1 mrg int
454 1.1 mrg schizo_print(void *aux, const char *p)
455 1.1 mrg {
456 1.2 mrg
457 1.1 mrg if (p == NULL)
458 1.1 mrg return (UNCONF);
459 1.1 mrg return (QUIET);
460 1.1 mrg }
461 1.1 mrg
462 1.1 mrg pcireg_t
463 1.1 mrg schizo_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
464 1.1 mrg {
465 1.2 mrg struct schizo_pbm *sp = pc->cookie;
466 1.2 mrg pcireg_t val;
467 1.2 mrg
468 1.2 mrg DPRINTF(SDB_CONF, ("%s: tag %lx reg %x ", __func__, (long)tag, reg));
469 1.2 mrg val = bus_space_read_4(sp->sp_cfgt, sp->sp_cfgh,
470 1.2 mrg PCITAG_OFFSET(tag) + reg);
471 1.2 mrg DPRINTF(SDB_CONF, (" returning %08x\n", (u_int)val));
472 1.2 mrg return (val);
473 1.1 mrg }
474 1.1 mrg
475 1.1 mrg void
476 1.1 mrg schizo_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
477 1.1 mrg {
478 1.2 mrg struct schizo_pbm *sp = pc->cookie;
479 1.2 mrg
480 1.2 mrg DPRINTF(SDB_CONF, ("%s: tag %lx; reg %x; data %x", __func__,
481 1.2 mrg (long)tag, reg, (int)data));
482 1.2 mrg bus_space_write_4(sp->sp_cfgt, sp->sp_cfgh,
483 1.1 mrg PCITAG_OFFSET(tag) + reg, data);
484 1.2 mrg DPRINTF(SDB_CONF, (" .. done\n"));
485 1.1 mrg }
486 1.1 mrg
487 1.2 mrg #if 0
488 1.1 mrg /*
489 1.1 mrg * Bus-specific interrupt mapping
490 1.1 mrg */
491 1.1 mrg int
492 1.1 mrg schizo_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
493 1.1 mrg {
494 1.1 mrg struct schizo_pbm *sp = pa->pa_pc->cookie;
495 1.1 mrg struct schizo_softc *sc = sp->sp_sc;
496 1.1 mrg u_int dev;
497 1.1 mrg
498 1.1 mrg if (*ihp != (pci_intr_handle_t)-1) {
499 1.1 mrg *ihp |= sc->sc_ign;
500 1.1 mrg return (0);
501 1.1 mrg }
502 1.1 mrg
503 1.1 mrg /*
504 1.1 mrg * We didn't find a PROM mapping for this interrupt. Try to
505 1.1 mrg * construct one ourselves based on the swizzled interrupt pin
506 1.1 mrg * and the interrupt mapping for PCI slots documented in the
507 1.1 mrg * UltraSPARC-IIi User's Manual.
508 1.1 mrg */
509 1.1 mrg
510 1.1 mrg if (pa->pa_intrpin == 0)
511 1.1 mrg return (-1);
512 1.1 mrg
513 1.1 mrg /*
514 1.1 mrg * This deserves some documentation. Should anyone
515 1.1 mrg * have anything official looking, please speak up.
516 1.1 mrg */
517 1.1 mrg dev = pa->pa_device - 1;
518 1.1 mrg
519 1.1 mrg *ihp = (pa->pa_intrpin - 1) & INTMAP_PCIINT;
520 1.1 mrg *ihp |= (dev << 2) & INTMAP_PCISLOT;
521 1.1 mrg *ihp |= sc->sc_ign;
522 1.1 mrg
523 1.1 mrg return (0);
524 1.1 mrg }
525 1.2 mrg #endif
526 1.1 mrg
527 1.1 mrg void
528 1.1 mrg schizo_set_intr(struct schizo_softc *sc, struct schizo_pbm *pbm, int ipl,
529 1.2 mrg int (*handler)(void *), void *arg, int ino, const char *what)
530 1.1 mrg {
531 1.1 mrg struct intrhand *ih;
532 1.2 mrg //volatile u_int64_t *map, *clr;
533 1.2 mrg //struct schizo_pbm_regs *pbmreg;
534 1.2 mrg u_int64_t mapoff, clroff;
535 1.2 mrg
536 1.2 mrg //pbmreg = bus_space_vaddr(pbm->sp_regt, pbm->sp_regh);
537 1.2 mrg //map = &pbmreg->imap[ino];
538 1.2 mrg //clr = &pbmreg->iclr[ino];
539 1.2 mrg mapoff = offsetof(struct schizo_pbm_regs, imap[ino]);
540 1.2 mrg clroff = offsetof(struct schizo_pbm_regs, iclr[ino]);
541 1.1 mrg ino |= sc->sc_ign;
542 1.1 mrg
543 1.2 mrg ih = (struct intrhand *)
544 1.2 mrg malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
545 1.2 mrg if (ih == NULL)
546 1.1 mrg return;
547 1.2 mrg ih->ih_arg = arg;
548 1.2 mrg //ih->ih_map = map;
549 1.2 mrg //ih->ih_clr = clr;
550 1.2 mrg ih->ih_map = (uint64_t *)mapoff; // XXX FIXME
551 1.2 mrg ih->ih_clr = (uint64_t *)clroff; // XXX FIXME
552 1.2 mrg ih->ih_fun = handler;
553 1.2 mrg ih->ih_pil = (1<<ipl);
554 1.2 mrg ih->ih_number = INTVEC(schizo_pbm_read(pbm, mapoff));
555 1.2 mrg intr_establish(ipl, ipl != IPL_VM, ih);
556 1.2 mrg
557 1.2 mrg schizo_pbm_write(pbm, mapoff,
558 1.2 mrg ih->ih_number | INTMAP_V | (CPU_UPAID << INTMAP_TID_SHIFT));
559 1.1 mrg
560 1.1 mrg }
561 1.1 mrg
562 1.1 mrg bus_space_tag_t
563 1.1 mrg schizo_alloc_mem_tag(struct schizo_pbm *sp)
564 1.1 mrg {
565 1.1 mrg return (schizo_alloc_bus_tag(sp, "mem",
566 1.2 mrg PCI_MEMORY_BUS_SPACE));
567 1.1 mrg }
568 1.1 mrg
569 1.1 mrg bus_space_tag_t
570 1.1 mrg schizo_alloc_io_tag(struct schizo_pbm *sp)
571 1.1 mrg {
572 1.1 mrg return (schizo_alloc_bus_tag(sp, "io",
573 1.2 mrg PCI_IO_BUS_SPACE));
574 1.1 mrg }
575 1.1 mrg
576 1.1 mrg bus_space_tag_t
577 1.1 mrg schizo_alloc_config_tag(struct schizo_pbm *sp)
578 1.1 mrg {
579 1.1 mrg return (schizo_alloc_bus_tag(sp, "cfg",
580 1.2 mrg PCI_CONFIG_BUS_SPACE));
581 1.1 mrg }
582 1.1 mrg
583 1.1 mrg bus_space_tag_t
584 1.2 mrg schizo_alloc_bus_tag(struct schizo_pbm *pbm, const char *name, int type)
585 1.1 mrg {
586 1.1 mrg struct schizo_softc *sc = pbm->sp_sc;
587 1.2 mrg bus_space_tag_t bt;
588 1.1 mrg
589 1.2 mrg bt = (bus_space_tag_t) malloc(sizeof(struct sparc_bus_space_tag),
590 1.2 mrg M_DEVBUF, M_NOWAIT | M_ZERO);
591 1.1 mrg if (bt == NULL)
592 1.1 mrg panic("schizo: could not allocate bus tag");
593 1.1 mrg
594 1.1 mrg bt->cookie = pbm;
595 1.2 mrg bt->parent = sc->sc_bustag;
596 1.2 mrg bt->type = type;
597 1.1 mrg bt->sparc_bus_map = schizo_bus_map;
598 1.1 mrg bt->sparc_bus_mmap = schizo_bus_mmap;
599 1.1 mrg bt->sparc_intr_establish = schizo_intr_establish;
600 1.1 mrg return (bt);
601 1.1 mrg }
602 1.1 mrg
603 1.1 mrg bus_dma_tag_t
604 1.1 mrg schizo_alloc_dma_tag(struct schizo_pbm *pbm)
605 1.1 mrg {
606 1.1 mrg struct schizo_softc *sc = pbm->sp_sc;
607 1.1 mrg bus_dma_tag_t dt, pdt = sc->sc_dmat;
608 1.1 mrg
609 1.1 mrg dt = malloc(sizeof(*dt), M_DEVBUF, M_NOWAIT | M_ZERO);
610 1.1 mrg if (dt == NULL)
611 1.1 mrg panic("schizo: could not alloc dma tag");
612 1.1 mrg
613 1.1 mrg dt->_cookie = pbm;
614 1.1 mrg dt->_parent = pdt;
615 1.2 mrg #define PCOPY(x) dt->x = pdt->x
616 1.2 mrg PCOPY(_dmamap_create);
617 1.2 mrg PCOPY(_dmamap_destroy);
618 1.2 mrg dt->_dmamap_load = iommu_dvmamap_load;
619 1.2 mrg PCOPY(_dmamap_load_mbuf);
620 1.2 mrg PCOPY(_dmamap_load_uio);
621 1.2 mrg dt->_dmamap_load_raw = iommu_dvmamap_load_raw;
622 1.2 mrg dt->_dmamap_unload = iommu_dvmamap_unload;
623 1.2 mrg dt->_dmamap_sync = iommu_dvmamap_sync;
624 1.2 mrg dt->_dmamem_alloc = iommu_dvmamem_alloc;
625 1.2 mrg dt->_dmamem_free = iommu_dvmamem_free;
626 1.2 mrg dt->_dmamem_map = iommu_dvmamem_map;
627 1.2 mrg dt->_dmamem_unmap = iommu_dvmamem_unmap;
628 1.2 mrg PCOPY(_dmamem_mmap);
629 1.2 mrg #undef PCOPY
630 1.1 mrg return (dt);
631 1.1 mrg }
632 1.1 mrg
633 1.1 mrg pci_chipset_tag_t
634 1.1 mrg schizo_alloc_chipset(struct schizo_pbm *pbm, int node, pci_chipset_tag_t pc)
635 1.1 mrg {
636 1.1 mrg pci_chipset_tag_t npc;
637 1.1 mrg
638 1.1 mrg npc = malloc(sizeof *npc, M_DEVBUF, M_NOWAIT);
639 1.1 mrg if (npc == NULL)
640 1.1 mrg panic("schizo: could not allocate pci_chipset_tag_t");
641 1.1 mrg memcpy(npc, pc, sizeof *pc);
642 1.1 mrg npc->cookie = pbm;
643 1.1 mrg npc->rootnode = node;
644 1.2 mrg npc->spc_conf_read = schizo_conf_read;
645 1.2 mrg npc->spc_conf_write = schizo_conf_write;
646 1.2 mrg npc->spc_intr_establish = schizo_pci_intr_establish;
647 1.2 mrg npc->spc_find_ino = schizo_pci_find_ino;
648 1.1 mrg return (npc);
649 1.1 mrg }
650 1.1 mrg
651 1.2 mrg #if 0
652 1.1 mrg int
653 1.2 mrg schizo_dmamap_create(bus_dma_tag_t t, bus_size_t size,
654 1.1 mrg int nsegments, bus_size_t maxsegsz, bus_size_t boundary, int flags,
655 1.1 mrg bus_dmamap_t *dmamp)
656 1.1 mrg {
657 1.2 mrg struct schizo_pbm *pbm = t->_cookie;
658 1.1 mrg
659 1.2 mrg return (iommu_dvmamap_create(t, &pbm->sp_sb, size, nsegments,
660 1.1 mrg maxsegsz, boundary, flags, dmamp));
661 1.1 mrg }
662 1.2 mrg #endif
663 1.2 mrg
664 1.2 mrg static struct schizo_range *
665 1.2 mrg get_schizorange(struct schizo_pbm *pbm, int ss)
666 1.2 mrg {
667 1.2 mrg int i;
668 1.2 mrg
669 1.2 mrg for (i = 0; i < pbm->sp_nrange; i++) {
670 1.2 mrg if (((pbm->sp_range[i].cspace >> 24) & 0x03) == ss)
671 1.2 mrg return (&pbm->sp_range[i]);
672 1.2 mrg }
673 1.2 mrg /* not found */
674 1.2 mrg return (NULL);
675 1.2 mrg }
676 1.1 mrg
677 1.1 mrg int
678 1.2 mrg schizo_bus_map(bus_space_tag_t t, bus_addr_t offset, bus_size_t size,
679 1.2 mrg int flags, vaddr_t unused, bus_space_handle_t *hp)
680 1.1 mrg {
681 1.2 mrg bus_addr_t paddr;
682 1.1 mrg struct schizo_pbm *pbm = t->cookie;
683 1.2 mrg struct schizo_softc *sc = pbm->sp_sc;
684 1.2 mrg struct schizo_range *sr;
685 1.2 mrg int ss;
686 1.1 mrg
687 1.1 mrg DPRINTF(SDB_BUSMAP, ("schizo_bus_map: type %d off %qx sz %qx flags %d",
688 1.2 mrg t->type,
689 1.1 mrg (unsigned long long)offset,
690 1.1 mrg (unsigned long long)size,
691 1.1 mrg flags));
692 1.1 mrg
693 1.2 mrg ss = sparc_pci_childspace(t->type);
694 1.2 mrg DPRINTF(SDB_BUSMAP, (" cspace %d\n", ss));
695 1.1 mrg
696 1.2 mrg sr = get_schizorange(pbm, ss);
697 1.2 mrg if (sr != NULL) {
698 1.2 mrg paddr = BUS_ADDR(sr->phys_hi, sr->phys_lo + offset);
699 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: mapping paddr "
700 1.2 mrg "space %lx offset %lx paddr %qx\n",
701 1.2 mrg __func__, (long)ss, (long)offset,
702 1.2 mrg (unsigned long long)paddr));
703 1.2 mrg return ((*sc->sc_bustag->sparc_bus_map)(t, paddr, size,
704 1.2 mrg flags, 0, hp));
705 1.1 mrg }
706 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: FAILED\n", __func__));
707 1.1 mrg return (EINVAL);
708 1.1 mrg }
709 1.1 mrg
710 1.2 mrg static paddr_t
711 1.2 mrg schizo_bus_mmap(bus_space_tag_t t, bus_addr_t paddr, off_t off, int prot,
712 1.2 mrg int flags)
713 1.1 mrg {
714 1.1 mrg bus_addr_t offset = paddr;
715 1.1 mrg struct schizo_pbm *pbm = t->cookie;
716 1.2 mrg struct schizo_softc *sc = pbm->sp_sc;
717 1.2 mrg struct schizo_range *sr;
718 1.2 mrg int ss;
719 1.1 mrg
720 1.2 mrg ss = sparc_pci_childspace(t->type);
721 1.1 mrg
722 1.1 mrg DPRINTF(SDB_BUSMAP, ("schizo_bus_mmap: prot %d flags %d pa %qx\n",
723 1.1 mrg prot, flags, (unsigned long long)paddr));
724 1.1 mrg
725 1.2 mrg sr = get_schizorange(pbm, ss);
726 1.2 mrg if (sr != NULL) {
727 1.2 mrg paddr = BUS_ADDR(sr->phys_hi, sr->phys_lo + offset);
728 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: mapping paddr "
729 1.2 mrg "space %lx offset %lx paddr %qx\n",
730 1.2 mrg __func__, (long)ss, (long)offset,
731 1.2 mrg (unsigned long long)paddr));
732 1.2 mrg return (bus_space_mmap(sc->sc_bustag, paddr, off,
733 1.2 mrg prot, flags));
734 1.1 mrg }
735 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: FAILED\n", __func__));
736 1.1 mrg return (-1);
737 1.1 mrg }
738 1.1 mrg
739 1.2 mrg static void *
740 1.2 mrg schizo_intr_establish(bus_space_tag_t t, int ihandle, int level,
741 1.2 mrg int (*handler)(void *), void *arg, void (*fastvec)(void) /* ignored */)
742 1.1 mrg {
743 1.1 mrg struct schizo_pbm *pbm = t->cookie;
744 1.1 mrg struct intrhand *ih = NULL;
745 1.1 mrg volatile u_int64_t *intrmapptr = NULL, *intrclrptr = NULL;
746 1.1 mrg int ino;
747 1.1 mrg long vec = INTVEC(ihandle);
748 1.1 mrg
749 1.1 mrg vec = INTVEC(ihandle);
750 1.1 mrg ino = INTINO(vec);
751 1.1 mrg
752 1.2 mrg DPRINTF(SDB_INTR, ("%s: ihandle %d level %d fn %p arg %p\n", __func__,
753 1.2 mrg ihandle, level, handler, arg));
754 1.2 mrg
755 1.1 mrg if (level == IPL_NONE)
756 1.1 mrg level = INTLEV(vec);
757 1.1 mrg if (level == IPL_NONE) {
758 1.1 mrg printf(": no IPL, setting IPL 2.\n");
759 1.1 mrg level = 2;
760 1.1 mrg }
761 1.1 mrg
762 1.2 mrg #if 0
763 1.1 mrg if ((flags & BUS_INTR_ESTABLISH_SOFTINTR) == 0) {
764 1.1 mrg struct schizo_pbm_regs *pbmreg;
765 1.1 mrg
766 1.1 mrg pbmreg = bus_space_vaddr(pbm->sp_regt, pbm->sp_regh);
767 1.1 mrg intrmapptr = &pbmreg->imap[ino];
768 1.1 mrg intrclrptr = &pbmreg->iclr[ino];
769 1.1 mrg if (INTIGN(vec) == 0)
770 1.1 mrg ino |= (*intrmapptr) & INTMAP_IGN;
771 1.1 mrg else
772 1.1 mrg ino |= vec & INTMAP_IGN;
773 1.1 mrg }
774 1.1 mrg
775 1.2 mrg ih = bus_intr_allocate(t, handler, arg, ino, level, intrmapptr,
776 1.1 mrg intrclrptr, what);
777 1.2 mrg #endif
778 1.2 mrg ih = malloc(sizeof *ih, M_DEVBUF, M_NOWAIT);
779 1.1 mrg if (ih == NULL)
780 1.1 mrg return (NULL);
781 1.1 mrg
782 1.2 mrg ih->ih_map = intrmapptr;
783 1.2 mrg ih->ih_clr = intrclrptr;
784 1.2 mrg
785 1.2 mrg ih->ih_fun = handler;
786 1.2 mrg ih->ih_arg = arg;
787 1.2 mrg ih->ih_pil = level;
788 1.2 mrg ih->ih_number = ino | pbm->sp_sc->sc_ign;
789 1.2 mrg
790 1.2 mrg intr_establish(ih->ih_pil, level != IPL_VM, ih);
791 1.1 mrg
792 1.1 mrg if (intrmapptr != NULL) {
793 1.2 mrg u_int64_t imap;
794 1.1 mrg
795 1.2 mrg imap = *intrmapptr;
796 1.2 mrg imap |= INTMAP_V;
797 1.2 mrg *intrmapptr = imap;
798 1.2 mrg imap = *intrmapptr;
799 1.2 mrg ih->ih_number |= imap & INTMAP_INR;
800 1.1 mrg }
801 1.1 mrg
802 1.1 mrg return (ih);
803 1.1 mrg }
804 1.1 mrg
805 1.2 mrg static void *
806 1.2 mrg schizo_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
807 1.2 mrg int (*func)(void *), void *arg)
808 1.2 mrg {
809 1.2 mrg void *cookie;
810 1.2 mrg struct schizo_pbm *pbm = (struct schizo_pbm *)pc->cookie;
811 1.2 mrg
812 1.2 mrg DPRINTF(SDB_INTR, ("pci_intr_establish: ih %lu; level %d", (u_long)ih, level));
813 1.2 mrg cookie = bus_intr_establish(pbm->sp_memt, ih, level, func, arg);
814 1.2 mrg
815 1.2 mrg DPRINTF(SDB_INTR, ("; returning handle %p\n", cookie));
816 1.2 mrg return (cookie);
817 1.2 mrg }
818 1.2 mrg
819 1.2 mrg static int
820 1.2 mrg schizo_pci_find_ino(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
821 1.2 mrg {
822 1.2 mrg #if 0
823 1.2 mrg struct schizo_pbm *pbm = pa->pa_pc->cookie;
824 1.2 mrg struct schizo_softc *sc = pbm->sp_sc;
825 1.2 mrg u_int bus;
826 1.2 mrg u_int dev;
827 1.2 mrg u_int pin;
828 1.2 mrg #endif
829 1.2 mrg
830 1.2 mrg DPRINTF(SDB_INTMAP, ("pci_find_ino: pa_tag: node %x, %d:%d:%d\n",
831 1.2 mrg PCITAG_NODE(pa->pa_tag), (int)PCITAG_BUS(pa->pa_tag),
832 1.2 mrg (int)PCITAG_DEV(pa->pa_tag),
833 1.2 mrg (int)PCITAG_FUN(pa->pa_tag)));
834 1.2 mrg DPRINTF(SDB_INTMAP,
835 1.2 mrg ("pci_find_ino: intrswiz %d, intrpin %d, intrline %d, rawintrpin %d\n",
836 1.2 mrg pa->pa_intrswiz, pa->pa_intrpin, pa->pa_intrline, pa->pa_rawintrpin));
837 1.2 mrg DPRINTF(SDB_INTMAP, ("pci_find_ino: pa_intrtag: node %x, %d:%d:%d\n",
838 1.2 mrg PCITAG_NODE(pa->pa_intrtag),
839 1.2 mrg (int)PCITAG_BUS(pa->pa_intrtag),
840 1.2 mrg (int)PCITAG_DEV(pa->pa_intrtag),
841 1.2 mrg (int)PCITAG_FUN(pa->pa_intrtag)));
842 1.2 mrg
843 1.2 mrg #if 0
844 1.2 mrg bus = (pp->pp_id == PSYCHO_PBM_B);
845 1.2 mrg /*
846 1.2 mrg * If we are on a ppb, use the devno on the underlying bus when forming
847 1.2 mrg * the ivec.
848 1.2 mrg */
849 1.2 mrg if (pa->pa_intrswiz != 0 && PCITAG_NODE(pa->pa_intrtag) != 0)
850 1.2 mrg dev = PCITAG_DEV(pa->pa_intrtag);
851 1.2 mrg else
852 1.2 mrg dev = pa->pa_device;
853 1.2 mrg dev--;
854 1.2 mrg
855 1.2 mrg if (sc->sc_mode == PSYCHO_MODE_PSYCHO &&
856 1.2 mrg pp->pp_id == PSYCHO_PBM_B)
857 1.2 mrg dev--;
858 1.2 mrg
859 1.2 mrg pin = pa->pa_intrpin - 1;
860 1.2 mrg DPRINTF(SDB_INTMAP, ("pci_find_ino: mode %d, pbm %d, dev %d, pin %d\n",
861 1.2 mrg sc->sc_mode, pp->pp_id, dev, pin));
862 1.2 mrg
863 1.2 mrg *ihp = sc->sc_ign | ((bus << 4) & INTMAP_PCIBUS) |
864 1.2 mrg ((dev << 2) & INTMAP_PCISLOT) | (pin & INTMAP_PCIINT);
865 1.2 mrg #endif
866 1.2 mrg
867 1.2 mrg return (0);
868 1.2 mrg }
869