tcasic.c revision 1.20 1 /* $NetBSD: tcasic.c,v 1.20 1997/09/02 13:29:19 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.20 1997/09/02 13:29:19 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
44 #include <dev/tc/tcvar.h>
45 #include <alpha/tc/tc_conf.h>
46
47 /* Definition of the driver for autoconfig. */
48 int tcasicmatch(struct device *, struct cfdata *, void *);
49 void tcasicattach(struct device *, struct device *, void *);
50
51 struct cfattach tcasic_ca = {
52 sizeof (struct device), tcasicmatch, tcasicattach,
53 };
54
55 struct cfdriver tcasic_cd = {
56 NULL, "tcasic", DV_DULL,
57 };
58
59 int tcasicprint __P((void *, const char *));
60
61 extern int cputype;
62
63 /* There can be only one. */
64 int tcasicfound;
65
66 int
67 tcasicmatch(parent, cfdata, aux)
68 struct device *parent;
69 struct cfdata *cfdata;
70 void *aux;
71 {
72 struct confargs *ca = aux;
73
74 /* Make sure that we're looking for a TurboChannel ASIC. */
75 if (strcmp(ca->ca_name, tcasic_cd.cd_name))
76 return (0);
77
78 /* Make sure that the system supports a TurboChannel ASIC. */
79 if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
80 return (0);
81
82 if (tcasicfound)
83 return (0);
84
85 return (1);
86 }
87
88 void
89 tcasicattach(parent, self, aux)
90 struct device *parent;
91 struct device *self;
92 void *aux;
93 {
94 struct tcbus_attach_args tba;
95 void (*intr_setup) __P((void));
96 void (*iointr) __P((void *, unsigned long));
97
98 printf("\n");
99 tcasicfound = 1;
100
101 switch (cputype) {
102 #ifdef DEC_3000_500
103 case ST_DEC_3000_500:
104
105 intr_setup = tc_3000_500_intr_setup;
106 iointr = tc_3000_500_iointr;
107
108 tc_dma_get_tag_func = tc_dma_get_tag_3000_500;
109
110 tba.tba_busname = "tc";
111 tba.tba_speed = TC_SPEED_25_MHZ;
112 tba.tba_nslots = tc_3000_500_nslots;
113 tba.tba_slots = tc_3000_500_slots;
114 if (hwrpb->rpb_variation & SV_GRAPHICS) {
115 tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
116 tba.tba_builtins = tc_3000_500_graphics_builtins;
117 } else {
118 tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
119 tba.tba_builtins = tc_3000_500_nographics_builtins;
120 }
121 tba.tba_intr_establish = tc_3000_500_intr_establish;
122 tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
123
124 /* Do 3000/500-specific DMA setup now. */
125 tc_dma_init_3000_500(tc_3000_500_nslots);
126 break;
127 #endif /* DEC_3000_500 */
128
129 #ifdef DEC_3000_300
130 case ST_DEC_3000_300:
131
132 intr_setup = tc_3000_300_intr_setup;
133 iointr = tc_3000_300_iointr;
134
135 tc_dma_get_tag_func = tc_dma_get_tag_3000_300;
136
137 tba.tba_busname = "tc";
138 tba.tba_speed = TC_SPEED_12_5_MHZ;
139 tba.tba_nslots = tc_3000_300_nslots;
140 tba.tba_slots = tc_3000_300_slots;
141 tba.tba_nbuiltins = tc_3000_300_nbuiltins;
142 tba.tba_builtins = tc_3000_300_builtins;
143 tba.tba_intr_establish = tc_3000_300_intr_establish;
144 tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
145 break;
146 #endif /* DEC_3000_300 */
147
148 default:
149 panic("tcasicattach: bad cputype");
150 }
151
152 tba.tba_memt = tc_bus_mem_init(NULL);
153
154 tc_dma_init();
155
156 (*intr_setup)();
157 set_iointr(iointr);
158
159 config_found(self, &tba, tcasicprint);
160 }
161
162 int
163 tcasicprint(aux, pnp)
164 void *aux;
165 const char *pnp;
166 {
167
168 /* only TCs can attach to tcasics; easy. */
169 if (pnp)
170 printf("tc at %s", pnp);
171 return (UNCONF);
172 }
173