schizo.c revision 1.2 1 1.2 mrg /* $NetBSD: schizo.c,v 1.2 2008/12/10 05:56:22 mrg 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.1 mrg
231 1.1 mrg pba.pba_bus = busranges[0];
232 1.1 mrg pba.pba_bridgetag = NULL;
233 1.1 mrg pba.pba_pc = pbm->sp_pc;
234 1.1 mrg pba.pba_flags = pbm->sp_flags;
235 1.1 mrg pba.pba_dmat = pbm->sp_dmat;
236 1.2 mrg pba.pba_dmat64 = NULL; /* XXX */
237 1.1 mrg pba.pba_memt = pbm->sp_memt;
238 1.1 mrg pba.pba_iot = pbm->sp_iot;
239 1.2 mrg #if 0
240 1.1 mrg pba.pba_pc->intr_map = schizo_intr_map;
241 1.2 mrg #endif
242 1.1 mrg
243 1.1 mrg free(busranges, M_DEVBUF);
244 1.1 mrg
245 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_INTR_RETRY, 5);
246 1.1 mrg
247 1.1 mrg /* clear out the bus errors */
248 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_CTRL, schizo_pbm_read(pbm, SCZ_PCI_CTRL));
249 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_AFSR, schizo_pbm_read(pbm, SCZ_PCI_AFSR));
250 1.1 mrg schizo_cfg_write(pbm, PCI_COMMAND_STATUS_REG,
251 1.1 mrg schizo_cfg_read(pbm, PCI_COMMAND_STATUS_REG));
252 1.1 mrg
253 1.1 mrg reg = schizo_pbm_read(pbm, SCZ_PCI_CTRL);
254 1.1 mrg /* enable/disable error interrupts and arbiter */
255 1.1 mrg reg |= SCZ_PCICTRL_EEN | SCZ_PCICTRL_MMU_INT | SCZ_PCICTRL_ARB;
256 1.1 mrg reg &= ~SCZ_PCICTRL_SBH_INT;
257 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_CTRL, reg);
258 1.1 mrg
259 1.1 mrg reg = schizo_pbm_read(pbm, SCZ_PCI_DIAG);
260 1.1 mrg reg &= ~(SCZ_PCIDIAG_D_RTRYARB | SCZ_PCIDIAG_D_RETRY |
261 1.1 mrg SCZ_PCIDIAG_D_INTSYNC);
262 1.1 mrg schizo_pbm_write(pbm, SCZ_PCI_DIAG, reg);
263 1.1 mrg
264 1.2 mrg if (pbm->sp_bus_a)
265 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_pci_error,
266 1.1 mrg pbm, SCZ_PCIERR_A_INO, "pci_a");
267 1.1 mrg else
268 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_pci_error,
269 1.1 mrg pbm, SCZ_PCIERR_B_INO, "pci_b");
270 1.1 mrg
271 1.1 mrg /* double mapped */
272 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ue, sc, SCZ_UE_INO,
273 1.1 mrg "ue");
274 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ce, sc, SCZ_CE_INO,
275 1.1 mrg "ce");
276 1.1 mrg schizo_set_intr(sc, pbm, PIL_HIGH, schizo_safari_error, sc,
277 1.1 mrg SCZ_SERR_INO, "safari");
278 1.1 mrg
279 1.1 mrg config_found(&sc->sc_dv, &pba, schizo_print);
280 1.1 mrg }
281 1.1 mrg
282 1.1 mrg int
283 1.1 mrg schizo_ue(void *vsc)
284 1.1 mrg {
285 1.1 mrg struct schizo_softc *sc = vsc;
286 1.1 mrg
287 1.1 mrg panic("%s: uncorrectable error", sc->sc_dv.dv_xname);
288 1.1 mrg return (1);
289 1.1 mrg }
290 1.1 mrg
291 1.1 mrg int
292 1.1 mrg schizo_ce(void *vsc)
293 1.1 mrg {
294 1.1 mrg struct schizo_softc *sc = vsc;
295 1.1 mrg
296 1.1 mrg panic("%s: correctable error", sc->sc_dv.dv_xname);
297 1.1 mrg return (1);
298 1.1 mrg }
299 1.1 mrg
300 1.1 mrg int
301 1.1 mrg schizo_pci_error(void *vpbm)
302 1.1 mrg {
303 1.1 mrg struct schizo_pbm *sp = vpbm;
304 1.1 mrg struct schizo_softc *sc = sp->sp_sc;
305 1.2 mrg u_int64_t afsr, afar, ctrl, tfar;
306 1.1 mrg u_int32_t csr;
307 1.2 mrg char bits[128];
308 1.1 mrg
309 1.1 mrg afsr = schizo_pbm_read(sp, SCZ_PCI_AFSR);
310 1.1 mrg afar = schizo_pbm_read(sp, SCZ_PCI_AFAR);
311 1.1 mrg ctrl = schizo_pbm_read(sp, SCZ_PCI_CTRL);
312 1.1 mrg csr = schizo_cfg_read(sp, PCI_COMMAND_STATUS_REG);
313 1.1 mrg
314 1.1 mrg printf("%s: pci bus %c error\n", sc->sc_dv.dv_xname,
315 1.1 mrg sp->sp_bus_a ? 'A' : 'B');
316 1.1 mrg
317 1.2 mrg printf("PCIAFSR=%s\n", bitmask_snprintf(afsr, SCZ_PCIAFSR_BITS,
318 1.2 mrg bits, sizeof(bits)));
319 1.1 mrg printf("PCIAFAR=%lx\n", afar);
320 1.2 mrg printf("PCICTRL=%s\n", bitmask_snprintf(ctrl, SCZ_PCICTRL_BITS,
321 1.2 mrg bits, sizeof(bits)));
322 1.2 mrg #ifdef PCI_COMMAND_STATUS_BITS
323 1.2 mrg printf("PCICSR=%s\n", bitmask_snprintf(csr, PCI_COMMAND_STATUS_BITS,
324 1.2 mrg bits, sizeof(bits)));
325 1.2 mrg #endif
326 1.1 mrg
327 1.1 mrg if (ctrl & SCZ_PCICTRL_MMU_ERR) {
328 1.1 mrg ctrl = schizo_pbm_read(sp, SCZ_PCI_IOMMU_CTRL);
329 1.1 mrg printf("IOMMUCTRL=%lx\n", ctrl);
330 1.1 mrg
331 1.1 mrg if ((ctrl & TOM_IOMMU_ERR) == 0)
332 1.1 mrg goto clear_error;
333 1.1 mrg
334 1.1 mrg if (sc->sc_tomatillo) {
335 1.1 mrg tfar = schizo_pbm_read(sp, TOM_PCI_IOMMU_TFAR);
336 1.1 mrg printf("IOMMUTFAR=%lx\n", tfar);
337 1.1 mrg }
338 1.1 mrg
339 1.1 mrg /* These are non-fatal if target abort was signalled. */
340 1.1 mrg if ((ctrl & TOM_IOMMU_ERR_MASK) == TOM_IOMMU_INV_ERR ||
341 1.1 mrg ctrl & TOM_IOMMU_ILLTSBTBW_ERR ||
342 1.1 mrg ctrl & TOM_IOMMU_BADVA_ERR) {
343 1.1 mrg if (csr & PCI_STATUS_TARGET_TARGET_ABORT) {
344 1.1 mrg schizo_pbm_write(sp, SCZ_PCI_IOMMU_CTRL, ctrl);
345 1.1 mrg goto clear_error;
346 1.1 mrg }
347 1.1 mrg }
348 1.1 mrg }
349 1.1 mrg
350 1.1 mrg panic("%s: fatal", sc->sc_dv.dv_xname);
351 1.1 mrg
352 1.1 mrg clear_error:
353 1.1 mrg schizo_cfg_write(sp, PCI_COMMAND_STATUS_REG, csr);
354 1.1 mrg schizo_pbm_write(sp, SCZ_PCI_CTRL, ctrl);
355 1.1 mrg schizo_pbm_write(sp, SCZ_PCI_AFSR, afsr);
356 1.1 mrg return (1);
357 1.1 mrg }
358 1.1 mrg
359 1.1 mrg int
360 1.1 mrg schizo_safari_error(void *vsc)
361 1.1 mrg {
362 1.1 mrg struct schizo_softc *sc = vsc;
363 1.1 mrg
364 1.1 mrg printf("%s: safari error\n", sc->sc_dv.dv_xname);
365 1.1 mrg
366 1.1 mrg printf("ERRLOG=%lx\n", schizo_read(sc, SCZ_SAFARI_ERRLOG));
367 1.1 mrg printf("UE_AFSR=%lx\n", schizo_read(sc, SCZ_UE_AFSR));
368 1.1 mrg printf("UE_AFAR=%lx\n", schizo_read(sc, SCZ_UE_AFAR));
369 1.1 mrg printf("CE_AFSR=%lx\n", schizo_read(sc, SCZ_CE_AFSR));
370 1.1 mrg printf("CE_AFAR=%lx\n", schizo_read(sc, SCZ_CE_AFAR));
371 1.1 mrg
372 1.1 mrg panic("%s: fatal", sc->sc_dv.dv_xname);
373 1.1 mrg return (1);
374 1.1 mrg }
375 1.1 mrg
376 1.1 mrg void
377 1.1 mrg schizo_init_iommu(struct schizo_softc *sc, struct schizo_pbm *pbm)
378 1.1 mrg {
379 1.1 mrg struct iommu_state *is = &pbm->sp_is;
380 1.1 mrg int *vdma = NULL, nitem, tsbsize = 7;
381 1.1 mrg u_int32_t iobase = -1;
382 1.1 mrg vaddr_t va;
383 1.1 mrg char *name;
384 1.1 mrg
385 1.1 mrg va = (vaddr_t)pbm->sp_flush[0x40];
386 1.1 mrg
387 1.1 mrg is->is_bustag = pbm->sp_regt;
388 1.1 mrg
389 1.1 mrg if (bus_space_subregion(is->is_bustag, pbm->sp_regh,
390 1.1 mrg offsetof(struct schizo_pbm_regs, iommu),
391 1.1 mrg sizeof(struct iommureg), &is->is_iommu)) {
392 1.1 mrg panic("schizo: unable to create iommu handle");
393 1.1 mrg }
394 1.1 mrg
395 1.1 mrg is->is_sb[0] = &pbm->sp_sb;
396 1.2 mrg // XXXSCHIZO?
397 1.2 mrg //is->is_sb[0]->sb_bustag = is->is_bustag;
398 1.1 mrg is->is_sb[0]->sb_flush = (void *)(va & ~0x3f);
399 1.1 mrg
400 1.1 mrg if (bus_space_subregion(is->is_bustag, pbm->sp_regh,
401 1.1 mrg offsetof(struct schizo_pbm_regs, strbuf),
402 1.1 mrg sizeof(struct iommu_strbuf), &is->is_sb[0]->sb_sb)) {
403 1.1 mrg panic("schizo: unable to create streaming buffer handle");
404 1.1 mrg is->is_sb[0]->sb_flush = NULL;
405 1.1 mrg }
406 1.1 mrg
407 1.1 mrg #if 1
408 1.1 mrg /* XXX disable the streaming buffers for now */
409 1.1 mrg bus_space_write_8(is->is_bustag, is->is_sb[0]->sb_sb,
410 1.1 mrg STRBUFREG(strbuf_ctl),
411 1.1 mrg bus_space_read_8(is->is_bustag, is->is_sb[0]->sb_sb,
412 1.1 mrg STRBUFREG(strbuf_ctl)) & ~STRBUF_EN);
413 1.1 mrg is->is_sb[0]->sb_flush = NULL;
414 1.1 mrg #endif
415 1.1 mrg
416 1.1 mrg name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
417 1.1 mrg if (name == NULL)
418 1.1 mrg panic("couldn't malloc iommu name");
419 1.1 mrg snprintf(name, 32, "%s dvma", sc->sc_dv.dv_xname);
420 1.1 mrg
421 1.1 mrg /*
422 1.1 mrg * Separate the men from the boys. If the `virtual-dma'
423 1.1 mrg * property exists, use it.
424 1.1 mrg */
425 1.2 mrg if (!prom_getprop(sc->sc_node, "virtual-dma", sizeof(vdma), &nitem,
426 1.1 mrg (void **)&vdma)) {
427 1.1 mrg /* Damn. Gotta use these values. */
428 1.1 mrg iobase = vdma[0];
429 1.1 mrg #define TSBCASE(x) case 1 << ((x) + 23): tsbsize = (x); break
430 1.1 mrg switch (vdma[1]) {
431 1.1 mrg TSBCASE(1); TSBCASE(2); TSBCASE(3);
432 1.1 mrg TSBCASE(4); TSBCASE(5); TSBCASE(6);
433 1.1 mrg default:
434 1.1 mrg printf("bogus tsb size %x, using 7\n", vdma[1]);
435 1.1 mrg TSBCASE(7);
436 1.1 mrg }
437 1.1 mrg #undef TSBCASE
438 1.2 mrg DPRINTF(SDB_BUSMAP, ("schizo_init_iommu: iobase=0x%x\n", iobase));
439 1.1 mrg free(vdma, M_DEVBUF);
440 1.1 mrg } else {
441 1.2 mrg DPRINTF(SDB_BUSMAP, ("schizo_init_iommu: getprop failed, "
442 1.1 mrg "using iobase=0x%x, tsbsize=%d\n", iobase, tsbsize));
443 1.1 mrg }
444 1.1 mrg
445 1.1 mrg iommu_init(name, is, tsbsize, iobase);
446 1.1 mrg }
447 1.1 mrg
448 1.1 mrg int
449 1.1 mrg schizo_print(void *aux, const char *p)
450 1.1 mrg {
451 1.2 mrg
452 1.1 mrg if (p == NULL)
453 1.1 mrg return (UNCONF);
454 1.1 mrg return (QUIET);
455 1.1 mrg }
456 1.1 mrg
457 1.1 mrg pcireg_t
458 1.1 mrg schizo_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
459 1.1 mrg {
460 1.2 mrg struct schizo_pbm *sp = pc->cookie;
461 1.2 mrg pcireg_t val;
462 1.2 mrg
463 1.2 mrg DPRINTF(SDB_CONF, ("%s: tag %lx reg %x ", __func__, (long)tag, reg));
464 1.2 mrg val = bus_space_read_4(sp->sp_cfgt, sp->sp_cfgh,
465 1.2 mrg PCITAG_OFFSET(tag) + reg);
466 1.2 mrg DPRINTF(SDB_CONF, (" returning %08x\n", (u_int)val));
467 1.2 mrg return (val);
468 1.1 mrg }
469 1.1 mrg
470 1.1 mrg void
471 1.1 mrg schizo_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
472 1.1 mrg {
473 1.2 mrg struct schizo_pbm *sp = pc->cookie;
474 1.2 mrg
475 1.2 mrg DPRINTF(SDB_CONF, ("%s: tag %lx; reg %x; data %x", __func__,
476 1.2 mrg (long)tag, reg, (int)data));
477 1.2 mrg bus_space_write_4(sp->sp_cfgt, sp->sp_cfgh,
478 1.1 mrg PCITAG_OFFSET(tag) + reg, data);
479 1.2 mrg DPRINTF(SDB_CONF, (" .. done\n"));
480 1.1 mrg }
481 1.1 mrg
482 1.2 mrg #if 0
483 1.1 mrg /*
484 1.1 mrg * Bus-specific interrupt mapping
485 1.1 mrg */
486 1.1 mrg int
487 1.1 mrg schizo_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
488 1.1 mrg {
489 1.1 mrg struct schizo_pbm *sp = pa->pa_pc->cookie;
490 1.1 mrg struct schizo_softc *sc = sp->sp_sc;
491 1.1 mrg u_int dev;
492 1.1 mrg
493 1.1 mrg if (*ihp != (pci_intr_handle_t)-1) {
494 1.1 mrg *ihp |= sc->sc_ign;
495 1.1 mrg return (0);
496 1.1 mrg }
497 1.1 mrg
498 1.1 mrg /*
499 1.1 mrg * We didn't find a PROM mapping for this interrupt. Try to
500 1.1 mrg * construct one ourselves based on the swizzled interrupt pin
501 1.1 mrg * and the interrupt mapping for PCI slots documented in the
502 1.1 mrg * UltraSPARC-IIi User's Manual.
503 1.1 mrg */
504 1.1 mrg
505 1.1 mrg if (pa->pa_intrpin == 0)
506 1.1 mrg return (-1);
507 1.1 mrg
508 1.1 mrg /*
509 1.1 mrg * This deserves some documentation. Should anyone
510 1.1 mrg * have anything official looking, please speak up.
511 1.1 mrg */
512 1.1 mrg dev = pa->pa_device - 1;
513 1.1 mrg
514 1.1 mrg *ihp = (pa->pa_intrpin - 1) & INTMAP_PCIINT;
515 1.1 mrg *ihp |= (dev << 2) & INTMAP_PCISLOT;
516 1.1 mrg *ihp |= sc->sc_ign;
517 1.1 mrg
518 1.1 mrg return (0);
519 1.1 mrg }
520 1.2 mrg #endif
521 1.1 mrg
522 1.1 mrg void
523 1.1 mrg schizo_set_intr(struct schizo_softc *sc, struct schizo_pbm *pbm, int ipl,
524 1.2 mrg int (*handler)(void *), void *arg, int ino, const char *what)
525 1.1 mrg {
526 1.1 mrg struct intrhand *ih;
527 1.2 mrg //volatile u_int64_t *map, *clr;
528 1.2 mrg //struct schizo_pbm_regs *pbmreg;
529 1.2 mrg u_int64_t mapoff, clroff;
530 1.2 mrg
531 1.2 mrg //pbmreg = bus_space_vaddr(pbm->sp_regt, pbm->sp_regh);
532 1.2 mrg //map = &pbmreg->imap[ino];
533 1.2 mrg //clr = &pbmreg->iclr[ino];
534 1.2 mrg mapoff = offsetof(struct schizo_pbm_regs, imap[ino]);
535 1.2 mrg clroff = offsetof(struct schizo_pbm_regs, iclr[ino]);
536 1.1 mrg ino |= sc->sc_ign;
537 1.1 mrg
538 1.2 mrg ih = (struct intrhand *)
539 1.2 mrg malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
540 1.2 mrg if (ih == NULL)
541 1.1 mrg return;
542 1.2 mrg ih->ih_arg = arg;
543 1.2 mrg //ih->ih_map = map;
544 1.2 mrg //ih->ih_clr = clr;
545 1.2 mrg ih->ih_map = (uint64_t *)mapoff; // XXX FIXME
546 1.2 mrg ih->ih_clr = (uint64_t *)clroff; // XXX FIXME
547 1.2 mrg ih->ih_fun = handler;
548 1.2 mrg ih->ih_pil = (1<<ipl);
549 1.2 mrg ih->ih_number = INTVEC(schizo_pbm_read(pbm, mapoff));
550 1.2 mrg intr_establish(ipl, ipl != IPL_VM, ih);
551 1.2 mrg
552 1.2 mrg schizo_pbm_write(pbm, mapoff,
553 1.2 mrg ih->ih_number | INTMAP_V | (CPU_UPAID << INTMAP_TID_SHIFT));
554 1.1 mrg
555 1.1 mrg }
556 1.1 mrg
557 1.1 mrg bus_space_tag_t
558 1.1 mrg schizo_alloc_mem_tag(struct schizo_pbm *sp)
559 1.1 mrg {
560 1.1 mrg return (schizo_alloc_bus_tag(sp, "mem",
561 1.2 mrg PCI_MEMORY_BUS_SPACE));
562 1.1 mrg }
563 1.1 mrg
564 1.1 mrg bus_space_tag_t
565 1.1 mrg schizo_alloc_io_tag(struct schizo_pbm *sp)
566 1.1 mrg {
567 1.1 mrg return (schizo_alloc_bus_tag(sp, "io",
568 1.2 mrg PCI_IO_BUS_SPACE));
569 1.1 mrg }
570 1.1 mrg
571 1.1 mrg bus_space_tag_t
572 1.1 mrg schizo_alloc_config_tag(struct schizo_pbm *sp)
573 1.1 mrg {
574 1.1 mrg return (schizo_alloc_bus_tag(sp, "cfg",
575 1.2 mrg PCI_CONFIG_BUS_SPACE));
576 1.1 mrg }
577 1.1 mrg
578 1.1 mrg bus_space_tag_t
579 1.2 mrg schizo_alloc_bus_tag(struct schizo_pbm *pbm, const char *name, int type)
580 1.1 mrg {
581 1.1 mrg struct schizo_softc *sc = pbm->sp_sc;
582 1.2 mrg bus_space_tag_t bt;
583 1.1 mrg
584 1.2 mrg bt = (bus_space_tag_t) malloc(sizeof(struct sparc_bus_space_tag),
585 1.2 mrg M_DEVBUF, M_NOWAIT | M_ZERO);
586 1.1 mrg if (bt == NULL)
587 1.1 mrg panic("schizo: could not allocate bus tag");
588 1.1 mrg
589 1.1 mrg bt->cookie = pbm;
590 1.2 mrg bt->parent = sc->sc_bustag;
591 1.2 mrg bt->type = type;
592 1.1 mrg bt->sparc_bus_map = schizo_bus_map;
593 1.1 mrg bt->sparc_bus_mmap = schizo_bus_mmap;
594 1.1 mrg bt->sparc_intr_establish = schizo_intr_establish;
595 1.1 mrg return (bt);
596 1.1 mrg }
597 1.1 mrg
598 1.1 mrg bus_dma_tag_t
599 1.1 mrg schizo_alloc_dma_tag(struct schizo_pbm *pbm)
600 1.1 mrg {
601 1.1 mrg struct schizo_softc *sc = pbm->sp_sc;
602 1.1 mrg bus_dma_tag_t dt, pdt = sc->sc_dmat;
603 1.1 mrg
604 1.1 mrg dt = malloc(sizeof(*dt), M_DEVBUF, M_NOWAIT | M_ZERO);
605 1.1 mrg if (dt == NULL)
606 1.1 mrg panic("schizo: could not alloc dma tag");
607 1.1 mrg
608 1.1 mrg dt->_cookie = pbm;
609 1.1 mrg dt->_parent = pdt;
610 1.2 mrg #define PCOPY(x) dt->x = pdt->x
611 1.2 mrg PCOPY(_dmamap_create);
612 1.2 mrg PCOPY(_dmamap_destroy);
613 1.2 mrg dt->_dmamap_load = iommu_dvmamap_load;
614 1.2 mrg PCOPY(_dmamap_load_mbuf);
615 1.2 mrg PCOPY(_dmamap_load_uio);
616 1.2 mrg dt->_dmamap_load_raw = iommu_dvmamap_load_raw;
617 1.2 mrg dt->_dmamap_unload = iommu_dvmamap_unload;
618 1.2 mrg dt->_dmamap_sync = iommu_dvmamap_sync;
619 1.2 mrg dt->_dmamem_alloc = iommu_dvmamem_alloc;
620 1.2 mrg dt->_dmamem_free = iommu_dvmamem_free;
621 1.2 mrg dt->_dmamem_map = iommu_dvmamem_map;
622 1.2 mrg dt->_dmamem_unmap = iommu_dvmamem_unmap;
623 1.2 mrg PCOPY(_dmamem_mmap);
624 1.2 mrg #undef PCOPY
625 1.1 mrg return (dt);
626 1.1 mrg }
627 1.1 mrg
628 1.1 mrg pci_chipset_tag_t
629 1.1 mrg schizo_alloc_chipset(struct schizo_pbm *pbm, int node, pci_chipset_tag_t pc)
630 1.1 mrg {
631 1.1 mrg pci_chipset_tag_t npc;
632 1.1 mrg
633 1.1 mrg npc = malloc(sizeof *npc, M_DEVBUF, M_NOWAIT);
634 1.1 mrg if (npc == NULL)
635 1.1 mrg panic("schizo: could not allocate pci_chipset_tag_t");
636 1.1 mrg memcpy(npc, pc, sizeof *pc);
637 1.1 mrg npc->cookie = pbm;
638 1.1 mrg npc->rootnode = node;
639 1.2 mrg npc->spc_conf_read = schizo_conf_read;
640 1.2 mrg npc->spc_conf_write = schizo_conf_write;
641 1.2 mrg npc->spc_intr_establish = schizo_pci_intr_establish;
642 1.2 mrg npc->spc_find_ino = schizo_pci_find_ino;
643 1.1 mrg return (npc);
644 1.1 mrg }
645 1.1 mrg
646 1.2 mrg #if 0
647 1.1 mrg int
648 1.2 mrg schizo_dmamap_create(bus_dma_tag_t t, bus_size_t size,
649 1.1 mrg int nsegments, bus_size_t maxsegsz, bus_size_t boundary, int flags,
650 1.1 mrg bus_dmamap_t *dmamp)
651 1.1 mrg {
652 1.2 mrg struct schizo_pbm *pbm = t->_cookie;
653 1.1 mrg
654 1.2 mrg return (iommu_dvmamap_create(t, &pbm->sp_sb, size, nsegments,
655 1.1 mrg maxsegsz, boundary, flags, dmamp));
656 1.1 mrg }
657 1.2 mrg #endif
658 1.2 mrg
659 1.2 mrg static struct schizo_range *
660 1.2 mrg get_schizorange(struct schizo_pbm *pbm, int ss)
661 1.2 mrg {
662 1.2 mrg int i;
663 1.2 mrg
664 1.2 mrg for (i = 0; i < pbm->sp_nrange; i++) {
665 1.2 mrg if (((pbm->sp_range[i].cspace >> 24) & 0x03) == ss)
666 1.2 mrg return (&pbm->sp_range[i]);
667 1.2 mrg }
668 1.2 mrg /* not found */
669 1.2 mrg return (NULL);
670 1.2 mrg }
671 1.1 mrg
672 1.1 mrg int
673 1.2 mrg schizo_bus_map(bus_space_tag_t t, bus_addr_t offset, bus_size_t size,
674 1.2 mrg int flags, vaddr_t unused, bus_space_handle_t *hp)
675 1.1 mrg {
676 1.2 mrg bus_addr_t paddr;
677 1.1 mrg struct schizo_pbm *pbm = t->cookie;
678 1.2 mrg struct schizo_softc *sc = pbm->sp_sc;
679 1.2 mrg struct schizo_range *sr;
680 1.2 mrg int ss;
681 1.1 mrg
682 1.1 mrg DPRINTF(SDB_BUSMAP, ("schizo_bus_map: type %d off %qx sz %qx flags %d",
683 1.2 mrg t->type,
684 1.1 mrg (unsigned long long)offset,
685 1.1 mrg (unsigned long long)size,
686 1.1 mrg flags));
687 1.1 mrg
688 1.2 mrg ss = sparc_pci_childspace(t->type);
689 1.2 mrg DPRINTF(SDB_BUSMAP, (" cspace %d\n", ss));
690 1.1 mrg
691 1.2 mrg sr = get_schizorange(pbm, ss);
692 1.2 mrg if (sr != NULL) {
693 1.2 mrg paddr = BUS_ADDR(sr->phys_hi, sr->phys_lo + offset);
694 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: mapping paddr "
695 1.2 mrg "space %lx offset %lx paddr %qx\n",
696 1.2 mrg __func__, (long)ss, (long)offset,
697 1.2 mrg (unsigned long long)paddr));
698 1.2 mrg return ((*sc->sc_bustag->sparc_bus_map)(t, paddr, size,
699 1.2 mrg flags, 0, hp));
700 1.1 mrg }
701 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: FAILED\n", __func__));
702 1.1 mrg return (EINVAL);
703 1.1 mrg }
704 1.1 mrg
705 1.2 mrg static paddr_t
706 1.2 mrg schizo_bus_mmap(bus_space_tag_t t, bus_addr_t paddr, off_t off, int prot,
707 1.2 mrg int flags)
708 1.1 mrg {
709 1.1 mrg bus_addr_t offset = paddr;
710 1.1 mrg struct schizo_pbm *pbm = t->cookie;
711 1.2 mrg struct schizo_softc *sc = pbm->sp_sc;
712 1.2 mrg struct schizo_range *sr;
713 1.2 mrg int ss;
714 1.1 mrg
715 1.2 mrg ss = sparc_pci_childspace(t->type);
716 1.1 mrg
717 1.1 mrg DPRINTF(SDB_BUSMAP, ("schizo_bus_mmap: prot %d flags %d pa %qx\n",
718 1.1 mrg prot, flags, (unsigned long long)paddr));
719 1.1 mrg
720 1.2 mrg sr = get_schizorange(pbm, ss);
721 1.2 mrg if (sr != NULL) {
722 1.2 mrg paddr = BUS_ADDR(sr->phys_hi, sr->phys_lo + offset);
723 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: mapping paddr "
724 1.2 mrg "space %lx offset %lx paddr %qx\n",
725 1.2 mrg __func__, (long)ss, (long)offset,
726 1.2 mrg (unsigned long long)paddr));
727 1.2 mrg return (bus_space_mmap(sc->sc_bustag, paddr, off,
728 1.2 mrg prot, flags));
729 1.1 mrg }
730 1.2 mrg DPRINTF(SDB_BUSMAP, ("%s: FAILED\n", __func__));
731 1.1 mrg return (-1);
732 1.1 mrg }
733 1.1 mrg
734 1.2 mrg static void *
735 1.2 mrg schizo_intr_establish(bus_space_tag_t t, int ihandle, int level,
736 1.2 mrg int (*handler)(void *), void *arg, void (*fastvec)(void) /* ignored */)
737 1.1 mrg {
738 1.1 mrg struct schizo_pbm *pbm = t->cookie;
739 1.1 mrg struct intrhand *ih = NULL;
740 1.1 mrg volatile u_int64_t *intrmapptr = NULL, *intrclrptr = NULL;
741 1.1 mrg int ino;
742 1.1 mrg long vec = INTVEC(ihandle);
743 1.1 mrg
744 1.1 mrg vec = INTVEC(ihandle);
745 1.1 mrg ino = INTINO(vec);
746 1.1 mrg
747 1.2 mrg DPRINTF(SDB_INTR, ("%s: ihandle %d level %d fn %p arg %p\n", __func__,
748 1.2 mrg ihandle, level, handler, arg));
749 1.2 mrg
750 1.1 mrg if (level == IPL_NONE)
751 1.1 mrg level = INTLEV(vec);
752 1.1 mrg if (level == IPL_NONE) {
753 1.1 mrg printf(": no IPL, setting IPL 2.\n");
754 1.1 mrg level = 2;
755 1.1 mrg }
756 1.1 mrg
757 1.2 mrg #if 0
758 1.1 mrg if ((flags & BUS_INTR_ESTABLISH_SOFTINTR) == 0) {
759 1.1 mrg struct schizo_pbm_regs *pbmreg;
760 1.1 mrg
761 1.1 mrg pbmreg = bus_space_vaddr(pbm->sp_regt, pbm->sp_regh);
762 1.1 mrg intrmapptr = &pbmreg->imap[ino];
763 1.1 mrg intrclrptr = &pbmreg->iclr[ino];
764 1.1 mrg if (INTIGN(vec) == 0)
765 1.1 mrg ino |= (*intrmapptr) & INTMAP_IGN;
766 1.1 mrg else
767 1.1 mrg ino |= vec & INTMAP_IGN;
768 1.1 mrg }
769 1.1 mrg
770 1.2 mrg ih = bus_intr_allocate(t, handler, arg, ino, level, intrmapptr,
771 1.1 mrg intrclrptr, what);
772 1.2 mrg #endif
773 1.2 mrg ih = malloc(sizeof *ih, M_DEVBUF, M_NOWAIT);
774 1.1 mrg if (ih == NULL)
775 1.1 mrg return (NULL);
776 1.1 mrg
777 1.2 mrg ih->ih_map = intrmapptr;
778 1.2 mrg ih->ih_clr = intrclrptr;
779 1.2 mrg
780 1.2 mrg ih->ih_fun = handler;
781 1.2 mrg ih->ih_arg = arg;
782 1.2 mrg ih->ih_pil = level;
783 1.2 mrg ih->ih_number = ino | pbm->sp_sc->sc_ign;
784 1.2 mrg
785 1.2 mrg intr_establish(ih->ih_pil, level != IPL_VM, ih);
786 1.1 mrg
787 1.1 mrg if (intrmapptr != NULL) {
788 1.2 mrg u_int64_t imap;
789 1.1 mrg
790 1.2 mrg imap = *intrmapptr;
791 1.2 mrg imap |= INTMAP_V;
792 1.2 mrg *intrmapptr = imap;
793 1.2 mrg imap = *intrmapptr;
794 1.2 mrg ih->ih_number |= imap & INTMAP_INR;
795 1.1 mrg }
796 1.1 mrg
797 1.1 mrg return (ih);
798 1.1 mrg }
799 1.1 mrg
800 1.2 mrg static void *
801 1.2 mrg schizo_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
802 1.2 mrg int (*func)(void *), void *arg)
803 1.2 mrg {
804 1.2 mrg void *cookie;
805 1.2 mrg struct schizo_pbm *pbm = (struct schizo_pbm *)pc->cookie;
806 1.2 mrg
807 1.2 mrg DPRINTF(SDB_INTR, ("pci_intr_establish: ih %lu; level %d", (u_long)ih, level));
808 1.2 mrg cookie = bus_intr_establish(pbm->sp_memt, ih, level, func, arg);
809 1.2 mrg
810 1.2 mrg DPRINTF(SDB_INTR, ("; returning handle %p\n", cookie));
811 1.2 mrg return (cookie);
812 1.2 mrg }
813 1.2 mrg
814 1.2 mrg static int
815 1.2 mrg schizo_pci_find_ino(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
816 1.2 mrg {
817 1.2 mrg #if 0
818 1.2 mrg struct schizo_pbm *pbm = pa->pa_pc->cookie;
819 1.2 mrg struct schizo_softc *sc = pbm->sp_sc;
820 1.2 mrg u_int bus;
821 1.2 mrg u_int dev;
822 1.2 mrg u_int pin;
823 1.2 mrg #endif
824 1.2 mrg
825 1.2 mrg DPRINTF(SDB_INTMAP, ("pci_find_ino: pa_tag: node %x, %d:%d:%d\n",
826 1.2 mrg PCITAG_NODE(pa->pa_tag), (int)PCITAG_BUS(pa->pa_tag),
827 1.2 mrg (int)PCITAG_DEV(pa->pa_tag),
828 1.2 mrg (int)PCITAG_FUN(pa->pa_tag)));
829 1.2 mrg DPRINTF(SDB_INTMAP,
830 1.2 mrg ("pci_find_ino: intrswiz %d, intrpin %d, intrline %d, rawintrpin %d\n",
831 1.2 mrg pa->pa_intrswiz, pa->pa_intrpin, pa->pa_intrline, pa->pa_rawintrpin));
832 1.2 mrg DPRINTF(SDB_INTMAP, ("pci_find_ino: pa_intrtag: node %x, %d:%d:%d\n",
833 1.2 mrg PCITAG_NODE(pa->pa_intrtag),
834 1.2 mrg (int)PCITAG_BUS(pa->pa_intrtag),
835 1.2 mrg (int)PCITAG_DEV(pa->pa_intrtag),
836 1.2 mrg (int)PCITAG_FUN(pa->pa_intrtag)));
837 1.2 mrg
838 1.2 mrg #if 0
839 1.2 mrg bus = (pp->pp_id == PSYCHO_PBM_B);
840 1.2 mrg /*
841 1.2 mrg * If we are on a ppb, use the devno on the underlying bus when forming
842 1.2 mrg * the ivec.
843 1.2 mrg */
844 1.2 mrg if (pa->pa_intrswiz != 0 && PCITAG_NODE(pa->pa_intrtag) != 0)
845 1.2 mrg dev = PCITAG_DEV(pa->pa_intrtag);
846 1.2 mrg else
847 1.2 mrg dev = pa->pa_device;
848 1.2 mrg dev--;
849 1.2 mrg
850 1.2 mrg if (sc->sc_mode == PSYCHO_MODE_PSYCHO &&
851 1.2 mrg pp->pp_id == PSYCHO_PBM_B)
852 1.2 mrg dev--;
853 1.2 mrg
854 1.2 mrg pin = pa->pa_intrpin - 1;
855 1.2 mrg DPRINTF(SDB_INTMAP, ("pci_find_ino: mode %d, pbm %d, dev %d, pin %d\n",
856 1.2 mrg sc->sc_mode, pp->pp_id, dev, pin));
857 1.2 mrg
858 1.2 mrg *ihp = sc->sc_ign | ((bus << 4) & INTMAP_PCIBUS) |
859 1.2 mrg ((dev << 2) & INTMAP_PCISLOT) | (pin & INTMAP_PCIINT);
860 1.2 mrg #endif
861 1.2 mrg
862 1.2 mrg return (0);
863 1.2 mrg }
864