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