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