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