1 /* $NetBSD: vme_two_68k.c,v 1.1 2002/02/12 20:38:31 scw 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 int vmetwo_match __P((struct device *, struct cfdata *, void *)); 64 void vmetwo_attach __P((struct device *, struct device *, void *)); 65 66 struct cfattach vmetwo_ca = { 67 sizeof(struct vmetwo_softc), vmetwo_match, vmetwo_attach 68 }; 69 struct cfdriver vmetwo_cd; 70 71 static void vmetwoisrlink(void *, int (*)(void *), void *, 72 int, int, struct evcnt *); 73 static void vmetwoisrunlink(void *, int); 74 static struct evcnt *vmetwoisrevcnt(void *, int); 75 76 77 /* ARGSUSED */ 78 int 79 vmetwo_match(parent, cf, aux) 80 struct device *parent; 81 struct cfdata *cf; 82 void *aux; 83 { 84 struct mainbus_attach_args *ma; 85 static int matched = 0; 86 87 ma = aux; 88 89 if (strcmp(ma->ma_name, vmetwo_cd.cd_name)) 90 return (0); 91 92 /* Only one VMEchip2, please. */ 93 if (matched++) 94 return (0); 95 96 /* 97 * Some mvme1[67]2 boards have a `no VMEchip2' build option... 98 */ 99 return (vmetwo_probe(ma->ma_bust, ma->ma_offset) ? 1 : 0); 100 } 101 102 /* ARGSUSED */ 103 void 104 vmetwo_attach(parent, self, aux) 105 struct device *parent; 106 struct device *self; 107 void *aux; 108 { 109 struct mainbus_attach_args *ma; 110 struct vmetwo_softc *sc; 111 112 sc = (struct vmetwo_softc *) self; 113 ma = aux; 114 115 /* 116 * Map the local control registers 117 */ 118 bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_LCSR_OFFSET, 119 VME2LCSR_SIZE, 0, &sc->sc_lcrh); 120 121 #ifdef notyet 122 /* 123 * Map the global control registers 124 */ 125 bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_GCSR_OFFSET, 126 VME2GCSR_SIZE, 0, &sc->sc_gcrh); 127 #endif 128 129 /* Initialise stuff for the common vme_two back-end */ 130 sc->sc_mvmebus.sc_bust = ma->ma_bust; 131 sc->sc_mvmebus.sc_dmat = ma->ma_dmat; 132 sc->sc_isrlink = vmetwoisrlink; 133 sc->sc_isrunlink = vmetwoisrunlink; 134 sc->sc_isrevcnt = vmetwoisrevcnt; 135 136 vmetwo_init(sc); 137 } 138 139 /* ARGSUSED */ 140 static void 141 vmetwoisrlink(cookie, fn, arg, ipl, vec, evcnt) 142 void *cookie; 143 int (*fn)(void *); 144 void *arg; 145 int ipl, vec; 146 struct evcnt *evcnt; 147 { 148 149 isrlink_vectored(fn, arg, ipl, vec, evcnt); 150 } 151 152 /* ARGSUSED */ 153 static void 154 vmetwoisrunlink(cookie, vec) 155 void *cookie; 156 int vec; 157 { 158 159 isrunlink_vectored(vec); 160 } 161 162 /* ARGSUSED */ 163 static struct evcnt * 164 vmetwoisrevcnt(cookie, ipl) 165 void *cookie; 166 int ipl; 167 { 168 169 return (isrlink_evcnt(ipl)); 170 } 171