1 /* $NetBSD: vme_two_68k.c,v 1.3 2002/05/14 02:03:01 matt Exp $ */ 2 3 /*- 4 * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Steve C. Woodford. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 /* 40 * Front-end for the VMEchip2 found on the MVME-1[67][27] boards. 41 */ 42 43 #include "vmetwo.h" 44 45 #include <sys/param.h> 46 #include <sys/kernel.h> 47 #include <sys/systm.h> 48 #include <sys/device.h> 49 50 #include <machine/cpu.h> 51 #include <machine/bus.h> 52 53 #include <dev/vme/vmereg.h> 54 #include <dev/vme/vmevar.h> 55 56 #include <mvme68k/mvme68k/isr.h> 57 #include <mvme68k/dev/mainbus.h> 58 59 #include <dev/mvme/mvmebus.h> 60 #include <dev/mvme/vme_tworeg.h> 61 #include <dev/mvme/vme_twovar.h> 62 63 64 static void vmetwoisrlink(void *, int (*)(void *), void *, 65 int, int, struct evcnt *); 66 static void vmetwoisrunlink(void *, int); 67 static struct evcnt *vmetwoisrevcnt(void *, int); 68 69 #if NVMETWO > 0 70 71 int vmetwo_match __P((struct device *, struct cfdata *, void *)); 72 void vmetwo_attach __P((struct device *, struct device *, void *)); 73 74 struct cfattach vmetwo_ca = { 75 sizeof(struct vmetwo_softc), vmetwo_match, vmetwo_attach 76 }; 77 extern struct cfdriver vmetwo_cd; 78 79 80 /* ARGSUSED */ 81 int 82 vmetwo_match(parent, cf, aux) 83 struct device *parent; 84 struct cfdata *cf; 85 void *aux; 86 { 87 struct mainbus_attach_args *ma; 88 static int matched = 0; 89 90 ma = aux; 91 92 if (strcmp(ma->ma_name, vmetwo_cd.cd_name)) 93 return (0); 94 95 /* Only one VMEchip2, please. */ 96 if (matched++) 97 return (0); 98 99 /* 100 * Some mvme1[67]2 boards have a `no VMEchip2' build option... 101 */ 102 return (vmetwo_probe(ma->ma_bust, ma->ma_offset) ? 1 : 0); 103 } 104 105 /* ARGSUSED */ 106 void 107 vmetwo_attach(parent, self, aux) 108 struct device *parent; 109 struct device *self; 110 void *aux; 111 { 112 struct mainbus_attach_args *ma; 113 struct vmetwo_softc *sc; 114 115 sc = (struct vmetwo_softc *) self; 116 ma = aux; 117 118 /* 119 * Map the local control registers 120 */ 121 bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_LCSR_OFFSET, 122 VME2LCSR_SIZE, 0, &sc->sc_lcrh); 123 124 #ifdef notyet 125 /* 126 * Map the global control registers 127 */ 128 bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_GCSR_OFFSET, 129 VME2GCSR_SIZE, 0, &sc->sc_gcrh); 130 #endif 131 132 /* Initialise stuff for the common vme_two back-end */ 133 sc->sc_mvmebus.sc_bust = ma->ma_bust; 134 sc->sc_mvmebus.sc_dmat = ma->ma_dmat; 135 136 vmetwo_init(sc); 137 } 138 139 #endif /* NVMETWO > 0 */ 140 141 void 142 vmetwo_md_intr_init(sc) 143 struct vmetwo_softc *sc; 144 { 145 146 sc->sc_isrlink = vmetwoisrlink; 147 sc->sc_isrunlink = vmetwoisrunlink; 148 sc->sc_isrevcnt = vmetwoisrevcnt; 149 } 150 151 /* ARGSUSED */ 152 static void 153 vmetwoisrlink(cookie, fn, arg, ipl, vec, evcnt) 154 void *cookie; 155 int (*fn)(void *); 156 void *arg; 157 int ipl, vec; 158 struct evcnt *evcnt; 159 { 160 161 isrlink_vectored(fn, arg, ipl, vec, evcnt); 162 } 163 164 /* ARGSUSED */ 165 static void 166 vmetwoisrunlink(cookie, vec) 167 void *cookie; 168 int vec; 169 { 170 171 isrunlink_vectored(vec); 172 } 173 174 /* ARGSUSED */ 175 static struct evcnt * 176 vmetwoisrevcnt(cookie, ipl) 177 void *cookie; 178 int ipl; 179 { 180 181 return (isrlink_evcnt(ipl)); 182 } 183