rmixl_pcix.c revision 1.1.2.2 1 1.1.2.2 cliff /* $NetBSD: rmixl_pcix.c,v 1.1.2.2 2010/04/12 22:03:33 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 XLR 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_pcix.c,v 1.1.2.2 2010/04/12 22:03:33 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_intr.h>
64 1.1.2.1 cliff #include <mips/rmi/rmixl_pcixvar.h>
65 1.1.2.1 cliff
66 1.1.2.1 cliff #include <mips/rmi/rmixl_obiovar.h>
67 1.1.2.1 cliff
68 1.1.2.1 cliff #include <dev/pci/pcivar.h>
69 1.1.2.1 cliff #include <dev/pci/pcidevs.h>
70 1.1.2.1 cliff #include <dev/pci/pciconf.h>
71 1.1.2.1 cliff
72 1.1.2.1 cliff #ifdef PCI_NETBSD_CONFIGURE
73 1.1.2.1 cliff #include <mips/cache.h>
74 1.1.2.1 cliff #endif
75 1.1.2.1 cliff
76 1.1.2.1 cliff #include <machine/pci_machdep.h>
77 1.1.2.1 cliff
78 1.1.2.1 cliff #ifdef PCI_DEBUG
79 1.1.2.1 cliff int rmixl_pcix_debug = PCI_DEBUG;
80 1.1.2.1 cliff # define DPRINTF(x) do { if (rmixl_pcix_debug) printf x ; } while (0)
81 1.1.2.1 cliff #else
82 1.1.2.1 cliff # define DPRINTF(x)
83 1.1.2.1 cliff #endif
84 1.1.2.1 cliff
85 1.1.2.1 cliff #ifndef DDB
86 1.1.2.1 cliff # define STATIC static
87 1.1.2.1 cliff #else
88 1.1.2.1 cliff # define STATIC
89 1.1.2.1 cliff #endif
90 1.1.2.1 cliff
91 1.1.2.1 cliff
92 1.1.2.1 cliff /*
93 1.1.2.1 cliff * XLR PCI-X Extended Configuration Registers
94 1.1.2.1 cliff * Note:
95 1.1.2.1 cliff * - MSI-related regs are omitted
96 1.1.2.1 cliff * - Device mode regs are omitted
97 1.1.2.1 cliff */
98 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR0_ADDR 0x100 /* Host BAR0 Address */
99 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR1_ADDR 0x104 /* Host BAR1 Address */
100 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR2_ADDR 0x108 /* Host BAR2 Address */
101 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR3_ADDR 0x10c /* Host BAR3 Address */
102 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR4_ADDR 0x110 /* Host BAR4 Address */
103 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR5_ADDR 0x114 /* Host BAR5 Address */
104 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR0_SIZE 0x118 /* Host BAR0 Size */
105 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR1_SIZE 0x11c /* Host BAR1 Size */
106 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR2_SIZE 0x120 /* Host BAR2 Size */
107 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR3_SIZE 0x124 /* Host BAR3 Size */
108 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR4_SIZE 0x128 /* Host BAR4 Size */
109 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_BAR5_SIZE 0x12c /* Host BAR5 Size */
110 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_MATCH_BIT_ADDR 0x130 /* Match Bit Address BAR */
111 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_MATCH_BIT_SIZE 0x134 /* Match Bit Size BAR */
112 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_XLR_CONTROL 0x138 /* XLR Control reg */
113 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_INTR_CONTROL 0x13c /* Interrupt Control reg */
114 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_INTR_STATUS 0x140 /* Interrupt Status reg */
115 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_INTR_ERR_STATUS 0x144 /* Interrupt Error Status reg */
116 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_MODE_STS 0x178 /* Host Mode Status */
117 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_XLR_MBLE 0x17c /* XLR Match Byte Lane Enable */
118 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_XROM_ADDR 0x180 /* Host Expansion ROM Address */
119 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_XROM_SIZE 0x184 /* Host Expansion ROM Size */
120 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_HOST_MODE_CTL 0x18c /* Host Mode Control */
121 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_TXCAL_CTL 0x1a0 /* TX Calibration Preset Control */
122 1.1.2.1 cliff #define RMIXL_PCIX_ECFG_TXCAL_COUNT 0x1a4 /* TX Calibration Preset Count */
123 1.1.2.1 cliff
124 1.1.2.1 cliff /*
125 1.1.2.1 cliff * RMIXL_PCIX_ECFG_INTR_CONTROL bit defines
126 1.1.2.1 cliff */
127 1.1.2.1 cliff #define PCIX_INTR_CONTROL_RESV __BITS(31,8)
128 1.1.2.1 cliff #define PCIX_INTR_CONTROL_MSI1_MASK __BIT(7)
129 1.1.2.1 cliff #define PCIX_INTR_CONTROL_MSI0_MASK __BIT(6)
130 1.1.2.1 cliff #define PCIX_INTR_CONTROL_INTD_MASK __BIT(5)
131 1.1.2.1 cliff #define PCIX_INTR_CONTROL_INTC_MASK __BIT(4)
132 1.1.2.1 cliff #define PCIX_INTR_CONTROL_INTB_MASK __BIT(3)
133 1.1.2.1 cliff #define PCIX_INTR_CONTROL_INTA_MASK __BIT(2)
134 1.1.2.1 cliff #define PCIX_INTR_CONTROL_TMSI __BIT(1) /* Trigger MSI Interrupt */
135 1.1.2.1 cliff #define PCIX_INTR_CONTROL_DIA __BIT(0) /* Device Interrupt through INTA Pin */
136 1.1.2.1 cliff #define PCIX_INTR_CONTROL_MASK_ALL \
137 1.1.2.1 cliff (PCIX_INTR_CONTROL_MSI1_MASK|PCIX_INTR_CONTROL_MSI0_MASK \
138 1.1.2.1 cliff |PCIX_INTR_CONTROL_INTD_MASK|PCIX_INTR_CONTROL_INTC_MASK \
139 1.1.2.1 cliff |PCIX_INTR_CONTROL_INTB_MASK|PCIX_INTR_CONTROL_INTA_MASK)
140 1.1.2.1 cliff
141 1.1.2.1 cliff /*
142 1.1.2.1 cliff * RMIXL_PCIX_ECFG_INTR_STATUS bit defines
143 1.1.2.1 cliff */
144 1.1.2.1 cliff #define PCIX_INTR_STATUS_RESV __BITS(31,6)
145 1.1.2.1 cliff #define PCIX_INTR_STATUS_MSI1 __BIT(5)
146 1.1.2.1 cliff #define PCIX_INTR_STATUS_MSI0 __BIT(4)
147 1.1.2.1 cliff #define PCIX_INTR_STATUS_INTD __BIT(3)
148 1.1.2.1 cliff #define PCIX_INTR_STATUS_INTC __BIT(2)
149 1.1.2.1 cliff #define PCIX_INTR_STATUS_INTB __BIT(1)
150 1.1.2.1 cliff #define PCIX_INTR_STATUS_INTA __BIT(0)
151 1.1.2.1 cliff
152 1.1.2.1 cliff /*
153 1.1.2.1 cliff * RMIXL_PCIX_ECFG_INTR_ERR_STATUS bit defines
154 1.1.2.1 cliff */
155 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_RESa __BITS(31,5)
156 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_SERR __BIT(4) /* System Error */
157 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_RESb __BIT(3)
158 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_TE __BIT(2) /* Target Error */
159 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_IE __BIT(1) /* Initiator Error */
160 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_RCE __BIT(0) /* Retry Count Expired */
161 1.1.2.1 cliff #define PCIX_INTR_ERR_STATUS_RESV \
162 1.1.2.1 cliff (PCIX_INTR_ERR_STATUS_RESa|PCIX_INTR_ERR_STATUS_RESb)
163 1.1.2.1 cliff
164 1.1.2.2 cliff /*
165 1.1.2.2 cliff * RMIXL_PCIX_ECFG_HOST_MODE_CTL bit defines
166 1.1.2.2 cliff */
167 1.1.2.2 cliff #define PCIX_HOST_MODE_CTL_HDMSTAT __BIT(1) /* Host/Dev Mode status
168 1.1.2.2 cliff * read-only
169 1.1.2.2 cliff * 1 = host
170 1.1.2.2 cliff * 0 = device
171 1.1.2.2 cliff */
172 1.1.2.2 cliff #define PCIX_HOST_MODE_CTL_HOSTSWRST __BIT(0) /* Host soft reset
173 1.1.2.2 cliff * set to 1 to reset
174 1.1.2.2 cliff * set to 0 to un-reset
175 1.1.2.2 cliff */
176 1.1.2.1 cliff
177 1.1.2.1 cliff
178 1.1.2.1 cliff #if BYTE_ORDER == BIG_ENDIAN
179 1.1.2.1 cliff # define RMIXL_PCIXREG_BASE RMIXL_IO_DEV_PCIX_EB
180 1.1.2.1 cliff #else
181 1.1.2.1 cliff # define RMIXL_PCIXREG_BASE RMIXL_IO_DEV_PCIX_EL
182 1.1.2.1 cliff #endif
183 1.1.2.1 cliff
184 1.1.2.1 cliff #define RMIXL_PCIXREG_VADDR(o) \
185 1.1.2.1 cliff (volatile uint32_t *)MIPS_PHYS_TO_KSEG1( \
186 1.1.2.1 cliff rmixl_configuration.rc_io_pbase \
187 1.1.2.1 cliff + RMIXL_PCIXREG_BASE + (o))
188 1.1.2.1 cliff
189 1.1.2.1 cliff #define RMIXL_PCIXREG_READ(o) (*RMIXL_PCIXREG_VADDR(o))
190 1.1.2.1 cliff #define RMIXL_PCIXREG_WRITE(o,v) *RMIXL_PCIXREG_VADDR(o) = (v)
191 1.1.2.1 cliff
192 1.1.2.1 cliff /*
193 1.1.2.1 cliff * XXX use locks
194 1.1.2.1 cliff */
195 1.1.2.1 cliff #define PCI_CONF_LOCK(s) (s) = splhigh()
196 1.1.2.1 cliff #define PCI_CONF_UNLOCK(s) splx((s))
197 1.1.2.1 cliff
198 1.1.2.1 cliff
199 1.1.2.1 cliff #define RMIXL_PCIX_CONCAT3(a,b,c) a ## b ## c
200 1.1.2.1 cliff #define RMIXL_PCIX_BAR_INIT(reg, bar, size, align) { \
201 1.1.2.1 cliff struct extent *ext = rmixl_configuration.rc_phys_ex; \
202 1.1.2.1 cliff u_long region_start; \
203 1.1.2.1 cliff uint64_t ba; \
204 1.1.2.1 cliff int err; \
205 1.1.2.1 cliff \
206 1.1.2.1 cliff err = extent_alloc(ext, (size), (align), 0UL, EX_NOWAIT, \
207 1.1.2.1 cliff ®ion_start); \
208 1.1.2.1 cliff if (err != 0) \
209 1.1.2.1 cliff panic("%s: extent_alloc(%p, %#lx, %#lx, %#lx, %#x, %p)",\
210 1.1.2.1 cliff __func__, ext, size, align, 0UL, EX_NOWAIT, \
211 1.1.2.1 cliff ®ion_start); \
212 1.1.2.1 cliff ba = (uint64_t)region_start; \
213 1.1.2.1 cliff ba *= (1024 * 1024); \
214 1.1.2.1 cliff bar = RMIXL_PCIX_CONCAT3(RMIXL_PCIX_,reg,_BAR)(ba, 1); \
215 1.1.2.1 cliff DPRINTF(("PCIX %s BAR was not enabled by firmware\n" \
216 1.1.2.1 cliff "enabling %s at phys %#" PRIxBUSADDR ", size %lu MB\n", \
217 1.1.2.1 cliff __STRING(reg), __STRING(reg), ba, size)); \
218 1.1.2.1 cliff RMIXL_IOREG_WRITE(RMIXL_IO_DEV_BRIDGE + \
219 1.1.2.1 cliff RMIXL_PCIX_CONCAT3(RMIXLR_SBC_PCIX_,reg,_BAR), bar); \
220 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + \
221 1.1.2.1 cliff RMIXL_PCIX_CONCAT3(RMIXLR_SBC_PCIX_,reg,_BAR)); \
222 1.1.2.1 cliff DPRINTF(("%s: %s BAR %#x\n", __func__, __STRING(reg), bar)); \
223 1.1.2.1 cliff }
224 1.1.2.1 cliff
225 1.1.2.1 cliff static int rmixl_pcix_match(device_t, cfdata_t, void *);
226 1.1.2.1 cliff static void rmixl_pcix_attach(device_t, device_t, void *);
227 1.1.2.1 cliff static void rmixl_pcix_init(rmixl_pcix_softc_t *);
228 1.1.2.1 cliff static void rmixl_pcix_init_errors(rmixl_pcix_softc_t *);
229 1.1.2.1 cliff static void rmixl_pcix_attach_hook(struct device *, struct device *,
230 1.1.2.1 cliff struct pcibus_attach_args *);
231 1.1.2.1 cliff static void rmixl_pcix_intcfg(rmixl_pcix_softc_t *);
232 1.1.2.1 cliff static void rmixl_pcix_errata(rmixl_pcix_softc_t *);
233 1.1.2.1 cliff static void rmixl_conf_interrupt(void *, int, int, int, int, int *);
234 1.1.2.1 cliff static int rmixl_pcix_bus_maxdevs(void *, int);
235 1.1.2.1 cliff static pcitag_t rmixl_pcix_make_tag(void *, int, int, int);
236 1.1.2.1 cliff static void rmixl_pcix_decompose_tag(void *, pcitag_t, int *, int *, int *);
237 1.1.2.1 cliff void rmixl_pcix_tag_print(const char *restrict, void *, pcitag_t, int, vaddr_t, u_long);
238 1.1.2.1 cliff static int rmixl_pcix_conf_setup(rmixl_pcix_softc_t *,
239 1.1.2.1 cliff pcitag_t, int *, bus_space_tag_t *,
240 1.1.2.1 cliff bus_space_handle_t *);
241 1.1.2.1 cliff static pcireg_t rmixl_pcix_conf_read(void *, pcitag_t, int);
242 1.1.2.1 cliff static void rmixl_pcix_conf_write(void *, pcitag_t, int, pcireg_t);
243 1.1.2.1 cliff
244 1.1.2.1 cliff static int rmixl_pcix_intr_map(struct pci_attach_args *,
245 1.1.2.1 cliff pci_intr_handle_t *);
246 1.1.2.1 cliff static const char *
247 1.1.2.1 cliff rmixl_pcix_intr_string(void *, pci_intr_handle_t);
248 1.1.2.1 cliff static const struct evcnt *
249 1.1.2.1 cliff rmixl_pcix_intr_evcnt(void *, pci_intr_handle_t);
250 1.1.2.1 cliff static pci_intr_handle_t
251 1.1.2.1 cliff rmixl_pcix_make_pih(u_int, u_int);
252 1.1.2.1 cliff static void rmixl_pcix_decompose_pih(pci_intr_handle_t, u_int *, u_int *);
253 1.1.2.1 cliff static void rmixl_pcix_intr_disestablish(void *, void *);
254 1.1.2.1 cliff static void *rmixl_pcix_intr_establish(void *, pci_intr_handle_t,
255 1.1.2.1 cliff int, int (*)(void *), void *);
256 1.1.2.1 cliff static int rmixl_pcix_intr(void *);
257 1.1.2.1 cliff static int rmixl_pcix_error_intr(void *);
258 1.1.2.1 cliff
259 1.1.2.1 cliff
260 1.1.2.1 cliff CFATTACH_DECL_NEW(rmixl_pcix, sizeof(rmixl_pcix_softc_t),
261 1.1.2.1 cliff rmixl_pcix_match, rmixl_pcix_attach, NULL, NULL);
262 1.1.2.1 cliff
263 1.1.2.1 cliff
264 1.1.2.1 cliff static int rmixl_pcix_found;
265 1.1.2.1 cliff
266 1.1.2.1 cliff #if defined(DIAGNOSTIC) || defined(DEBUG) || defined(DDB)
267 1.1.2.1 cliff static rmixl_pcix_softc_t *rmixl_pcix_sc;
268 1.1.2.1 cliff #endif
269 1.1.2.1 cliff
270 1.1.2.1 cliff
271 1.1.2.1 cliff static int
272 1.1.2.1 cliff rmixl_pcix_match(device_t parent, cfdata_t cf, void *aux)
273 1.1.2.1 cliff {
274 1.1.2.1 cliff uint32_t r;
275 1.1.2.1 cliff
276 1.1.2.1 cliff /*
277 1.1.2.1 cliff * PCI-X interface exists on XLR chips only
278 1.1.2.1 cliff */
279 1.1.2.1 cliff if (! cpu_rmixlr(mips_options.mips_cpu))
280 1.1.2.1 cliff return 0;
281 1.1.2.1 cliff
282 1.1.2.1 cliff /* XXX
283 1.1.2.1 cliff * for now there is only one PCI-X Interface on chip
284 1.1.2.1 cliff * and only one chip in the system
285 1.1.2.1 cliff * this could change with furture RMI XL family designs
286 1.1.2.1 cliff * or when we have multi-chip systems.
287 1.1.2.1 cliff */
288 1.1.2.1 cliff if (rmixl_pcix_found)
289 1.1.2.1 cliff return 0;
290 1.1.2.1 cliff
291 1.1.2.1 cliff /* read Host Mode Control register */
292 1.1.2.1 cliff r = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_HOST_MODE_CTL);
293 1.1.2.2 cliff r &= PCIX_HOST_MODE_CTL_HDMSTAT;
294 1.1.2.1 cliff if (r == 0)
295 1.1.2.1 cliff return 0; /* strapped for Device Mode */
296 1.1.2.1 cliff
297 1.1.2.1 cliff return 1;
298 1.1.2.1 cliff }
299 1.1.2.1 cliff
300 1.1.2.1 cliff static void
301 1.1.2.1 cliff rmixl_pcix_attach(device_t parent, device_t self, void *aux)
302 1.1.2.1 cliff {
303 1.1.2.1 cliff rmixl_pcix_softc_t *sc = device_private(self);
304 1.1.2.1 cliff struct obio_attach_args *obio = aux;
305 1.1.2.1 cliff struct rmixl_config *rcp = &rmixl_configuration;
306 1.1.2.1 cliff struct pcibus_attach_args pba;
307 1.1.2.1 cliff uint32_t bar;
308 1.1.2.1 cliff
309 1.1.2.1 cliff rmixl_pcix_found = 1;
310 1.1.2.1 cliff #ifdef DIAGNOSTIC
311 1.1.2.1 cliff rmixl_pcix_sc = sc;
312 1.1.2.1 cliff #endif
313 1.1.2.1 cliff sc->sc_dev = self;
314 1.1.2.1 cliff sc->sc_29bit_dmat = obio->obio_29bit_dmat;
315 1.1.2.1 cliff sc->sc_32bit_dmat = obio->obio_32bit_dmat;
316 1.1.2.1 cliff sc->sc_64bit_dmat = obio->obio_64bit_dmat;
317 1.1.2.1 cliff sc->sc_tmsk = obio->obio_tmsk;
318 1.1.2.1 cliff
319 1.1.2.1 cliff aprint_normal(" RMI XLR PCI-X Interface\n");
320 1.1.2.1 cliff
321 1.1.2.1 cliff rmixl_pcix_intcfg(sc);
322 1.1.2.1 cliff
323 1.1.2.1 cliff rmixl_pcix_errata(sc);
324 1.1.2.1 cliff
325 1.1.2.1 cliff /*
326 1.1.2.1 cliff * check XLR Control Register
327 1.1.2.1 cliff */
328 1.1.2.2 cliff DPRINTF(("%s: XLR_CONTROL=%#x\n", __func__,
329 1.1.2.2 cliff RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_XLR_CONTROL)));
330 1.1.2.2 cliff
331 1.1.2.2 cliff /*
332 1.1.2.2 cliff * HBAR[0] if a 32 bit BAR, or
333 1.1.2.2 cliff * HBAR[0,1] if a 64 bit BAR pair
334 1.1.2.2 cliff * must cover all RAM
335 1.1.2.2 cliff */
336 1.1.2.2 cliff extern u_quad_t mem_cluster_maxaddr;
337 1.1.2.2 cliff uint64_t hbar_addr;
338 1.1.2.2 cliff uint64_t hbar_size;
339 1.1.2.2 cliff uint32_t hbar_size_lo, hbar_size_hi;
340 1.1.2.2 cliff uint32_t hbar_addr_lo, hbar_addr_hi;
341 1.1.2.2 cliff
342 1.1.2.2 cliff hbar_addr_lo = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_HOST_BAR0_ADDR);
343 1.1.2.2 cliff hbar_addr_hi = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_HOST_BAR1_ADDR);
344 1.1.2.2 cliff hbar_size_lo = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_HOST_BAR0_SIZE);
345 1.1.2.2 cliff hbar_size_hi = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_HOST_BAR1_SIZE);
346 1.1.2.2 cliff
347 1.1.2.2 cliff hbar_addr = (u_quad_t)(hbar_addr_lo & PCI_MAPREG_MEM_ADDR_MASK);
348 1.1.2.2 cliff hbar_size = hbar_size_lo;
349 1.1.2.2 cliff if ((hbar_size_lo & PCI_MAPREG_MEM_TYPE_64BIT) != 0) {
350 1.1.2.2 cliff hbar_addr |= (uint64_t)hbar_addr_hi << 32;
351 1.1.2.2 cliff hbar_size |= (uint64_t)hbar_size_hi << 32;
352 1.1.2.2 cliff }
353 1.1.2.2 cliff if ((hbar_addr != 0) || (hbar_size < mem_cluster_maxaddr)) {
354 1.1.2.2 cliff printf("%s: HostBAR0 addr %#x, size %#x\n",
355 1.1.2.2 cliff device_xname(self), hbar_addr_lo, hbar_size_lo);
356 1.1.2.2 cliff if ((hbar_size_lo & PCI_MAPREG_MEM_TYPE_64BIT) != 0)
357 1.1.2.2 cliff printf("%s: HostBAR1 addr %#x, size %#x\n",
358 1.1.2.2 cliff device_xname(self), hbar_addr_hi, hbar_size_hi);
359 1.1.2.2 cliff panic("PCI-X Host BAR does not cover RAM range 0..%#"PRIx64,
360 1.1.2.2 cliff mem_cluster_maxaddr);
361 1.1.2.1 cliff }
362 1.1.2.1 cliff
363 1.1.2.1 cliff /*
364 1.1.2.1 cliff * check PCI-X interface byteswap setup
365 1.1.2.1 cliff * ensure 'Match Byte Lane' is disabled
366 1.1.2.1 cliff */
367 1.1.2.1 cliff uint32_t mble, mba, mbs;
368 1.1.2.1 cliff mble = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_XLR_MBLE);
369 1.1.2.1 cliff mba = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_MATCH_BIT_ADDR);
370 1.1.2.1 cliff mbs = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_MATCH_BIT_SIZE);
371 1.1.2.2 cliff DPRINTF(("%s: MBLE=%#x, MBA=%#x, MBS=%#x\n", __func__, mble, mba, mbs));
372 1.1.2.1 cliff if ((mble & __BIT(40)) != 0)
373 1.1.2.1 cliff RMIXL_PCIXREG_WRITE(RMIXL_PCIX_ECFG_XLR_MBLE, 0);
374 1.1.2.1 cliff
375 1.1.2.1 cliff /*
376 1.1.2.1 cliff * get PCI config space base addr from SBC PCIe CFG BAR
377 1.1.2.1 cliff * initialize it if necessary
378 1.1.2.1 cliff */
379 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXLR_SBC_PCIX_CFG_BAR);
380 1.1.2.1 cliff DPRINTF(("%s: PCIX_CFG_BAR %#x\n", __func__, bar));
381 1.1.2.1 cliff if ((bar & RMIXL_PCIX_CFG_BAR_ENB) == 0) {
382 1.1.2.1 cliff u_long n = RMIXL_PCIX_CFG_SIZE / (1024 * 1024);
383 1.1.2.1 cliff RMIXL_PCIX_BAR_INIT(CFG, bar, n, n);
384 1.1.2.1 cliff }
385 1.1.2.1 cliff rcp->rc_pci_cfg_pbase = (bus_addr_t)RMIXL_PCIX_CFG_BAR_TO_BA(bar);
386 1.1.2.1 cliff rcp->rc_pci_cfg_size = (bus_size_t)RMIXL_PCIX_CFG_SIZE;
387 1.1.2.1 cliff
388 1.1.2.1 cliff /*
389 1.1.2.1 cliff * get PCI MEM space base [addr, size] from SBC PCIe MEM BAR
390 1.1.2.1 cliff * initialize it if necessary
391 1.1.2.1 cliff */
392 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXLR_SBC_PCIX_MEM_BAR);
393 1.1.2.1 cliff DPRINTF(("%s: PCIX_MEM_BAR %#x\n", __func__, bar));
394 1.1.2.1 cliff if ((bar & RMIXL_PCIX_MEM_BAR_ENB) == 0) {
395 1.1.2.1 cliff u_long n = 256; /* 256 MB */
396 1.1.2.1 cliff RMIXL_PCIX_BAR_INIT(MEM, bar, n, n);
397 1.1.2.1 cliff }
398 1.1.2.1 cliff rcp->rc_pci_mem_pbase = (bus_addr_t)RMIXL_PCIX_MEM_BAR_TO_BA(bar);
399 1.1.2.1 cliff rcp->rc_pci_mem_size = (bus_size_t)RMIXL_PCIX_MEM_BAR_TO_SIZE(bar);
400 1.1.2.1 cliff
401 1.1.2.1 cliff /*
402 1.1.2.1 cliff * get PCI IO space base [addr, size] from SBC PCIe IO BAR
403 1.1.2.1 cliff * initialize it if necessary
404 1.1.2.1 cliff */
405 1.1.2.1 cliff bar = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXLR_SBC_PCIX_IO_BAR);
406 1.1.2.1 cliff DPRINTF(("%s: PCIX_IO_BAR %#x\n", __func__, bar));
407 1.1.2.1 cliff if ((bar & RMIXL_PCIX_IO_BAR_ENB) == 0) {
408 1.1.2.1 cliff u_long n = 32; /* 32 MB */
409 1.1.2.1 cliff RMIXL_PCIX_BAR_INIT(IO, bar, n, n);
410 1.1.2.1 cliff }
411 1.1.2.1 cliff rcp->rc_pci_io_pbase = (bus_addr_t)RMIXL_PCIX_IO_BAR_TO_BA(bar);
412 1.1.2.1 cliff rcp->rc_pci_io_size = (bus_size_t)RMIXL_PCIX_IO_BAR_TO_SIZE(bar);
413 1.1.2.1 cliff
414 1.1.2.1 cliff /*
415 1.1.2.1 cliff * initialize the PCI CFG bus space tag
416 1.1.2.1 cliff */
417 1.1.2.1 cliff rmixl_pci_cfg_bus_mem_init(&rcp->rc_pci_cfg_memt, rcp);
418 1.1.2.1 cliff sc->sc_pci_cfg_memt = &rcp->rc_pci_cfg_memt;
419 1.1.2.1 cliff
420 1.1.2.1 cliff /*
421 1.1.2.1 cliff * initialize the PCI MEM and IO bus space tags
422 1.1.2.1 cliff */
423 1.1.2.1 cliff rmixl_pci_bus_mem_init(&rcp->rc_pci_memt, rcp);
424 1.1.2.1 cliff rmixl_pci_bus_io_init(&rcp->rc_pci_iot, rcp);
425 1.1.2.1 cliff
426 1.1.2.1 cliff /*
427 1.1.2.1 cliff * initialize the extended configuration regs
428 1.1.2.1 cliff */
429 1.1.2.1 cliff rmixl_pcix_init_errors(sc);
430 1.1.2.1 cliff
431 1.1.2.1 cliff /*
432 1.1.2.1 cliff * initialize the PCI chipset tag
433 1.1.2.1 cliff */
434 1.1.2.1 cliff rmixl_pcix_init(sc);
435 1.1.2.1 cliff
436 1.1.2.1 cliff /*
437 1.1.2.1 cliff * attach the PCI bus
438 1.1.2.1 cliff */
439 1.1.2.1 cliff memset(&pba, 0, sizeof(pba));
440 1.1.2.1 cliff pba.pba_memt = &rcp->rc_pci_memt;
441 1.1.2.1 cliff pba.pba_iot = &rcp->rc_pci_iot;
442 1.1.2.1 cliff pba.pba_dmat = sc->sc_32bit_dmat;
443 1.1.2.1 cliff pba.pba_dmat64 = sc->sc_64bit_dmat;
444 1.1.2.1 cliff pba.pba_pc = &sc->sc_pci_chipset;
445 1.1.2.1 cliff pba.pba_bus = 0;
446 1.1.2.1 cliff pba.pba_bridgetag = NULL;
447 1.1.2.1 cliff pba.pba_intrswiz = 0;
448 1.1.2.1 cliff pba.pba_intrtag = 0;
449 1.1.2.1 cliff pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
450 1.1.2.1 cliff PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
451 1.1.2.1 cliff
452 1.1.2.1 cliff (void) config_found_ia(self, "pcibus", &pba, pcibusprint);
453 1.1.2.1 cliff }
454 1.1.2.1 cliff
455 1.1.2.1 cliff /*
456 1.1.2.1 cliff * rmixl_pcix_intcfg - init PCI-X interrupt control
457 1.1.2.1 cliff */
458 1.1.2.1 cliff static void
459 1.1.2.1 cliff rmixl_pcix_intcfg(rmixl_pcix_softc_t *sc)
460 1.1.2.1 cliff {
461 1.1.2.1 cliff DPRINTF(("%s\n", __func__));
462 1.1.2.1 cliff
463 1.1.2.1 cliff /* mask all interrupts until they are established */
464 1.1.2.1 cliff RMIXL_PCIXREG_WRITE(RMIXL_PCIX_ECFG_INTR_CONTROL,
465 1.1.2.1 cliff PCIX_INTR_CONTROL_MASK_ALL);
466 1.1.2.1 cliff
467 1.1.2.1 cliff /*
468 1.1.2.1 cliff * read-to-clear any pre-existing interrupts
469 1.1.2.1 cliff * XXX MSI bits in STATUS are also documented as write 1 to clear in PRM
470 1.1.2.1 cliff */
471 1.1.2.1 cliff (void)RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_STATUS);
472 1.1.2.1 cliff (void)RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_ERR_STATUS);
473 1.1.2.1 cliff
474 1.1.2.1 cliff /* initialize the dispatch handles */
475 1.1.2.1 cliff for (int i=0; i < RMIXL_PCIX_NINTR; i++) {
476 1.1.2.1 cliff rmixl_pcix_intr_t *ih = &sc->sc_intr[i];
477 1.1.2.1 cliff LIST_INIT(&ih->dispatch);
478 1.1.2.1 cliff ih->ih = NULL;
479 1.1.2.1 cliff ih->intrpin = i;
480 1.1.2.1 cliff ih->enabled = false;
481 1.1.2.1 cliff }
482 1.1.2.1 cliff
483 1.1.2.1 cliff sc->sc_ih = rmixl_intr_establish(16, sc->sc_tmsk,
484 1.1.2.1 cliff IPL_VM, RMIXL_TRIG_LEVEL, RMIXL_POLR_HIGH,
485 1.1.2.1 cliff rmixl_pcix_intr, sc);
486 1.1.2.1 cliff if (sc->sc_ih == NULL)
487 1.1.2.1 cliff panic("%s: cannot establish irq %d", __func__, 16);
488 1.1.2.1 cliff
489 1.1.2.1 cliff sc->sc_fatal_ih = rmixl_intr_establish(24, sc->sc_tmsk,
490 1.1.2.1 cliff IPL_VM, RMIXL_TRIG_LEVEL, RMIXL_POLR_HIGH,
491 1.1.2.1 cliff rmixl_pcix_error_intr, sc);
492 1.1.2.1 cliff if (sc->sc_fatal_ih == NULL)
493 1.1.2.1 cliff panic("%s: cannot establish irq %d", __func__, 24);
494 1.1.2.1 cliff
495 1.1.2.1 cliff sc->sc_intr_init_done = true;
496 1.1.2.1 cliff }
497 1.1.2.1 cliff
498 1.1.2.1 cliff static void
499 1.1.2.1 cliff rmixl_pcix_errata(rmixl_pcix_softc_t *sc)
500 1.1.2.1 cliff {
501 1.1.2.1 cliff /* nothing */
502 1.1.2.1 cliff }
503 1.1.2.1 cliff
504 1.1.2.1 cliff static void
505 1.1.2.1 cliff rmixl_pcix_init(rmixl_pcix_softc_t *sc)
506 1.1.2.1 cliff {
507 1.1.2.1 cliff pci_chipset_tag_t pc = &sc->sc_pci_chipset;
508 1.1.2.1 cliff #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
509 1.1.2.1 cliff struct extent *ioext, *memext;
510 1.1.2.1 cliff #endif
511 1.1.2.1 cliff
512 1.1.2.1 cliff pc->pc_conf_v = (void *)sc;
513 1.1.2.1 cliff pc->pc_attach_hook = rmixl_pcix_attach_hook;
514 1.1.2.1 cliff pc->pc_bus_maxdevs = rmixl_pcix_bus_maxdevs;
515 1.1.2.1 cliff pc->pc_make_tag = rmixl_pcix_make_tag;
516 1.1.2.1 cliff pc->pc_decompose_tag = rmixl_pcix_decompose_tag;
517 1.1.2.1 cliff pc->pc_conf_read = rmixl_pcix_conf_read;
518 1.1.2.1 cliff pc->pc_conf_write = rmixl_pcix_conf_write;
519 1.1.2.1 cliff
520 1.1.2.1 cliff pc->pc_intr_v = (void *)sc;
521 1.1.2.1 cliff pc->pc_intr_map = rmixl_pcix_intr_map;
522 1.1.2.1 cliff pc->pc_intr_string = rmixl_pcix_intr_string;
523 1.1.2.1 cliff pc->pc_intr_evcnt = rmixl_pcix_intr_evcnt;
524 1.1.2.1 cliff pc->pc_intr_establish = rmixl_pcix_intr_establish;
525 1.1.2.1 cliff pc->pc_intr_disestablish = rmixl_pcix_intr_disestablish;
526 1.1.2.1 cliff pc->pc_conf_interrupt = rmixl_conf_interrupt;
527 1.1.2.1 cliff
528 1.1.2.1 cliff #if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
529 1.1.2.1 cliff /*
530 1.1.2.1 cliff * Configure the PCI bus.
531 1.1.2.1 cliff */
532 1.1.2.1 cliff struct rmixl_config *rcp = &rmixl_configuration;
533 1.1.2.1 cliff
534 1.1.2.1 cliff aprint_normal("%s: configuring PCI bus\n",
535 1.1.2.1 cliff device_xname(sc->sc_dev));
536 1.1.2.1 cliff
537 1.1.2.1 cliff ioext = extent_create("pciio",
538 1.1.2.1 cliff rcp->rc_pci_io_pbase,
539 1.1.2.1 cliff rcp->rc_pci_io_pbase + rcp->rc_pci_io_size - 1,
540 1.1.2.1 cliff M_DEVBUF, NULL, 0, EX_NOWAIT);
541 1.1.2.1 cliff
542 1.1.2.1 cliff memext = extent_create("pcimem",
543 1.1.2.1 cliff rcp->rc_pci_mem_pbase,
544 1.1.2.1 cliff rcp->rc_pci_mem_pbase + rcp->rc_pci_mem_size - 1,
545 1.1.2.1 cliff M_DEVBUF, NULL, 0, EX_NOWAIT);
546 1.1.2.1 cliff
547 1.1.2.1 cliff pci_configure_bus(pc, ioext, memext, NULL, 0,
548 1.1.2.1 cliff mips_cache_info.mci_dcache_align);
549 1.1.2.1 cliff
550 1.1.2.1 cliff extent_destroy(ioext);
551 1.1.2.1 cliff extent_destroy(memext);
552 1.1.2.1 cliff #endif
553 1.1.2.1 cliff }
554 1.1.2.1 cliff
555 1.1.2.1 cliff static void
556 1.1.2.1 cliff rmixl_pcix_init_errors(rmixl_pcix_softc_t *sc)
557 1.1.2.1 cliff {
558 1.1.2.1 cliff /* nothing */
559 1.1.2.1 cliff }
560 1.1.2.1 cliff
561 1.1.2.1 cliff void
562 1.1.2.1 cliff rmixl_conf_interrupt(void *v, int bus, int dev, int ipin, int swiz, int *iline)
563 1.1.2.1 cliff {
564 1.1.2.1 cliff DPRINTF(("%s: %p, %d, %d, %d, %d, %p\n",
565 1.1.2.1 cliff __func__, v, bus, dev, ipin, swiz, iline));
566 1.1.2.1 cliff }
567 1.1.2.1 cliff
568 1.1.2.1 cliff void
569 1.1.2.1 cliff rmixl_pcix_attach_hook(struct device *parent, struct device *self,
570 1.1.2.1 cliff struct pcibus_attach_args *pba)
571 1.1.2.1 cliff {
572 1.1.2.1 cliff DPRINTF(("%s: pba_bus %d, pba_bridgetag %p, pc_conf_v %p\n",
573 1.1.2.1 cliff __func__, pba->pba_bus, pba->pba_bridgetag,
574 1.1.2.1 cliff pba->pba_pc->pc_conf_v));
575 1.1.2.1 cliff }
576 1.1.2.1 cliff
577 1.1.2.1 cliff int
578 1.1.2.1 cliff rmixl_pcix_bus_maxdevs(void *v, int busno)
579 1.1.2.1 cliff {
580 1.1.2.1 cliff return (32); /* XXX depends on the family of XLS SoC */
581 1.1.2.1 cliff }
582 1.1.2.1 cliff
583 1.1.2.1 cliff /*
584 1.1.2.1 cliff * XLS pci tag is a 40 bit address composed thusly:
585 1.1.2.1 cliff * 39:25 (reserved)
586 1.1.2.1 cliff * 24 Swap (0=little, 1=big endian)
587 1.1.2.1 cliff * 23:16 Bus number
588 1.1.2.1 cliff * 15:11 Device number
589 1.1.2.1 cliff * 10:8 Function number
590 1.1.2.1 cliff * 7:0 Register number
591 1.1.2.1 cliff *
592 1.1.2.1 cliff * Note: this is the "native" composition for addressing CFG space, but not for ECFG space.
593 1.1.2.1 cliff */
594 1.1.2.1 cliff pcitag_t
595 1.1.2.1 cliff rmixl_pcix_make_tag(void *v, int bus, int dev, int fun)
596 1.1.2.1 cliff {
597 1.1.2.1 cliff return ((bus << 16) | (dev << 11) | (fun << 8));
598 1.1.2.1 cliff }
599 1.1.2.1 cliff
600 1.1.2.1 cliff void
601 1.1.2.1 cliff rmixl_pcix_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp, int *fp)
602 1.1.2.1 cliff {
603 1.1.2.1 cliff if (bp != NULL)
604 1.1.2.1 cliff *bp = (tag >> 16) & 0xff;
605 1.1.2.1 cliff if (dp != NULL)
606 1.1.2.1 cliff *dp = (tag >> 11) & 0x1f;
607 1.1.2.1 cliff if (fp != NULL)
608 1.1.2.1 cliff *fp = (tag >> 8) & 0x7;
609 1.1.2.1 cliff }
610 1.1.2.1 cliff
611 1.1.2.1 cliff void
612 1.1.2.1 cliff rmixl_pcix_tag_print(const char *restrict s, void *v, pcitag_t tag, int offset,
613 1.1.2.1 cliff vaddr_t va, u_long r)
614 1.1.2.1 cliff {
615 1.1.2.1 cliff int bus, dev, fun;
616 1.1.2.1 cliff
617 1.1.2.1 cliff rmixl_pcix_decompose_tag(v, tag, &bus, &dev, &fun);
618 1.1.2.1 cliff printf("%s: %d/%d/%d/%d - %#" PRIxVADDR ":%#lx\n",
619 1.1.2.1 cliff s, bus, dev, fun, offset, va, r);
620 1.1.2.1 cliff }
621 1.1.2.1 cliff
622 1.1.2.1 cliff static int
623 1.1.2.1 cliff rmixl_pcix_conf_setup(rmixl_pcix_softc_t *sc,
624 1.1.2.1 cliff pcitag_t tag, int *offp, bus_space_tag_t *bstp,
625 1.1.2.1 cliff bus_space_handle_t *bshp)
626 1.1.2.1 cliff {
627 1.1.2.1 cliff struct rmixl_config *rcp = &rmixl_configuration;
628 1.1.2.1 cliff bus_space_tag_t bst;
629 1.1.2.1 cliff bus_space_handle_t bsh;
630 1.1.2.1 cliff bus_size_t size;
631 1.1.2.1 cliff pcitag_t mask;
632 1.1.2.1 cliff bus_addr_t ba;
633 1.1.2.1 cliff int err;
634 1.1.2.1 cliff static bus_space_handle_t cfg_bsh;
635 1.1.2.1 cliff static bus_addr_t cfg_oba = -1;
636 1.1.2.1 cliff
637 1.1.2.1 cliff /*
638 1.1.2.1 cliff * bus space depends on offset
639 1.1.2.1 cliff */
640 1.1.2.1 cliff if ((*offp >= 0) && (*offp < 0x100)) {
641 1.1.2.1 cliff mask = __BITS(15,0);
642 1.1.2.1 cliff bst = sc->sc_pci_cfg_memt;
643 1.1.2.1 cliff ba = rcp->rc_pci_cfg_pbase;
644 1.1.2.1 cliff ba += (tag & ~mask);
645 1.1.2.1 cliff *offp += (tag & mask);
646 1.1.2.1 cliff if (ba != cfg_oba) {
647 1.1.2.1 cliff size = (bus_size_t)(mask + 1);
648 1.1.2.1 cliff if (cfg_oba != -1)
649 1.1.2.1 cliff bus_space_unmap(bst, cfg_bsh, size);
650 1.1.2.1 cliff err = bus_space_map(bst, ba, size, 0, &cfg_bsh);
651 1.1.2.1 cliff if (err != 0) {
652 1.1.2.1 cliff #ifdef DEBUG
653 1.1.2.1 cliff panic("%s: bus_space_map err %d, CFG space",
654 1.1.2.1 cliff __func__, err); /* XXX */
655 1.1.2.1 cliff #endif
656 1.1.2.1 cliff return -1;
657 1.1.2.1 cliff }
658 1.1.2.1 cliff cfg_oba = ba;
659 1.1.2.1 cliff }
660 1.1.2.1 cliff bsh = cfg_bsh;
661 1.1.2.1 cliff } else {
662 1.1.2.1 cliff #ifdef DEBUG
663 1.1.2.1 cliff panic("%s: offset %#x: unknown", __func__, *offp);
664 1.1.2.1 cliff #endif
665 1.1.2.1 cliff return -1;
666 1.1.2.1 cliff }
667 1.1.2.1 cliff
668 1.1.2.1 cliff *bstp = bst;
669 1.1.2.1 cliff *bshp = bsh;
670 1.1.2.1 cliff
671 1.1.2.1 cliff return 0;
672 1.1.2.1 cliff }
673 1.1.2.1 cliff
674 1.1.2.1 cliff pcireg_t
675 1.1.2.1 cliff rmixl_pcix_conf_read(void *v, pcitag_t tag, int offset)
676 1.1.2.1 cliff {
677 1.1.2.1 cliff rmixl_pcix_softc_t *sc = v;
678 1.1.2.1 cliff static bus_space_handle_t bsh;
679 1.1.2.1 cliff bus_space_tag_t bst;
680 1.1.2.1 cliff pcireg_t rv;
681 1.1.2.1 cliff uint64_t cfg0;
682 1.1.2.1 cliff u_int s;
683 1.1.2.1 cliff
684 1.1.2.1 cliff PCI_CONF_LOCK(s);
685 1.1.2.1 cliff
686 1.1.2.1 cliff if (rmixl_pcix_conf_setup(sc, tag, &offset, &bst, &bsh) == 0) {
687 1.1.2.1 cliff cfg0 = rmixl_cache_err_dis();
688 1.1.2.1 cliff rv = bus_space_read_4(bst, bsh, (bus_size_t)offset);
689 1.1.2.1 cliff if (rmixl_cache_err_check() != 0) {
690 1.1.2.1 cliff #ifdef DIAGNOSTIC
691 1.1.2.1 cliff int bus, dev, fun;
692 1.1.2.1 cliff
693 1.1.2.1 cliff rmixl_pcix_decompose_tag(v, tag, &bus, &dev, &fun);
694 1.1.2.1 cliff printf("%s: %d/%d/%d, offset %#x: bad address\n",
695 1.1.2.1 cliff __func__, bus, dev, fun, offset);
696 1.1.2.1 cliff #endif
697 1.1.2.1 cliff rv = (pcireg_t) -1;
698 1.1.2.1 cliff }
699 1.1.2.1 cliff rmixl_cache_err_restore(cfg0);
700 1.1.2.1 cliff } else {
701 1.1.2.1 cliff rv = -1;
702 1.1.2.1 cliff }
703 1.1.2.1 cliff
704 1.1.2.1 cliff PCI_CONF_UNLOCK(s);
705 1.1.2.1 cliff return rv;
706 1.1.2.1 cliff }
707 1.1.2.1 cliff
708 1.1.2.1 cliff void
709 1.1.2.1 cliff rmixl_pcix_conf_write(void *v, pcitag_t tag, int offset, pcireg_t val)
710 1.1.2.1 cliff {
711 1.1.2.1 cliff rmixl_pcix_softc_t *sc = v;
712 1.1.2.1 cliff static bus_space_handle_t bsh;
713 1.1.2.1 cliff bus_space_tag_t bst;
714 1.1.2.1 cliff uint64_t cfg0;
715 1.1.2.1 cliff u_int s;
716 1.1.2.1 cliff
717 1.1.2.1 cliff PCI_CONF_LOCK(s);
718 1.1.2.1 cliff
719 1.1.2.1 cliff if (rmixl_pcix_conf_setup(sc, tag, &offset, &bst, &bsh) == 0) {
720 1.1.2.1 cliff cfg0 = rmixl_cache_err_dis();
721 1.1.2.1 cliff bus_space_write_4(bst, bsh, (bus_size_t)offset, val);
722 1.1.2.1 cliff if (rmixl_cache_err_check() != 0) {
723 1.1.2.1 cliff #ifdef DIAGNOSTIC
724 1.1.2.1 cliff int bus, dev, fun;
725 1.1.2.1 cliff
726 1.1.2.1 cliff rmixl_pcix_decompose_tag(v, tag, &bus, &dev, &fun);
727 1.1.2.1 cliff printf("%s: %d/%d/%d, offset %#x: bad address\n",
728 1.1.2.1 cliff __func__, bus, dev, fun, offset);
729 1.1.2.1 cliff #endif
730 1.1.2.1 cliff }
731 1.1.2.1 cliff rmixl_cache_err_restore(cfg0);
732 1.1.2.1 cliff }
733 1.1.2.1 cliff
734 1.1.2.1 cliff PCI_CONF_UNLOCK(s);
735 1.1.2.1 cliff }
736 1.1.2.1 cliff
737 1.1.2.1 cliff int
738 1.1.2.1 cliff rmixl_pcix_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *pih)
739 1.1.2.1 cliff {
740 1.1.2.1 cliff const u_int irq = 16; /* PCIX index in IRT */
741 1.1.2.1 cliff
742 1.1.2.1 cliff #ifdef DEBUG
743 1.1.2.1 cliff DPRINTF(("%s: ps_bus %d, pa_intrswiz %#x, pa_intrtag %#lx,"
744 1.1.2.1 cliff " pa_intrpin %d, pa_intrline %d, pa_rawintrpin %d\n",
745 1.1.2.1 cliff __func__, pa->pa_bus, pa->pa_intrswiz, pa->pa_intrtag,
746 1.1.2.1 cliff pa->pa_intrpin, pa->pa_intrline, pa->pa_rawintrpin));
747 1.1.2.1 cliff #endif
748 1.1.2.1 cliff
749 1.1.2.1 cliff if (pa->pa_intrpin != PCI_INTERRUPT_PIN_NONE)
750 1.1.2.1 cliff *pih = rmixl_pcix_make_pih(pa->pa_intrpin - 1, irq);
751 1.1.2.1 cliff else
752 1.1.2.1 cliff *pih = ~0;
753 1.1.2.1 cliff
754 1.1.2.1 cliff return 0;
755 1.1.2.1 cliff }
756 1.1.2.1 cliff
757 1.1.2.1 cliff const char *
758 1.1.2.1 cliff rmixl_pcix_intr_string(void *v, pci_intr_handle_t pih)
759 1.1.2.1 cliff {
760 1.1.2.1 cliff u_int bitno, irq;
761 1.1.2.1 cliff
762 1.1.2.1 cliff rmixl_pcix_decompose_pih(pih, &bitno, &irq);
763 1.1.2.1 cliff
764 1.1.2.1 cliff if (! cpu_rmixlr(mips_options.mips_cpu))
765 1.1.2.1 cliff panic("%s: cpu %#x not supported\n",
766 1.1.2.1 cliff __func__, mips_options.mips_cpu_id);
767 1.1.2.1 cliff
768 1.1.2.1 cliff return rmixl_intr_string(irq);
769 1.1.2.1 cliff }
770 1.1.2.1 cliff
771 1.1.2.1 cliff const struct evcnt *
772 1.1.2.1 cliff rmixl_pcix_intr_evcnt(void *v, pci_intr_handle_t pih)
773 1.1.2.1 cliff {
774 1.1.2.1 cliff return NULL;
775 1.1.2.1 cliff }
776 1.1.2.1 cliff
777 1.1.2.1 cliff static pci_intr_handle_t
778 1.1.2.1 cliff rmixl_pcix_make_pih(u_int bitno, u_int irq)
779 1.1.2.1 cliff {
780 1.1.2.1 cliff pci_intr_handle_t pih;
781 1.1.2.1 cliff
782 1.1.2.1 cliff KASSERT(bitno < 64);
783 1.1.2.1 cliff KASSERT(irq < 32);
784 1.1.2.1 cliff
785 1.1.2.1 cliff pih = (irq << 6);
786 1.1.2.1 cliff pih |= bitno;
787 1.1.2.1 cliff
788 1.1.2.1 cliff return pih;
789 1.1.2.1 cliff }
790 1.1.2.1 cliff
791 1.1.2.1 cliff static void
792 1.1.2.1 cliff rmixl_pcix_decompose_pih(pci_intr_handle_t pih, u_int *bitno, u_int *irq)
793 1.1.2.1 cliff {
794 1.1.2.1 cliff *bitno = (u_int)(pih & 0x3f);
795 1.1.2.1 cliff *irq = (u_int)(pih >> 6);
796 1.1.2.1 cliff
797 1.1.2.1 cliff KASSERT(*bitno < 64);
798 1.1.2.1 cliff KASSERT(*irq < 31);
799 1.1.2.1 cliff }
800 1.1.2.1 cliff
801 1.1.2.1 cliff static void
802 1.1.2.1 cliff rmixl_pcix_intr_disestablish(void *v, void *ih)
803 1.1.2.1 cliff {
804 1.1.2.1 cliff rmixl_pcix_softc_t *sc = v;
805 1.1.2.1 cliff rmixl_pcix_dispatch_t *dip = ih;
806 1.1.2.1 cliff rmixl_pcix_intr_t *pip = &sc->sc_intr[dip->bitno];;
807 1.1.2.1 cliff
808 1.1.2.1 cliff DPRINTF(("%s: pin=%d irq=%d\n",
809 1.1.2.1 cliff __func__, dip->bitno + 1, dip->irq));
810 1.1.2.1 cliff KASSERT(dip->bitno < RMIXL_PCIX_NINTR);
811 1.1.2.1 cliff
812 1.1.2.1 cliff LIST_REMOVE(dip, next);
813 1.1.2.1 cliff evcnt_detach(&dip->count);
814 1.1.2.1 cliff free(dip, M_DEVBUF);
815 1.1.2.1 cliff
816 1.1.2.1 cliff if (LIST_EMPTY(&pip->dispatch)) {
817 1.1.2.1 cliff uint32_t bit = 1 << (dip->bitno + 2);
818 1.1.2.1 cliff uint32_t r;
819 1.1.2.1 cliff
820 1.1.2.1 cliff r = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_CONTROL);
821 1.1.2.1 cliff r |= bit; /* set mask */
822 1.1.2.1 cliff RMIXL_PCIXREG_WRITE(RMIXL_PCIX_ECFG_INTR_CONTROL, r);
823 1.1.2.1 cliff DPRINTF(("%s: disabled pin %d\n", __func__, dip->bitno + 1));
824 1.1.2.1 cliff
825 1.1.2.1 cliff pip->enabled = false;
826 1.1.2.1 cliff }
827 1.1.2.1 cliff }
828 1.1.2.1 cliff
829 1.1.2.1 cliff static void *
830 1.1.2.1 cliff rmixl_pcix_intr_establish(void *v, pci_intr_handle_t pih, int ipl,
831 1.1.2.1 cliff int (*func)(void *), void *arg)
832 1.1.2.1 cliff {
833 1.1.2.1 cliff rmixl_pcix_softc_t *sc = v;
834 1.1.2.1 cliff u_int bitno, irq;
835 1.1.2.1 cliff rmixl_pcix_intr_t *pip;
836 1.1.2.1 cliff rmixl_pcix_dispatch_t *dip;
837 1.1.2.1 cliff int s;
838 1.1.2.1 cliff
839 1.1.2.1 cliff if (pih == ~0) {
840 1.1.2.1 cliff DPRINTF(("%s: bad pih=%#lx, implies PCI_INTERRUPT_PIN_NONE\n",
841 1.1.2.1 cliff __func__, pih));
842 1.1.2.1 cliff return NULL;
843 1.1.2.1 cliff }
844 1.1.2.1 cliff
845 1.1.2.1 cliff rmixl_pcix_decompose_pih(pih, &bitno, &irq);
846 1.1.2.1 cliff DPRINTF(("%s: pin=%d irq=%d\n", __func__, bitno + 1, irq));
847 1.1.2.1 cliff
848 1.1.2.1 cliff KASSERT(bitno < RMIXL_PCIX_NINTR);
849 1.1.2.1 cliff pip = &sc->sc_intr[bitno];
850 1.1.2.1 cliff
851 1.1.2.1 cliff s = splhigh();
852 1.1.2.1 cliff
853 1.1.2.1 cliff /*
854 1.1.2.1 cliff * all PCI-X device intrs get same ipl and sc
855 1.1.2.1 cliff */
856 1.1.2.1 cliff KASSERT(sc == rmixl_pcix_sc);
857 1.1.2.1 cliff KASSERT(ipl == IPL_VM);
858 1.1.2.1 cliff
859 1.1.2.1 cliff /*
860 1.1.2.1 cliff * allocate and initialize a dispatch handle
861 1.1.2.1 cliff */
862 1.1.2.1 cliff dip = malloc(sizeof(*dip), M_DEVBUF, M_NOWAIT);
863 1.1.2.1 cliff if (dip == NULL) {
864 1.1.2.1 cliff printf("%s: cannot malloc dispatch handle\n", __func__);
865 1.1.2.1 cliff goto out;
866 1.1.2.1 cliff }
867 1.1.2.1 cliff
868 1.1.2.1 cliff dip->bitno = bitno;
869 1.1.2.1 cliff dip->irq = irq;
870 1.1.2.1 cliff dip->func = func;
871 1.1.2.1 cliff dip->arg = arg;
872 1.1.2.1 cliff snprintf(dip->count_name, sizeof(dip->count_name),
873 1.1.2.1 cliff "pin %d", bitno + 1);
874 1.1.2.1 cliff evcnt_attach_dynamic(&dip->count, EVCNT_TYPE_INTR, NULL,
875 1.1.2.1 cliff "rmixl_pcix", dip->count_name);
876 1.1.2.1 cliff
877 1.1.2.1 cliff if (pip->enabled == false) {
878 1.1.2.1 cliff uint32_t bit = 1 << (bitno + 2);
879 1.1.2.1 cliff uint32_t r;
880 1.1.2.1 cliff
881 1.1.2.1 cliff r = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_CONTROL);
882 1.1.2.1 cliff r &= ~bit; /* clear mask */
883 1.1.2.1 cliff RMIXL_PCIXREG_WRITE(RMIXL_PCIX_ECFG_INTR_CONTROL, r);
884 1.1.2.1 cliff
885 1.1.2.1 cliff pip->sc = sc;
886 1.1.2.1 cliff pip->ipl = ipl;
887 1.1.2.1 cliff pip->enabled = true;
888 1.1.2.1 cliff DPRINTF(("%s: enabled pin %d\n", __func__, bitno + 1));
889 1.1.2.1 cliff }
890 1.1.2.1 cliff
891 1.1.2.1 cliff LIST_INSERT_HEAD(&pip->dispatch, dip, next);
892 1.1.2.1 cliff
893 1.1.2.1 cliff out:
894 1.1.2.1 cliff splx(s);
895 1.1.2.1 cliff return dip;
896 1.1.2.1 cliff }
897 1.1.2.1 cliff
898 1.1.2.1 cliff static int
899 1.1.2.1 cliff rmixl_pcix_intr(void *arg)
900 1.1.2.1 cliff {
901 1.1.2.1 cliff rmixl_pcix_softc_t *sc = arg;
902 1.1.2.1 cliff int rv = 0;
903 1.1.2.1 cliff
904 1.1.2.1 cliff uint32_t status = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_STATUS);
905 1.1.2.1 cliff DPRINTF(("%s: %#x\n", __func__, status));
906 1.1.2.1 cliff
907 1.1.2.1 cliff if (status != 0) {
908 1.1.2.1 cliff for (int i=0; i < RMIXL_PCIX_NINTR; i++) {
909 1.1.2.1 cliff uint32_t bit = 1 << i;
910 1.1.2.1 cliff if ((status & bit) != 0) {
911 1.1.2.1 cliff rmixl_pcix_intr_t *pip = &sc->sc_intr[i];
912 1.1.2.1 cliff rmixl_pcix_dispatch_t *dip;
913 1.1.2.1 cliff LIST_FOREACH(dip, &pip->dispatch, next) {
914 1.1.2.1 cliff (void)(*dip->func)(dip->arg);
915 1.1.2.1 cliff dip->count.ev_count++;
916 1.1.2.1 cliff rv = 1;
917 1.1.2.1 cliff }
918 1.1.2.1 cliff }
919 1.1.2.1 cliff }
920 1.1.2.1 cliff }
921 1.1.2.1 cliff return rv;
922 1.1.2.1 cliff }
923 1.1.2.1 cliff
924 1.1.2.1 cliff static int
925 1.1.2.1 cliff rmixl_pcix_error_intr(void *arg)
926 1.1.2.1 cliff {
927 1.1.2.1 cliff rmixl_pcix_softc_t *sc = arg;
928 1.1.2.1 cliff uint32_t error_status;
929 1.1.2.1 cliff
930 1.1.2.1 cliff error_status = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_ERR_STATUS);
931 1.1.2.1 cliff
932 1.1.2.1 cliff #ifdef DIAGNOSTIC
933 1.1.2.1 cliff printf("%s: error status %#x\n", __func__, error_status);
934 1.1.2.1 cliff #endif
935 1.1.2.1 cliff
936 1.1.2.1 cliff #if DDB
937 1.1.2.1 cliff Debugger();
938 1.1.2.1 cliff #endif
939 1.1.2.1 cliff
940 1.1.2.1 cliff /* XXX reset and recover? */
941 1.1.2.1 cliff
942 1.1.2.1 cliff panic("%s: error %#x\n", device_xname(sc->sc_dev), error_status);
943 1.1.2.1 cliff }
944 1.1.2.1 cliff
945 1.1.2.1 cliff /*
946 1.1.2.1 cliff * rmixl_physaddr_init_pcix:
947 1.1.2.1 cliff * called from rmixl_physaddr_init to get region addrs & sizes
948 1.1.2.1 cliff * from PCIX CFG, ECFG, IO, MEM BARs
949 1.1.2.1 cliff */
950 1.1.2.1 cliff void
951 1.1.2.1 cliff rmixl_physaddr_init_pcix(struct extent *ext)
952 1.1.2.1 cliff {
953 1.1.2.1 cliff u_long base;
954 1.1.2.1 cliff u_long size;
955 1.1.2.1 cliff uint32_t r;
956 1.1.2.1 cliff
957 1.1.2.1 cliff r = RMIXL_PCIXREG_READ(RMIXLR_SBC_PCIX_CFG_BAR);
958 1.1.2.1 cliff if ((r & RMIXL_PCIX_CFG_BAR_ENB) != 0) {
959 1.1.2.1 cliff base = (u_long)(RMIXL_PCIX_CFG_BAR_TO_BA((uint64_t)r)
960 1.1.2.1 cliff / (1024 * 1024));
961 1.1.2.1 cliff size = (u_long)RMIXL_PCIX_CFG_SIZE / (1024 * 1024);
962 1.1.2.1 cliff DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__,
963 1.1.2.1 cliff __LINE__, "CFG", r, base * 1024 * 1024, size));
964 1.1.2.1 cliff if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0)
965 1.1.2.1 cliff panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) "
966 1.1.2.1 cliff "failed", __func__, ext, base, size, EX_NOWAIT);
967 1.1.2.1 cliff }
968 1.1.2.1 cliff
969 1.1.2.1 cliff r = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXLR_SBC_PCIX_MEM_BAR);
970 1.1.2.1 cliff if ((r & RMIXL_PCIX_MEM_BAR_ENB) != 0) {
971 1.1.2.1 cliff base = (u_long)(RMIXL_PCIX_MEM_BAR_TO_BA((uint64_t)r)
972 1.1.2.1 cliff / (1024 * 1024));
973 1.1.2.1 cliff size = (u_long)(RMIXL_PCIX_MEM_BAR_TO_SIZE((uint64_t)r)
974 1.1.2.1 cliff / (1024 * 1024));
975 1.1.2.1 cliff DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__,
976 1.1.2.1 cliff __LINE__, "MEM", r, base * 1024 * 1024, size));
977 1.1.2.1 cliff if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0)
978 1.1.2.1 cliff panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) "
979 1.1.2.1 cliff "failed", __func__, ext, base, size, EX_NOWAIT);
980 1.1.2.1 cliff }
981 1.1.2.1 cliff
982 1.1.2.1 cliff r = RMIXL_IOREG_READ(RMIXL_IO_DEV_BRIDGE + RMIXLR_SBC_PCIX_IO_BAR);
983 1.1.2.1 cliff if ((r & RMIXL_PCIX_IO_BAR_ENB) != 0) {
984 1.1.2.1 cliff base = (u_long)(RMIXL_PCIX_IO_BAR_TO_BA((uint64_t)r)
985 1.1.2.1 cliff / (1024 * 1024));
986 1.1.2.1 cliff size = (u_long)(RMIXL_PCIX_IO_BAR_TO_SIZE((uint64_t)r)
987 1.1.2.1 cliff / (1024 * 1024));
988 1.1.2.1 cliff DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__,
989 1.1.2.1 cliff __LINE__, "IO", r, base * 1024 * 1024, size));
990 1.1.2.1 cliff if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0)
991 1.1.2.1 cliff panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) "
992 1.1.2.1 cliff "failed", __func__, ext, base, size, EX_NOWAIT);
993 1.1.2.1 cliff }
994 1.1.2.1 cliff }
995 1.1.2.1 cliff
996 1.1.2.1 cliff #ifdef DDB
997 1.1.2.1 cliff int rmixl_pcix_intr_chk(void);
998 1.1.2.1 cliff int
999 1.1.2.1 cliff rmixl_pcix_intr_chk(void)
1000 1.1.2.1 cliff {
1001 1.1.2.1 cliff uint32_t control, status, error_status;
1002 1.1.2.1 cliff
1003 1.1.2.1 cliff control = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_CONTROL);
1004 1.1.2.1 cliff status = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_STATUS);
1005 1.1.2.1 cliff error_status = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_ERR_STATUS);
1006 1.1.2.1 cliff
1007 1.1.2.1 cliff printf("%s: %#x, %#x, %#x\n", __func__, control, status, error_status);
1008 1.1.2.1 cliff
1009 1.1.2.1 cliff control |= PCIX_INTR_CONTROL_DIA;
1010 1.1.2.1 cliff RMIXL_PCIXREG_WRITE(RMIXL_PCIX_ECFG_INTR_CONTROL, control);
1011 1.1.2.1 cliff
1012 1.1.2.1 cliff control = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_CONTROL);
1013 1.1.2.1 cliff status = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_STATUS);
1014 1.1.2.1 cliff error_status = RMIXL_PCIXREG_READ(RMIXL_PCIX_ECFG_INTR_ERR_STATUS);
1015 1.1.2.1 cliff
1016 1.1.2.1 cliff printf("%s: %#x, %#x, %#x\n", __func__, control, status, error_status);
1017 1.1.2.1 cliff
1018 1.1.2.1 cliff return 0;
1019 1.1.2.1 cliff }
1020 1.1.2.1 cliff #endif
1021