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