cia.c revision 1.57.4.2 1 1.57.4.2 nathanw /* $NetBSD: cia.c,v 1.57.4.2 2002/06/20 03:37:40 nathanw Exp $ */
2 1.57.4.2 nathanw
3 1.57.4.2 nathanw /*-
4 1.57.4.2 nathanw * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
5 1.57.4.2 nathanw * All rights reserved.
6 1.57.4.2 nathanw *
7 1.57.4.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.57.4.2 nathanw * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.57.4.2 nathanw * NASA Ames Research Center.
10 1.57.4.2 nathanw *
11 1.57.4.2 nathanw * Redistribution and use in source and binary forms, with or without
12 1.57.4.2 nathanw * modification, are permitted provided that the following conditions
13 1.57.4.2 nathanw * are met:
14 1.57.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
15 1.57.4.2 nathanw * notice, this list of conditions and the following disclaimer.
16 1.57.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
17 1.57.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
18 1.57.4.2 nathanw * documentation and/or other materials provided with the distribution.
19 1.57.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
20 1.57.4.2 nathanw * must display the following acknowledgement:
21 1.57.4.2 nathanw * This product includes software developed by the NetBSD
22 1.57.4.2 nathanw * Foundation, Inc. and its contributors.
23 1.57.4.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.57.4.2 nathanw * contributors may be used to endorse or promote products derived
25 1.57.4.2 nathanw * from this software without specific prior written permission.
26 1.57.4.2 nathanw *
27 1.57.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.57.4.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.57.4.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.57.4.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.57.4.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.57.4.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.57.4.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.57.4.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.57.4.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.57.4.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.57.4.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
38 1.57.4.2 nathanw */
39 1.57.4.2 nathanw
40 1.57.4.2 nathanw /*
41 1.57.4.2 nathanw * Copyright (c) 1995, 1996 Carnegie-Mellon University.
42 1.57.4.2 nathanw * All rights reserved.
43 1.57.4.2 nathanw *
44 1.57.4.2 nathanw * Author: Chris G. Demetriou
45 1.57.4.2 nathanw *
46 1.57.4.2 nathanw * Permission to use, copy, modify and distribute this software and
47 1.57.4.2 nathanw * its documentation is hereby granted, provided that both the copyright
48 1.57.4.2 nathanw * notice and this permission notice appear in all copies of the
49 1.57.4.2 nathanw * software, derivative works or modified versions, and any portions
50 1.57.4.2 nathanw * thereof, and that both notices appear in supporting documentation.
51 1.57.4.2 nathanw *
52 1.57.4.2 nathanw * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
53 1.57.4.2 nathanw * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
54 1.57.4.2 nathanw * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
55 1.57.4.2 nathanw *
56 1.57.4.2 nathanw * Carnegie Mellon requests users of this software to return to
57 1.57.4.2 nathanw *
58 1.57.4.2 nathanw * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
59 1.57.4.2 nathanw * School of Computer Science
60 1.57.4.2 nathanw * Carnegie Mellon University
61 1.57.4.2 nathanw * Pittsburgh PA 15213-3890
62 1.57.4.2 nathanw *
63 1.57.4.2 nathanw * any improvements or extensions that they make and grant Carnegie the
64 1.57.4.2 nathanw * rights to redistribute these changes.
65 1.57.4.2 nathanw */
66 1.57.4.2 nathanw
67 1.57.4.2 nathanw #include "opt_dec_eb164.h"
68 1.57.4.2 nathanw #include "opt_dec_kn20aa.h"
69 1.57.4.2 nathanw #include "opt_dec_550.h"
70 1.57.4.2 nathanw #include "opt_dec_1000a.h"
71 1.57.4.2 nathanw #include "opt_dec_1000.h"
72 1.57.4.2 nathanw
73 1.57.4.2 nathanw #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
74 1.57.4.2 nathanw
75 1.57.4.2 nathanw __KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.57.4.2 2002/06/20 03:37:40 nathanw Exp $");
76 1.57.4.2 nathanw
77 1.57.4.2 nathanw #include <sys/param.h>
78 1.57.4.2 nathanw #include <sys/systm.h>
79 1.57.4.2 nathanw #include <sys/kernel.h>
80 1.57.4.2 nathanw #include <sys/malloc.h>
81 1.57.4.2 nathanw #include <sys/device.h>
82 1.57.4.2 nathanw
83 1.57.4.2 nathanw #include <uvm/uvm_extern.h>
84 1.57.4.2 nathanw
85 1.57.4.2 nathanw #include <machine/autoconf.h>
86 1.57.4.2 nathanw #include <machine/rpb.h>
87 1.57.4.2 nathanw #include <machine/sysarch.h>
88 1.57.4.2 nathanw #include <machine/alpha.h>
89 1.57.4.2 nathanw
90 1.57.4.2 nathanw #include <dev/isa/isareg.h>
91 1.57.4.2 nathanw #include <dev/isa/isavar.h>
92 1.57.4.2 nathanw
93 1.57.4.2 nathanw #include <dev/pci/pcireg.h>
94 1.57.4.2 nathanw #include <dev/pci/pcivar.h>
95 1.57.4.2 nathanw #include <alpha/pci/ciareg.h>
96 1.57.4.2 nathanw #include <alpha/pci/ciavar.h>
97 1.57.4.2 nathanw
98 1.57.4.2 nathanw #ifdef DEC_KN20AA
99 1.57.4.2 nathanw #include <alpha/pci/pci_kn20aa.h>
100 1.57.4.2 nathanw #endif
101 1.57.4.2 nathanw #ifdef DEC_EB164
102 1.57.4.2 nathanw #include <alpha/pci/pci_eb164.h>
103 1.57.4.2 nathanw #endif
104 1.57.4.2 nathanw #ifdef DEC_550
105 1.57.4.2 nathanw #include <alpha/pci/pci_550.h>
106 1.57.4.2 nathanw #endif
107 1.57.4.2 nathanw #ifdef DEC_1000A
108 1.57.4.2 nathanw #include <alpha/pci/pci_1000a.h>
109 1.57.4.2 nathanw #endif
110 1.57.4.2 nathanw #ifdef DEC_1000
111 1.57.4.2 nathanw #include <alpha/pci/pci_1000.h>
112 1.57.4.2 nathanw #endif
113 1.57.4.2 nathanw
114 1.57.4.2 nathanw int ciamatch __P((struct device *, struct cfdata *, void *));
115 1.57.4.2 nathanw void ciaattach __P((struct device *, struct device *, void *));
116 1.57.4.2 nathanw
117 1.57.4.2 nathanw struct cfattach cia_ca = {
118 1.57.4.2 nathanw sizeof(struct cia_softc), ciamatch, ciaattach,
119 1.57.4.2 nathanw };
120 1.57.4.2 nathanw
121 1.57.4.2 nathanw extern struct cfdriver cia_cd;
122 1.57.4.2 nathanw
123 1.57.4.2 nathanw static int ciaprint __P((void *, const char *pnp));
124 1.57.4.2 nathanw
125 1.57.4.2 nathanw int cia_bus_get_window __P((int, int,
126 1.57.4.2 nathanw struct alpha_bus_space_translation *));
127 1.57.4.2 nathanw
128 1.57.4.2 nathanw /* There can be only one. */
129 1.57.4.2 nathanw int ciafound;
130 1.57.4.2 nathanw struct cia_config cia_configuration;
131 1.57.4.2 nathanw
132 1.57.4.2 nathanw /*
133 1.57.4.2 nathanw * This determines if we attempt to use BWX for PCI bus and config space
134 1.57.4.2 nathanw * access. Some systems, notably with Pyxis, don't fare so well unless
135 1.57.4.2 nathanw * BWX is used.
136 1.57.4.2 nathanw *
137 1.57.4.2 nathanw * EXCEPT! Some devices have a really hard time if BWX is used (WHY?!).
138 1.57.4.2 nathanw * So, we decouple the uses for PCI config space and PCI bus space.
139 1.57.4.2 nathanw *
140 1.57.4.2 nathanw * FURTHERMORE! The Pyxis, most notably earlier revs, really don't
141 1.57.4.2 nathanw * do so well if you don't use BWX for bus access. So we default to
142 1.57.4.2 nathanw * forcing BWX on those chips.
143 1.57.4.2 nathanw *
144 1.57.4.2 nathanw * Geez.
145 1.57.4.2 nathanw */
146 1.57.4.2 nathanw
147 1.57.4.2 nathanw #ifndef CIA_PCI_USE_BWX
148 1.57.4.2 nathanw #define CIA_PCI_USE_BWX 1
149 1.57.4.2 nathanw #endif
150 1.57.4.2 nathanw
151 1.57.4.2 nathanw #ifndef CIA_BUS_USE_BWX
152 1.57.4.2 nathanw #define CIA_BUS_USE_BWX 0
153 1.57.4.2 nathanw #endif
154 1.57.4.2 nathanw
155 1.57.4.2 nathanw #ifndef CIA_PYXIS_FORCE_BWX
156 1.57.4.2 nathanw #define CIA_PYXIS_FORCE_BWX 0
157 1.57.4.2 nathanw #endif
158 1.57.4.2 nathanw
159 1.57.4.2 nathanw int cia_pci_use_bwx = CIA_PCI_USE_BWX;
160 1.57.4.2 nathanw int cia_bus_use_bwx = CIA_BUS_USE_BWX;
161 1.57.4.2 nathanw int cia_pyxis_force_bwx = CIA_PYXIS_FORCE_BWX;
162 1.57.4.2 nathanw
163 1.57.4.2 nathanw int
164 1.57.4.2 nathanw ciamatch(parent, match, aux)
165 1.57.4.2 nathanw struct device *parent;
166 1.57.4.2 nathanw struct cfdata *match;
167 1.57.4.2 nathanw void *aux;
168 1.57.4.2 nathanw {
169 1.57.4.2 nathanw struct mainbus_attach_args *ma = aux;
170 1.57.4.2 nathanw
171 1.57.4.2 nathanw /* Make sure that we're looking for a CIA. */
172 1.57.4.2 nathanw if (strcmp(ma->ma_name, cia_cd.cd_name) != 0)
173 1.57.4.2 nathanw return (0);
174 1.57.4.2 nathanw
175 1.57.4.2 nathanw if (ciafound)
176 1.57.4.2 nathanw return (0);
177 1.57.4.2 nathanw
178 1.57.4.2 nathanw return (1);
179 1.57.4.2 nathanw }
180 1.57.4.2 nathanw
181 1.57.4.2 nathanw /*
182 1.57.4.2 nathanw * Set up the chipset's function pointers.
183 1.57.4.2 nathanw */
184 1.57.4.2 nathanw void
185 1.57.4.2 nathanw cia_init(ccp, mallocsafe)
186 1.57.4.2 nathanw struct cia_config *ccp;
187 1.57.4.2 nathanw int mallocsafe;
188 1.57.4.2 nathanw {
189 1.57.4.2 nathanw int pci_use_bwx = cia_pci_use_bwx;
190 1.57.4.2 nathanw int bus_use_bwx = cia_bus_use_bwx;
191 1.57.4.2 nathanw
192 1.57.4.2 nathanw ccp->cc_hae_mem = REGVAL(CIA_CSR_HAE_MEM);
193 1.57.4.2 nathanw ccp->cc_hae_io = REGVAL(CIA_CSR_HAE_IO);
194 1.57.4.2 nathanw ccp->cc_rev = REGVAL(CIA_CSR_REV) & REV_MASK;
195 1.57.4.2 nathanw
196 1.57.4.2 nathanw /*
197 1.57.4.2 nathanw * Determine if we have a Pyxis. Only two systypes can
198 1.57.4.2 nathanw * have this: the EB164 systype (AlphaPC164LX and AlphaPC164SX)
199 1.57.4.2 nathanw * and the DEC_550 systype (Miata).
200 1.57.4.2 nathanw */
201 1.57.4.2 nathanw if ((cputype == ST_EB164 &&
202 1.57.4.2 nathanw (hwrpb->rpb_variation & SV_ST_MASK) >= SV_ST_ALPHAPC164LX_400) ||
203 1.57.4.2 nathanw cputype == ST_DEC_550) {
204 1.57.4.2 nathanw ccp->cc_flags |= CCF_ISPYXIS;
205 1.57.4.2 nathanw if (cia_pyxis_force_bwx)
206 1.57.4.2 nathanw pci_use_bwx = bus_use_bwx = 1;
207 1.57.4.2 nathanw }
208 1.57.4.2 nathanw
209 1.57.4.2 nathanw /*
210 1.57.4.2 nathanw * ALCOR/ALCOR2 Revisions >= 2 and Pyxis have the CNFG register.
211 1.57.4.2 nathanw */
212 1.57.4.2 nathanw if (ccp->cc_rev >= 2 || (ccp->cc_flags & CCF_ISPYXIS) != 0)
213 1.57.4.2 nathanw ccp->cc_cnfg = REGVAL(CIA_CSR_CNFG);
214 1.57.4.2 nathanw else
215 1.57.4.2 nathanw ccp->cc_cnfg = 0;
216 1.57.4.2 nathanw
217 1.57.4.2 nathanw /*
218 1.57.4.2 nathanw * Use BWX iff:
219 1.57.4.2 nathanw *
220 1.57.4.2 nathanw * - It hasn't been disbled by the user,
221 1.57.4.2 nathanw * - it's enabled in CNFG,
222 1.57.4.2 nathanw * - we're implementation version ev5,
223 1.57.4.2 nathanw * - BWX is enabled in the CPU's capabilities mask
224 1.57.4.2 nathanw */
225 1.57.4.2 nathanw if ((pci_use_bwx || bus_use_bwx) &&
226 1.57.4.2 nathanw (ccp->cc_cnfg & CNFG_BWEN) != 0 &&
227 1.57.4.2 nathanw (cpu_amask & ALPHA_AMASK_BWX) != 0) {
228 1.57.4.2 nathanw u_int32_t ctrl;
229 1.57.4.2 nathanw
230 1.57.4.2 nathanw if (pci_use_bwx)
231 1.57.4.2 nathanw ccp->cc_flags |= CCF_PCI_USE_BWX;
232 1.57.4.2 nathanw if (bus_use_bwx)
233 1.57.4.2 nathanw ccp->cc_flags |= CCF_BUS_USE_BWX;
234 1.57.4.2 nathanw
235 1.57.4.2 nathanw /*
236 1.57.4.2 nathanw * For whatever reason, the firmware seems to enable PCI
237 1.57.4.2 nathanw * loopback mode if it also enables BWX. Make sure it's
238 1.57.4.2 nathanw * enabled if we have an old, buggy firmware rev.
239 1.57.4.2 nathanw */
240 1.57.4.2 nathanw alpha_mb();
241 1.57.4.2 nathanw ctrl = REGVAL(CIA_CSR_CTRL);
242 1.57.4.2 nathanw if ((ctrl & CTRL_PCI_LOOP_EN) == 0) {
243 1.57.4.2 nathanw REGVAL(CIA_CSR_CTRL) = ctrl | CTRL_PCI_LOOP_EN;
244 1.57.4.2 nathanw alpha_mb();
245 1.57.4.2 nathanw }
246 1.57.4.2 nathanw }
247 1.57.4.2 nathanw
248 1.57.4.2 nathanw if (!ccp->cc_initted) {
249 1.57.4.2 nathanw /* don't do these twice since they set up extents */
250 1.57.4.2 nathanw if (ccp->cc_flags & CCF_BUS_USE_BWX) {
251 1.57.4.2 nathanw cia_bwx_bus_io_init(&ccp->cc_iot, ccp);
252 1.57.4.2 nathanw cia_bwx_bus_mem_init(&ccp->cc_memt, ccp);
253 1.57.4.2 nathanw
254 1.57.4.2 nathanw /*
255 1.57.4.2 nathanw * We have one window for both PCI I/O and MEM
256 1.57.4.2 nathanw * in BWX mode.
257 1.57.4.2 nathanw */
258 1.57.4.2 nathanw alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
259 1.57.4.2 nathanw alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1;
260 1.57.4.2 nathanw } else {
261 1.57.4.2 nathanw cia_swiz_bus_io_init(&ccp->cc_iot, ccp);
262 1.57.4.2 nathanw cia_swiz_bus_mem_init(&ccp->cc_memt, ccp);
263 1.57.4.2 nathanw
264 1.57.4.2 nathanw /*
265 1.57.4.2 nathanw * We have two I/O windows and 4 MEM windows in
266 1.57.4.2 nathanw * SWIZ mode.
267 1.57.4.2 nathanw */
268 1.57.4.2 nathanw alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 2;
269 1.57.4.2 nathanw alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 4;
270 1.57.4.2 nathanw }
271 1.57.4.2 nathanw alpha_bus_get_window = cia_bus_get_window;
272 1.57.4.2 nathanw }
273 1.57.4.2 nathanw ccp->cc_mallocsafe = mallocsafe;
274 1.57.4.2 nathanw
275 1.57.4.2 nathanw cia_pci_init(&ccp->cc_pc, ccp);
276 1.57.4.2 nathanw alpha_pci_chipset = &ccp->cc_pc;
277 1.57.4.2 nathanw
278 1.57.4.2 nathanw ccp->cc_initted = 1;
279 1.57.4.2 nathanw }
280 1.57.4.2 nathanw
281 1.57.4.2 nathanw void
282 1.57.4.2 nathanw ciaattach(parent, self, aux)
283 1.57.4.2 nathanw struct device *parent, *self;
284 1.57.4.2 nathanw void *aux;
285 1.57.4.2 nathanw {
286 1.57.4.2 nathanw struct cia_softc *sc = (struct cia_softc *)self;
287 1.57.4.2 nathanw struct cia_config *ccp;
288 1.57.4.2 nathanw struct pcibus_attach_args pba;
289 1.57.4.2 nathanw char bits[64];
290 1.57.4.2 nathanw const char *name;
291 1.57.4.2 nathanw int pass;
292 1.57.4.2 nathanw
293 1.57.4.2 nathanw /* note that we've attached the chipset; can't have 2 CIAs. */
294 1.57.4.2 nathanw ciafound = 1;
295 1.57.4.2 nathanw
296 1.57.4.2 nathanw /*
297 1.57.4.2 nathanw * set up the chipset's info; done once at console init time
298 1.57.4.2 nathanw * (maybe), but we must do it here as well to take care of things
299 1.57.4.2 nathanw * that need to use memory allocation.
300 1.57.4.2 nathanw */
301 1.57.4.2 nathanw ccp = sc->sc_ccp = &cia_configuration;
302 1.57.4.2 nathanw cia_init(ccp, 1);
303 1.57.4.2 nathanw
304 1.57.4.2 nathanw if (ccp->cc_flags & CCF_ISPYXIS) {
305 1.57.4.2 nathanw name = "Pyxis";
306 1.57.4.2 nathanw pass = ccp->cc_rev;
307 1.57.4.2 nathanw } else {
308 1.57.4.2 nathanw name = "ALCOR/ALCOR2";
309 1.57.4.2 nathanw pass = ccp->cc_rev + 1;
310 1.57.4.2 nathanw }
311 1.57.4.2 nathanw
312 1.57.4.2 nathanw printf(": DECchip 2117x Core Logic Chipset (%s), pass %d\n",
313 1.57.4.2 nathanw name, pass);
314 1.57.4.2 nathanw if (ccp->cc_cnfg)
315 1.57.4.2 nathanw printf("%s: extended capabilities: %s\n", self->dv_xname,
316 1.57.4.2 nathanw bitmask_snprintf(ccp->cc_cnfg, CIA_CSR_CNFG_BITS,
317 1.57.4.2 nathanw bits, sizeof(bits)));
318 1.57.4.2 nathanw
319 1.57.4.2 nathanw switch (ccp->cc_flags & (CCF_PCI_USE_BWX|CCF_BUS_USE_BWX)) {
320 1.57.4.2 nathanw case CCF_PCI_USE_BWX|CCF_BUS_USE_BWX:
321 1.57.4.2 nathanw name = "PCI config and bus";
322 1.57.4.2 nathanw break;
323 1.57.4.2 nathanw case CCF_PCI_USE_BWX:
324 1.57.4.2 nathanw name = "PCI config";
325 1.57.4.2 nathanw break;
326 1.57.4.2 nathanw case CCF_BUS_USE_BWX:
327 1.57.4.2 nathanw name = "bus";
328 1.57.4.2 nathanw break;
329 1.57.4.2 nathanw default:
330 1.57.4.2 nathanw name = NULL;
331 1.57.4.2 nathanw break;
332 1.57.4.2 nathanw }
333 1.57.4.2 nathanw if (name != NULL)
334 1.57.4.2 nathanw printf("%s: using BWX for %s access\n", self->dv_xname, name);
335 1.57.4.2 nathanw
336 1.57.4.2 nathanw #ifdef DEC_550
337 1.57.4.2 nathanw if (cputype == ST_DEC_550 &&
338 1.57.4.2 nathanw (hwrpb->rpb_variation & SV_ST_MASK) < SV_ST_MIATA_1_5) {
339 1.57.4.2 nathanw /*
340 1.57.4.2 nathanw * Miata 1 systems have a bug: DMA cannot cross
341 1.57.4.2 nathanw * an 8k boundary! Make sure PCI read prefetching
342 1.57.4.2 nathanw * is disabled on these chips. Note that secondary
343 1.57.4.2 nathanw * PCI busses don't have this problem, because of
344 1.57.4.2 nathanw * the way PPBs handle PCI read requests.
345 1.57.4.2 nathanw *
346 1.57.4.2 nathanw * In the 21174 Technical Reference Manual, this is
347 1.57.4.2 nathanw * actually documented as "Pyxis Pass 1", but apparently
348 1.57.4.2 nathanw * there are chips that report themselves as "Pass 1"
349 1.57.4.2 nathanw * which do not have the bug! Miatas with the Cypress
350 1.57.4.2 nathanw * PCI-ISA bridge (i.e. Miata 1.5 and Miata 2) do not
351 1.57.4.2 nathanw * have the bug, so we use this check.
352 1.57.4.2 nathanw *
353 1.57.4.2 nathanw * NOTE: This bug is actually worked around in cia_dma.c,
354 1.57.4.2 nathanw * when direct-mapped DMA maps are created.
355 1.57.4.2 nathanw *
356 1.57.4.2 nathanw * XXX WE NEED TO THINK ABOUT HOW TO HANDLE THIS FOR
357 1.57.4.2 nathanw * XXX SGMAP DMA MAPPINGS!
358 1.57.4.2 nathanw */
359 1.57.4.2 nathanw u_int32_t ctrl;
360 1.57.4.2 nathanw
361 1.57.4.2 nathanw /* XXX no bets... */
362 1.57.4.2 nathanw printf("%s: WARNING: Pyxis pass 1 DMA bug; no bets...\n",
363 1.57.4.2 nathanw self->dv_xname);
364 1.57.4.2 nathanw
365 1.57.4.2 nathanw ccp->cc_flags |= CCF_PYXISBUG;
366 1.57.4.2 nathanw
367 1.57.4.2 nathanw alpha_mb();
368 1.57.4.2 nathanw ctrl = REGVAL(CIA_CSR_CTRL);
369 1.57.4.2 nathanw ctrl &= ~(CTRL_RD_TYPE|CTRL_RL_TYPE|CTRL_RM_TYPE);
370 1.57.4.2 nathanw REGVAL(CIA_CSR_CTRL) = ctrl;
371 1.57.4.2 nathanw alpha_mb();
372 1.57.4.2 nathanw }
373 1.57.4.2 nathanw #endif /* DEC_550 */
374 1.57.4.2 nathanw
375 1.57.4.2 nathanw cia_dma_init(ccp);
376 1.57.4.2 nathanw
377 1.57.4.2 nathanw switch (cputype) {
378 1.57.4.2 nathanw #ifdef DEC_KN20AA
379 1.57.4.2 nathanw case ST_DEC_KN20AA:
380 1.57.4.2 nathanw pci_kn20aa_pickintr(ccp);
381 1.57.4.2 nathanw break;
382 1.57.4.2 nathanw #endif
383 1.57.4.2 nathanw
384 1.57.4.2 nathanw #ifdef DEC_EB164
385 1.57.4.2 nathanw case ST_EB164:
386 1.57.4.2 nathanw pci_eb164_pickintr(ccp);
387 1.57.4.2 nathanw break;
388 1.57.4.2 nathanw #endif
389 1.57.4.2 nathanw
390 1.57.4.2 nathanw #ifdef DEC_550
391 1.57.4.2 nathanw case ST_DEC_550:
392 1.57.4.2 nathanw pci_550_pickintr(ccp);
393 1.57.4.2 nathanw break;
394 1.57.4.2 nathanw #endif
395 1.57.4.2 nathanw
396 1.57.4.2 nathanw #ifdef DEC_1000A
397 1.57.4.2 nathanw case ST_DEC_1000A:
398 1.57.4.2 nathanw pci_1000a_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
399 1.57.4.2 nathanw &ccp->cc_pc);
400 1.57.4.2 nathanw break;
401 1.57.4.2 nathanw #endif
402 1.57.4.2 nathanw
403 1.57.4.2 nathanw #ifdef DEC_1000
404 1.57.4.2 nathanw case ST_DEC_1000:
405 1.57.4.2 nathanw pci_1000_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
406 1.57.4.2 nathanw &ccp->cc_pc);
407 1.57.4.2 nathanw break;
408 1.57.4.2 nathanw #endif
409 1.57.4.2 nathanw
410 1.57.4.2 nathanw default:
411 1.57.4.2 nathanw panic("ciaattach: shouldn't be here, really...");
412 1.57.4.2 nathanw }
413 1.57.4.2 nathanw
414 1.57.4.2 nathanw pba.pba_busname = "pci";
415 1.57.4.2 nathanw pba.pba_iot = &ccp->cc_iot;
416 1.57.4.2 nathanw pba.pba_memt = &ccp->cc_memt;
417 1.57.4.2 nathanw pba.pba_dmat =
418 1.57.4.2 nathanw alphabus_dma_get_tag(&ccp->cc_dmat_direct, ALPHA_BUS_PCI);
419 1.57.4.2 nathanw pba.pba_pc = &ccp->cc_pc;
420 1.57.4.2 nathanw pba.pba_bus = 0;
421 1.57.4.2 nathanw pba.pba_bridgetag = NULL;
422 1.57.4.2 nathanw pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
423 1.57.4.2 nathanw if ((ccp->cc_flags & CCF_PYXISBUG) == 0)
424 1.57.4.2 nathanw pba.pba_flags |= PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
425 1.57.4.2 nathanw PCI_FLAGS_MWI_OKAY;
426 1.57.4.2 nathanw config_found(self, &pba, ciaprint);
427 1.57.4.2 nathanw }
428 1.57.4.2 nathanw
429 1.57.4.2 nathanw static int
430 1.57.4.2 nathanw ciaprint(aux, pnp)
431 1.57.4.2 nathanw void *aux;
432 1.57.4.2 nathanw const char *pnp;
433 1.57.4.2 nathanw {
434 1.57.4.2 nathanw register struct pcibus_attach_args *pba = aux;
435 1.57.4.2 nathanw
436 1.57.4.2 nathanw /* only PCIs can attach to CIAs; easy. */
437 1.57.4.2 nathanw if (pnp)
438 1.57.4.2 nathanw printf("%s at %s", pba->pba_busname, pnp);
439 1.57.4.2 nathanw printf(" bus %d", pba->pba_bus);
440 1.57.4.2 nathanw return (UNCONF);
441 1.57.4.2 nathanw }
442 1.57.4.2 nathanw
443 1.57.4.2 nathanw int
444 1.57.4.2 nathanw cia_bus_get_window(type, window, abst)
445 1.57.4.2 nathanw int type, window;
446 1.57.4.2 nathanw struct alpha_bus_space_translation *abst;
447 1.57.4.2 nathanw {
448 1.57.4.2 nathanw struct cia_config *ccp = &cia_configuration;
449 1.57.4.2 nathanw bus_space_tag_t st;
450 1.57.4.2 nathanw
451 1.57.4.2 nathanw switch (type) {
452 1.57.4.2 nathanw case ALPHA_BUS_TYPE_PCI_IO:
453 1.57.4.2 nathanw st = &ccp->cc_iot;
454 1.57.4.2 nathanw break;
455 1.57.4.2 nathanw
456 1.57.4.2 nathanw case ALPHA_BUS_TYPE_PCI_MEM:
457 1.57.4.2 nathanw st = &ccp->cc_memt;
458 1.57.4.2 nathanw break;
459 1.57.4.2 nathanw
460 1.57.4.2 nathanw default:
461 1.57.4.2 nathanw panic("cia_bus_get_window");
462 1.57.4.2 nathanw }
463 1.57.4.2 nathanw
464 1.57.4.2 nathanw return (alpha_bus_space_get_window(st, window, abst));
465 1.57.4.2 nathanw }
466 1.57.4.2 nathanw
467 1.57.4.2 nathanw void
468 1.57.4.2 nathanw cia_pyxis_intr_enable(irq, onoff)
469 1.57.4.2 nathanw int irq, onoff;
470 1.57.4.2 nathanw {
471 1.57.4.2 nathanw u_int64_t imask;
472 1.57.4.2 nathanw int s;
473 1.57.4.2 nathanw
474 1.57.4.2 nathanw #if 0
475 1.57.4.2 nathanw printf("cia_pyxis_intr_enable: %s %d\n",
476 1.57.4.2 nathanw onoff ? "enabling" : "disabling", irq);
477 1.57.4.2 nathanw #endif
478 1.57.4.2 nathanw
479 1.57.4.2 nathanw s = splhigh();
480 1.57.4.2 nathanw alpha_mb();
481 1.57.4.2 nathanw imask = REGVAL64(PYXIS_INT_MASK);
482 1.57.4.2 nathanw if (onoff)
483 1.57.4.2 nathanw imask |= (1UL << irq);
484 1.57.4.2 nathanw else
485 1.57.4.2 nathanw imask &= ~(1UL << irq);
486 1.57.4.2 nathanw REGVAL64(PYXIS_INT_MASK) = imask;
487 1.57.4.2 nathanw alpha_mb();
488 1.57.4.2 nathanw splx(s);
489 1.57.4.2 nathanw }
490