vme_two_68k.c revision 1.8 1 /* $NetBSD: vme_two_68k.c,v 1.8 2008/01/12 09:54:27 tsutsui 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 <sys/cdefs.h>
44 __KERNEL_RCSID(0, "$NetBSD: vme_two_68k.c,v 1.8 2008/01/12 09:54:27 tsutsui Exp $");
45
46 #include "vmetwo.h"
47
48 #include <sys/param.h>
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
51 #include <sys/device.h>
52
53 #include <machine/cpu.h>
54 #include <machine/bus.h>
55
56 #include <dev/vme/vmereg.h>
57 #include <dev/vme/vmevar.h>
58
59 #include <mvme68k/mvme68k/isr.h>
60 #include <mvme68k/dev/mainbus.h>
61
62 #include <dev/mvme/mvmebus.h>
63 #include <dev/mvme/vme_tworeg.h>
64 #include <dev/mvme/vme_twovar.h>
65
66 #include "ioconf.h"
67
68 static void vmetwoisrlink(void *, int (*)(void *), void *,
69 int, int, struct evcnt *);
70 static void vmetwoisrunlink(void *, int);
71 static struct evcnt *vmetwoisrevcnt(void *, int);
72
73 #if NVMETWO > 0
74
75 int vmetwo_match(struct device *, struct cfdata *, void *);
76 void vmetwo_attach(struct device *, struct device *, void *);
77
78 CFATTACH_DECL(vmetwo, sizeof(struct vmetwo_softc),
79 vmetwo_match, vmetwo_attach, NULL, NULL);
80
81
82 /* ARGSUSED */
83 int
84 vmetwo_match(struct device *parent, struct cfdata *cf, void *aux)
85 {
86 struct mainbus_attach_args *ma;
87 static int matched = 0;
88
89 ma = aux;
90
91 if (strcmp(ma->ma_name, vmetwo_cd.cd_name))
92 return 0;
93
94 /* Only one VMEchip2, please. */
95 if (matched++)
96 return 0;
97
98 /*
99 * Some mvme1[67]2 boards have a `no VMEchip2' build option...
100 */
101 return vmetwo_probe(ma->ma_bust, ma->ma_offset) ? 1 : 0;
102 }
103
104 /* ARGSUSED */
105 void
106 vmetwo_attach(struct device *parent, struct device *self, void *aux)
107 {
108 struct mainbus_attach_args *ma;
109 struct vmetwo_softc *sc;
110
111 sc = (struct vmetwo_softc *) self;
112 ma = aux;
113
114 /*
115 * Map the local control registers
116 */
117 bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_LCSR_OFFSET,
118 VME2LCSR_SIZE, 0, &sc->sc_lcrh);
119
120 #ifdef notyet
121 /*
122 * Map the global control registers
123 */
124 bus_space_map(ma->ma_bust, ma->ma_offset + VME2REG_GCSR_OFFSET,
125 VME2GCSR_SIZE, 0, &sc->sc_gcrh);
126 #endif
127
128 /* Initialise stuff for the common vme_two back-end */
129 sc->sc_mvmebus.sc_bust = ma->ma_bust;
130 sc->sc_mvmebus.sc_dmat = ma->ma_dmat;
131
132 vmetwo_init(sc);
133 }
134
135 #endif /* NVMETWO > 0 */
136
137 void
138 vmetwo_md_intr_init(struct vmetwo_softc *sc)
139 {
140
141 sc->sc_isrlink = vmetwoisrlink;
142 sc->sc_isrunlink = vmetwoisrunlink;
143 sc->sc_isrevcnt = vmetwoisrevcnt;
144 }
145
146 /* ARGSUSED */
147 static void
148 vmetwoisrlink(void *cookie, int (*fn)(void *), void *arg, int ipl, int vec,
149 struct evcnt *evcnt)
150 {
151
152 isrlink_vectored(fn, arg, ipl, vec, evcnt);
153 }
154
155 /* ARGSUSED */
156 static void
157 vmetwoisrunlink(void *cookie, int vec)
158 {
159
160 isrunlink_vectored(vec);
161 }
162
163 /* ARGSUSED */
164 static struct evcnt *
165 vmetwoisrevcnt(void *cookie, int ipl)
166 {
167
168 return isrlink_evcnt(ipl);
169 }
170