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