tcasic.c revision 1.36.2.3 1 1.36.2.3 thorpej /* $NetBSD: tcasic.c,v 1.36.2.3 2003/01/03 16:38:42 thorpej Exp $ */
2 1.36.2.2 nathanw
3 1.36.2.2 nathanw /*
4 1.36.2.2 nathanw * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5 1.36.2.2 nathanw * All rights reserved.
6 1.36.2.2 nathanw *
7 1.36.2.2 nathanw * Author: Chris G. Demetriou
8 1.36.2.2 nathanw *
9 1.36.2.2 nathanw * Permission to use, copy, modify and distribute this software and
10 1.36.2.2 nathanw * its documentation is hereby granted, provided that both the copyright
11 1.36.2.2 nathanw * notice and this permission notice appear in all copies of the
12 1.36.2.2 nathanw * software, derivative works or modified versions, and any portions
13 1.36.2.2 nathanw * thereof, and that both notices appear in supporting documentation.
14 1.36.2.2 nathanw *
15 1.36.2.2 nathanw * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.36.2.2 nathanw * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.36.2.2 nathanw * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.36.2.2 nathanw *
19 1.36.2.2 nathanw * Carnegie Mellon requests users of this software to return to
20 1.36.2.2 nathanw *
21 1.36.2.2 nathanw * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.36.2.2 nathanw * School of Computer Science
23 1.36.2.2 nathanw * Carnegie Mellon University
24 1.36.2.2 nathanw * Pittsburgh PA 15213-3890
25 1.36.2.2 nathanw *
26 1.36.2.2 nathanw * any improvements or extensions that they make and grant Carnegie the
27 1.36.2.2 nathanw * rights to redistribute these changes.
28 1.36.2.2 nathanw */
29 1.36.2.2 nathanw
30 1.36.2.2 nathanw #include "opt_dec_3000_300.h"
31 1.36.2.2 nathanw #include "opt_dec_3000_500.h"
32 1.36.2.2 nathanw
33 1.36.2.2 nathanw #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 1.36.2.2 nathanw
35 1.36.2.3 thorpej __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.36.2.3 2003/01/03 16:38:42 thorpej Exp $");
36 1.36.2.2 nathanw
37 1.36.2.2 nathanw #include <sys/param.h>
38 1.36.2.2 nathanw #include <sys/systm.h>
39 1.36.2.2 nathanw #include <sys/device.h>
40 1.36.2.2 nathanw
41 1.36.2.2 nathanw #include <machine/autoconf.h>
42 1.36.2.2 nathanw #include <machine/rpb.h>
43 1.36.2.2 nathanw #include <machine/alpha.h>
44 1.36.2.2 nathanw
45 1.36.2.2 nathanw #include <dev/tc/tcvar.h>
46 1.36.2.2 nathanw #include <alpha/tc/tc_conf.h>
47 1.36.2.2 nathanw
48 1.36.2.2 nathanw /* Definition of the driver for autoconfig. */
49 1.36.2.2 nathanw int tcasicmatch(struct device *, struct cfdata *, void *);
50 1.36.2.2 nathanw void tcasicattach(struct device *, struct device *, void *);
51 1.36.2.2 nathanw
52 1.36.2.2 nathanw CFATTACH_DECL(tcasic, sizeof (struct device),
53 1.36.2.2 nathanw tcasicmatch, tcasicattach, NULL, NULL);
54 1.36.2.2 nathanw
55 1.36.2.2 nathanw extern struct cfdriver tcasic_cd;
56 1.36.2.2 nathanw
57 1.36.2.2 nathanw int tcasicprint __P((void *, const char *));
58 1.36.2.2 nathanw
59 1.36.2.2 nathanw /* There can be only one. */
60 1.36.2.2 nathanw int tcasicfound;
61 1.36.2.2 nathanw
62 1.36.2.2 nathanw int
63 1.36.2.2 nathanw tcasicmatch(parent, cfdata, aux)
64 1.36.2.2 nathanw struct device *parent;
65 1.36.2.2 nathanw struct cfdata *cfdata;
66 1.36.2.2 nathanw void *aux;
67 1.36.2.2 nathanw {
68 1.36.2.2 nathanw struct mainbus_attach_args *ma = aux;
69 1.36.2.2 nathanw
70 1.36.2.2 nathanw /* Make sure that we're looking for a TurboChannel ASIC. */
71 1.36.2.2 nathanw if (strcmp(ma->ma_name, tcasic_cd.cd_name))
72 1.36.2.2 nathanw return (0);
73 1.36.2.2 nathanw
74 1.36.2.2 nathanw /* Make sure that the system supports a TurboChannel ASIC. */
75 1.36.2.2 nathanw if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
76 1.36.2.2 nathanw return (0);
77 1.36.2.2 nathanw
78 1.36.2.2 nathanw if (tcasicfound)
79 1.36.2.2 nathanw return (0);
80 1.36.2.2 nathanw
81 1.36.2.2 nathanw return (1);
82 1.36.2.2 nathanw }
83 1.36.2.2 nathanw
84 1.36.2.2 nathanw void
85 1.36.2.2 nathanw tcasicattach(parent, self, aux)
86 1.36.2.2 nathanw struct device *parent;
87 1.36.2.2 nathanw struct device *self;
88 1.36.2.2 nathanw void *aux;
89 1.36.2.2 nathanw {
90 1.36.2.2 nathanw struct tcbus_attach_args tba;
91 1.36.2.2 nathanw void (*intr_setup) __P((void));
92 1.36.2.2 nathanw void (*iointr) __P((void *, unsigned long));
93 1.36.2.2 nathanw
94 1.36.2.2 nathanw printf("\n");
95 1.36.2.2 nathanw tcasicfound = 1;
96 1.36.2.2 nathanw
97 1.36.2.2 nathanw switch (cputype) {
98 1.36.2.2 nathanw #ifdef DEC_3000_500
99 1.36.2.2 nathanw case ST_DEC_3000_500:
100 1.36.2.2 nathanw
101 1.36.2.2 nathanw intr_setup = tc_3000_500_intr_setup;
102 1.36.2.2 nathanw iointr = tc_3000_500_iointr;
103 1.36.2.2 nathanw
104 1.36.2.2 nathanw tba.tba_speed = TC_SPEED_25_MHZ;
105 1.36.2.2 nathanw tba.tba_nslots = tc_3000_500_nslots;
106 1.36.2.2 nathanw tba.tba_slots = tc_3000_500_slots;
107 1.36.2.2 nathanw if (hwrpb->rpb_variation & SV_GRAPHICS) {
108 1.36.2.2 nathanw tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
109 1.36.2.2 nathanw tba.tba_builtins = tc_3000_500_graphics_builtins;
110 1.36.2.2 nathanw } else {
111 1.36.2.2 nathanw tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
112 1.36.2.2 nathanw tba.tba_builtins = tc_3000_500_nographics_builtins;
113 1.36.2.2 nathanw }
114 1.36.2.2 nathanw tba.tba_intr_evcnt = tc_3000_500_intr_evcnt;
115 1.36.2.2 nathanw tba.tba_intr_establish = tc_3000_500_intr_establish;
116 1.36.2.2 nathanw tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
117 1.36.2.2 nathanw tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
118 1.36.2.2 nathanw
119 1.36.2.2 nathanw /* Do 3000/500-specific DMA setup now. */
120 1.36.2.2 nathanw tc_dma_init_3000_500(tc_3000_500_nslots);
121 1.36.2.2 nathanw break;
122 1.36.2.2 nathanw #endif /* DEC_3000_500 */
123 1.36.2.2 nathanw
124 1.36.2.2 nathanw #ifdef DEC_3000_300
125 1.36.2.2 nathanw case ST_DEC_3000_300:
126 1.36.2.2 nathanw
127 1.36.2.2 nathanw intr_setup = tc_3000_300_intr_setup;
128 1.36.2.2 nathanw iointr = tc_3000_300_iointr;
129 1.36.2.2 nathanw
130 1.36.2.2 nathanw tba.tba_speed = TC_SPEED_12_5_MHZ;
131 1.36.2.2 nathanw tba.tba_nslots = tc_3000_300_nslots;
132 1.36.2.2 nathanw tba.tba_slots = tc_3000_300_slots;
133 1.36.2.2 nathanw tba.tba_nbuiltins = tc_3000_300_nbuiltins;
134 1.36.2.2 nathanw tba.tba_builtins = tc_3000_300_builtins;
135 1.36.2.2 nathanw tba.tba_intr_evcnt = tc_3000_300_intr_evcnt;
136 1.36.2.2 nathanw tba.tba_intr_establish = tc_3000_300_intr_establish;
137 1.36.2.2 nathanw tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
138 1.36.2.2 nathanw tba.tba_get_dma_tag = tc_dma_get_tag_3000_300;
139 1.36.2.2 nathanw break;
140 1.36.2.2 nathanw #endif /* DEC_3000_300 */
141 1.36.2.2 nathanw
142 1.36.2.2 nathanw default:
143 1.36.2.2 nathanw panic("tcasicattach: bad cputype");
144 1.36.2.2 nathanw }
145 1.36.2.2 nathanw
146 1.36.2.2 nathanw tba.tba_busname = "tc";
147 1.36.2.2 nathanw tba.tba_memt = tc_bus_mem_init(NULL);
148 1.36.2.2 nathanw
149 1.36.2.2 nathanw tc_dma_init();
150 1.36.2.2 nathanw
151 1.36.2.2 nathanw (*intr_setup)();
152 1.36.2.2 nathanw
153 1.36.2.2 nathanw /* They all come in at 0x800. */
154 1.36.2.2 nathanw scb_set(0x800, iointr, NULL);
155 1.36.2.2 nathanw
156 1.36.2.2 nathanw config_found(self, &tba, tcasicprint);
157 1.36.2.2 nathanw }
158 1.36.2.2 nathanw
159 1.36.2.2 nathanw int
160 1.36.2.2 nathanw tcasicprint(aux, pnp)
161 1.36.2.2 nathanw void *aux;
162 1.36.2.2 nathanw const char *pnp;
163 1.36.2.2 nathanw {
164 1.36.2.2 nathanw
165 1.36.2.2 nathanw /* only TCs can attach to tcasics; easy. */
166 1.36.2.2 nathanw if (pnp)
167 1.36.2.3 thorpej aprint_normal("tc at %s", pnp);
168 1.36.2.2 nathanw return (UNCONF);
169 1.36.2.2 nathanw }
170 1.36.2.2 nathanw
171 1.36.2.2 nathanw #include "wsdisplay.h"
172 1.36.2.2 nathanw
173 1.36.2.2 nathanw #if NWSDISPLAY > 0
174 1.36.2.2 nathanw
175 1.36.2.2 nathanw #include "sfb.h"
176 1.36.2.2 nathanw #include "sfbp.h"
177 1.36.2.2 nathanw #include "cfb.h"
178 1.36.2.2 nathanw #include "mfb.h"
179 1.36.2.2 nathanw #include "tfb.h"
180 1.36.2.2 nathanw #include "px.h"
181 1.36.2.2 nathanw #include "pxg.h"
182 1.36.2.2 nathanw
183 1.36.2.2 nathanw extern void sfb_cnattach __P((tc_addr_t));
184 1.36.2.2 nathanw extern void sfbp_cnattach __P((tc_addr_t));
185 1.36.2.2 nathanw extern void cfb_cnattach __P((tc_addr_t));
186 1.36.2.2 nathanw extern void mfb_cnattach __P((tc_addr_t));
187 1.36.2.2 nathanw extern void tfb_cnattach __P((tc_addr_t));
188 1.36.2.2 nathanw extern void px_cnattach __P((tc_addr_t));
189 1.36.2.2 nathanw extern void pxg_cnattach __P((tc_addr_t));
190 1.36.2.2 nathanw extern int tc_checkslot __P((tc_addr_t, char *));
191 1.36.2.2 nathanw
192 1.36.2.2 nathanw struct cnboards {
193 1.36.2.2 nathanw const char *cb_tcname;
194 1.36.2.2 nathanw void (*cb_cnattach)(tc_addr_t);
195 1.36.2.2 nathanw } static const cnboards[] = {
196 1.36.2.2 nathanw #if NSFB > 0
197 1.36.2.2 nathanw { "PMAGB-BA", sfb_cnattach },
198 1.36.2.2 nathanw #endif
199 1.36.2.2 nathanw #if NSFBP > 0
200 1.36.2.2 nathanw { "PMAGD ", sfbp_cnattach },
201 1.36.2.2 nathanw #endif
202 1.36.2.2 nathanw #if NCFB > 0
203 1.36.2.2 nathanw { "PMAG-BA ", cfb_cnattach },
204 1.36.2.2 nathanw #endif
205 1.36.2.2 nathanw #if NMFB > 0
206 1.36.2.2 nathanw { "PMAG-AA ", mfb_cnattach },
207 1.36.2.2 nathanw #endif
208 1.36.2.2 nathanw #if NTFB > 0
209 1.36.2.2 nathanw { "PMAG-JA ", tfb_cnattach },
210 1.36.2.2 nathanw #endif
211 1.36.2.2 nathanw #if NPX > 0
212 1.36.2.2 nathanw { "PMAG-CA ", px_cnattach },
213 1.36.2.2 nathanw #endif
214 1.36.2.2 nathanw #if NPXG > 0
215 1.36.2.2 nathanw { "PMAG-DA ", pxg_cnattach },
216 1.36.2.2 nathanw { "PMAG-FA ", pxg_cnattach },
217 1.36.2.2 nathanw { "PMAG-FB ", pxg_cnattach },
218 1.36.2.2 nathanw { "PMAGB-FA", pxg_cnattach },
219 1.36.2.2 nathanw { "PMAGB-FB", pxg_cnattach },
220 1.36.2.2 nathanw #endif
221 1.36.2.2 nathanw };
222 1.36.2.2 nathanw
223 1.36.2.2 nathanw /*
224 1.36.2.2 nathanw * tc_fb_cnattach --
225 1.36.2.2 nathanw * Attempt to attach the appropriate display driver to the
226 1.36.2.2 nathanw * output console.
227 1.36.2.2 nathanw */
228 1.36.2.2 nathanw int
229 1.36.2.2 nathanw tc_fb_cnattach(tcaddr)
230 1.36.2.2 nathanw tc_addr_t tcaddr;
231 1.36.2.2 nathanw {
232 1.36.2.2 nathanw char tcname[TC_ROM_LLEN];
233 1.36.2.2 nathanw int i;
234 1.36.2.2 nathanw
235 1.36.2.2 nathanw if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0))
236 1.36.2.2 nathanw return (EINVAL);
237 1.36.2.2 nathanw
238 1.36.2.2 nathanw for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
239 1.36.2.2 nathanw if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
240 1.36.2.2 nathanw break;
241 1.36.2.2 nathanw
242 1.36.2.2 nathanw if (i == sizeof(cnboards) / sizeof(cnboards[0]))
243 1.36.2.2 nathanw return (ENXIO);
244 1.36.2.2 nathanw
245 1.36.2.2 nathanw (cnboards[i].cb_cnattach)(tcaddr);
246 1.36.2.2 nathanw return (0);
247 1.36.2.2 nathanw }
248 1.36.2.2 nathanw #endif /* if NWSDISPLAY > 0 */
249