tcbus.c revision 1.8 1 /* $NetBSD: tcbus.c,v 1.8 2000/02/03 04:09:07 nisimura 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.8 2000/02/03 04:09:07 nisimura Exp $");
35
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
39
40 #include <machine/autoconf.h>
41 #include <machine/sysconf.h>
42
43 #define _PMAX_BUS_DMA_PRIVATE
44 #include <machine/bus.h>
45
46 #include <dev/tc/tcvar.h>
47 #include <pmax/pmax/pmaxtype.h>
48
49 /*
50 * Which system models were configured?
51 */
52 #include "opt_dec_3max.h"
53 #include "opt_dec_3min.h"
54 #include "opt_dec_maxine.h"
55 #include "opt_dec_3maxplus.h"
56
57 /* XXX XXX TO BE REMOVED XXX XXX */
58 /*
59 * DECstation tc implementations dont' have a tcasic to handle interrupts,
60 * and the mapping to CPU interrupt lines is model-dependent.
61 * We have to pass TC interrupt establish/disestablish requests up to
62 * motherboard-specific code.
63 */
64 static void tc_ds_intr_establish __P((struct device *, void *,
65 int, int (*)(void *), void *));
66 static void tc_ds_intr_disestablish __P((struct device *, void *));
67 /* XXX XXX XXX XXX XXX XXX XXX */
68
69 static bus_dma_tag_t tc_ds_get_dma_tag __P((int));
70
71 extern struct tcbus_attach_args kn02_tc_desc[]; /* XXX */
72 extern struct tcbus_attach_args kmin_tc_desc[]; /* XXX */
73 extern struct tcbus_attach_args xine_tc_desc[]; /* XXX */
74 extern struct tcbus_attach_args kn03_tc_desc[]; /* XXX */
75
76 static int tcbus_match __P((struct device *, struct cfdata *, void *));
77 static void tcbus_attach __P((struct device *, struct device *, void *));
78
79 struct cfattach tcbus_ca = {
80 sizeof(struct tc_softc), tcbus_match, tcbus_attach,
81 };
82
83 static int tcbus_found;
84
85 int
86 tcbus_match(parent, cfdata, aux)
87 struct device *parent;
88 struct cfdata *cfdata;
89 void *aux;
90 {
91 struct mainbus_attach_args *ma = aux;
92
93 if (tcbus_found || strcmp(ma->ma_name, "tcbus"))
94 return 0;
95
96 return 1;
97 }
98
99 void
100 tcbus_attach(parent, self, aux)
101 struct device *parent, *self;
102 void *aux;
103 {
104 struct tcbus_attach_args *tba;
105
106 tcbus_found = 1;
107
108 switch (systype) {
109 #ifdef DEC_3MAX
110 case DS_3MAX:
111 tba = &kn02_tc_desc[0]; break;
112 #endif
113 #ifdef DEC_3MIN
114 case DS_3MIN:
115 tba = &kmin_tc_desc[0]; break;
116 #endif
117 #ifdef DEC_MAXINE
118 case DS_MAXINE:
119 tba = &xine_tc_desc[0]; break;
120 #endif
121 #ifdef DEC_3MAXPLUS
122 case DS_3MAXPLUS:
123 tba = &kn03_tc_desc[0]; break;
124 #endif
125 default:
126 panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype);
127 }
128
129 tba->tba_busname = "tc";
130 tba->tba_memt = 0;
131 tba->tba_intr_establish = tc_ds_intr_establish;
132 tba->tba_intr_disestablish = tc_ds_intr_disestablish;
133 tba->tba_get_dma_tag = tc_ds_get_dma_tag;
134
135 tcattach(parent, self, tba);
136 }
137
138 /*
139 * Return the DMA tag for use by the specified TURBOchannel slot.
140 */
141 static bus_dma_tag_t
142 tc_ds_get_dma_tag(slot)
143 int slot;
144 {
145 /*
146 * All DECstations use the default DMA tag.
147 */
148 return (&pmax_default_bus_dma_tag);
149 }
150
151 /*
152 * Establish an interrupt handler.
153 * For both TC and IOCTL asic, we must upcall to motherboard-specific
154 * interrupt-hanlder functions, in case we need to recompute masks for
155 * CPU interrupt lines.
156 */
157 static void
158 tc_ds_intr_establish(dev, cookie, level, handler, val)
159 struct device *dev;
160 void *cookie;
161 int level;
162 int (*handler) __P((void *));
163 void *val;
164 {
165
166 #ifdef DEBUG
167 printf("tc_ds_intr_establish: slot %d level %d handler %p sc %p on\n",
168 (int) cookie, (int) level, handler, val);
169 #endif
170
171 /*
172 * Enable the interrupt from tc (or ioctl asic) slot with NetBSD/pmax
173 * sw-convention name ``cookie'' on this CPU.
174 * XXX store the level somewhere for selective enabling of
175 * interrupts from TC option slots.
176 */
177 (*platform.intr_establish)(dev, cookie, level, handler, val);
178 }
179
180 static void
181 tc_ds_intr_disestablish(dev, arg)
182 struct device *dev;
183 void *arg;
184 {
185 /*(*platform.intr_disestablish)(dev, cookie, level, handler, val);*/
186 printf("cannot dis-establish IOASIC interrupts\n");
187 }
188
189 #include "rasterconsole.h"
190
191 #if NRASTERCONSOLE > 0
192
193 #include "mfb.h"
194 #include "cfb.h"
195 #include "sfb.h"
196 #include "px.h"
197
198 #include <machine/pmioctl.h> /* XXX */
199 #include <machine/fbio.h> /* XXX */
200 #include <machine/fbvar.h> /* XXX */
201 #include <pmax/dev/fbreg.h> /* XXX */
202 #include <pmax/dev/cfbvar.h>
203 #include <pmax/dev/mfbvar.h>
204 #include <pmax/dev/sfbvar.h>
205 #include <pmax/dev/pxreg.h>
206 #include <pmax/dev/pxvar.h>
207
208 #include <machine/dec_prom.h>
209
210 int
211 tcfb_cnattach(slotno)
212 int slotno;
213 {
214 paddr_t tcaddr;
215 char tcname[TC_ROM_LLEN];
216
217 tcaddr = (*callv->_slot_address)(slotno);
218 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
219 panic("TC console designated by PROM does not exist!?");
220
221 #if NSFB > 0
222 if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
223 return sfb_cnattach(tcaddr);
224 }
225 #endif
226 #if NCFB > 0
227 if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
228 return cfb_cnattach(tcaddr);
229 }
230 #endif
231 #if NMFB > 0
232 if (strncmp("PMAG-AA ", tcname, TC_ROM_LLEN) == 0) {
233 return mfb_cnattach(tcaddr);
234 }
235 #endif
236 #if NPX > 0
237 if (strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
238 || strncmp("PMAG-DA ", tcname, TC_ROM_LLEN) == 0
239 || strncmp("PMAG-FA ", tcname, TC_ROM_LLEN) == 0) {
240 int px_cnattach __P((paddr_t)); /* XXX much simpler XXX */
241
242 return px_cnattach(tcaddr);
243 }
244 #endif
245 return 0;
246 }
247
248 #endif
249