xref: /netbsd/sys/dev/pci/btvmei.c (revision c4a72b64)
1 /* $NetBSD: btvmei.c,v 1.11 2002/10/02 16:51:04 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 1999
5  *	Matthias Drochner.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  */
30 
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: btvmei.c,v 1.11 2002/10/02 16:51:04 thorpej Exp $");
33 
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/device.h>
38 #include <sys/proc.h>
39 #include <sys/malloc.h>
40 
41 #include <machine/bus.h>
42 #include <sys/extent.h>
43 
44 #include <dev/pci/pcireg.h>
45 #include <dev/pci/pcivar.h>
46 #include <dev/pci/pcidevs.h>
47 
48 #include <dev/vme/vmereg.h>
49 #include <dev/vme/vmevar.h>
50 
51 #include <dev/pci/btvmeireg.h>
52 #include <dev/pci/btvmeivar.h>
53 
54 static int b3_617_match __P((struct device *, struct cfdata *, void *));
55 static void b3_617_attach __P((struct device *, struct device *, void *));
56 #ifdef notyet
57 static int b3_617_detach __P((struct device *));
58 #endif
59 void b3_617_slaveconfig __P((struct device *, struct vme_attach_args *));
60 
61 static void b3_617_vmeintr __P((struct b3_617_softc *, unsigned char));
62 
63 /*
64  * mapping ressources, needed for deallocation
65  */
66 struct b3_617_vmeresc {
67 	bus_space_handle_t handle;
68 	bus_size_t len;
69 	int firstpage, maplen;
70 };
71 
72 CFATTACH_DECL(btvmei, sizeof(struct b3_617_softc),
73     b3_617_match, b3_617_attach, NULL, NULL);
74 
75 static int
76 b3_617_match(parent, match, aux)
77 	struct device *parent;
78 	struct cfdata *match;
79 	void *aux;
80 {
81 	struct pci_attach_args *pa = aux;
82 
83 	if ((PCI_VENDOR(pa->pa_id) != PCI_VENDOR_BIT3)
84 	    || (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_BIT3_PCIVME617))
85 		return (0);
86 	return (1);
87 }
88 
89 static void
90 b3_617_attach(parent, self, aux)
91 	struct device *parent, *self;
92 	void *aux;
93 {
94 	struct b3_617_softc *sc = (struct b3_617_softc*)self;
95 	struct pci_attach_args *pa = aux;
96 	pci_chipset_tag_t pc = pa->pa_pc;
97 
98 	int rev;
99 
100 	pci_intr_handle_t ih;
101 	const char *intrstr;
102 	struct vmebus_attach_args vaa;
103 
104 	sc->sc_pc = pc;
105 	sc->sc_dmat = pa->pa_dmat;
106 
107 	rev = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
108 	printf(": BIT3 PCI-VME 617 rev %d\n", rev);
109 
110 	/*
111 	 * Map CSR and mapping table spaces.
112 	 * Don't map VME window; parts are mapped as needed to
113 	 * save kernel virtual memory space
114 	 */
115 	if (pci_mapreg_map(pa, 0x14,
116 			   PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
117 			   0, &sc->csrt, &sc->csrh, NULL, NULL) &&
118 	    pci_mapreg_map(pa, 0x10,
119 			   PCI_MAPREG_TYPE_IO,
120 			   0, &sc->csrt, &sc->csrh, NULL, NULL)) {
121 		printf("%s: can't map CSR space\n", self->dv_xname);
122 		return;
123 	}
124 
125 	if (pci_mapreg_map(pa, 0x18,
126 			   PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
127 			   0, &sc->mapt, &sc->maph, NULL, NULL)) {
128 		printf("%s: can't map map space\n", self->dv_xname);
129 		return;
130 	}
131 
132 	if (pci_mapreg_info(pc, pa->pa_tag, 0x1c,
133 			    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
134 			    &sc->vmepbase, 0, 0)) {
135 		printf("%s: can't get VME range\n", self->dv_xname);
136 		return;
137 	}
138 	sc->sc_vmet = pa->pa_memt; /* XXX needed for VME mappings */
139 
140 	/* Map and establish the interrupt. */
141 	if (pci_intr_map(pa, &ih)) {
142 		printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
143 		return;
144 	}
145 	intrstr = pci_intr_string(pc, ih);
146 	/*
147 	 * Use a low interrupt level (the lowest?).
148 	 * We will raise before calling a subdevice's handler.
149 	 */
150 	sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, b3_617_intr, sc);
151 	if (sc->sc_ih == NULL) {
152 		printf("%s: couldn't establish interrupt",
153 		       sc->sc_dev.dv_xname);
154 		if (intrstr != NULL)
155 			printf(" at %s", intrstr);
156 		printf("\n");
157 		return;
158 	}
159 	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
160 
161 	if (b3_617_init(sc))
162 		return;
163 
164 	/*
165 	 * set up all the tags for use by VME devices
166 	 */
167 	sc->sc_vct.cookie = self;
168 	sc->sc_vct.vct_probe = b3_617_vme_probe;
169 	sc->sc_vct.vct_map = b3_617_map_vme;
170 	sc->sc_vct.vct_unmap = b3_617_unmap_vme;
171 	sc->sc_vct.vct_int_map = b3_617_map_vmeint;
172 	sc->sc_vct.vct_int_establish = b3_617_establish_vmeint;
173 	sc->sc_vct.vct_int_disestablish = b3_617_disestablish_vmeint;
174 	sc->sc_vct.vct_dmamap_create = b3_617_dmamap_create;
175 	sc->sc_vct.vct_dmamap_destroy = b3_617_dmamap_destroy;
176 	sc->sc_vct.vct_dmamem_alloc = b3_617_dmamem_alloc;
177 	sc->sc_vct.vct_dmamem_free = b3_617_dmamem_free;
178 
179 	vaa.va_vct = &(sc->sc_vct);
180 	vaa.va_bdt = pa->pa_dmat;
181 	vaa.va_slaveconfig = b3_617_slaveconfig;
182 
183 	sc->csrwindow.offset = -1;
184 	sc->dmawindow24.offset = -1;
185 	sc->dmawindow32.offset = -1;
186 	config_found(self, &vaa, 0);
187 }
188 
189 #ifdef notyet
190 static int
191 b3_617_detach(dev)
192 	struct device *dev;
193 {
194 	struct b3_617_softc *sc = (struct b3_617_softc *)dev;
195 
196 	b3_617_halt(sc);
197 
198 	if (sc->sc_ih)
199 		pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
200 
201 	bus_space_unmap(sc->sc_bc, sc->csrbase, 32);
202 	bus_space_unmap(sc->sc_bc, sc->mapbase, 64*1024);
203 
204 	return(0);
205 }
206 #endif
207 
208 void
209 b3_617_slaveconfig(dev, va)
210 	struct device *dev;
211 	struct vme_attach_args *va;
212 {
213 	struct b3_617_softc *sc = (struct b3_617_softc *)dev;
214 	vme_chipset_tag_t vmect;
215 	int i, res;
216 	char *name = 0; /* XXX gcc! */
217 
218 	vmect = &sc->sc_vct;
219 	if (!va)
220 		goto freeit;
221 
222 #ifdef DIAGNOSTIC
223 	if (vmect != va->va_vct)
224 		panic("pcivme_slaveconfig: chipset tag?");
225 #endif
226 
227 	for (i = 0; i < va->numcfranges; i++) {
228 		res = vme_space_alloc(vmect, va->r[i].offset,
229 				      va->r[i].size, va->r[i].am);
230 		if (res)
231 			panic("%s: can't alloc slave window %x/%x/%x",
232 			       dev->dv_xname, va->r[i].offset,
233 			       va->r[i].size, va->r[i].am);
234 
235 		switch (va->r[i].am & VME_AM_ADRSIZEMASK) {
236 			/* structure assignments! */
237 		    case VME_AM_A16:
238 			sc->csrwindow = va->r[i];
239 			name = "VME CSR";
240 			break;
241 		    case VME_AM_A24:
242 			sc->dmawindow24 = va->r[i];
243 			name = "A24 DMA";
244 			break;
245 		    case VME_AM_A32:
246 			sc->dmawindow32 = va->r[i];
247 			name = "A32 DMA";
248 			break;
249 		}
250 		printf("%s: %s window: %x-%x\n", dev->dv_xname,
251 		       name, va->r[i].offset,
252 		       va->r[i].offset + va->r[i].size - 1);
253 	}
254 	return;
255 
256 freeit:
257 	if (sc->csrwindow.offset != -1)
258 		vme_space_free(vmect, sc->csrwindow.offset,
259 			       sc->csrwindow.size, sc->csrwindow.am);
260 	if (sc->dmawindow32.offset != -1)
261 		vme_space_free(vmect, sc->dmawindow32.offset,
262 			       sc->dmawindow32.size, sc->dmawindow32.am);
263 	if (sc->dmawindow24.offset != -1)
264 		vme_space_free(vmect, sc->dmawindow24.offset,
265 			       sc->dmawindow24.size, sc->dmawindow24.am);
266 }
267 
268 int
269 b3_617_reset(sc)
270 	struct b3_617_softc *sc;
271 {
272 	unsigned char status;
273 
274 	/* reset sequence, ch 5.2 */
275 	status = read_csr_byte(sc, LOC_STATUS);
276 	if (status & LSR_NO_CONNECT) {
277 		printf("%s: not connected\n", sc->sc_dev.dv_xname);
278 		return (-1);
279 	}
280 	status = read_csr_byte(sc, REM_STATUS); /* discard */
281 	write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
282 	status = read_csr_byte(sc, LOC_STATUS);
283 	if (status & LSR_CERROR_MASK) {
284 		char sbuf[sizeof(BIT3_LSR_BITS) + 64];
285 
286 		bitmask_snprintf(status, BIT3_LSR_BITS, sbuf, sizeof(sbuf));
287 		printf("%s: interface error, lsr=%s\n", sc->sc_dev.dv_xname,
288 		       sbuf);
289 		return (-1);
290 	}
291 	return (0);
292 }
293 
294 int
295 b3_617_init(sc)
296 	struct b3_617_softc *sc;
297 {
298 	unsigned int i;
299 
300 	if (b3_617_reset(sc))
301 		return (-1);
302 
303 	/* all maps invalid */
304 	for (i = MR_PCI_VME; i < MR_PCI_VME + MR_PCI_VME_SIZE; i += 4)
305 		write_mapmem(sc, i, MR_RAM_INVALID);
306 	for (i = MR_VME_PCI; i < MR_VME_PCI + MR_VME_PCI_SIZE; i += 4)
307 		write_mapmem(sc, i, MR_RAM_INVALID);
308 	for (i = MR_DMA_PCI; i < MR_DMA_PCI + MR_DMA_PCI_SIZE; i += 4)
309 		write_mapmem(sc, i, MR_RAM_INVALID);
310 
311 	/*
312 	 * set up scatter page allocation control
313 	 */
314 	sc->vmeext = extent_create("pcivme", MR_PCI_VME,
315 				   MR_PCI_VME + MR_PCI_VME_SIZE - 1, M_DEVBUF,
316 				   sc->vmemap, sizeof(sc->vmemap),
317 				   EX_NOCOALESCE);
318 #if 0
319 	sc->pciext = extent_create("vmepci", MR_VME_PCI,
320 				   MR_VME_PCI + MR_VME_PCI_SIZE - 1, M_DEVBUF,
321 				   sc->pcimap, sizeof(sc->pcimap),
322 				   EX_NOCOALESCE);
323 	sc->dmaext = extent_create("dmapci", MR_DMA_PCI,
324 				   MR_DMA_PCI + MR_DMA_PCI_SIZE - 1, M_DEVBUF,
325 				   sc->dmamap, sizeof(sc->dmamap),
326 				   EX_NOCOALESCE);
327 #endif
328 
329 	/*
330 	 * init int handler queue,
331 	 * enable interrupts if PCI interrupt available
332 	 */
333 	TAILQ_INIT(&(sc->intrhdls));
334 	sc->strayintrs = 0;
335 
336 	if (sc->sc_ih)
337 		write_csr_byte(sc, LOC_INT_CTRL, LIC_INT_ENABLE);
338 	/* no error ints */
339 	write_csr_byte(sc, REM_CMD2, 0); /* enables VME IRQ */
340 
341 	return (0);
342 }
343 
344 #ifdef notyet /* for detach */
345 void
346 b3_617_halt(sc)
347 	struct b3_617_softc *sc;
348 {
349 	/*
350 	 * because detach code checks for existence of children,
351 	 * all ressources (mappings, VME IRQs, DMA requests)
352 	 * should be deallocated at this point
353 	 */
354 
355 	/* disable IRQ */
356 	write_csr_byte(sc, LOC_INT_CTRL, 0);
357 }
358 #endif
359 
360 static void
361 b3_617_vmeintr(sc, lstat)
362 	struct b3_617_softc *sc;
363 	unsigned char lstat;
364 {
365 	int level;
366 
367 	for (level = 7; level >= 1; level--) {
368 		unsigned char vector;
369 		struct b3_617_vmeintrhand *ih;
370 		int found;
371 
372 		if (!(lstat & (1 << level)))
373 			continue;
374 
375 		write_csr_byte(sc, REM_CMD1, level);
376 		vector = read_csr_byte(sc, REM_IACK);
377 
378 		found = 0;
379 
380 		for (ih = sc->intrhdls.tqh_first; ih;
381 		     ih = ih->ih_next.tqe_next) {
382 			if ((ih->ih_level == level) &&
383 			    ((ih->ih_vector == -1) ||
384 			     (ih->ih_vector == vector))) {
385 				int s, res;
386 				/*
387 				 * We should raise the interrupt level
388 				 * to ih->ih_prior here. How to do this
389 				 * machine-independantly?
390 				 * To be safe, raise to the maximum.
391 				 */
392 				s = splhigh();
393 				found |= (res = (*(ih->ih_fun))(ih->ih_arg));
394 				splx(s);
395 				if (res)
396 					ih->ih_count++;
397 				if (res == 1)
398 					break;
399 			}
400 		}
401 		if (!found)
402 			sc->strayintrs++;
403 	}
404 }
405 
406 #define sc ((struct b3_617_softc*)vsc)
407 
408 int
409 b3_617_map_vme(vsc, vmeaddr, len, am, datasizes, swap, tag, handle, resc)
410 	void *vsc;
411 	vme_addr_t vmeaddr;
412 	vme_size_t len;
413 	vme_am_t am;
414 	vme_datasize_t datasizes;
415 	vme_swap_t swap;
416 	bus_space_tag_t *tag;
417 	bus_space_handle_t *handle;
418 	vme_mapresc_t *resc;
419 {
420 	vme_addr_t vmebase, vmeend, va;
421 	unsigned long maplen, first, i;
422 	u_int32_t mapreg;
423 	bus_addr_t pcibase;
424 	int res;
425 	struct b3_617_vmeresc *r;
426 
427 	/* first mapped address */
428 	vmebase = vmeaddr & ~(VME_PAGESIZE - 1);
429 	/* base of last mapped page */
430 	vmeend = (vmeaddr + len - 1) & ~(VME_PAGESIZE - 1);
431 	/* bytes in scatter table required */
432 	maplen = ((vmeend - vmebase) / VME_PAGESIZE + 1) * 4;
433 
434 	if (extent_alloc(sc->vmeext, maplen, 4, 0, EX_FAST, &first))
435 		return (ENOMEM);
436 
437 	/*
438 	 * set up adapter mapping registers
439 	 */
440 	mapreg = (am << MR_AMOD_SHIFT) | MR_FC_RRAM | swap;
441 
442 	for (i = first, va = vmebase;
443 	     i < first + maplen;
444 	     i += 4, va += VME_PAGESIZE) {
445 		write_mapmem(sc, i, mapreg | va);
446 #ifdef BIT3DEBUG
447 		printf("mapreg@%lx=%x\n", i, read_mapmem(sc, i));
448 #endif
449 	}
450 
451 #ifdef DIAGNOSTIC
452 	if (va != vmeend + VME_PAGESIZE)
453 		panic("b3_617_map_pci_vme: botch");
454 #endif
455 	/*
456 	 * map needed range in PCI space
457 	 */
458 	pcibase = sc->vmepbase + (first - MR_PCI_VME) / 4 * VME_PAGESIZE
459 	    + (vmeaddr & (VME_PAGESIZE - 1));
460 
461 	if ((res = bus_space_map(sc->sc_vmet, pcibase, len, 0, handle))) {
462 		for (i = first; i < first + maplen; i += 4)
463 			write_mapmem(sc, i, MR_RAM_INVALID);
464 		extent_free(sc->vmeext, first, maplen, 0);
465 		return (res);
466 	}
467 
468 	*tag = sc->sc_vmet;
469 
470 	/*
471 	 * save all data needed for later unmapping
472 	 */
473 	r = malloc(sizeof(*r), M_DEVBUF, M_NOWAIT); /* XXX check! */
474 	r->handle = *handle;
475 	r->len = len;
476 	r->firstpage = first;
477 	r->maplen = maplen;
478 	*resc = r;
479 	return (0);
480 }
481 
482 void
483 b3_617_unmap_vme(vsc, resc)
484 	void *vsc;
485 	vme_mapresc_t resc;
486 {
487 	unsigned long i;
488 	struct b3_617_vmeresc *r = resc;
489 
490 	/* unmap PCI window */
491 	bus_space_unmap(sc->sc_vmet, r->handle, r->len);
492 
493 	for (i = r->firstpage; i < r->firstpage + r->maplen; i += 4)
494 		write_mapmem(sc, i, MR_RAM_INVALID);
495 
496 	extent_free(sc->vmeext, r->firstpage, r->maplen, 0);
497 
498 	free(r, M_DEVBUF);
499 }
500 
501 int
502 b3_617_vme_probe(vsc, addr, len, am, datasize, callback, cbarg)
503 	void *vsc;
504 	vme_addr_t addr;
505 	vme_size_t len;
506 	vme_am_t am;
507 	vme_datasize_t datasize;
508 	int (*callback) __P((void *, bus_space_tag_t, bus_space_handle_t));
509 	void *cbarg;
510 {
511 	bus_space_tag_t tag;
512 	bus_space_handle_t handle;
513 	vme_mapresc_t resc;
514 	int res, i;
515 	volatile u_int32_t dummy;
516 	int status;
517 
518 	res = b3_617_map_vme(vsc, addr, len, am, 0, 0,
519 			     &tag, &handle, &resc);
520 	if (res)
521 		return (res);
522 
523 	if (read_csr_byte(sc, LOC_STATUS) & LSR_ERROR_MASK) {
524 		printf("b3_617_vme_badaddr: error bit not clean - resetting\n");
525 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
526 	}
527 
528 	if (callback)
529 		res = (*callback)(cbarg, tag, handle);
530 	else {
531 		for (i = 0; i < len;) {
532 			switch (datasize) {
533 			    case VME_D8:
534 				dummy = bus_space_read_1(tag, handle, i);
535 				i++;
536 				break;
537 			    case VME_D16:
538 				dummy = bus_space_read_2(tag, handle, i);
539 				i += 2;
540 				break;
541 			    case VME_D32:
542 				dummy = bus_space_read_4(tag, handle, i);
543 				i += 4;
544 				break;
545 			    default:
546 				panic("b3_617_vme_probe: invalid datasize %x",
547 				      datasize);
548 			}
549 		}
550 	}
551 
552 	if ((status = read_csr_byte(sc, LOC_STATUS)) & LSR_ERROR_MASK) {
553 #ifdef BIT3DEBUG
554 		printf("b3_617_vme_badaddr: caught error %x\n", status);
555 #endif
556 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
557 		res = EIO;
558 	}
559 
560 	b3_617_unmap_vme(vsc, resc);
561 	return (res);
562 }
563 
564 int
565 b3_617_map_vmeint(vsc, level, vector, handlep)
566 	void *vsc;
567 	int level, vector;
568 	vme_intr_handle_t *handlep;
569 {
570 	if (!sc->sc_ih) {
571 		printf("%s: b3_617_map_vmeint: no IRQ\n",
572 		       sc->sc_dev.dv_xname);
573 		return (ENXIO);
574 	}
575 	/*
576 	 * We should check whether the interface can pass this interrupt
577 	 * level at all, but we don't know much about the jumper setting.
578 	 */
579 	*handlep = (void *)(long)((level << 8) | vector); /* XXX */
580 	return (0);
581 }
582 
583 void *
584 b3_617_establish_vmeint(vsc, handle, prior, func, arg)
585 	void *vsc;
586 	vme_intr_handle_t handle;
587 	int prior;
588 	int (*func) __P((void *));
589 	void *arg;
590 {
591 	struct b3_617_vmeintrhand *ih;
592 	long lv;
593 	int s;
594 
595 	/* no point in sleeping unless someone can free memory. */
596 	ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
597 	if (ih == NULL)
598 		panic("b3_617_map_vmeint: can't malloc handler info");
599 
600 	lv = (long)handle; /* XXX */
601 
602 	ih->ih_fun = func;
603 	ih->ih_arg = arg;
604 	ih->ih_level = lv >> 8;
605 	ih->ih_vector = lv & 0xff;
606 	ih->ih_prior = prior;
607 	ih->ih_count = 0;
608 
609 	s = splhigh();
610 	TAILQ_INSERT_TAIL(&(sc->intrhdls), ih, ih_next);
611 	splx(s);
612 
613 	return (ih);
614 }
615 
616 void
617 b3_617_disestablish_vmeint(vsc, cookie)
618 	void *vsc;
619 	void *cookie;
620 {
621 	struct b3_617_vmeintrhand *ih = cookie;
622 	int s;
623 
624 	if (!ih) {
625 		printf("b3_617_unmap_vmeint: NULL arg\n");
626 		return;
627 	}
628 
629 	s = splhigh();
630 	TAILQ_REMOVE(&(sc->intrhdls), ih, ih_next);
631 	splx(s);
632 
633 	free(ih, M_DEVBUF);
634 }
635 
636 int
637 b3_617_intr(vsc)
638 	void *vsc;
639 {
640 	int handled = 0;
641 
642 	/* follows ch. 5.5.5 (reordered for speed) */
643 	while (read_csr_byte(sc, LOC_INT_CTRL) & LIC_INT_PENDING) {
644 		unsigned char lstat;
645 
646 		handled = 1;
647 
648 		/* no error interrupts! */
649 
650 		lstat = read_csr_byte(sc, LDMA_CMD);
651 		if ((lstat & LDC_DMA_DONE) && (lstat & LDC_DMA_INT_ENABLE)) {
652 			/* DMA done indicator flag */
653 			write_csr_byte(sc, LDMA_CMD, lstat & (~LDC_DMA_DONE));
654 #if 0
655 			b3_617_cntlrdma_done(sc);
656 #endif
657 			continue;
658 		}
659 
660 		lstat = read_csr_byte(sc, LOC_INT_STATUS);
661 		if (lstat & LIS_CINT_MASK) {
662 			/* VME backplane interrupt, ch. 5.5.3 */
663 			b3_617_vmeintr(sc, lstat);
664 		}
665 
666 		/* for now, ignore "mailbox interrupts" */
667 
668 		lstat = read_csr_byte(sc, LOC_STATUS);
669 		if (lstat & LSR_PR_STATUS) {
670 			/* PR interrupt received from REMOTE  */
671 			write_csr_byte(sc, LOC_CMD1, LC1_CLR_PR_INT);
672 			continue;
673 		}
674 
675 		lstat = read_csr_byte(sc, REM_STATUS);
676 		if (lstat & RSR_PT_STATUS) {
677 			/* PT interrupt is set */
678 			write_csr_byte(sc, REM_CMD1, RC1_CLR_PT_INT);
679 			continue;
680 		}
681 	}
682 	return (handled);
683 }
684 
685 int
686 b3_617_dmamap_create(vsc, len, am, datasize, swap,
687 		   nsegs, segsz, bound,
688 		   flags, mapp)
689 	void *vsc;
690 	vme_size_t len;
691 	vme_am_t am;
692 	vme_datasize_t datasize;
693 	vme_swap_t swap;
694 	int nsegs;
695 	vme_size_t segsz;
696 	vme_addr_t bound;
697 	int flags;
698 	bus_dmamap_t *mapp;
699 {
700 	return (EINVAL);
701 }
702 
703 void
704 b3_617_dmamap_destroy(vsc, map)
705 	void *vsc;
706 	bus_dmamap_t map;
707 {
708 }
709 
710 int
711 b3_617_dmamem_alloc(vsc, len, am, datasizes, swap,
712 		    segs, nsegs, rsegs, flags)
713 	void *vsc;
714 	vme_size_t len;
715 	vme_am_t am;
716 	vme_datasize_t datasizes;
717 	vme_swap_t swap;
718 	bus_dma_segment_t *segs;
719 	int nsegs;
720 	int *rsegs;
721 	int flags;
722 {
723 	return (EINVAL);
724 }
725 
726 void
727 b3_617_dmamem_free(vsc, segs, nsegs)
728 	void *vsc;
729 	bus_dma_segment_t *segs;
730 	int nsegs;
731 {
732 }
733 
734 #undef sc
735