isa_machdep.c revision 1.11 1 1.11 dsl /* $NetBSD: isa_machdep.c,v 1.11 2009/03/14 21:04:05 dsl Exp $ */
2 1.1 chris
3 1.1 chris /*-
4 1.1 chris * Copyright (c) 1996-1998 The NetBSD Foundation, Inc.
5 1.1 chris * All rights reserved.
6 1.1 chris *
7 1.1 chris * This code is derived from software contributed to The NetBSD Foundation
8 1.1 chris * by Mark Brinicombe, Charles M. Hannum and by Jason R. Thorpe of the
9 1.1 chris * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
10 1.1 chris *
11 1.1 chris * Redistribution and use in source and binary forms, with or without
12 1.1 chris * modification, are permitted provided that the following conditions
13 1.1 chris * are met:
14 1.1 chris * 1. Redistributions of source code must retain the above copyright
15 1.1 chris * notice, this list of conditions and the following disclaimer.
16 1.1 chris * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 chris * notice, this list of conditions and the following disclaimer in the
18 1.1 chris * documentation and/or other materials provided with the distribution.
19 1.1 chris *
20 1.1 chris * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 1.1 chris * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.1 chris * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 1.1 chris * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 1.1 chris * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.1 chris * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.1 chris * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.1 chris * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.1 chris * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.1 chris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.1 chris * POSSIBILITY OF SUCH DAMAGE.
31 1.1 chris */
32 1.1 chris
33 1.1 chris /*-
34 1.1 chris * Copyright (c) 1991 The Regents of the University of California.
35 1.1 chris * All rights reserved.
36 1.1 chris *
37 1.1 chris * This code is derived from software contributed to Berkeley by
38 1.1 chris * William Jolitz.
39 1.1 chris *
40 1.1 chris * Redistribution and use in source and binary forms, with or without
41 1.1 chris * modification, are permitted provided that the following conditions
42 1.1 chris * are met:
43 1.1 chris * 1. Redistributions of source code must retain the above copyright
44 1.1 chris * notice, this list of conditions and the following disclaimer.
45 1.1 chris * 2. Redistributions in binary form must reproduce the above copyright
46 1.1 chris * notice, this list of conditions and the following disclaimer in the
47 1.1 chris * documentation and/or other materials provided with the distribution.
48 1.5 agc * 3. Neither the name of the University nor the names of its contributors
49 1.1 chris * may be used to endorse or promote products derived from this software
50 1.1 chris * without specific prior written permission.
51 1.1 chris *
52 1.1 chris * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 1.1 chris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 1.1 chris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 1.1 chris * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 1.1 chris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 1.1 chris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 1.1 chris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 1.1 chris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 1.1 chris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 1.1 chris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 1.1 chris * SUCH DAMAGE.
63 1.1 chris *
64 1.1 chris * @(#)isa.c 7.2 (Berkeley) 5/13/91
65 1.1 chris */
66 1.3 chris
67 1.3 chris #include <sys/cdefs.h>
68 1.11 dsl __KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.11 2009/03/14 21:04:05 dsl Exp $");
69 1.1 chris
70 1.1 chris #include "opt_irqstats.h"
71 1.1 chris
72 1.1 chris #include <sys/param.h>
73 1.1 chris #include <sys/systm.h>
74 1.1 chris #include <sys/kernel.h>
75 1.1 chris #include <sys/syslog.h>
76 1.1 chris #include <sys/device.h>
77 1.1 chris #include <sys/malloc.h>
78 1.1 chris #include <sys/proc.h>
79 1.1 chris
80 1.1 chris #define _ARM32_BUS_DMA_PRIVATE
81 1.1 chris #include <machine/bus.h>
82 1.1 chris
83 1.1 chris #include <machine/intr.h>
84 1.1 chris #include <machine/pio.h>
85 1.1 chris #include <machine/bootconfig.h>
86 1.1 chris #include <machine/isa_machdep.h>
87 1.1 chris
88 1.1 chris #include <dev/isa/isareg.h>
89 1.1 chris #include <dev/isa/isavar.h>
90 1.1 chris #include <dev/isa/isadmareg.h>
91 1.1 chris #include <dev/isa/isadmavar.h>
92 1.1 chris #include <arm/footbridge/isa/icu.h>
93 1.1 chris #include <arm/footbridge/dc21285reg.h>
94 1.1 chris #include <arm/footbridge/dc21285mem.h>
95 1.1 chris
96 1.1 chris #include <uvm/uvm_extern.h>
97 1.1 chris
98 1.1 chris #include "isadma.h"
99 1.1 chris
100 1.1 chris /* prototypes */
101 1.9 dsl static void isa_icu_init(void);
102 1.1 chris
103 1.1 chris struct arm32_isa_chipset isa_chipset_tag;
104 1.1 chris
105 1.9 dsl void isa_strayintr(int);
106 1.9 dsl void intr_calculatemasks(void);
107 1.9 dsl int fakeintr(void *);
108 1.1 chris
109 1.9 dsl int isa_irqdispatch(void *arg);
110 1.1 chris
111 1.2 chris u_int imask[NIPL];
112 1.1 chris unsigned imen;
113 1.1 chris
114 1.1 chris #define AUTO_EOI_1
115 1.1 chris #define AUTO_EOI_2
116 1.1 chris
117 1.1 chris /*
118 1.1 chris * Fill in default interrupt table (in case of spuruious interrupt
119 1.1 chris * during configuration of kernel, setup interrupt control unit
120 1.1 chris */
121 1.1 chris static void
122 1.1 chris isa_icu_init(void)
123 1.1 chris {
124 1.1 chris /* initialize 8259's */
125 1.1 chris outb(IO_ICU1, 0x11); /* reset; program device, four bytes */
126 1.1 chris outb(IO_ICU1+1, ICU_OFFSET); /* starting at this vector index */
127 1.1 chris outb(IO_ICU1+1, 1 << IRQ_SLAVE); /* slave on line 2 */
128 1.1 chris #ifdef AUTO_EOI_1
129 1.1 chris outb(IO_ICU1+1, 2 | 1); /* auto EOI, 8086 mode */
130 1.1 chris #else
131 1.1 chris outb(IO_ICU1+1, 1); /* 8086 mode */
132 1.1 chris #endif
133 1.1 chris outb(IO_ICU1+1, 0xff); /* leave interrupts masked */
134 1.1 chris outb(IO_ICU1, 0x68); /* special mask mode (if available) */
135 1.1 chris outb(IO_ICU1, 0x0a); /* Read IRR by default. */
136 1.1 chris #ifdef REORDER_IRQ
137 1.1 chris outb(IO_ICU1, 0xc0 | (3 - 1)); /* pri order 3-7, 0-2 (com2 first) */
138 1.1 chris #endif
139 1.1 chris
140 1.1 chris outb(IO_ICU2, 0x11); /* reset; program device, four bytes */
141 1.1 chris outb(IO_ICU2+1, ICU_OFFSET+8); /* staring at this vector index */
142 1.1 chris outb(IO_ICU2+1, IRQ_SLAVE);
143 1.1 chris #ifdef AUTO_EOI_2
144 1.1 chris outb(IO_ICU2+1, 2 | 1); /* auto EOI, 8086 mode */
145 1.1 chris #else
146 1.1 chris outb(IO_ICU2+1, 1); /* 8086 mode */
147 1.1 chris #endif
148 1.1 chris outb(IO_ICU2+1, 0xff); /* leave interrupts masked */
149 1.1 chris outb(IO_ICU2, 0x68); /* special mask mode (if available) */
150 1.1 chris outb(IO_ICU2, 0x0a); /* Read IRR by default. */
151 1.1 chris }
152 1.1 chris
153 1.1 chris /*
154 1.1 chris * Caught a stray interrupt, notify
155 1.1 chris */
156 1.1 chris void
157 1.10 dsl isa_strayintr(int irq)
158 1.1 chris {
159 1.1 chris static u_long strays;
160 1.1 chris
161 1.1 chris /*
162 1.1 chris * Stray interrupts on irq 7 occur when an interrupt line is raised
163 1.1 chris * and then lowered before the CPU acknowledges it. This generally
164 1.1 chris * means either the device is screwed or something is cli'ing too
165 1.1 chris * long and it's timing out.
166 1.1 chris */
167 1.1 chris if (++strays <= 5)
168 1.1 chris log(LOG_ERR, "stray interrupt %d%s\n", irq,
169 1.1 chris strays >= 5 ? "; stopped logging" : "");
170 1.1 chris }
171 1.1 chris
172 1.2 chris static struct intrq isa_intrq[ICU_LEN];
173 1.1 chris
174 1.1 chris /*
175 1.1 chris * Recalculate the interrupt masks from scratch.
176 1.1 chris * We could code special registry and deregistry versions of this function that
177 1.1 chris * would be faster, but the code would be nastier, and we don't expect this to
178 1.1 chris * happen very much anyway.
179 1.1 chris */
180 1.1 chris void
181 1.1 chris intr_calculatemasks()
182 1.1 chris {
183 1.1 chris int irq, level;
184 1.2 chris struct intrq *iq;
185 1.2 chris struct intrhand *ih;
186 1.1 chris
187 1.1 chris /* First, figure out which levels each IRQ uses. */
188 1.1 chris for (irq = 0; irq < ICU_LEN; irq++) {
189 1.1 chris int levels = 0;
190 1.2 chris iq = &isa_intrq[irq];
191 1.2 chris for (ih = TAILQ_FIRST(&iq->iq_list); ih != NULL;
192 1.2 chris ih = TAILQ_NEXT(ih, ih_list))
193 1.2 chris levels |= (1U << ih->ih_ipl);
194 1.2 chris iq->iq_levels = levels;
195 1.1 chris }
196 1.1 chris
197 1.1 chris /* Then figure out which IRQs use each level. */
198 1.2 chris for (level = 0; level < NIPL; level++) {
199 1.1 chris int irqs = 0;
200 1.1 chris for (irq = 0; irq < ICU_LEN; irq++)
201 1.2 chris if (isa_intrq[irq].iq_levels & (1U << level))
202 1.2 chris irqs |= (1U << irq);
203 1.1 chris imask[level] = irqs;
204 1.1 chris }
205 1.1 chris
206 1.1 chris imask[IPL_NONE] = 0;
207 1.7 ad imask[IPL_SOFTCLOCK] |= imask[IPL_NONE];
208 1.7 ad imask[IPL_SOFTBIO] |= imask[IPL_SOFTCLOCK];
209 1.7 ad imask[IPL_SOFTNET] |= imask[IPL_SOFTBIO];
210 1.7 ad imask[IPL_SOFTSERIAL] |= imask[IPL_SOFTNET];
211 1.7 ad imask[IPL_VM] |= imask[IPL_SOFTSERIAL];
212 1.7 ad imask[IPL_SCHED] |= imask[IPL_VM];
213 1.7 ad imask[IPL_HIGH] |= imask[IPL_SCHED];
214 1.1 chris
215 1.1 chris /* And eventually calculate the complete masks. */
216 1.1 chris for (irq = 0; irq < ICU_LEN; irq++) {
217 1.1 chris int irqs = 1 << irq;
218 1.2 chris iq = &isa_intrq[irq];
219 1.2 chris for (ih = TAILQ_FIRST(&iq->iq_list); ih != NULL;
220 1.2 chris ih = TAILQ_NEXT(ih, ih_list))
221 1.2 chris irqs |= imask[ih->ih_ipl];
222 1.2 chris iq->iq_mask = irqs;
223 1.1 chris }
224 1.1 chris
225 1.1 chris /* Lastly, determine which IRQs are actually in use. */
226 1.1 chris {
227 1.1 chris int irqs = 0;
228 1.1 chris for (irq = 0; irq < ICU_LEN; irq++)
229 1.2 chris if (!TAILQ_EMPTY(&isa_intrq[irq].iq_list))
230 1.2 chris irqs |= (1U << irq);
231 1.1 chris if (irqs >= 0x100) /* any IRQs >= 8 in use */
232 1.1 chris irqs |= 1 << IRQ_SLAVE;
233 1.1 chris imen = ~irqs;
234 1.1 chris SET_ICUS();
235 1.1 chris }
236 1.1 chris #if 0
237 1.1 chris printf("type\tmask\tlevel\thand\n");
238 1.1 chris for (irq = 0; irq < ICU_LEN; irq++) {
239 1.1 chris printf("%x\t%04x\t%x\t%p\n", intrtype[irq], intrmask[irq],
240 1.1 chris intrlevel[irq], intrhand[irq]);
241 1.1 chris }
242 1.1 chris for (level = 0; level < IPL_LEVELS; ++level)
243 1.1 chris printf("%d: %08x\n", level, imask[level]);
244 1.1 chris #endif
245 1.1 chris }
246 1.1 chris
247 1.1 chris int
248 1.10 dsl fakeintr(void *arg)
249 1.1 chris {
250 1.1 chris
251 1.1 chris return 0;
252 1.1 chris }
253 1.1 chris
254 1.1 chris #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != 2)
255 1.1 chris
256 1.1 chris int
257 1.10 dsl isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq)
258 1.1 chris {
259 1.1 chris int i, tmp, bestirq, count;
260 1.2 chris struct intrq *iq;
261 1.2 chris struct intrhand *ih;
262 1.1 chris
263 1.1 chris if (type == IST_NONE)
264 1.1 chris panic("intr_alloc: bogus type");
265 1.1 chris
266 1.1 chris bestirq = -1;
267 1.1 chris count = -1;
268 1.1 chris
269 1.1 chris /* some interrupts should never be dynamically allocated */
270 1.1 chris mask &= 0xdef8;
271 1.1 chris
272 1.1 chris /*
273 1.1 chris * XXX some interrupts will be used later (6 for fdc, 12 for pms).
274 1.1 chris * the right answer is to do "breadth-first" searching of devices.
275 1.1 chris */
276 1.1 chris mask &= 0xefbf;
277 1.1 chris
278 1.1 chris for (i = 0; i < ICU_LEN; i++) {
279 1.1 chris if (LEGAL_IRQ(i) == 0 || (mask & (1<<i)) == 0)
280 1.1 chris continue;
281 1.2 chris
282 1.2 chris iq = &isa_intrq[i];
283 1.2 chris switch(iq->iq_ist) {
284 1.1 chris case IST_NONE:
285 1.1 chris /*
286 1.1 chris * if nothing's using the irq, just return it
287 1.1 chris */
288 1.1 chris *irq = i;
289 1.1 chris return (0);
290 1.1 chris
291 1.1 chris case IST_EDGE:
292 1.1 chris case IST_LEVEL:
293 1.2 chris if (type != iq->iq_ist)
294 1.1 chris continue;
295 1.1 chris /*
296 1.1 chris * if the irq is shareable, count the number of other
297 1.1 chris * handlers, and if it's smaller than the last irq like
298 1.1 chris * this, remember it
299 1.1 chris *
300 1.1 chris * XXX We should probably also consider the
301 1.1 chris * interrupt level and stick IPL_TTY with other
302 1.1 chris * IPL_TTY, etc.
303 1.1 chris */
304 1.2 chris tmp = 0;
305 1.2 chris TAILQ_FOREACH(ih, &(iq->iq_list), ih_list)
306 1.2 chris tmp++;
307 1.1 chris if ((bestirq == -1) || (count > tmp)) {
308 1.1 chris bestirq = i;
309 1.1 chris count = tmp;
310 1.1 chris }
311 1.1 chris break;
312 1.1 chris
313 1.1 chris case IST_PULSE:
314 1.1 chris /* this just isn't shareable */
315 1.1 chris continue;
316 1.1 chris }
317 1.1 chris }
318 1.1 chris
319 1.1 chris if (bestirq == -1)
320 1.1 chris return (1);
321 1.1 chris
322 1.1 chris *irq = bestirq;
323 1.1 chris
324 1.1 chris return (0);
325 1.1 chris }
326 1.1 chris
327 1.1 chris const struct evcnt *
328 1.1 chris isa_intr_evcnt(isa_chipset_tag_t ic, int irq)
329 1.1 chris {
330 1.2 chris return &isa_intrq[irq].iq_ev;
331 1.1 chris }
332 1.1 chris
333 1.1 chris /*
334 1.1 chris * Set up an interrupt handler to start being called.
335 1.1 chris * XXX PRONE TO RACE CONDITIONS, UGLY, 'INTERESTING' INSERTION ALGORITHM.
336 1.1 chris */
337 1.1 chris void *
338 1.1 chris isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg)
339 1.1 chris isa_chipset_tag_t ic;
340 1.1 chris int irq;
341 1.1 chris int type;
342 1.1 chris int level;
343 1.9 dsl int (*ih_fun)(void *);
344 1.1 chris void *ih_arg;
345 1.1 chris {
346 1.2 chris struct intrq *iq;
347 1.2 chris struct intrhand *ih;
348 1.2 chris u_int oldirqstate;
349 1.1 chris
350 1.2 chris #if 0
351 1.2 chris printf("isa_intr_establish(%d, %d, %d)\n", irq, type, level);
352 1.2 chris #endif
353 1.1 chris /* no point in sleeping unless someone can free memory. */
354 1.1 chris ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
355 1.1 chris if (ih == NULL)
356 1.2 chris return (NULL);
357 1.1 chris
358 1.1 chris if (!LEGAL_IRQ(irq) || type == IST_NONE)
359 1.1 chris panic("intr_establish: bogus irq or type");
360 1.1 chris
361 1.2 chris iq = &isa_intrq[irq];
362 1.2 chris
363 1.2 chris switch (iq->iq_ist) {
364 1.1 chris case IST_NONE:
365 1.2 chris iq->iq_ist = type;
366 1.2 chris #if 0
367 1.2 chris printf("Setting irq %d to type %d - ", irq, type);
368 1.2 chris #endif
369 1.1 chris if (irq < 8) {
370 1.1 chris outb(0x4d0, (inb(0x4d0) & ~(1 << irq))
371 1.1 chris | ((type == IST_LEVEL) ? (1 << irq) : 0));
372 1.1 chris /* printf("%02x\n", inb(0x4d0));*/
373 1.1 chris } else {
374 1.1 chris outb(0x4d1, (inb(0x4d1) & ~(1 << irq))
375 1.1 chris | ((type == IST_LEVEL) ? (1 << irq) : 0));
376 1.1 chris /* printf("%02x\n", inb(0x4d1));*/
377 1.1 chris }
378 1.1 chris break;
379 1.1 chris case IST_EDGE:
380 1.1 chris case IST_LEVEL:
381 1.2 chris if (iq->iq_ist == type)
382 1.1 chris break;
383 1.1 chris case IST_PULSE:
384 1.1 chris if (type != IST_NONE)
385 1.1 chris panic("intr_establish: can't share %s with %s",
386 1.2 chris isa_intr_typename(iq->iq_ist),
387 1.1 chris isa_intr_typename(type));
388 1.1 chris break;
389 1.1 chris }
390 1.1 chris
391 1.2 chris ih->ih_func = ih_fun;
392 1.2 chris ih->ih_arg = ih_arg;
393 1.2 chris ih->ih_ipl = level;
394 1.2 chris ih->ih_irq = irq;
395 1.1 chris
396 1.2 chris /* do not stop us */
397 1.2 chris oldirqstate = disable_interrupts(I32_bit);
398 1.2 chris
399 1.2 chris TAILQ_INSERT_TAIL(&iq->iq_list, ih, ih_list);
400 1.1 chris
401 1.1 chris intr_calculatemasks();
402 1.2 chris restore_interrupts(oldirqstate);
403 1.2 chris
404 1.1 chris return (ih);
405 1.1 chris }
406 1.1 chris
407 1.1 chris /*
408 1.1 chris * Deregister an interrupt handler.
409 1.1 chris */
410 1.1 chris void
411 1.10 dsl isa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
412 1.1 chris {
413 1.2 chris struct intrhand *ih = arg;
414 1.2 chris struct intrq *iq = &isa_intrq[ih->ih_irq];
415 1.2 chris int irq = ih->ih_irq;
416 1.2 chris u_int oldirqstate;
417 1.2 chris
418 1.1 chris if (!LEGAL_IRQ(irq))
419 1.1 chris panic("intr_disestablish: bogus irq");
420 1.1 chris
421 1.2 chris oldirqstate = disable_interrupts(I32_bit);
422 1.2 chris
423 1.2 chris TAILQ_REMOVE(&iq->iq_list, ih, ih_list);
424 1.1 chris
425 1.1 chris intr_calculatemasks();
426 1.1 chris
427 1.2 chris restore_interrupts(oldirqstate);
428 1.2 chris
429 1.2 chris free(ih, M_DEVBUF);
430 1.2 chris
431 1.2 chris if (TAILQ_EMPTY(&(iq->iq_list)))
432 1.2 chris iq->iq_ist = IST_NONE;
433 1.1 chris }
434 1.1 chris
435 1.1 chris /*
436 1.1 chris * isa_intr_init()
437 1.1 chris *
438 1.1 chris * Initialise the ISA ICU and attach an ISA interrupt handler to the
439 1.1 chris * ISA interrupt line on the footbridge.
440 1.1 chris */
441 1.1 chris void
442 1.1 chris isa_intr_init(void)
443 1.1 chris {
444 1.1 chris static void *isa_ih;
445 1.2 chris struct intrq *iq;
446 1.2 chris int i;
447 1.2 chris
448 1.2 chris /*
449 1.2 chris * should get the parent here, but initialisation order being so
450 1.2 chris * strange I need to check if it's available
451 1.2 chris */
452 1.2 chris for (i = 0; i < ICU_LEN; i++) {
453 1.2 chris iq = &isa_intrq[i];
454 1.2 chris TAILQ_INIT(&iq->iq_list);
455 1.2 chris
456 1.2 chris sprintf(iq->iq_name, "irq %d", i);
457 1.2 chris evcnt_attach_dynamic(&iq->iq_ev, EVCNT_TYPE_INTR,
458 1.2 chris NULL, "isa", iq->iq_name);
459 1.2 chris }
460 1.2 chris
461 1.1 chris isa_icu_init();
462 1.2 chris intr_calculatemasks();
463 1.2 chris /* something to break the build in an informative way */
464 1.1 chris #ifndef ISA_FOOTBRIDGE_IRQ
465 1.1 chris #warning Before using isa with footbridge you must define ISA_FOOTBRIDGE_IRQ
466 1.1 chris #endif
467 1.2 chris isa_ih = footbridge_intr_claim(ISA_FOOTBRIDGE_IRQ, IPL_BIO, "isabus",
468 1.1 chris isa_irqdispatch, NULL);
469 1.1 chris
470 1.1 chris }
471 1.1 chris
472 1.1 chris /* Static array of ISA DMA segments. We only have one on CATS */
473 1.1 chris #if NISADMA > 0
474 1.1 chris struct arm32_dma_range machdep_isa_dma_ranges[1];
475 1.1 chris #endif
476 1.1 chris
477 1.1 chris void
478 1.11 dsl isa_footbridge_init(u_int iobase, u_int membase)
479 1.1 chris {
480 1.1 chris #if NISADMA > 0
481 1.1 chris extern struct arm32_dma_range *footbridge_isa_dma_ranges;
482 1.1 chris extern int footbridge_isa_dma_nranges;
483 1.1 chris
484 1.1 chris machdep_isa_dma_ranges[0].dr_sysbase = bootconfig.dram[0].address;
485 1.1 chris machdep_isa_dma_ranges[0].dr_busbase = bootconfig.dram[0].address;
486 1.1 chris machdep_isa_dma_ranges[0].dr_len = (16 * 1024 * 1024);
487 1.1 chris
488 1.1 chris footbridge_isa_dma_ranges = machdep_isa_dma_ranges;
489 1.1 chris footbridge_isa_dma_nranges = 1;
490 1.1 chris #endif
491 1.1 chris
492 1.1 chris isa_io_init(iobase, membase);
493 1.1 chris }
494 1.1 chris
495 1.1 chris void
496 1.11 dsl isa_attach_hook(struct device *parent, struct device *self, struct isabus_attach_args *iba)
497 1.1 chris {
498 1.1 chris /*
499 1.1 chris * Since we can only have one ISA bus, we just use a single
500 1.1 chris * statically allocated ISA chipset structure. Pass it up
501 1.1 chris * now.
502 1.1 chris */
503 1.1 chris iba->iba_ic = &isa_chipset_tag;
504 1.1 chris #if NISADMA > 0
505 1.1 chris isa_dma_init();
506 1.1 chris #endif
507 1.1 chris }
508 1.1 chris
509 1.1 chris int
510 1.10 dsl isa_irqdispatch(void *arg)
511 1.1 chris {
512 1.2 chris struct clockframe *frame = arg;
513 1.1 chris int irq;
514 1.2 chris struct intrq *iq;
515 1.2 chris struct intrhand *ih;
516 1.1 chris u_int iack;
517 1.2 chris int res = 0;
518 1.1 chris
519 1.1 chris iack = *((u_int *)(DC21285_PCI_IACK_VBASE));
520 1.1 chris iack &= 0xff;
521 1.1 chris if (iack < 0x20 || iack > 0x2f) {
522 1.1 chris printf("isa_irqdispatch: %x\n", iack);
523 1.1 chris return(0);
524 1.1 chris }
525 1.1 chris
526 1.1 chris irq = iack & 0x0f;
527 1.2 chris iq = &isa_intrq[irq];
528 1.2 chris iq->iq_ev.ev_count++;
529 1.2 chris for (ih = TAILQ_FIRST(&iq->iq_list); res != 1 && ih != NULL;
530 1.2 chris ih = TAILQ_NEXT(ih, ih_list)) {
531 1.2 chris res = (*ih->ih_func)(ih->ih_arg ? ih->ih_arg : frame);
532 1.1 chris }
533 1.2 chris return res;
534 1.1 chris }
535 1.1 chris
536 1.1 chris
537 1.1 chris void
538 1.10 dsl isa_fillw(u_int val, void *addr, size_t len)
539 1.1 chris {
540 1.1 chris if ((u_int)addr >= isa_mem_data_vaddr()
541 1.1 chris && (u_int)addr < isa_mem_data_vaddr() + 0x100000) {
542 1.1 chris bus_size_t offset = ((u_int)addr) & 0xfffff;
543 1.1 chris bus_space_set_region_2(&isa_mem_bs_tag,
544 1.1 chris (bus_space_handle_t)isa_mem_bs_tag.bs_cookie, offset,
545 1.1 chris val, len);
546 1.1 chris } else {
547 1.1 chris u_short *ptr = addr;
548 1.1 chris
549 1.1 chris while (len > 0) {
550 1.1 chris *ptr++ = val;
551 1.1 chris --len;
552 1.1 chris }
553 1.1 chris }
554 1.1 chris }
555