tcbus.c revision 1.17 1 /* $NetBSD: tcbus.c,v 1.17 2003/12/13 23:04:38 ad Exp $ */
2
3 /*
4 * Copyright (c) 1999, 2000 Tohru Nishimura. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Tohru Nishimura
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 __KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.17 2003/12/13 23:04:38 ad Exp $");
35
36 /*
37 * Which system models were configured?
38 */
39 #include "opt_dec_3max.h"
40 #include "opt_dec_3min.h"
41 #include "opt_dec_maxine.h"
42 #include "opt_dec_3maxplus.h"
43
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/device.h>
47
48 #include <machine/autoconf.h>
49 #include <machine/sysconf.h>
50
51 #define _PMAX_BUS_DMA_PRIVATE
52 #include <machine/bus.h>
53
54 #include <dev/tc/tcvar.h>
55 #include <pmax/pmax/pmaxtype.h>
56
57 static const struct evcnt *tc_ds_intr_evcnt __P((struct device *, void *));
58 static void tc_ds_intr_establish __P((struct device *, void *,
59 int, int (*)(void *), void *));
60 static void tc_ds_intr_disestablish __P((struct device *, void *));
61 static bus_dma_tag_t tc_ds_get_dma_tag __P((int));
62
63 extern struct tcbus_attach_args kn02_tc_desc[]; /* XXX */
64 extern struct tcbus_attach_args kmin_tc_desc[]; /* XXX */
65 extern struct tcbus_attach_args xine_tc_desc[]; /* XXX */
66 extern struct tcbus_attach_args kn03_tc_desc[]; /* XXX */
67
68 static int tcbus_match __P((struct device *, struct cfdata *, void *));
69 static void tcbus_attach __P((struct device *, struct device *, void *));
70
71 CFATTACH_DECL(tcbus, sizeof(struct tc_softc),
72 tcbus_match, tcbus_attach, NULL, NULL);
73
74 static int tcbus_found;
75
76 static int
77 tcbus_match(parent, cfdata, aux)
78 struct device *parent;
79 struct cfdata *cfdata;
80 void *aux;
81 {
82 struct mainbus_attach_args *ma = aux;
83
84 if (tcbus_found || strcmp(ma->ma_name, "tcbus"))
85 return 0;
86
87 return 1;
88 }
89
90 static void
91 tcbus_attach(parent, self, aux)
92 struct device *parent, *self;
93 void *aux;
94 {
95 struct tcbus_attach_args *tba;
96
97 tcbus_found = 1;
98
99 switch (systype) {
100 #ifdef DEC_3MAX
101 case DS_3MAX:
102 tba = &kn02_tc_desc[0]; break;
103 #endif
104 #ifdef DEC_3MIN
105 case DS_3MIN:
106 tba = &kmin_tc_desc[0]; break;
107 #endif
108 #ifdef DEC_MAXINE
109 case DS_MAXINE:
110 tba = &xine_tc_desc[0]; break;
111 #endif
112 #ifdef DEC_3MAXPLUS
113 case DS_3MAXPLUS:
114 tba = &kn03_tc_desc[0]; break;
115 #endif
116 default:
117 panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype);
118 }
119
120 tba->tba_busname = "tc";
121 tba->tba_memt = 0;
122 tba->tba_intr_evcnt = tc_ds_intr_evcnt;
123 tba->tba_intr_establish = tc_ds_intr_establish;
124 tba->tba_intr_disestablish = tc_ds_intr_disestablish;
125 tba->tba_get_dma_tag = tc_ds_get_dma_tag;
126
127 tcattach(parent, self, tba);
128 }
129
130 /*
131 * Dispatch to model specific interrupt line evcnt fetch rontine
132 */
133 static const struct evcnt *
134 tc_ds_intr_evcnt(dev, cookie)
135 struct device *dev;
136 void *cookie;
137 {
138
139 /* XXX for now, no evcnt parent reported */
140 return NULL;
141 }
142
143 /*
144 * Dispatch to model specific interrupt establishing routine
145 */
146 static void
147 tc_ds_intr_establish(dev, cookie, level, handler, val)
148 struct device *dev;
149 void *cookie;
150 int level;
151 int (*handler) __P((void *));
152 void *val;
153 {
154
155 (*platform.intr_establish)(dev, cookie, level, handler, val);
156 }
157
158 static void
159 tc_ds_intr_disestablish(dev, arg)
160 struct device *dev;
161 void *arg;
162 {
163
164 printf("cannot disestablish TC interrupts\n");
165 }
166
167 /*
168 * Return the DMA tag for use by the specified TURBOchannel slot.
169 */
170 static bus_dma_tag_t
171 tc_ds_get_dma_tag(slot)
172 int slot;
173 {
174 /*
175 * All DECstations use the default DMA tag.
176 */
177 return (&pmax_default_bus_dma_tag);
178 }
179
180 #ifdef WSCONS
181
182 #include "wsdisplay.h"
183
184 #if NWSDISPLAY > 0
185
186 #include "sfb.h"
187 /* #include "sfbp.h" */
188 #include "cfb.h"
189 #include "mfb.h"
190 #include "tfb.h"
191 #include "xcfb.h"
192 #include "px.h"
193 #include "pxg.h"
194
195 #include <pmax/pmax/cons.h>
196 #include <machine/dec_prom.h>
197
198 int tc_checkslot __P((tc_addr_t, char *));
199
200 struct cnboards {
201 const char *cb_tcname;
202 void (*cb_cnattach)(tc_addr_t);
203 } static const cnboards[] = {
204 #if NXCFB > 0
205 { "PMAG-DV ", xcfb_cnattach },
206 #endif
207 #if NSFB > 0
208 { "PMAGB-BA", sfb_cnattach },
209 #endif
210 #if NSFBP > 0
211 { "PMAGD ", sfbp_cnattach },
212 #endif
213 #if NCFB > 0
214 { "PMAG-BA ", cfb_cnattach },
215 #endif
216 #if NMFB > 0
217 { "PMAG-AA ", mfb_cnattach },
218 #endif
219 #if NTFB > 0
220 { "PMAG-JA ", tfb_cnattach },
221 #endif
222 #if NPX > 0
223 { "PMAG-CA ", px_cnattach },
224 #endif
225 #if NPXG > 0
226 { "PMAG-DA ", pxg_cnattach },
227 { "PMAG-FA ", pxg_cnattach },
228 { "PMAG-FB ", pxg_cnattach },
229 { "PMAGB-FA", pxg_cnattach },
230 { "PMAGB-FB", pxg_cnattach },
231 #endif
232 };
233
234 int
235 tcfb_cnattach(slotno)
236 int slotno;
237 {
238 paddr_t tcaddr;
239 char tcname[TC_ROM_LLEN];
240 int i;
241
242 tcaddr = (*callv->_slot_address)(slotno);
243 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
244 panic("TC console designated by PROM does not exist!?");
245
246 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
247 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
248 break;
249
250 if (i == sizeof(cnboards) / sizeof(cnboards[0]))
251 return (0);
252
253 (cnboards[i].cb_cnattach)(tcaddr);
254 return (1);
255 }
256
257 #endif /* NWSDISPLAY */
258
259 #else /* WSCONS */
260
261 #include "rasterconsole.h"
262
263 #if NRASTERCONSOLE > 0
264
265 #include "mfb.h"
266 #include "cfb.h"
267 #include "sfb.h"
268 #include "px.h"
269
270 #include <machine/pmioctl.h> /* XXX */
271 #include <dev/sun/fbio.h> /* XXX */
272 #include <machine/fbvar.h> /* XXX */
273 #include <pmax/dev/fbreg.h> /* XXX */
274 #include <pmax/dev/cfbvar.h>
275 #include <pmax/dev/mfbvar.h>
276 #include <pmax/dev/sfbvar.h>
277 #include <pmax/dev/pxreg.h>
278 #include <pmax/dev/pxvar.h>
279
280 #include <machine/dec_prom.h>
281
282 int
283 tcfb_cnattach(slotno)
284 int slotno;
285 {
286 paddr_t tcaddr;
287 char tcname[TC_ROM_LLEN];
288
289 tcaddr = (*callv->_slot_address)(slotno);
290 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
291 panic("TC console designated by PROM does not exist!?");
292
293 #if NSFB > 0
294 if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
295 return sfb_cnattach(tcaddr);
296 }
297 #endif
298 #if NCFB > 0
299 if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
300 return cfb_cnattach(tcaddr);
301 }
302 #endif
303 #if NMFB > 0
304 if (strncmp("PMAG-AA ", tcname, TC_ROM_LLEN) == 0) {
305 return mfb_cnattach(tcaddr);
306 }
307 #endif
308 #if NPX > 0
309 if (strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
310 || strncmp("PMAG-DA ", tcname, TC_ROM_LLEN) == 0
311 || strncmp("PMAG-FA ", tcname, TC_ROM_LLEN) == 0) {
312 int px_cnattach __P((paddr_t)); /* XXX much simpler XXX */
313
314 return px_cnattach(tcaddr);
315 }
316 #endif
317 return 0;
318 }
319
320 #endif /* NRASTERCONSOLE */
321
322 #endif /* WSCONS */
323