tcasic.c revision 1.48 1 /* $NetBSD: tcasic.c,v 1.48 2020/09/22 15:24:02 thorpej 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.48 2020/09/22 15:24:02 thorpej 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(device_t, cfdata_t, void *);
50 void tcasicattach(device_t, device_t, void *);
51
52 CFATTACH_DECL_NEW(tcasic, 0,
53 tcasicmatch, tcasicattach, NULL, NULL);
54
55 extern struct cfdriver tcasic_cd;
56
57 int tcasicprint(void *, const char *);
58
59 /* There can be only one. */
60 int tcasicfound;
61
62 int
63 tcasicmatch(device_t parent, cfdata_t cf, void *aux)
64 {
65 struct mainbus_attach_args *ma = aux;
66
67 /* Make sure that we're looking for a TURBOchannel ASIC. */
68 if (strcmp(ma->ma_name, tcasic_cd.cd_name))
69 return (0);
70
71 /* Make sure that the system supports a TURBOchannel ASIC. */
72 if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
73 return (0);
74
75 if (tcasicfound)
76 return (0);
77
78 return (1);
79 }
80
81 void
82 tcasicattach(device_t parent, device_t self, void *aux)
83 {
84 struct tcbus_attach_args tba;
85 void (*intr_setup)(void);
86 void (*iointr)(void *, unsigned long);
87
88 printf("\n");
89 tcasicfound = 1;
90
91 switch (cputype) {
92 #ifdef DEC_3000_500
93 case ST_DEC_3000_500:
94
95 intr_setup = tc_3000_500_intr_setup;
96 iointr = tc_3000_500_iointr;
97
98 tba.tba_speed = TC_SPEED_25_MHZ;
99 tba.tba_nslots = tc_3000_500_nslots;
100 tba.tba_slots = tc_3000_500_slots;
101 if (hwrpb->rpb_variation & SV_GRAPHICS) {
102 tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
103 tba.tba_builtins = tc_3000_500_graphics_builtins;
104 } else {
105 tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
106 tba.tba_builtins = tc_3000_500_nographics_builtins;
107 }
108 tba.tba_intr_evcnt = tc_3000_500_intr_evcnt;
109 tba.tba_intr_establish = tc_3000_500_intr_establish;
110 tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
111 tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
112
113 /* Do 3000/500-specific DMA setup now. */
114 tc_dma_init_3000_500(tc_3000_500_nslots);
115 break;
116 #endif /* DEC_3000_500 */
117
118 #ifdef DEC_3000_300
119 case ST_DEC_3000_300:
120
121 intr_setup = tc_3000_300_intr_setup;
122 iointr = tc_3000_300_iointr;
123
124 tba.tba_speed = TC_SPEED_12_5_MHZ;
125 tba.tba_nslots = tc_3000_300_nslots;
126 tba.tba_slots = tc_3000_300_slots;
127 tba.tba_nbuiltins = tc_3000_300_nbuiltins;
128 tba.tba_builtins = tc_3000_300_builtins;
129 tba.tba_intr_evcnt = tc_3000_300_intr_evcnt;
130 tba.tba_intr_establish = tc_3000_300_intr_establish;
131 tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
132 tba.tba_get_dma_tag = tc_dma_get_tag_3000_300;
133 break;
134 #endif /* DEC_3000_300 */
135
136 default:
137 panic("tcasicattach: bad cputype");
138 }
139
140 tba.tba_busname = "tc";
141 tba.tba_memt = tc_bus_mem_init(NULL);
142
143 tc_dma_init();
144
145 (*intr_setup)();
146
147 /* They all come in at 0x800. */
148 scb_set(0x800, iointr, NULL);
149
150 config_found(self, &tba, tcasicprint);
151 }
152
153 int
154 tcasicprint(void *aux, const char *pnp)
155 {
156
157 /* only TCs can attach to tcasics; easy. */
158 if (pnp)
159 aprint_normal("tc at %s", pnp);
160 return (UNCONF);
161 }
162
163 #include "wsdisplay.h"
164
165 #if NWSDISPLAY > 0
166
167 #include "sfb.h"
168 #include "sfbp.h"
169 #include "cfb.h"
170 #include "mfb.h"
171 #include "tfb.h"
172 #include "px.h"
173 #include "pxg.h"
174
175 extern void sfb_cnattach(tc_addr_t);
176 extern void sfbp_cnattach(tc_addr_t);
177 extern void cfb_cnattach(tc_addr_t);
178 extern void mfb_cnattach(tc_addr_t);
179 extern void tfb_cnattach(tc_addr_t);
180 extern void px_cnattach(tc_addr_t);
181 extern void pxg_cnattach(tc_addr_t);
182
183 struct cnboards {
184 const char *cb_tcname;
185 void (*cb_cnattach)(tc_addr_t);
186 } static const cnboards[] = {
187 #if NSFB > 0
188 { "PMAGB-BA", sfb_cnattach },
189 #endif
190 #if NSFBP > 0
191 { "PMAGD ", sfbp_cnattach },
192 #endif
193 #if NCFB > 0
194 { "PMAG-BA ", cfb_cnattach },
195 #endif
196 #if NMFB > 0
197 { "PMAG-AA ", mfb_cnattach },
198 #endif
199 #if NTFB > 0
200 { "PMAG-JA ", tfb_cnattach },
201 #endif
202 #if NPX > 0
203 { "PMAG-CA ", px_cnattach },
204 #endif
205 #if NPXG > 0
206 { "PMAG-DA ", pxg_cnattach },
207 { "PMAG-FA ", pxg_cnattach },
208 { "PMAG-FB ", pxg_cnattach },
209 { "PMAGB-FA", pxg_cnattach },
210 { "PMAGB-FB", pxg_cnattach },
211 #endif
212 };
213
214 /*
215 * tc_fb_cnattach --
216 * Attempt to attach the appropriate display driver to the
217 * output console.
218 */
219 int
220 tc_fb_cnattach(tc_addr_t tcaddr)
221 {
222 char tcname[TC_ROM_LLEN];
223 int i;
224
225 if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname, NULL) == 0))
226 return (EINVAL);
227
228 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
229 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
230 break;
231
232 if (i == sizeof(cnboards) / sizeof(cnboards[0]))
233 return (ENXIO);
234
235 (cnboards[i].cb_cnattach)(tcaddr);
236 return (0);
237 }
238 #endif /* if NWSDISPLAY > 0 */
239