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