rmixl_pcie.c revision 1.1.2.2 1 1.1.2.2 cliff /* $NetBSD: rmixl_pcie.c,v 1.1.2.2 2009/11/13 05:22:19 cliff Exp $ */
2 1.1.2.1 cliff
3 1.1.2.1 cliff /*
4 1.1.2.1 cliff * Copyright (c) 2001 Wasabi Systems, Inc.
5 1.1.2.1 cliff * All rights reserved.
6 1.1.2.1 cliff *
7 1.1.2.1 cliff * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.1.2.1 cliff *
9 1.1.2.1 cliff * Redistribution and use in source and binary forms, with or without
10 1.1.2.1 cliff * modification, are permitted provided that the following conditions
11 1.1.2.1 cliff * are met:
12 1.1.2.1 cliff * 1. Redistributions of source code must retain the above copyright
13 1.1.2.1 cliff * notice, this list of conditions and the following disclaimer.
14 1.1.2.1 cliff * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.2.1 cliff * notice, this list of conditions and the following disclaimer in the
16 1.1.2.1 cliff * documentation and/or other materials provided with the distribution.
17 1.1.2.1 cliff * 3. All advertising materials mentioning features or use of this software
18 1.1.2.1 cliff * must display the following acknowledgement:
19 1.1.2.1 cliff * This product includes software developed for the NetBSD Project by
20 1.1.2.1 cliff * Wasabi Systems, Inc.
21 1.1.2.1 cliff * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.1.2.1 cliff * or promote products derived from this software without specific prior
23 1.1.2.1 cliff * written permission.
24 1.1.2.1 cliff *
25 1.1.2.1 cliff * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.1.2.1 cliff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1.2.1 cliff * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1.2.1 cliff * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.1.2.1 cliff * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1.2.1 cliff * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1.2.1 cliff * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1.2.1 cliff * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1.2.1 cliff * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1.2.1 cliff * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1.2.1 cliff * POSSIBILITY OF SUCH DAMAGE.
36 1.1.2.1 cliff */
37 1.1.2.1 cliff
38 1.1.2.1 cliff /*
39 1.1.2.1 cliff * PCI configuration support for RMI XLS SoC
40 1.1.2.1 cliff */
41 1.1.2.1 cliff
42 1.1.2.1 cliff #include <sys/cdefs.h>
43 1.1.2.2 cliff __KERNEL_RCSID(0, "$NetBSD: rmixl_pcie.c,v 1.1.2.2 2009/11/13 05:22:19 cliff Exp $");
44 1.1.2.1 cliff
45 1.1.2.1 cliff #include "opt_pci.h"
46 1.1.2.1 cliff #include "pci.h"
47 1.1.2.1 cliff
48 1.1.2.1 cliff #include <sys/cdefs.h>
49 1.1.2.1 cliff
50 1.1.2.1 cliff #include <sys/param.h>
51 1.1.2.1 cliff #include <sys/systm.h>
52 1.1.2.1 cliff #include <sys/device.h>
53 1.1.2.1 cliff #include <sys/extent.h>
54 1.1.2.1 cliff #include <sys/malloc.h>
55 1.1.2.1 cliff
56 1.1.2.1 cliff #include <uvm/uvm_extern.h>
57 1.1.2.1 cliff
58 1.1.2.1 cliff #include <machine/bus.h>
59 1.1.2.1 cliff #include <machine/intr.h>
60 1.1.2.1 cliff
61 1.1.2.1 cliff #include <mips/rmi/rmixlreg.h>
62 1.1.2.1 cliff #include <mips/rmi/rmixlvar.h>
63 1.1.2.1 cliff #include <mips/rmi/rmixl_pcievar.h>
64 1.1.2.1 cliff
65 1.1.2.1 cliff #include <mips/rmi/rmixl_obiovar.h>
66 1.1.2.1 cliff
67 1.1.2.1 cliff #include <dev/pci/pcivar.h>
68 1.1.2.1 cliff #include <dev/pci/pcidevs.h>
69 1.1.2.1 cliff #include <dev/pci/pciconf.h>
70 1.1.2.1 cliff
71 1.1.2.1 cliff #ifdef PCI_NETBSD_CONFIGURE
72 1.1.2.1 cliff #include <mips/cache.h>
73 1.1.2.1 cliff #endif
74 1.1.2.1 cliff
75 1.1.2.1 cliff #include <machine/pci_machdep.h>
76 1.1.2.1 cliff
77 1.1.2.1 cliff #ifdef PCI_DEBUG
78 1.1.2.1 cliff int rmixl_pcie_debug = PCI_DEBUG;
79 1.1.2.1 cliff # define DPRINTF(x) do { if (rmixl_pcie_debug) printf x ; } while (0)
80 1.1.2.1 cliff #else
81 1.1.2.1 cliff # define DPRINTF(x)
82 1.1.2.1 cliff #endif
83 1.1.2.1 cliff
84 1.1.2.1 cliff #ifndef DDB
85 1.1.2.1 cliff # define STATIC static
86 1.1.2.1 cliff #else
87 1.1.2.1 cliff # define STATIC
88 1.1.2.1 cliff #endif
89 1.1.2.1 cliff
90 1.1.2.1 cliff
91 1.1.2.1 cliff /*
92 1.1.2.1 cliff * use XKPHYS in order to accomodate XLS 40 bit PCIe bus address
93 1.1.2.1 cliff * PCIe config space is all little endian for now
94 1.1.2.1 cliff */
95 1.1.2.1 cliff #define RMIXL_PCI_VADDR(ba) \
96 1.1.2.1 cliff (volatile uint32_t *)MIPS_PHYS_TO_XKPHYS_UNCACHED(ba)
97 1.1.2.1 cliff #define RMIXL_PCI_READ(o) le32toh(*RMIXL_PCI_VADDR(o))
98 1.1.2.1 cliff #define RMIXL_PCI_WRITE(o,v) *RMIXL_PCI_VADDR(o) = htole32(v)
99 1.1.2.1 cliff
100 1.1.2.1 cliff
101 1.1.2.1 cliff /*
102 1.1.2.1 cliff * XLS PCIe Extended Configuration Registers
103 1.1.2.1 cliff */
104 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_UESR 0x104 /* Uncorrectable Error Status Reg */
105 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_UEMR 0x108 /* Uncorrectable Error Mask Reg */
106 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_UEVR 0x10c /* Uncorrectable Error seVerity Reg */
107 1.1.2.1 cliff #define PCIE_ECFG_UEVR_DFLT \
108 1.1.2.1 cliff (__BITS(18,17) | __BIT(31) | __BITS(5,4) | __BIT(0))
109 1.1.2.1 cliff #define PCIE_ECFG_UExR_RESV (__BITS(31,21) | __BITS(11,6) | __BITS(3,1))
110 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_CESR 0x110 /* Correctable Error Status Reg */
111 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_CEMR 0x114 /* Correctable Error Mask Reg */
112 1.1.2.1 cliff #define PCIE_ECFG_CExR_RESV (__BITS(31,14) | __BITS(11,9) | __BITS(5,1))
113 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_ACCR 0x118 /* Adv. Capabilities Control Reg */
114 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_HLRn(n) (0x11c + ((n) * 4)) /* Header Log Regs */
115 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_RECR 0x12c /* Root Error Command Reg */
116 1.1.2.1 cliff #define PCIE_ECFG_RECR_RESV __BITS(31,3)
117 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_RESR 0x130 /* Root Error Status Reg */
118 1.1.2.1 cliff #define PCIE_ECFG_RESR_RESV __BITS(26,7)
119 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_ESI 0x134 /* Error Source Identification Reg */
120 1.1.2.1 cliff #define RMIXL_PCIE_ECFG_DSNCR 0x140 /* Dev Serial Number Capability Regs */
121 1.1.2.1 cliff
122 1.1.2.1 cliff static const struct {
123 1.1.2.1 cliff u_int offset;
124 1.1.2.1 cliff u_int32_t rw1c;
125 1.1.2.1 cliff } pcie_ecfg_errs_tab[] = {
126 1.1.2.1 cliff { RMIXL_PCIE_ECFG_UESR, (__BITS(20,12) | __BIT(4)) },
127 1.1.2.1 cliff { RMIXL_PCIE_ECFG_CESR, (__BITS(20,12) | __BIT(4)) },
128 1.1.2.1 cliff { RMIXL_PCIE_ECFG_HLRn(0), 0 },
129 1.1.2.1 cliff { RMIXL_PCIE_ECFG_HLRn(1), 0 },
130 1.1.2.1 cliff { RMIXL_PCIE_ECFG_HLRn(2), 0 },
131 1.1.2.1 cliff { RMIXL_PCIE_ECFG_HLRn(3), 0 },
132 1.1.2.1 cliff { RMIXL_PCIE_ECFG_RESR, __BITS(6,0) },
133 1.1.2.1 cliff { RMIXL_PCIE_ECFG_ESI, 0 },
134 1.1.2.1 cliff };
135 1.1.2.1 cliff #define PCIE_ECFG_ERRS_OFFTAB_NENTRIES \
136 1.1.2.1 cliff (sizeof(pcie_ecfg_errs_tab)/sizeof(pcie_ecfg_errs_tab[0]))
137 1.1.2.1 cliff
138 1.1.2.1 cliff static int rmixl_pcie_match(device_t, cfdata_t, void *);
139 1.1.2.1 cliff static void rmixl_pcie_attach(device_t, device_t, void *);
140 1.1.2.1 cliff static void rmixl_pcie_init(struct rmixl_pcie_softc *);
141 1.1.2.1 cliff static void rmixl_pcie_init_ecfg(struct rmixl_pcie_softc *);
142 1.1.2.1 cliff static void rmixl_pcie_attach_hook(struct device *, struct device *,
143 1.1.2.1 cliff struct pcibus_attach_args *);
144 1.1.2.1 cliff static void rmixl_pcie_lnkcfg_4xx(rmixl_pcie_lnktab_t *, uint32_t);
145 1.1.2.1 cliff static void rmixl_pcie_lnkcfg_408Lite(rmixl_pcie_lnktab_t *, uint32_t);
146 1.1.2.1 cliff static void rmixl_pcie_lnkcfg_2xx(rmixl_pcie_lnktab_t *, uint32_t);
147 1.1.2.1 cliff static void rmixl_pcie_lnkcfg_1xx(rmixl_pcie_lnktab_t *, uint32_t);
148 1.1.2.1 cliff static void rmixl_pcie_lnkcfg(struct rmixl_pcie_softc *);
149 1.1.2.1 cliff static void rmixl_pcie_errata(struct rmixl_pcie_softc *);
150 1.1.2.1 cliff static void rmixl_conf_interrupt(void *, int, int, int, int, int *);
151 1.1.2.1 cliff static int rmixl_pcie_bus_maxdevs(void *, int);
152 1.1.2.1 cliff static pcitag_t rmixl_pcie_make_tag(void *, int, int, int);
153 1.1.2.1 cliff static void rmixl_pcie_decompose_tag(void *, pcitag_t, int *, int *, int *);
154 1.1.2.1 cliff void rmixl_pcie_tag_print(const char *restrict, void *, pcitag_t, int, vaddr_t, u_long);
155 1.1.2.1 cliff static pcireg_t rmixl_pcie_conf_read(void *, pcitag_t, int);
156 1.1.2.1 cliff static void rmixl_pcie_conf_write(void *, pcitag_t, int, pcireg_t);
157 1.1.2.1 cliff
158 1.1.2.1 cliff static int rmixl_pcie_intr_map(struct pci_attach_args *,
159 1.1.2.1 cliff pci_intr_handle_t *);
160 1.1.2.1 cliff static const char *
161 1.1.2.1 cliff rmixl_pcie_intr_string(void *, pci_intr_handle_t);
162 1.1.2.1 cliff static const struct evcnt *
163 1.1.2.1 cliff rmixl_pcie_intr_evcnt(void *, pci_intr_handle_t);
164 1.1.2.1 cliff static void *rmixl_pcie_intr_establish(void *, pci_intr_handle_t,
165 1.1.2.1 cliff int, int (*)(void *), void *);
166 1.1.2.1 cliff static void rmixl_pcie_intr_disestablish(void *, void *);
167 1.1.2.1 cliff #if defined(DEBUG) || defined(DDB)
168 1.1.2.1 cliff int rmixl_pcie_error_check(void);
169 1.1.2.1 cliff #endif
170 1.1.2.1 cliff static int _rmixl_pcie_error_check(void *);
171 1.1.2.1 cliff static int rmixl_pcie_error_intr(void *);
172 1.1.2.1 cliff
173 1.1.2.1 cliff /*
174 1.1.2.1 cliff * XXX use locks
175 1.1.2.1 cliff */
176 1.1.2.1 cliff #define PCI_CONF_LOCK(s) (s) = splhigh()
177 1.1.2.1 cliff #define PCI_CONF_UNLOCK(s) splx((s))
178 1.1.2.1 cliff
179 1.1.2.1 cliff
180 1.1.2.1 cliff #define RMIXL_PCIE_CONCAT3(a,b,c) a ## b ## c
181 1.1.2.1 cliff #define RMIXL_PCIE_BAR_INIT(reg, bar, size, align) { \
182 1.1.2.1 cliff struct extent *ext = rmixl_configuration.rc_phys_ex; \
183 1.1.2.1 cliff u_long region_start; \
184 1.1.2.1 cliff uint64_t ba; \
185 1.1.2.1 cliff int err; \
186 1.1.2.1 cliff \
187 1.1.2.1 cliff err = extent_alloc(ext, (size), (align), 0UL, EX_NOWAIT, \
188 1.1.2.1 cliff ®ion_start); \
189 1.1.2.1 cliff if (err != 0) \
190 1.1.2.1 cliff panic("%s: extent_alloc(%p, %#lx, %#lx, %#lx, %#x, %p)",\
191 1.1.2.1 cliff __func__, ext, size, align, 0UL, EX_NOWAIT, \
192 1.1.2.1 cliff ®ion_start); \
193 1.1.2.1 cliff ba = (uint64_t)region_start; \
194 1.1.2.1 cliff ba *= (1024 * 1024); \
195 1.1.2.1 cliff bar = RMIXL_PCIE_CONCAT3(RMIXL_PCIE_,reg,_BAR)(ba, 1); \
196 1.1.2.1 cliff DPRINTF(("PCIE %s BAR was not enabled by firmware\n" \
197 1.1.2.1 cliff "enabling %s at phys %" PRIx64 ", size %lu MB\n", \
198 1.1.2.1 cliff __STRING(reg), __STRING(reg), ba, size)); \
199 1.1.2.1 cliff RMIXL_IOREG_WRITE(RMIXL_IO_DEV_BRIDGE + \
200 1.1.2.1 cliff RMIXL_PCIE_CONCAT3(RMIXL_SBC_PCIE_,reg,_BAR), bar); \
201 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + \
202 1.1.2.1 cliff RMIXL_PCIE_CONCAT3(RMIXL_SBC_PCIE_,reg,_BAR)); \
203 1.1.2.1 cliff DPRINTF(("%s: %s BAR %#x\n", __func__, __STRING(reg), bar)); \
204 1.1.2.1 cliff }
205 1.1.2.1 cliff
206 1.1.2.1 cliff
207 1.1.2.1 cliff #if defined(DEBUG) || defined(DDB)
208 1.1.2.1 cliff static void *rmixl_pcie_v;
209 1.1.2.1 cliff #endif
210 1.1.2.1 cliff
211 1.1.2.1 cliff CFATTACH_DECL_NEW(rmixl_pcie, sizeof(struct rmixl_pcie_softc),
212 1.1.2.1 cliff rmixl_pcie_match, rmixl_pcie_attach, NULL, NULL);
213 1.1.2.1 cliff
214 1.1.2.1 cliff static int rmixl_pcie_found;
215 1.1.2.1 cliff
216 1.1.2.1 cliff /*
217 1.1.2.1 cliff * rmixl_cache_err_dis:
218 1.1.2.1 cliff * - disable Cache, Data ECC, Snoop Tag Parity, Tag Parity errors
219 1.1.2.1 cliff * - clear the cache error log
220 1.1.2.1 cliff * - return previous value from RMIXL_PCR_L1D_CONFIG0
221 1.1.2.1 cliff */
222 1.1.2.1 cliff static inline uint64_t
223 1.1.2.1 cliff rmixl_cache_err_dis(void)
224 1.1.2.1 cliff {
225 1.1.2.1 cliff uint64_t r;
226 1.1.2.1 cliff
227 1.1.2.2 cliff r = rmixl_mfcr(RMIXL_PCR_L1D_CONFIG0);
228 1.1.2.2 cliff rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r & ~0x2e);
229 1.1.2.2 cliff rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
230 1.1.2.1 cliff return r;
231 1.1.2.1 cliff }
232 1.1.2.1 cliff
233 1.1.2.1 cliff /*
234 1.1.2.1 cliff * rmixl_cache_err_restore:
235 1.1.2.1 cliff * - clear the cache error log, cache error overflow log,
236 1.1.2.1 cliff * and cache interrupt registers
237 1.1.2.1 cliff * - restore previous value to RMIXL_PCR_L1D_CONFIG0
238 1.1.2.1 cliff */
239 1.1.2.1 cliff static inline void
240 1.1.2.1 cliff rmixl_cache_err_restore(uint64_t r)
241 1.1.2.1 cliff {
242 1.1.2.2 cliff rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
243 1.1.2.2 cliff rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_OVF_LO, 0);
244 1.1.2.2 cliff rmixl_mtcr(RMIXL_PCR_L1D_CACHE_INTERRUPT, 0);
245 1.1.2.2 cliff rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r);
246 1.1.2.1 cliff }
247 1.1.2.1 cliff
248 1.1.2.1 cliff static inline uint64_t
249 1.1.2.1 cliff rmixl_cache_err_check(void)
250 1.1.2.1 cliff {
251 1.1.2.2 cliff return rmixl_mfcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG);
252 1.1.2.1 cliff }
253 1.1.2.1 cliff
254 1.1.2.1 cliff static int
255 1.1.2.1 cliff rmixl_pcie_match(device_t parent, cfdata_t cf, void *aux)
256 1.1.2.1 cliff {
257 1.1.2.1 cliff uint32_t r;
258 1.1.2.1 cliff
259 1.1.2.1 cliff /* XXX
260 1.1.2.1 cliff * for now there is only one PCIe Interface on chip
261 1.1.2.1 cliff * this could change with furture RMI XL family designs
262 1.1.2.1 cliff */
263 1.1.2.1 cliff if (rmixl_pcie_found)
264 1.1.2.1 cliff return 0;
265 1.1.2.1 cliff
266 1.1.2.1 cliff /* read GPIO Reset Configuration register */
267 1.1.2.1 cliff /* XXX FIXME define the offset */
268 1.1.2.1 cliff r = RMIXL_IOREG_READ(RMIXL_IO_DEV_GPIO + RMIXL_GPIO_RESET_CFG);
269 1.1.2.1 cliff r >>= 26;
270 1.1.2.1 cliff r &= 3;
271 1.1.2.1 cliff if (r != 0)
272 1.1.2.1 cliff return 0; /* strapped for SRIO */
273 1.1.2.1 cliff
274 1.1.2.1 cliff return 1;
275 1.1.2.1 cliff }
276 1.1.2.1 cliff
277 1.1.2.1 cliff static void
278 1.1.2.1 cliff rmixl_pcie_attach(device_t parent, device_t self, void *aux)
279 1.1.2.1 cliff {
280 1.1.2.1 cliff struct rmixl_pcie_softc *sc = device_private(self);
281 1.1.2.1 cliff struct obio_attach_args *obio = aux;
282 1.1.2.1 cliff struct rmixl_config *rcp = &rmixl_configuration;
283 1.1.2.1 cliff struct pcibus_attach_args pba;
284 1.1.2.1 cliff uint32_t bar;
285 1.1.2.1 cliff
286 1.1.2.1 cliff rmixl_pcie_found = 1;
287 1.1.2.1 cliff sc->sc_dev = self;
288 1.1.2.1 cliff
289 1.1.2.1 cliff aprint_normal(" RMI XLS PCIe Interface\n");
290 1.1.2.1 cliff
291 1.1.2.1 cliff rmixl_pcie_lnkcfg(sc);
292 1.1.2.1 cliff
293 1.1.2.1 cliff rmixl_pcie_errata(sc);
294 1.1.2.1 cliff
295 1.1.2.1 cliff sc->sc_29bit_dmat = obio->obio_29bit_dmat;
296 1.1.2.1 cliff sc->sc_32bit_dmat = obio->obio_32bit_dmat;
297 1.1.2.1 cliff sc->sc_64bit_dmat = obio->obio_64bit_dmat;
298 1.1.2.1 cliff
299 1.1.2.1 cliff /*
300 1.1.2.1 cliff * get PCI config space base addr from SBC PCIe CFG BAR
301 1.1.2.1 cliff * initialize it if necessary
302 1.1.2.1 cliff */
303 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXL_SBC_PCIE_CFG_BAR);
304 1.1.2.1 cliff DPRINTF(("%s: PCIE_CFG_BAR %#x\n", __func__, bar));
305 1.1.2.1 cliff if ((bar & RMIXL_PCIE_CFG_BAR_ENB) == 0) {
306 1.1.2.1 cliff u_long n = RMIXL_PCIE_CFG_SIZE / (1024 * 1024);
307 1.1.2.1 cliff RMIXL_PCIE_BAR_INIT(CFG, bar, n, n);
308 1.1.2.1 cliff }
309 1.1.2.1 cliff sc->sc_pcie_cfg_pbase = RMIXL_PCIE_CFG_BAR_TO_BA(bar);
310 1.1.2.1 cliff
311 1.1.2.1 cliff /*
312 1.1.2.1 cliff * get PCIE Extended config space base addr from SBC PCIe ECFG BAR
313 1.1.2.1 cliff * initialize it if necessary
314 1.1.2.1 cliff */
315 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXL_SBC_PCIE_ECFG_BAR);
316 1.1.2.1 cliff DPRINTF(("%s: PCIE_ECFG_BAR %#x\n", __func__, bar));
317 1.1.2.1 cliff if ((bar & RMIXL_PCIE_ECFG_BAR_ENB) == 0) {
318 1.1.2.1 cliff u_long n = RMIXL_PCIE_ECFG_SIZE / (1024 * 1024);
319 1.1.2.1 cliff RMIXL_PCIE_BAR_INIT(ECFG, bar, n, n);
320 1.1.2.1 cliff }
321 1.1.2.1 cliff sc->sc_pcie_ecfg_pbase = RMIXL_PCIE_ECFG_BAR_TO_BA(bar);
322 1.1.2.1 cliff
323 1.1.2.1 cliff /*
324 1.1.2.1 cliff * get PCI MEM space base [addr, size] from SBC PCIe MEM BAR
325 1.1.2.1 cliff * initialize it if necessary
326 1.1.2.1 cliff */
327 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXL_SBC_PCIE_MEM_BAR);
328 1.1.2.1 cliff DPRINTF(("%s: PCIE_MEM_BAR %#x\n", __func__, bar));
329 1.1.2.1 cliff if ((bar & RMIXL_PCIE_MEM_BAR_ENB) == 0) {
330 1.1.2.1 cliff u_long n = 256; /* 256 MB */
331 1.1.2.1 cliff RMIXL_PCIE_BAR_INIT(MEM, bar, n, n);
332 1.1.2.1 cliff }
333 1.1.2.1 cliff rcp->rc_pci_mem_pbase = (bus_addr_t)RMIXL_PCIE_MEM_BAR_TO_BA(bar);
334 1.1.2.1 cliff rcp->rc_pci_mem_size = (bus_size_t)RMIXL_PCIE_MEM_BAR_TO_SIZE(bar);
335 1.1.2.1 cliff
336 1.1.2.1 cliff /*
337 1.1.2.1 cliff * get PCI IO space base [addr, size] from SBC PCIe IO BAR
338 1.1.2.1 cliff * initialize it if necessary
339 1.1.2.1 cliff */
340 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXL_SBC_PCIE_IO_BAR);
341 1.1.2.1 cliff DPRINTF(("%s: PCIE_IO_BAR %#x\n", __func__, bar));
342 1.1.2.1 cliff if ((bar & RMIXL_PCIE_IO_BAR_ENB) == 0) {
343 1.1.2.1 cliff u_long n = 32; /* 32 MB */
344 1.1.2.1 cliff RMIXL_PCIE_BAR_INIT(IO, bar, n, n);
345 1.1.2.1 cliff }
346 1.1.2.1 cliff rcp->rc_pci_io_pbase = (bus_addr_t)RMIXL_PCIE_IO_BAR_TO_BA(bar);
347 1.1.2.1 cliff rcp->rc_pci_io_size = (bus_size_t)RMIXL_PCIE_IO_BAR_TO_SIZE(bar);
348 1.1.2.1 cliff
349 1.1.2.1 cliff /*
350 1.1.2.1 cliff * initialize the PCI bus spaces tag
351 1.1.2.1 cliff */
352 1.1.2.1 cliff rmixl_pcie_bus_mem_init(&rcp->rc_pci_memt, rcp);
353 1.1.2.1 cliff rmixl_pcie_bus_io_init(&rcp->rc_pci_iot, rcp);
354 1.1.2.1 cliff
355 1.1.2.1 cliff /*
356 1.1.2.1 cliff * initialize the extended configuration regs
357 1.1.2.1 cliff */
358 1.1.2.1 cliff rmixl_pcie_init_ecfg(sc);
359 1.1.2.1 cliff
360 1.1.2.1 cliff /*
361 1.1.2.1 cliff * initialize the PCI chipset tag
362 1.1.2.1 cliff */
363 1.1.2.1 cliff rmixl_pcie_init(sc);
364 1.1.2.1 cliff
365 1.1.2.1 cliff /*
366 1.1.2.1 cliff * attach the PCI bus
367 1.1.2.1 cliff */
368 1.1.2.1 cliff memset(&pba, 0, sizeof(pba));
369 1.1.2.1 cliff pba.pba_memt = &rcp->rc_pci_memt;
370 1.1.2.1 cliff pba.pba_iot = &rcp->rc_pci_iot;
371 1.1.2.1 cliff pba.pba_dmat = sc->sc_29bit_dmat; /* XXX */
372 1.1.2.1 cliff #ifdef NOTYET
373 1.1.2.1 cliff pba.pba_dmat64 = NULL;
374 1.1.2.1 cliff #endif
375 1.1.2.1 cliff pba.pba_pc = &sc->sc_pci_chipset;
376 1.1.2.1 cliff pba.pba_bus = 0;
377 1.1.2.1 cliff pba.pba_bridgetag = NULL;
378 1.1.2.1 cliff pba.pba_intrswiz = 0;
379 1.1.2.1 cliff pba.pba_intrtag = 0;
380 1.1.2.1 cliff pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
381 1.1.2.1 cliff PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
382 1.1.2.1 cliff
383 1.1.2.1 cliff (void) config_found_ia(self, "pcibus", &pba, pcibusprint);
384 1.1.2.1 cliff }
385 1.1.2.1 cliff
386 1.1.2.1 cliff /*
387 1.1.2.1 cliff * rmixl_pcie_lnkcfg_4xx - link configs for XLS4xx and XLS6xx
388 1.1.2.1 cliff * use IO_AD[11] and IO_AD[10], observable in
389 1.1.2.1 cliff * Bits[21:20] of the GPIO Reset Configuration register
390 1.1.2.1 cliff */
391 1.1.2.1 cliff static void
392 1.1.2.1 cliff rmixl_pcie_lnkcfg_4xx(rmixl_pcie_lnktab_t *ltp, uint32_t grcr)
393 1.1.2.1 cliff {
394 1.1.2.1 cliff u_int index;
395 1.1.2.1 cliff static const rmixl_pcie_lnkcfg_t lnktab_4xx[4][4] = {
396 1.1.2.1 cliff {{ LCFG_EP, 4}, {LCFG_NO, 0}, {LCFG_NO, 0}, {LCFG_NO, 0}},
397 1.1.2.1 cliff {{ LCFG_RC, 4}, {LCFG_NO, 0}, {LCFG_NO, 0}, {LCFG_NO, 0}},
398 1.1.2.1 cliff {{ LCFG_EP, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}},
399 1.1.2.1 cliff {{ LCFG_RC, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}},
400 1.1.2.1 cliff };
401 1.1.2.1 cliff static const char *lnkstr_4xx[4] = {
402 1.1.2.1 cliff "EP 1x4",
403 1.1.2.1 cliff "RC 1x4",
404 1.1.2.1 cliff "EP 1x1, RC 4x1",
405 1.1.2.1 cliff "RC 4x1"
406 1.1.2.1 cliff };
407 1.1.2.1 cliff index = (grcr >> 20) & 3;
408 1.1.2.1 cliff ltp->ncfgs = 4;
409 1.1.2.1 cliff ltp->cfg = lnktab_4xx[index];
410 1.1.2.1 cliff ltp->str = lnkstr_4xx[index];
411 1.1.2.1 cliff }
412 1.1.2.1 cliff
413 1.1.2.1 cliff /*
414 1.1.2.1 cliff * rmixl_pcie_lnkcfg_408Lite - link configs for XLS408Lite and XLS04A
415 1.1.2.1 cliff * use IO_AD[11] and IO_AD[10], observable in
416 1.1.2.1 cliff * Bits[21:20] of the GPIO Reset Configuration register
417 1.1.2.1 cliff */
418 1.1.2.1 cliff static void
419 1.1.2.1 cliff rmixl_pcie_lnkcfg_408Lite(rmixl_pcie_lnktab_t *ltp, uint32_t grcr)
420 1.1.2.1 cliff {
421 1.1.2.1 cliff u_int index;
422 1.1.2.1 cliff static const rmixl_pcie_lnkcfg_t lnktab_408Lite[4][2] = {
423 1.1.2.1 cliff {{ LCFG_EP, 4}, {LCFG_NO, 0}},
424 1.1.2.1 cliff {{ LCFG_RC, 4}, {LCFG_NO, 0}},
425 1.1.2.1 cliff {{ LCFG_EP, 1}, {LCFG_RC, 1}},
426 1.1.2.1 cliff {{ LCFG_RC, 1}, {LCFG_RC, 1}},
427 1.1.2.1 cliff };
428 1.1.2.1 cliff static const char *lnkstr_408Lite[4] = {
429 1.1.2.1 cliff "EP 1x4",
430 1.1.2.1 cliff "RC 1x4",
431 1.1.2.1 cliff "EP 1x1, RC 1x1",
432 1.1.2.1 cliff "RC 2x1"
433 1.1.2.1 cliff };
434 1.1.2.1 cliff
435 1.1.2.1 cliff index = (grcr >> 20) & 3;
436 1.1.2.1 cliff ltp->ncfgs = 2;
437 1.1.2.1 cliff ltp->cfg = lnktab_408Lite[index];
438 1.1.2.1 cliff ltp->str = lnkstr_408Lite[index];
439 1.1.2.1 cliff }
440 1.1.2.1 cliff
441 1.1.2.1 cliff /*
442 1.1.2.1 cliff * rmixl_pcie_lnkcfg_2xx - link configs for XLS2xx
443 1.1.2.1 cliff * use IO_AD[10], observable in Bit[20] of the
444 1.1.2.1 cliff * GPIO Reset Configuration register
445 1.1.2.1 cliff */
446 1.1.2.1 cliff static void
447 1.1.2.1 cliff rmixl_pcie_lnkcfg_2xx(rmixl_pcie_lnktab_t *ltp, uint32_t grcr)
448 1.1.2.1 cliff {
449 1.1.2.1 cliff u_int index;
450 1.1.2.1 cliff static const rmixl_pcie_lnkcfg_t lnktab_2xx[2][4] = {
451 1.1.2.1 cliff {{ LCFG_EP, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}},
452 1.1.2.1 cliff {{ LCFG_RC, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}, {LCFG_RC, 1}}
453 1.1.2.1 cliff };
454 1.1.2.1 cliff static const char *lnkstr_2xx[2] = {
455 1.1.2.1 cliff "EP 1x1, RC 3x1",
456 1.1.2.1 cliff "RC 4x1",
457 1.1.2.1 cliff };
458 1.1.2.1 cliff
459 1.1.2.1 cliff index = (grcr >> 20) & 1;
460 1.1.2.1 cliff ltp->ncfgs = 4;
461 1.1.2.1 cliff ltp->cfg = lnktab_2xx[index];
462 1.1.2.1 cliff ltp->str = lnkstr_2xx[index];
463 1.1.2.1 cliff }
464 1.1.2.1 cliff
465 1.1.2.1 cliff /*
466 1.1.2.1 cliff * rmixl_pcie_lnkcfg_1xx - link configs for XLS1xx
467 1.1.2.1 cliff * use IO_AD[10], observable in Bit[20] of the
468 1.1.2.1 cliff * GPIO Reset Configuration register
469 1.1.2.1 cliff */
470 1.1.2.1 cliff static void
471 1.1.2.1 cliff rmixl_pcie_lnkcfg_1xx(rmixl_pcie_lnktab_t *ltp, uint32_t grcr)
472 1.1.2.1 cliff {
473 1.1.2.1 cliff u_int index;
474 1.1.2.1 cliff static const rmixl_pcie_lnkcfg_t lnktab_1xx[2][2] = {
475 1.1.2.1 cliff {{ LCFG_EP, 1}, {LCFG_RC, 1}},
476 1.1.2.1 cliff {{ LCFG_RC, 1}, {LCFG_RC, 1}}
477 1.1.2.1 cliff };
478 1.1.2.1 cliff static const char *lnkstr_1xx[2] = {
479 1.1.2.1 cliff "EP 1x1, RC 1x1",
480 1.1.2.1 cliff "RC 2x1",
481 1.1.2.1 cliff };
482 1.1.2.1 cliff
483 1.1.2.1 cliff index = (grcr >> 20) & 1;
484 1.1.2.1 cliff ltp->ncfgs = 2;
485 1.1.2.1 cliff ltp->cfg = lnktab_1xx[index];
486 1.1.2.1 cliff ltp->str = lnkstr_1xx[index];
487 1.1.2.1 cliff }
488 1.1.2.1 cliff
489 1.1.2.1 cliff /*
490 1.1.2.1 cliff * rmixl_pcie_lnkcfg - determine PCI Express Link Configuration
491 1.1.2.1 cliff */
492 1.1.2.1 cliff static void
493 1.1.2.1 cliff rmixl_pcie_lnkcfg(struct rmixl_pcie_softc *sc)
494 1.1.2.1 cliff {
495 1.1.2.1 cliff uint32_t r;
496 1.1.2.1 cliff
497 1.1.2.1 cliff /* read GPIO Reset Configuration register */
498 1.1.2.1 cliff r = RMIXL_IOREG_READ(RMIXL_IO_DEV_GPIO + RMIXL_GPIO_RESET_CFG);
499 1.1.2.1 cliff DPRINTF(("%s: GPIO RCR %#x\n", __func__, r));
500 1.1.2.1 cliff
501 1.1.2.1 cliff switch (MIPS_PRID_IMPL(cpu_id)) {
502 1.1.2.1 cliff case MIPS_XLS104:
503 1.1.2.1 cliff case MIPS_XLS108:
504 1.1.2.1 cliff rmixl_pcie_lnkcfg_1xx(&sc->sc_pcie_lnktab, r);
505 1.1.2.1 cliff break;
506 1.1.2.1 cliff case MIPS_XLS204:
507 1.1.2.1 cliff case MIPS_XLS208:
508 1.1.2.1 cliff rmixl_pcie_lnkcfg_2xx(&sc->sc_pcie_lnktab, r);
509 1.1.2.1 cliff break;
510 1.1.2.1 cliff case MIPS_XLS404LITE:
511 1.1.2.1 cliff case MIPS_XLS408LITE:
512 1.1.2.1 cliff rmixl_pcie_lnkcfg_408Lite(&sc->sc_pcie_lnktab, r);
513 1.1.2.1 cliff break;
514 1.1.2.1 cliff case MIPS_XLS404:
515 1.1.2.1 cliff case MIPS_XLS408:
516 1.1.2.1 cliff case MIPS_XLS416:
517 1.1.2.1 cliff case MIPS_XLS608:
518 1.1.2.1 cliff case MIPS_XLS616:
519 1.1.2.1 cliff /* 6xx uses same table as 4xx */
520 1.1.2.1 cliff rmixl_pcie_lnkcfg_4xx(&sc->sc_pcie_lnktab, r);
521 1.1.2.1 cliff break;
522 1.1.2.1 cliff default:
523 1.1.2.1 cliff panic("%s: unknown RMI PRID IMPL", __func__);
524 1.1.2.1 cliff }
525 1.1.2.1 cliff
526 1.1.2.1 cliff aprint_normal("%s: link config %s\n",
527 1.1.2.1 cliff device_xname(sc->sc_dev), sc->sc_pcie_lnktab.str);
528 1.1.2.1 cliff }
529 1.1.2.1 cliff
530 1.1.2.1 cliff static void
531 1.1.2.1 cliff rmixl_pcie_errata(struct rmixl_pcie_softc *sc)
532 1.1.2.1 cliff {
533 1.1.2.1 cliff u_int rev;
534 1.1.2.1 cliff u_int lanes;
535 1.1.2.1 cliff bool e391 = false;
536 1.1.2.1 cliff
537 1.1.2.1 cliff /*
538 1.1.2.1 cliff * 3.9.1 PCIe Link-0 Registers Reset to Incorrect Values
539 1.1.2.1 cliff * check if it allies to this CPU implementation and revision
540 1.1.2.1 cliff */
541 1.1.2.1 cliff rev = MIPS_PRID_REV(cpu_id);
542 1.1.2.1 cliff switch (MIPS_PRID_IMPL(cpu_id)) {
543 1.1.2.1 cliff case MIPS_XLS104:
544 1.1.2.1 cliff case MIPS_XLS108:
545 1.1.2.1 cliff break;
546 1.1.2.1 cliff case MIPS_XLS204:
547 1.1.2.1 cliff case MIPS_XLS208:
548 1.1.2.1 cliff /* stepping A0 is affected */
549 1.1.2.1 cliff if (rev == 0)
550 1.1.2.1 cliff e391 = true;
551 1.1.2.1 cliff break;
552 1.1.2.1 cliff case MIPS_XLS404LITE:
553 1.1.2.1 cliff case MIPS_XLS408LITE:
554 1.1.2.1 cliff break;
555 1.1.2.1 cliff case MIPS_XLS404:
556 1.1.2.1 cliff case MIPS_XLS408:
557 1.1.2.1 cliff case MIPS_XLS416:
558 1.1.2.1 cliff /* steppings A0 and A1 are affected */
559 1.1.2.1 cliff if ((rev == 0) || (rev == 1))
560 1.1.2.1 cliff e391 = true;
561 1.1.2.1 cliff break;
562 1.1.2.1 cliff case MIPS_XLS608:
563 1.1.2.1 cliff case MIPS_XLS616:
564 1.1.2.1 cliff break;
565 1.1.2.1 cliff default:
566 1.1.2.1 cliff panic("unknown RMI PRID IMPL");
567 1.1.2.1 cliff }
568 1.1.2.1 cliff
569 1.1.2.1 cliff /*
570 1.1.2.1 cliff * for XLS we only need to check entry #0
571 1.1.2.1 cliff * this may need to change for later XL family chips
572 1.1.2.1 cliff */
573 1.1.2.1 cliff lanes = sc->sc_pcie_lnktab.cfg[0].lanes;
574 1.1.2.1 cliff
575 1.1.2.1 cliff if ((e391 != false) && ((lanes == 2) || (lanes == 4))) {
576 1.1.2.1 cliff /*
577 1.1.2.1 cliff * attempt work around for errata 3.9.1
578 1.1.2.1 cliff * "PCIe Link-0 Registers Reset to Incorrect Values"
579 1.1.2.1 cliff * the registers are write-once: if the firmware already wrote,
580 1.1.2.1 cliff * then our writes are ignored; hope they did it right.
581 1.1.2.1 cliff */
582 1.1.2.1 cliff uint32_t queuectrl;
583 1.1.2.1 cliff uint32_t bufdepth;
584 1.1.2.1 cliff #ifdef DIAGNOSTIC
585 1.1.2.1 cliff uint32_t r;
586 1.1.2.1 cliff #endif
587 1.1.2.1 cliff
588 1.1.2.1 cliff aprint_normal("%s: attempt work around for errata 3.9.1",
589 1.1.2.1 cliff device_xname(sc->sc_dev));
590 1.1.2.1 cliff if (lanes == 4) {
591 1.1.2.1 cliff queuectrl = 0x00018074;
592 1.1.2.1 cliff bufdepth = 0x001901D1;
593 1.1.2.1 cliff } else {
594 1.1.2.1 cliff queuectrl = 0x00018036;
595 1.1.2.1 cliff bufdepth = 0x001900D9;
596 1.1.2.1 cliff }
597 1.1.2.1 cliff
598 1.1.2.1 cliff RMIXL_IOREG_WRITE(RMIXL_IO_DEV_PCIE_BE +
599 1.1.2.1 cliff RMIXL_VC0_POSTED_RX_QUEUE_CTRL, queuectrl);
600 1.1.2.1 cliff RMIXL_IOREG_WRITE(RMIXL_IO_DEV_PCIE_BE +
601 1.1.2.1 cliff RMIXL_VC0_POSTED_BUFFER_DEPTH, bufdepth);
602 1.1.2.1 cliff
603 1.1.2.1 cliff #ifdef DIAGNOSTIC
604 1.1.2.1 cliff r = RMIXL_IOREG_READ(RMIXL_IO_DEV_PCIE_BE +
605 1.1.2.1 cliff RMIXL_VC0_POSTED_RX_QUEUE_CTRL);
606 1.1.2.1 cliff printf("\nVC0_POSTED_RX_QUEUE_CTRL %#x\n", r);
607 1.1.2.1 cliff
608 1.1.2.1 cliff r = RMIXL_IOREG_READ(RMIXL_IO_DEV_PCIE_BE +
609 1.1.2.1 cliff RMIXL_VC0_POSTED_BUFFER_DEPTH);
610 1.1.2.1 cliff printf("VC0_POSTED_BUFFER_DEPTH %#x\n", r);
611 1.1.2.1 cliff #endif
612 1.1.2.1 cliff }
613 1.1.2.1 cliff }
614 1.1.2.1 cliff
615 1.1.2.1 cliff static void
616 1.1.2.1 cliff rmixl_pcie_init(struct rmixl_pcie_softc *sc)
617 1.1.2.1 cliff {
618 1.1.2.1 cliff pci_chipset_tag_t pc = &sc->sc_pci_chipset;
619 1.1.2.1 cliff #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
620 1.1.2.1 cliff struct extent *ioext, *memext;
621 1.1.2.1 cliff #endif
622 1.1.2.1 cliff
623 1.1.2.1 cliff pc->pc_conf_v = (void *)sc;
624 1.1.2.1 cliff pc->pc_attach_hook = rmixl_pcie_attach_hook;
625 1.1.2.1 cliff pc->pc_bus_maxdevs = rmixl_pcie_bus_maxdevs;
626 1.1.2.1 cliff pc->pc_make_tag = rmixl_pcie_make_tag;
627 1.1.2.1 cliff pc->pc_decompose_tag = rmixl_pcie_decompose_tag;
628 1.1.2.1 cliff pc->pc_conf_read = rmixl_pcie_conf_read;
629 1.1.2.1 cliff pc->pc_conf_write = rmixl_pcie_conf_write;
630 1.1.2.1 cliff
631 1.1.2.1 cliff pc->pc_intr_v = (void *)sc;
632 1.1.2.1 cliff pc->pc_intr_map = rmixl_pcie_intr_map;
633 1.1.2.1 cliff pc->pc_intr_string = rmixl_pcie_intr_string;
634 1.1.2.1 cliff pc->pc_intr_evcnt = rmixl_pcie_intr_evcnt;
635 1.1.2.1 cliff pc->pc_intr_establish = rmixl_pcie_intr_establish;
636 1.1.2.1 cliff pc->pc_intr_disestablish = rmixl_pcie_intr_disestablish;
637 1.1.2.1 cliff pc->pc_conf_interrupt = rmixl_conf_interrupt;
638 1.1.2.1 cliff
639 1.1.2.1 cliff #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
640 1.1.2.1 cliff /*
641 1.1.2.1 cliff * Configure the PCI bus.
642 1.1.2.1 cliff */
643 1.1.2.1 cliff struct rmixl_config *rcp = &rmixl_configuration;
644 1.1.2.1 cliff
645 1.1.2.1 cliff aprint_normal("%s: configuring PCI bus\n",
646 1.1.2.1 cliff device_xname(sc->sc_dev));
647 1.1.2.1 cliff
648 1.1.2.1 cliff ioext = extent_create("pciio",
649 1.1.2.1 cliff rcp->rc_pci_io_pbase,
650 1.1.2.1 cliff rcp->rc_pci_io_pbase + rcp->rc_pci_io_size - 1,
651 1.1.2.1 cliff M_DEVBUF, NULL, 0, EX_NOWAIT);
652 1.1.2.1 cliff
653 1.1.2.1 cliff memext = extent_create("pcimem",
654 1.1.2.1 cliff rcp->rc_pci_mem_pbase,
655 1.1.2.1 cliff rcp->rc_pci_mem_pbase + rcp->rc_pci_mem_size - 1,
656 1.1.2.1 cliff M_DEVBUF, NULL, 0, EX_NOWAIT);
657 1.1.2.1 cliff
658 1.1.2.1 cliff pci_configure_bus(pc, ioext, memext, NULL, 0, mips_dcache_align);
659 1.1.2.1 cliff
660 1.1.2.1 cliff extent_destroy(ioext);
661 1.1.2.1 cliff extent_destroy(memext);
662 1.1.2.1 cliff #endif
663 1.1.2.1 cliff }
664 1.1.2.1 cliff
665 1.1.2.1 cliff static void
666 1.1.2.1 cliff rmixl_pcie_init_ecfg(struct rmixl_pcie_softc *sc)
667 1.1.2.1 cliff {
668 1.1.2.1 cliff void *v;
669 1.1.2.1 cliff pcitag_t tag;
670 1.1.2.1 cliff pcireg_t r;
671 1.1.2.1 cliff
672 1.1.2.1 cliff v = sc;
673 1.1.2.1 cliff tag = rmixl_pcie_make_tag(v, 0, 0, 0);
674 1.1.2.1 cliff
675 1.1.2.1 cliff #ifdef PCI_DEBUG
676 1.1.2.1 cliff int i, offset;
677 1.1.2.1 cliff static const int offtab[] =
678 1.1.2.1 cliff { 0, 4, 8, 0xc, 0x10, 0x14, 0x18, 0x1c,
679 1.1.2.1 cliff 0x2c, 0x30, 0x34 };
680 1.1.2.1 cliff for (i=0; i < sizeof(offtab)/sizeof(offtab[0]); i++) {
681 1.1.2.1 cliff offset = 0x100 + offtab[i];
682 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, offset);
683 1.1.2.1 cliff printf("%s: %#x: %#x\n", __func__, offset, r);
684 1.1.2.1 cliff }
685 1.1.2.1 cliff #endif
686 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, 0x100);
687 1.1.2.1 cliff if (r == -1)
688 1.1.2.1 cliff return; /* cannot access */
689 1.1.2.1 cliff
690 1.1.2.1 cliff /* check pre-existing uncorrectable errs */
691 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, RMIXL_PCIE_ECFG_UESR);
692 1.1.2.1 cliff r &= ~PCIE_ECFG_UExR_RESV;
693 1.1.2.1 cliff if (r != 0)
694 1.1.2.1 cliff panic("%s: Uncorrectable Error Status: %#x\n",
695 1.1.2.1 cliff __func__, r);
696 1.1.2.1 cliff
697 1.1.2.1 cliff /* unmask all uncorrectable errs */
698 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, RMIXL_PCIE_ECFG_UEMR);
699 1.1.2.1 cliff r &= ~PCIE_ECFG_UExR_RESV;
700 1.1.2.1 cliff rmixl_pcie_conf_write(v, tag, RMIXL_PCIE_ECFG_UEMR, r);
701 1.1.2.1 cliff
702 1.1.2.1 cliff /* ensure default uncorrectable err severity confniguration */
703 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, RMIXL_PCIE_ECFG_UEVR);
704 1.1.2.1 cliff r &= ~PCIE_ECFG_UExR_RESV;
705 1.1.2.1 cliff r |= PCIE_ECFG_UEVR_DFLT;
706 1.1.2.1 cliff rmixl_pcie_conf_write(v, tag, RMIXL_PCIE_ECFG_UEVR, r);
707 1.1.2.1 cliff
708 1.1.2.1 cliff /* check pre-existing correctable errs */
709 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, RMIXL_PCIE_ECFG_CESR);
710 1.1.2.1 cliff r &= ~PCIE_ECFG_CExR_RESV;
711 1.1.2.1 cliff #ifdef DIAGNOSTIC
712 1.1.2.1 cliff if (r != 0)
713 1.1.2.1 cliff aprint_normal("%s: Correctable Error Status: %#x\n",
714 1.1.2.1 cliff device_xname(sc->sc_dev), r);
715 1.1.2.1 cliff #endif
716 1.1.2.1 cliff
717 1.1.2.1 cliff /* unmask all correctable errs */
718 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, RMIXL_PCIE_ECFG_CEMR);
719 1.1.2.1 cliff r &= ~PCIE_ECFG_CExR_RESV;
720 1.1.2.1 cliff rmixl_pcie_conf_write(v, tag, RMIXL_PCIE_ECFG_UEMR, r);
721 1.1.2.1 cliff
722 1.1.2.1 cliff /* check pre-existing Root Error Status */
723 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, RMIXL_PCIE_ECFG_RESR);
724 1.1.2.1 cliff r &= ~PCIE_ECFG_RESR_RESV;
725 1.1.2.1 cliff if (r != 0)
726 1.1.2.1 cliff panic("%s: Root Error Status: %#x\n", __func__, r);
727 1.1.2.1 cliff /* XXX TMP FIXME */
728 1.1.2.1 cliff
729 1.1.2.1 cliff /* enable all Root errs */
730 1.1.2.1 cliff r = (pcireg_t)(~PCIE_ECFG_RECR_RESV);
731 1.1.2.1 cliff rmixl_pcie_conf_write(v, tag, RMIXL_PCIE_ECFG_RECR, r);
732 1.1.2.1 cliff
733 1.1.2.1 cliff
734 1.1.2.1 cliff if (MIPS_PRID_IMPL(cpu_id) == MIPS_XLS408LITE) {
735 1.1.2.1 cliff /*
736 1.1.2.1 cliff * establish ISR for PCIE Fatal Error interrupt
737 1.1.2.1 cliff * XXX for XLS408Lite, XLS2xx, XLS1xx only
738 1.1.2.1 cliff * tested on XLS408Lite only
739 1.1.2.1 cliff */
740 1.1.2.1 cliff (void)rmixl_intr_establish(29, IPL_HIGH,
741 1.1.2.1 cliff RMIXL_INTR_LEVEL, RMIXL_INTR_HIGH,
742 1.1.2.1 cliff rmixl_pcie_error_intr, v);
743 1.1.2.1 cliff }
744 1.1.2.1 cliff #if defined(DEBUG) || defined(DDB)
745 1.1.2.1 cliff rmixl_pcie_v = v;
746 1.1.2.1 cliff #endif
747 1.1.2.1 cliff }
748 1.1.2.1 cliff
749 1.1.2.1 cliff void
750 1.1.2.1 cliff rmixl_conf_interrupt(void *v, int bus, int dev, int ipin, int swiz, int *iline)
751 1.1.2.1 cliff {
752 1.1.2.1 cliff DPRINTF(("%s: %p, %d, %d, %d, %d, %p\n",
753 1.1.2.1 cliff __func__, v, bus, dev, ipin, swiz, iline));
754 1.1.2.1 cliff }
755 1.1.2.1 cliff
756 1.1.2.1 cliff void
757 1.1.2.1 cliff rmixl_pcie_attach_hook(struct device *parent, struct device *self,
758 1.1.2.1 cliff struct pcibus_attach_args *pba)
759 1.1.2.1 cliff {
760 1.1.2.1 cliff DPRINTF(("%s: pba_bus %d, pba_bridgetag %p, pc_conf_v %p\n",
761 1.1.2.1 cliff __func__, pba->pba_bus, pba->pba_bridgetag,
762 1.1.2.1 cliff pba->pba_pc->pc_conf_v));
763 1.1.2.1 cliff }
764 1.1.2.1 cliff
765 1.1.2.1 cliff int
766 1.1.2.1 cliff rmixl_pcie_bus_maxdevs(void *v, int busno)
767 1.1.2.1 cliff {
768 1.1.2.1 cliff return (32); /* XXX depends on the family of XLS SoC */
769 1.1.2.1 cliff }
770 1.1.2.1 cliff
771 1.1.2.1 cliff /*
772 1.1.2.1 cliff * XLS pci tag is a 40 bit address composed thusly:
773 1.1.2.1 cliff * 39:25 (reserved)
774 1.1.2.1 cliff * 24 Swap (0=little, 1=big endian)
775 1.1.2.1 cliff * 23:16 Bus number
776 1.1.2.1 cliff * 15:11 Device number
777 1.1.2.1 cliff * 10:8 Function number
778 1.1.2.1 cliff * 0:7 Register number
779 1.1.2.1 cliff */
780 1.1.2.1 cliff pcitag_t
781 1.1.2.1 cliff rmixl_pcie_make_tag(void *v, int b, int d, int f)
782 1.1.2.1 cliff {
783 1.1.2.1 cliff return ((b << 16) | (d << 11) | (f << 8));
784 1.1.2.1 cliff }
785 1.1.2.1 cliff
786 1.1.2.1 cliff void
787 1.1.2.1 cliff rmixl_pcie_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp, int *fp)
788 1.1.2.1 cliff {
789 1.1.2.1 cliff if (bp != NULL)
790 1.1.2.1 cliff *bp = (tag >> 16) & 0xff;
791 1.1.2.1 cliff if (dp != NULL)
792 1.1.2.1 cliff *dp = (tag >> 11) & 0x1f;
793 1.1.2.1 cliff if (fp != NULL)
794 1.1.2.1 cliff *fp = (tag >> 8) & 0x7;
795 1.1.2.1 cliff }
796 1.1.2.1 cliff
797 1.1.2.1 cliff void
798 1.1.2.1 cliff rmixl_pcie_tag_print(const char *restrict s, void *v, pcitag_t tag, int offset,
799 1.1.2.1 cliff vaddr_t va, u_long r)
800 1.1.2.1 cliff {
801 1.1.2.1 cliff int bus, dev, fun;
802 1.1.2.1 cliff
803 1.1.2.1 cliff rmixl_pcie_decompose_tag(v, tag, &bus, &dev, &fun);
804 1.1.2.1 cliff printf("%s: %d/%d/%d/%d - %#lx:%#lx\n",
805 1.1.2.1 cliff s, bus, dev, fun, offset, va, r);
806 1.1.2.1 cliff }
807 1.1.2.1 cliff
808 1.1.2.1 cliff pcireg_t
809 1.1.2.1 cliff rmixl_pcie_conf_read(void *v, pcitag_t tag, int offset)
810 1.1.2.1 cliff {
811 1.1.2.1 cliff struct rmixl_pcie_softc *sc = v;
812 1.1.2.1 cliff bus_addr_t ba;
813 1.1.2.1 cliff vaddr_t va;
814 1.1.2.1 cliff pcireg_t rv;
815 1.1.2.1 cliff uint64_t cfg0;
816 1.1.2.1 cliff u_int s;
817 1.1.2.1 cliff
818 1.1.2.1 cliff PCI_CONF_LOCK(s);
819 1.1.2.1 cliff cfg0 = rmixl_cache_err_dis();
820 1.1.2.1 cliff
821 1.1.2.1 cliff /*
822 1.1.2.1 cliff * base bus addr depends on offset
823 1.1.2.1 cliff */
824 1.1.2.1 cliff if ((offset >= 0) && ( offset < 0x100)) {
825 1.1.2.1 cliff ba = sc->sc_pcie_cfg_pbase;
826 1.1.2.1 cliff } else if ((offset >= 0x100) && (offset <= 0x700)) {
827 1.1.2.1 cliff ba = sc->sc_pcie_ecfg_pbase;
828 1.1.2.1 cliff if (ba == -1)
829 1.1.2.1 cliff return -1;
830 1.1.2.1 cliff } else {
831 1.1.2.1 cliff panic("%s: offset %#x: unknown", __func__, offset);
832 1.1.2.1 cliff }
833 1.1.2.1 cliff ba += (tag + offset);
834 1.1.2.1 cliff va = (vaddr_t)RMIXL_PCI_VADDR(ba);
835 1.1.2.1 cliff rv = RMIXL_PCI_READ(va);
836 1.1.2.1 cliff if (rmixl_cache_err_check() != 0) {
837 1.1.2.1 cliff #ifdef DIAGNOSTIC
838 1.1.2.1 cliff int bus, dev, fun;
839 1.1.2.1 cliff
840 1.1.2.1 cliff rmixl_pcie_decompose_tag(v, tag, &bus, &dev, &fun);
841 1.1.2.1 cliff printf("%s: %d/%d/%d, offset %#x: bad address\n",
842 1.1.2.1 cliff __func__, bus, dev, fun, offset);
843 1.1.2.1 cliff #endif
844 1.1.2.1 cliff rv = (pcireg_t) -1;
845 1.1.2.1 cliff }
846 1.1.2.1 cliff
847 1.1.2.1 cliff rmixl_cache_err_restore(cfg0);
848 1.1.2.1 cliff PCI_CONF_UNLOCK(s);
849 1.1.2.1 cliff return rv;
850 1.1.2.1 cliff }
851 1.1.2.1 cliff
852 1.1.2.1 cliff void
853 1.1.2.1 cliff rmixl_pcie_conf_write(void *v, pcitag_t tag, int offset, pcireg_t val)
854 1.1.2.1 cliff {
855 1.1.2.1 cliff struct rmixl_pcie_softc *sc = v;
856 1.1.2.1 cliff bus_addr_t ba;
857 1.1.2.1 cliff vaddr_t va;
858 1.1.2.1 cliff uint64_t cfg0;
859 1.1.2.1 cliff u_int s;
860 1.1.2.1 cliff
861 1.1.2.1 cliff PCI_CONF_LOCK(s);
862 1.1.2.1 cliff cfg0 = rmixl_cache_err_dis();
863 1.1.2.1 cliff
864 1.1.2.1 cliff /*
865 1.1.2.1 cliff * base bus addr depends on offset
866 1.1.2.1 cliff */
867 1.1.2.1 cliff if ((offset >= 0) && ( offset < 0x100)) {
868 1.1.2.1 cliff ba = sc->sc_pcie_cfg_pbase;
869 1.1.2.1 cliff } else if ((offset >= 0x100) && (offset <= 0x700)) {
870 1.1.2.1 cliff ba = sc->sc_pcie_ecfg_pbase;
871 1.1.2.1 cliff if (ba == -1)
872 1.1.2.1 cliff panic("%s: offset %#x: PCIe ECFG space not connfigured",
873 1.1.2.1 cliff __func__, offset);
874 1.1.2.1 cliff } else {
875 1.1.2.1 cliff panic("%s: offset %#x: unknown", __func__, offset);
876 1.1.2.1 cliff }
877 1.1.2.1 cliff ba += (tag + offset);
878 1.1.2.1 cliff va = (vaddr_t)RMIXL_PCI_VADDR(ba);
879 1.1.2.1 cliff RMIXL_PCI_WRITE(ba, val);
880 1.1.2.1 cliff #ifdef DIAGNOSTIC
881 1.1.2.1 cliff if (rmixl_cache_err_check() != 0) {
882 1.1.2.1 cliff int bus, dev, fun;
883 1.1.2.1 cliff
884 1.1.2.1 cliff rmixl_pcie_decompose_tag(v, tag, &bus, &dev, &fun);
885 1.1.2.1 cliff printf("%s: %d/%d/%d, offset %#x: bad address\n",
886 1.1.2.1 cliff __func__, bus, dev, fun, offset);
887 1.1.2.1 cliff }
888 1.1.2.1 cliff #endif
889 1.1.2.1 cliff
890 1.1.2.1 cliff rmixl_cache_err_restore(cfg0);
891 1.1.2.1 cliff PCI_CONF_UNLOCK(s);
892 1.1.2.1 cliff }
893 1.1.2.1 cliff
894 1.1.2.1 cliff int
895 1.1.2.1 cliff rmixl_pcie_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *pih)
896 1.1.2.1 cliff {
897 1.1.2.1 cliff u_int irq;
898 1.1.2.1 cliff
899 1.1.2.1 cliff #ifdef DEBUG
900 1.1.2.1 cliff DPRINTF(("%s: ps_bus %d, pa_intrswiz %#x, pa_intrtag %#lx,"
901 1.1.2.1 cliff " pa_intrpin %d, pa_intrline %d, pa_rawintrpin %d\n",
902 1.1.2.1 cliff __func__, pa->pa_bus, pa->pa_intrswiz, pa->pa_intrtag,
903 1.1.2.1 cliff pa->pa_intrpin, pa->pa_intrline, pa->pa_rawintrpin));
904 1.1.2.1 cliff #endif
905 1.1.2.1 cliff
906 1.1.2.1 cliff /*
907 1.1.2.1 cliff * XXX cpu implementation specific
908 1.1.2.1 cliff */
909 1.1.2.1 cliff switch (MIPS_PRID_IMPL(cpu_id)) {
910 1.1.2.1 cliff case MIPS_XLS408LITE:
911 1.1.2.1 cliff switch (pa->pa_bus) {
912 1.1.2.1 cliff case 1:
913 1.1.2.1 cliff irq = 26;
914 1.1.2.1 cliff break;
915 1.1.2.1 cliff case 2:
916 1.1.2.1 cliff irq = 27;
917 1.1.2.1 cliff break;
918 1.1.2.1 cliff default:
919 1.1.2.1 cliff panic("%s: bad bus %d\n", __func__, pa->pa_bus);
920 1.1.2.1 cliff }
921 1.1.2.1 cliff break;
922 1.1.2.1 cliff case MIPS_XLS416:
923 1.1.2.1 cliff case MIPS_XLS616:
924 1.1.2.1 cliff switch (pa->pa_bus) {
925 1.1.2.1 cliff case 1:
926 1.1.2.1 cliff irq = 26;
927 1.1.2.1 cliff break;
928 1.1.2.1 cliff case 2:
929 1.1.2.1 cliff irq = 27;
930 1.1.2.1 cliff break;
931 1.1.2.1 cliff case 3:
932 1.1.2.1 cliff irq = 28;
933 1.1.2.1 cliff break;
934 1.1.2.1 cliff case 4:
935 1.1.2.1 cliff irq = 29;
936 1.1.2.1 cliff break;
937 1.1.2.1 cliff default:
938 1.1.2.1 cliff panic("%s: bad bus %d\n", __func__, pa->pa_bus);
939 1.1.2.1 cliff }
940 1.1.2.1 cliff break;
941 1.1.2.1 cliff default:
942 1.1.2.1 cliff panic("%s: cpu IMPL %#x not supported\n",
943 1.1.2.1 cliff __func__, MIPS_PRID_IMPL(cpu_id));
944 1.1.2.1 cliff }
945 1.1.2.1 cliff
946 1.1.2.1 cliff *pih = irq;
947 1.1.2.1 cliff
948 1.1.2.1 cliff return 0;
949 1.1.2.1 cliff }
950 1.1.2.1 cliff
951 1.1.2.1 cliff const char *
952 1.1.2.1 cliff rmixl_pcie_intr_string(void *v, pci_intr_handle_t pih)
953 1.1.2.1 cliff {
954 1.1.2.1 cliff const char *name = "(illegal)";
955 1.1.2.1 cliff int irq = (int)pih;
956 1.1.2.1 cliff
957 1.1.2.1 cliff switch (MIPS_PRID_IMPL(cpu_id)) {
958 1.1.2.1 cliff case MIPS_XLS408LITE:
959 1.1.2.1 cliff switch (irq) {
960 1.1.2.1 cliff case 26:
961 1.1.2.1 cliff case 27:
962 1.1.2.1 cliff name = rmixl_intr_string(irq);
963 1.1.2.1 cliff break;
964 1.1.2.1 cliff }
965 1.1.2.1 cliff break;
966 1.1.2.1 cliff case MIPS_XLS616:
967 1.1.2.1 cliff switch (irq) {
968 1.1.2.1 cliff case 26:
969 1.1.2.1 cliff case 27:
970 1.1.2.1 cliff case 28:
971 1.1.2.1 cliff case 29:
972 1.1.2.1 cliff name = rmixl_intr_string(irq);
973 1.1.2.1 cliff break;
974 1.1.2.1 cliff }
975 1.1.2.1 cliff break;
976 1.1.2.1 cliff }
977 1.1.2.1 cliff
978 1.1.2.1 cliff return name;
979 1.1.2.1 cliff }
980 1.1.2.1 cliff
981 1.1.2.1 cliff const struct evcnt *
982 1.1.2.1 cliff rmixl_pcie_intr_evcnt(void *v, pci_intr_handle_t pih)
983 1.1.2.1 cliff {
984 1.1.2.1 cliff return NULL;
985 1.1.2.1 cliff }
986 1.1.2.1 cliff
987 1.1.2.1 cliff static int
988 1.1.2.1 cliff rmixl_pcie_irq(pci_intr_handle_t pih)
989 1.1.2.1 cliff {
990 1.1.2.1 cliff return (int)pih;
991 1.1.2.1 cliff }
992 1.1.2.1 cliff
993 1.1.2.1 cliff static void *
994 1.1.2.1 cliff rmixl_pcie_intr_establish(void *v, pci_intr_handle_t pih, int ipl,
995 1.1.2.1 cliff int (*func)(void *), void *arg)
996 1.1.2.1 cliff {
997 1.1.2.1 cliff return rmixl_intr_establish(rmixl_pcie_irq((int)pih), ipl,
998 1.1.2.1 cliff RMIXL_INTR_LEVEL, RMIXL_INTR_HIGH, func, arg);
999 1.1.2.1 cliff }
1000 1.1.2.1 cliff
1001 1.1.2.1 cliff static void
1002 1.1.2.1 cliff rmixl_pcie_intr_disestablish(void *v, void *ih)
1003 1.1.2.1 cliff {
1004 1.1.2.1 cliff rmixl_intr_disestablish(ih);
1005 1.1.2.1 cliff }
1006 1.1.2.1 cliff
1007 1.1.2.1 cliff #if defined(DEBUG) || defined(DDB)
1008 1.1.2.1 cliff /* this function exists to facilitate call from ddb */
1009 1.1.2.1 cliff int
1010 1.1.2.1 cliff rmixl_pcie_error_check(void)
1011 1.1.2.1 cliff {
1012 1.1.2.1 cliff if (rmixl_pcie_v != 0)
1013 1.1.2.1 cliff return _rmixl_pcie_error_check(rmixl_pcie_v);
1014 1.1.2.1 cliff return -1;
1015 1.1.2.1 cliff }
1016 1.1.2.1 cliff #endif
1017 1.1.2.1 cliff
1018 1.1.2.1 cliff STATIC int
1019 1.1.2.1 cliff _rmixl_pcie_error_check(void *v)
1020 1.1.2.1 cliff {
1021 1.1.2.1 cliff int i, offset;
1022 1.1.2.1 cliff pcireg_t r;
1023 1.1.2.1 cliff pcitag_t tag;
1024 1.1.2.1 cliff int err=0;
1025 1.1.2.1 cliff #ifdef DIAGNOSTIC
1026 1.1.2.1 cliff pcireg_t regs[PCIE_ECFG_ERRS_OFFTAB_NENTRIES];
1027 1.1.2.1 cliff #endif
1028 1.1.2.1 cliff
1029 1.1.2.1 cliff tag = rmixl_pcie_make_tag(v, 0, 0, 0); /* XXX */
1030 1.1.2.1 cliff
1031 1.1.2.1 cliff for (i=0; i < PCIE_ECFG_ERRS_OFFTAB_NENTRIES; i++) {
1032 1.1.2.1 cliff offset = pcie_ecfg_errs_tab[i].offset;
1033 1.1.2.1 cliff r = rmixl_pcie_conf_read(v, tag, offset);
1034 1.1.2.1 cliff #ifdef DIAGNOSTIC
1035 1.1.2.1 cliff regs[i] = r;
1036 1.1.2.1 cliff #endif
1037 1.1.2.1 cliff if (r != 0) {
1038 1.1.2.1 cliff pcireg_t rw1c = r & pcie_ecfg_errs_tab[i].rw1c;
1039 1.1.2.1 cliff if (rw1c != 0) {
1040 1.1.2.1 cliff /* attempt to clear the error */
1041 1.1.2.1 cliff rmixl_pcie_conf_write(v, tag, offset, rw1c);
1042 1.1.2.1 cliff };
1043 1.1.2.1 cliff if (offset == RMIXL_PCIE_ECFG_CESR)
1044 1.1.2.1 cliff err |= 1; /* correctable */
1045 1.1.2.1 cliff else
1046 1.1.2.1 cliff err |= 2; /* uncorrectable */
1047 1.1.2.1 cliff }
1048 1.1.2.1 cliff }
1049 1.1.2.1 cliff #ifdef DIAGNOSTIC
1050 1.1.2.1 cliff if (err != 0) {
1051 1.1.2.1 cliff for (i=0; i < PCIE_ECFG_ERRS_OFFTAB_NENTRIES; i++) {
1052 1.1.2.1 cliff offset = pcie_ecfg_errs_tab[i].offset;
1053 1.1.2.1 cliff printf("%s: %#x: %#x\n", __func__, offset, regs[i]);
1054 1.1.2.1 cliff }
1055 1.1.2.1 cliff }
1056 1.1.2.1 cliff #endif
1057 1.1.2.1 cliff
1058 1.1.2.1 cliff return err;
1059 1.1.2.1 cliff }
1060 1.1.2.1 cliff
1061 1.1.2.1 cliff static int
1062 1.1.2.1 cliff rmixl_pcie_error_intr(void *v)
1063 1.1.2.1 cliff {
1064 1.1.2.1 cliff if (_rmixl_pcie_error_check(v) < 2)
1065 1.1.2.1 cliff return 0; /* correctable */
1066 1.1.2.1 cliff
1067 1.1.2.1 cliff /* uncorrectable */
1068 1.1.2.1 cliff #if DDB
1069 1.1.2.1 cliff Debugger();
1070 1.1.2.1 cliff #endif
1071 1.1.2.1 cliff
1072 1.1.2.1 cliff /* XXX reset and recover? */
1073 1.1.2.1 cliff
1074 1.1.2.1 cliff panic("%s\n", __func__);
1075 1.1.2.1 cliff }
1076