MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-ia64 / sn / pci / pcibr_private.h
blobbd9b395390ecc32856e5c7fc046af10de3e3a827
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
7 */
8 #ifndef _ASM_IA64_SN_PCI_PCIBR_PRIVATE_H
9 #define _ASM_IA64_SN_PCI_PCIBR_PRIVATE_H
12 * pcibr_private.h -- private definitions for pcibr
13 * only the pcibr driver (and its closest friends)
14 * should ever peek into this file.
17 #include <linux/pci.h>
18 #include <asm/sn/pci/pcibr.h>
19 #include <asm/sn/pci/pciio_private.h>
22 * convenience typedefs
25 typedef uint64_t pcibr_DMattr_t;
26 typedef uint32_t pcibr_ATEattr_t;
28 typedef struct pcibr_info_s *pcibr_info_t, **pcibr_info_h;
29 typedef struct pcibr_soft_s *pcibr_soft_t;
30 typedef struct pcibr_soft_slot_s *pcibr_soft_slot_t;
31 typedef struct pcibr_hints_s *pcibr_hints_t;
32 typedef struct pcibr_intr_list_s *pcibr_intr_list_t;
33 typedef struct pcibr_intr_wrap_s *pcibr_intr_wrap_t;
34 typedef struct pcibr_intr_cbuf_s *pcibr_intr_cbuf_t;
36 typedef volatile unsigned int *cfg_p;
37 typedef volatile bridgereg_t *reg_p;
40 * extern functions
42 cfg_p pcibr_slot_config_addr(pcibr_soft_t, pciio_slot_t, int);
43 cfg_p pcibr_func_config_addr(pcibr_soft_t, pciio_bus_t bus, pciio_slot_t, pciio_function_t, int);
44 void pcibr_debug(uint32_t, vertex_hdl_t, char *, ...);
45 void pcibr_func_config_set(pcibr_soft_t, pciio_slot_t, pciio_function_t, int, unsigned);
47 * pcireg_ externs
50 extern uint64_t pcireg_id_get(pcibr_soft_t);
51 extern uint64_t pcireg_bridge_id_get(void *);
52 extern uint64_t pcireg_bus_err_get(pcibr_soft_t);
53 extern uint64_t pcireg_control_get(pcibr_soft_t);
54 extern uint64_t pcireg_bridge_control_get(void *);
55 extern void pcireg_control_set(pcibr_soft_t, uint64_t);
56 extern void pcireg_control_bit_clr(pcibr_soft_t, uint64_t);
57 extern void pcireg_control_bit_set(pcibr_soft_t, uint64_t);
58 extern void pcireg_req_timeout_set(pcibr_soft_t, uint64_t);
59 extern void pcireg_intr_dst_set(pcibr_soft_t, uint64_t);
60 extern uint64_t pcireg_intr_dst_target_id_get(pcibr_soft_t);
61 extern void pcireg_intr_dst_target_id_set(pcibr_soft_t, uint64_t);
62 extern uint64_t pcireg_intr_dst_addr_get(pcibr_soft_t);
63 extern void pcireg_intr_dst_addr_set(pcibr_soft_t, uint64_t);
64 extern uint64_t pcireg_cmdword_err_get(pcibr_soft_t);
65 extern uint64_t pcireg_llp_cfg_get(pcibr_soft_t);
66 extern void pcireg_llp_cfg_set(pcibr_soft_t, uint64_t);
67 extern uint64_t pcireg_tflush_get(pcibr_soft_t);
68 extern uint64_t pcireg_linkside_err_get(pcibr_soft_t);
69 extern uint64_t pcireg_resp_err_get(pcibr_soft_t);
70 extern uint64_t pcireg_resp_err_addr_get(pcibr_soft_t);
71 extern uint64_t pcireg_resp_err_buf_get(pcibr_soft_t);
72 extern uint64_t pcireg_resp_err_dev_get(pcibr_soft_t);
73 extern uint64_t pcireg_linkside_err_addr_get(pcibr_soft_t);
74 extern uint64_t pcireg_dirmap_get(pcibr_soft_t);
75 extern void pcireg_dirmap_set(pcibr_soft_t, uint64_t);
76 extern void pcireg_dirmap_wid_set(pcibr_soft_t, uint64_t);
77 extern void pcireg_dirmap_diroff_set(pcibr_soft_t, uint64_t);
78 extern void pcireg_dirmap_add512_set(pcibr_soft_t);
79 extern void pcireg_dirmap_add512_clr(pcibr_soft_t);
80 extern uint64_t pcireg_map_fault_get(pcibr_soft_t);
81 extern uint64_t pcireg_arbitration_get(pcibr_soft_t);
82 extern void pcireg_arbitration_set(pcibr_soft_t, uint64_t);
83 extern void pcireg_arbitration_bit_clr(pcibr_soft_t, uint64_t);
84 extern void pcireg_arbitration_bit_set(pcibr_soft_t, uint64_t);
85 extern uint64_t pcireg_parity_err_get(pcibr_soft_t);
86 extern uint64_t pcireg_type1_cntr_get(pcibr_soft_t);
87 extern void pcireg_type1_cntr_set(pcibr_soft_t, uint64_t);
88 extern uint64_t pcireg_timeout_get(pcibr_soft_t);
89 extern void pcireg_timeout_set(pcibr_soft_t, uint64_t);
90 extern void pcireg_timeout_bit_clr(pcibr_soft_t, uint64_t);
91 extern void pcireg_timeout_bit_set(pcibr_soft_t, uint64_t);
92 extern uint64_t pcireg_pci_bus_addr_get(pcibr_soft_t);
93 extern uint64_t pcireg_pci_bus_addr_addr_get(pcibr_soft_t);
94 extern uint64_t pcireg_intr_status_get(pcibr_soft_t);
95 extern uint64_t pcireg_intr_enable_get(pcibr_soft_t);
96 extern void pcireg_intr_enable_set(pcibr_soft_t, uint64_t);
97 extern void pcireg_intr_enable_bit_clr(pcibr_soft_t, uint64_t);
98 extern void pcireg_intr_enable_bit_set(pcibr_soft_t, uint64_t);
99 extern void pcireg_intr_reset_set(pcibr_soft_t, uint64_t);
100 extern void pcireg_intr_reset_bit_set(pcibr_soft_t, uint64_t);
101 extern uint64_t pcireg_intr_mode_get(pcibr_soft_t);
102 extern void pcireg_intr_mode_set(pcibr_soft_t, uint64_t);
103 extern void pcireg_intr_mode_bit_clr(pcibr_soft_t, uint64_t);
104 extern uint64_t pcireg_intr_device_get(pcibr_soft_t);
105 extern void pcireg_intr_device_set(pcibr_soft_t, uint64_t);
106 extern void pcireg_intr_device_bit_set(pcibr_soft_t, uint64_t);
107 extern void pcireg_bridge_intr_device_bit_set(void *, uint64_t);
108 extern void pcireg_intr_device_bit_clr(pcibr_soft_t, uint64_t);
109 extern uint64_t pcireg_intr_host_err_get(pcibr_soft_t);
110 extern void pcireg_intr_host_err_set(pcibr_soft_t, uint64_t);
111 extern uint64_t pcireg_intr_addr_get(pcibr_soft_t, int);
112 extern void pcireg_intr_addr_set(pcibr_soft_t, int, uint64_t);
113 extern void pcireg_bridge_intr_addr_set(void *, int, uint64_t);
114 extern void * pcireg_intr_addr_addr(pcibr_soft_t, int);
115 extern void pcireg_intr_addr_vect_set(pcibr_soft_t, int, uint64_t);
116 extern void pcireg_bridge_intr_addr_vect_set(void *, int, uint64_t);
117 extern uint64_t pcireg_intr_addr_addr_get(pcibr_soft_t, int);
118 extern void pcireg_intr_addr_addr_set(pcibr_soft_t, int, uint64_t);
119 extern void pcireg_bridge_intr_addr_addr_set(void *, int, uint64_t);
120 extern uint64_t pcireg_intr_view_get(pcibr_soft_t);
121 extern uint64_t pcireg_intr_multiple_get(pcibr_soft_t);
122 extern void pcireg_force_always_set(pcibr_soft_t, int);
123 extern void * pcireg_bridge_force_always_addr_get(void *, int);
124 extern void * pcireg_force_always_addr_get(pcibr_soft_t, int);
125 extern void pcireg_force_intr_set(pcibr_soft_t, int);
126 extern uint64_t pcireg_device_get(pcibr_soft_t, int);
127 extern void pcireg_device_set(pcibr_soft_t, int, uint64_t);
128 extern void pcireg_device_bit_set(pcibr_soft_t, int, uint64_t);
129 extern void pcireg_device_bit_clr(pcibr_soft_t, int, uint64_t);
130 extern uint64_t pcireg_rrb_get(pcibr_soft_t, int);
131 extern void pcireg_rrb_set(pcibr_soft_t, int, uint64_t);
132 extern void pcireg_rrb_bit_set(pcibr_soft_t, int, uint64_t);
133 extern void pcireg_rrb_bit_clr(pcibr_soft_t, int, uint64_t);
134 extern uint64_t pcireg_rrb_status_get(pcibr_soft_t);
135 extern void pcireg_rrb_clear_set(pcibr_soft_t, uint64_t);
136 extern uint64_t pcireg_wrb_flush_get(pcibr_soft_t, int);
137 extern uint64_t pcireg_pcix_bus_err_addr_get(pcibr_soft_t);
138 extern uint64_t pcireg_pcix_bus_err_attr_get(pcibr_soft_t);
139 extern uint64_t pcireg_pcix_bus_err_data_get(pcibr_soft_t);
140 extern uint64_t pcireg_pcix_req_err_attr_get(pcibr_soft_t);
141 extern uint64_t pcireg_pcix_req_err_addr_get(pcibr_soft_t);
142 extern uint64_t pcireg_pcix_pio_split_addr_get(pcibr_soft_t);
143 extern uint64_t pcireg_pcix_pio_split_attr_get(pcibr_soft_t);
144 extern cfg_p pcireg_type1_cfg_addr(pcibr_soft_t, pciio_function_t,
145 int);
146 extern cfg_p pcireg_type0_cfg_addr(pcibr_soft_t, pciio_slot_t,
147 pciio_function_t, int);
148 extern bridge_ate_t pcireg_int_ate_get(pcibr_soft_t, int);
149 extern void pcireg_int_ate_set(pcibr_soft_t, int, bridge_ate_t);
150 extern bridge_ate_p pcireg_int_ate_addr(pcibr_soft_t, int);
152 extern uint64_t pcireg_speed_get(pcibr_soft_t);
153 extern uint64_t pcireg_mode_get(pcibr_soft_t);
156 * PCIBR_DEBUG() macro and debug bitmask defines
158 /* low freqency debug events (ie. initialization, resource allocation,...) */
159 #define PCIBR_DEBUG_INIT 0x00000001 /* bridge init */
160 #define PCIBR_DEBUG_HINTS 0x00000002 /* bridge hints */
161 #define PCIBR_DEBUG_ATTACH 0x00000004 /* bridge attach */
162 #define PCIBR_DEBUG_DETACH 0x00000008 /* bridge detach */
163 #define PCIBR_DEBUG_ATE 0x00000010 /* bridge ATE allocation */
164 #define PCIBR_DEBUG_RRB 0x00000020 /* bridge RRB allocation */
165 #define PCIBR_DEBUG_RBAR 0x00000040 /* bridge RBAR allocation */
166 #define PCIBR_DEBUG_PROBE 0x00000080 /* bridge device probing */
167 #define PCIBR_DEBUG_INTR_ERROR 0x00000100 /* bridge error interrupt */
168 #define PCIBR_DEBUG_ERROR_HDLR 0x00000200 /* bridge error handler */
169 #define PCIBR_DEBUG_CONFIG 0x00000400 /* device's config space */
170 #define PCIBR_DEBUG_BAR 0x00000800 /* device's BAR allocations */
171 #define PCIBR_DEBUG_INTR_ALLOC 0x00001000 /* device's intr allocation */
172 #define PCIBR_DEBUG_DEV_ATTACH 0x00002000 /* device's attach */
173 #define PCIBR_DEBUG_DEV_DETACH 0x00004000 /* device's detach */
174 #define PCIBR_DEBUG_HOTPLUG 0x00008000
176 /* high freqency debug events (ie. map allocation, direct translation,...) */
177 #define PCIBR_DEBUG_DEVREG 0x04000000 /* bridges device reg sets */
178 #define PCIBR_DEBUG_PIOMAP 0x08000000 /* pcibr_piomap */
179 #define PCIBR_DEBUG_PIODIR 0x10000000 /* pcibr_piotrans */
180 #define PCIBR_DEBUG_DMAMAP 0x20000000 /* pcibr_dmamap */
181 #define PCIBR_DEBUG_DMADIR 0x40000000 /* pcibr_dmatrans */
182 #define PCIBR_DEBUG_INTR 0x80000000 /* interrupts */
184 extern char *pcibr_debug_module;
185 extern int pcibr_debug_widget;
186 extern int pcibr_debug_slot;
187 extern uint32_t pcibr_debug_mask;
189 /* For low frequency events (ie. initialization, resource allocation,...) */
190 #define PCIBR_DEBUG_ALWAYS(args) pcibr_debug args ;
192 /* XXX: habeck: maybe make PCIBR_DEBUG() always available? Even in non-
193 * debug kernels? If tracing isn't enabled (i.e pcibr_debug_mask isn't
194 * set, then the overhead for this macro is just an extra 'if' check.
196 /* For high frequency events (ie. map allocation, direct translation,...) */
197 #if DEBUG
198 #define PCIBR_DEBUG(args) PCIBR_DEBUG_ALWAYS(args)
199 #else /* DEBUG */
200 #define PCIBR_DEBUG(args)
201 #endif /* DEBUG */
204 * Bridge sets up PIO using this information.
206 struct pcibr_piomap_s {
207 struct pciio_piomap_s bp_pp; /* generic stuff */
209 #define bp_flags bp_pp.pp_flags /* PCIBR_PIOMAP flags */
210 #define bp_dev bp_pp.pp_dev /* associated pci card */
211 #define bp_slot bp_pp.pp_slot /* which slot the card is in */
212 #define bp_space bp_pp.pp_space /* which address space */
213 #define bp_pciaddr bp_pp.pp_pciaddr /* starting offset of mapping */
214 #define bp_mapsz bp_pp.pp_mapsz /* size of this mapping */
215 #define bp_kvaddr bp_pp.pp_kvaddr /* kernel virtual address to use */
217 iopaddr_t bp_xtalk_addr; /* corresponding xtalk address */
218 xtalk_piomap_t bp_xtalk_pio; /* corresponding xtalk resource */
219 pcibr_piomap_t bp_next; /* Next piomap on the list */
220 pcibr_soft_t bp_soft; /* backpointer to bridge soft data */
221 atomic_t bp_toc; /* PCI timeout counter */
226 * Bridge sets up DMA using this information.
228 struct pcibr_dmamap_s {
229 struct pciio_dmamap_s bd_pd;
230 #define bd_flags bd_pd.pd_flags /* PCIBR_DMAMAP flags */
231 #define bd_dev bd_pd.pd_dev /* associated pci card */
232 #define bd_slot bd_pd.pd_slot /* which slot the card is in */
233 struct pcibr_soft_s *bd_soft; /* pcibr soft state backptr */
234 xtalk_dmamap_t bd_xtalk; /* associated xtalk resources */
236 size_t bd_max_size; /* maximum size of mapping */
237 xwidgetnum_t bd_xio_port; /* target XIO port */
238 iopaddr_t bd_xio_addr; /* target XIO address */
239 iopaddr_t bd_pci_addr; /* via PCI address */
241 int bd_ate_index; /* Address Translation Entry Index */
242 int bd_ate_count; /* number of ATE's allocated */
243 bridge_ate_p bd_ate_ptr; /* where to write first ATE */
244 bridge_ate_t bd_ate_proto; /* prototype ATE (for xioaddr=0) */
245 bridge_ate_t bd_ate_prime; /* value of 1st ATE written */
246 dma_addr_t bd_dma_addr; /* Linux dma handle */
247 struct resource resource;
250 #define IBUFSIZE 5 /* size of circular buffer (holds 4) */
253 * Circular buffer used for interrupt processing
255 struct pcibr_intr_cbuf_s {
256 spinlock_t ib_lock; /* cbuf 'put' lock */
257 int ib_in; /* index of next free entry */
258 int ib_out; /* index of next full entry */
259 pcibr_intr_wrap_t ib_cbuf[IBUFSIZE]; /* circular buffer of wrap */
263 * Bridge sets up interrupts using this information.
266 struct pcibr_intr_s {
267 struct pciio_intr_s bi_pi;
268 #define bi_flags bi_pi.pi_flags /* PCIBR_INTR flags */
269 #define bi_dev bi_pi.pi_dev /* associated pci card */
270 #define bi_lines bi_pi.pi_lines /* which PCI interrupt line(s) */
271 #define bi_func bi_pi.pi_func /* handler function (when connected) */
272 #define bi_arg bi_pi.pi_arg /* handler parameter (when connected) */
273 #define bi_mustruncpu bi_pi.pi_mustruncpu /* Where we must run. */
274 #define bi_irq bi_pi.pi_irq /* IRQ assigned. */
275 #define bi_cpu bi_pi.pi_cpu /* cpu assigned. */
276 unsigned int bi_ibits; /* which Bridge interrupt bit(s) */
277 pcibr_soft_t bi_soft; /* shortcut to soft info */
278 struct pcibr_intr_cbuf_s bi_ibuf; /* circular buffer of wrap ptrs */
279 unsigned bi_last_intr; /* For Shub lb lost intr. bug */
284 * PCIBR_INFO_SLOT_GET_EXT returns the external slot number that the card
285 * resides in. (i.e the slot number silk screened on the back of the I/O
286 * brick). PCIBR_INFO_SLOT_GET_INT returns the internal slot (or device)
287 * number used by the pcibr code to represent that external slot (i.e to
288 * set bit patterns in BRIDGE/PIC registers to represent the device, or to
289 * offset into an array, or ...).
291 * In BRIDGE and XBRIDGE the external slot and internal device numbering
292 * are the same. (0->0, 1->1, 2->2,... 7->7) BUT in the PIC the external
293 * slot number is always 1 greater than the internal device number (1->0,
294 * 2->1, 3->2, 4->3). This is due to the fact that the PCI-X spec requires
295 * that the 'bridge' (i.e PIC) be designated as 'device 0', thus external
296 * slot numbering can't start at zero.
298 * PCIBR_DEVICE_TO_SLOT converts an internal device number to an external
299 * slot number. NOTE: PCIIO_SLOT_NONE stays as PCIIO_SLOT_NONE.
301 * PCIBR_SLOT_TO_DEVICE converts an external slot number to an internal
302 * device number. NOTE: PCIIO_SLOT_NONE stays as PCIIO_SLOT_NONE.
304 #define PCIBR_INFO_SLOT_GET_EXT(info) (((pcibr_info_t)info)->f_slot)
305 #define PCIBR_INFO_SLOT_GET_INT(info) (((pcibr_info_t)info)->f_dev)
307 #define PCIBR_DEVICE_TO_SLOT(pcibr_soft, dev_num) \
308 (((dev_num) != PCIIO_SLOT_NONE) ? ((dev_num) + 1) : PCIIO_SLOT_NONE)
310 #define PCIBR_SLOT_TO_DEVICE(pcibr_soft, slot) \
311 (((slot) != PCIIO_SLOT_NONE) ? ((slot) - 1) : PCIIO_SLOT_NONE)
314 * per-connect point pcibr data, including standard pciio data in-line:
316 struct pcibr_info_s {
317 struct pciio_info_s f_c; /* MUST BE FIRST. */
318 #define f_vertex f_c.c_vertex /* back pointer to vertex */
319 #define f_bus f_c.c_bus /* which bus the card is in */
320 #define f_slot f_c.c_slot /* which slot the card is in */
321 #define f_func f_c.c_func /* which func (on multi-func cards) */
322 #define f_vendor f_c.c_vendor /* PCI card "vendor" code */
323 #define f_device f_c.c_device /* PCI card "device" code */
324 #define f_master f_c.c_master /* PCI bus provider */
325 #define f_mfast f_c.c_mfast /* cached fastinfo from c_master */
326 #define f_pops f_c.c_pops /* cached provider from c_master */
327 #define f_efunc f_c.c_efunc /* error handling function */
328 #define f_einfo f_c.c_einfo /* first parameter for efunc */
329 #define f_window f_c.c_window /* state of BASE regs */
330 #define f_rwindow f_c.c_rwindow /* expansion ROM BASE regs */
331 #define f_rbase f_c.c_rbase /* expansion ROM base */
332 #define f_rsize f_c.c_rsize /* expansion ROM size */
333 #define f_piospace f_c.c_piospace /* additional I/O spaces allocated */
335 /* pcibr-specific connection state */
336 int f_ibit[4]; /* Bridge bit for each INTx */
337 pcibr_piomap_t f_piomap;
338 int f_att_det_error;
339 pciio_slot_t f_dev; /* which device the card represents */
340 cap_pcix_type0_t *f_pcix_cap; /* pointer to the pcix capability */
343 /* =====================================================================
344 * Shared Interrupt Information
347 struct pcibr_intr_list_s {
348 pcibr_intr_list_t il_next;
349 pcibr_intr_t il_intr;
350 pcibr_soft_t il_soft;
351 pciio_slot_t il_slot;
354 /* =====================================================================
355 * Interrupt Wrapper Data
357 struct pcibr_intr_wrap_s {
358 pcibr_soft_t iw_soft; /* which bridge */
359 volatile bridgereg_t *iw_stat; /* ptr to b_int_status */
360 bridgereg_t iw_ibit; /* bit in b_int_status */
361 pcibr_intr_list_t iw_list; /* ghostbusters! */
362 int iw_hdlrcnt; /* running handler count */
363 int iw_shared; /* if Bridge bit is shared */
364 int iw_connected; /* if already connected */
367 #define PCIBR_ISR_ERR_START 8
368 #define PCIBR_ISR_MAX_ERRS_BRIDGE 32
369 #define PCIBR_ISR_MAX_ERRS_PIC 45
370 #define PCIBR_ISR_MAX_ERRS PCIBR_ISR_MAX_ERRS_PIC
373 * PCI Base Address Register window allocation constants.
374 * To reduce the size of the internal resource mapping structures, do
375 * not use the entire PCI bus I/O address space
377 #define PCIBR_BUS_IO_BASE 0x200000
378 #define PCIBR_BUS_IO_MAX 0x0FFFFFFF
379 #define PCIBR_BUS_IO_PAGE 0x100000
381 #define PCIBR_BUS_SWIN_BASE PAGE_SIZE
382 #define PCIBR_BUS_SWIN_MAX 0x000FFFFF
383 #define PCIBR_BUS_SWIN_PAGE PAGE_SIZE
385 #define PCIBR_BUS_MEM_BASE 0x200000
386 #define PCIBR_BUS_MEM_MAX 0x3FFFFFFF
387 #define PCIBR_BUS_MEM_PAGE 0x100000
389 /* defines for pcibr_soft_s->bs_bridge_type */
390 #define PCIBR_BRIDGETYPE_PIC 2
391 #define IS_PIC_BUSNUM_SOFT(ps, bus) ((ps)->bs_busnum == (bus))
394 * Runtime checks for workarounds.
396 #define PCIBR_WAR_ENABLED(pv, pcibr_soft) \
397 ((1 << XWIDGET_PART_REV_NUM_REV(pcibr_soft->bs_rev_num)) & pv)
399 /* defines for pcibr_soft_s->bs_bridge_mode */
400 #define PCIBR_BRIDGEMODE_PCI_33 0x0
401 #define PCIBR_BRIDGEMODE_PCI_66 0x2
402 #define PCIBR_BRIDGEMODE_PCIX_66 0x3
403 #define PCIBR_BRIDGEMODE_PCIX_100 0x5
404 #define PCIBR_BRIDGEMODE_PCIX_133 0x7
405 #define BUSSPEED_MASK 0x6
406 #define BUSTYPE_MASK 0x1
408 #define IS_PCI(ps) (!IS_PCIX(ps))
409 #define IS_PCIX(ps) ((ps)->bs_bridge_mode & BUSTYPE_MASK)
411 #define IS_33MHZ(ps) ((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCI_33)
412 #define IS_66MHZ(ps) (((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCI_66) || \
413 ((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCIX_66))
414 #define IS_100MHZ(ps) ((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCIX_100)
415 #define IS_133MHZ(ps) ((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCIX_133)
418 /* Number of PCI slots. NOTE: this works as long as the first slot
419 * is zero. Otherwise use ((ps->bs_max_slot+1) - ps->bs_min_slot)
421 #define PCIBR_NUM_SLOTS(ps) (ps->bs_max_slot+1)
423 /* =====================================================================
424 * Bridge Device State structure
426 * one instance of this structure is kept for each
427 * Bridge ASIC in the system.
430 struct pcibr_soft_s {
431 vertex_hdl_t bs_conn; /* xtalk connection point */
432 vertex_hdl_t bs_vhdl; /* vertex owned by pcibr */
433 uint64_t bs_int_enable; /* Mask of enabled intrs */
434 void *bs_base; /* PIO pointer to Bridge chip */
435 char *bs_name; /* hw graph name */
436 char bs_asic_name[16]; /* ASIC name */
437 xwidgetnum_t bs_xid; /* Bridge's xtalk ID number */
438 vertex_hdl_t bs_master; /* xtalk master vertex */
439 xwidgetnum_t bs_mxid; /* master's xtalk ID number */
440 pciio_slot_t bs_first_slot; /* first existing slot */
441 pciio_slot_t bs_last_slot; /* last existing slot */
442 pciio_slot_t bs_last_reset; /* last slot to reset */
443 uint32_t bs_unused_slot; /* unavailable slots bitmask */
444 pciio_slot_t bs_min_slot; /* lowest possible slot */
445 pciio_slot_t bs_max_slot; /* highest possible slot */
446 pcibr_soft_t bs_peers_soft; /* PICs other bus's soft */
447 int bs_busnum; /* PIC has two pci busses */
449 iopaddr_t bs_dir_xbase; /* xtalk address for 32-bit PCI direct map */
450 xwidgetnum_t bs_dir_xport; /* xtalk port for 32-bit PCI direct map */
452 struct resource bs_int_ate_resource;/* root resource for internal ATEs */
453 struct resource bs_ext_ate_resource;/* root resource for external ATEs */
454 void *bs_allocated_ate_res;/* resource struct allocated */
455 short bs_int_ate_size; /* number of internal ates */
456 short bs_bridge_type; /* see defines above */
457 short bs_bridge_mode; /* see defines above */
459 int bs_rev_num; /* revision number of Bridge */
461 /* bs_dma_flags are the forced dma flags used on all DMAs. Used for
462 * working around ASIC rev issues and protocol specific requirements
464 unsigned int bs_dma_flags; /* forced DMA flags */
466 nasid_t bs_nasid; /* nasid this bus is on */
467 moduleid_t bs_moduleid; /* io brick moduleid */
468 short bs_bricktype; /* io brick type */
471 * Lock used primarily to get mutual exclusion while managing any
472 * bridge resources..
474 spinlock_t bs_lock;
476 vertex_hdl_t bs_noslot_conn; /* NO-SLOT connection point */
477 pcibr_info_t bs_noslot_info;
479 #ifdef CONFIG_HOTPLUG_PCI_SGI
480 /* Linux PCI bus structure pointer */
481 struct pci_bus *bs_pci_bus;
482 #endif
484 struct pcibr_soft_slot_s {
485 /* information we keep about each CFG slot */
487 /* some devices (ioc3 in non-slotted
488 * configurations, sometimes) make use
489 * of more than one REQ/GNT/INT* signal
490 * sets. The slot corresponding to the
491 * IDSEL that the device responds to is
492 * called the host slot; the slot
493 * numbers that the device is stealing
494 * REQ/GNT/INT bits from are known as
495 * the guest slots.
497 int has_host;
498 pciio_slot_t host_slot;
499 vertex_hdl_t slot_conn;
501 #ifdef CONFIG_HOTPLUG_PCI_SGI
502 /* PCI Hot-Plug status word */
503 int slot_status;
505 /* PCI Hot-Plug core structure pointer */
506 struct hotplug_slot *bss_hotplug_slot;
507 #endif /* CONFIG_HOTPLUG_PCI_SGI */
509 /* Potentially several connection points
510 * for this slot. bss_ninfo is how many,
511 * and bss_infos is a pointer to
512 * an array pcibr_info_t values (which are
513 * pointers to pcibr_info structs, stored
514 * as device_info in connection ponts).
516 int bss_ninfo;
517 pcibr_info_h bss_infos;
519 /* Temporary Compatibility Macros, for
520 * stuff that has moved out of bs_slot
521 * and into the info structure. These
522 * will go away when their users have
523 * converted over to multifunction-
524 * friendly use of bss_{ninfo,infos}.
526 #define bss_vendor_id bss_infos[0]->f_vendor
527 #define bss_device_id bss_infos[0]->f_device
528 #define bss_window bss_infos[0]->f_window
529 #define bssw_space w_space
530 #define bssw_base w_base
531 #define bssw_size w_size
533 /* Where is DevIO(x) pointing? */
534 /* bssd_space is NONE if it is not assigned. */
535 struct {
536 pciio_space_t bssd_space;
537 iopaddr_t bssd_base;
538 int bssd_ref_cnt;
539 } bss_devio;
541 /* Shadow value for Device(x) register,
542 * so we don't have to go to the chip.
544 uint64_t bss_device;
546 /* Number of sets on GBR/REALTIME bit outstanding
547 * Used by Priority I/O for tracking reservations
549 int bss_pri_uctr;
551 /* Number of "uses" of PMU, 32-bit direct,
552 * and 64-bit direct DMA (0:none, <0: trans,
553 * >0: how many dmamaps). Device(x) bits
554 * controlling attribute of each kind of
555 * channel can't be changed by dmamap_alloc
556 * or dmatrans if the controlling counter
557 * is nonzero. dmatrans is forever.
559 int bss_pmu_uctr;
560 int bss_d32_uctr;
561 int bss_d64_uctr;
563 /* When the contents of mapping configuration
564 * information is locked down by dmatrans,
565 * repeated checks of the same flags should
566 * be shortcircuited for efficiency.
568 iopaddr_t bss_d64_base;
569 unsigned bss_d64_flags;
570 iopaddr_t bss_d32_base;
571 unsigned bss_d32_flags;
572 } bs_slot[8];
574 pcibr_intr_bits_f *bs_intr_bits;
576 /* PIC PCI-X Read Buffer Management :
577 * bs_pcix_num_funcs: the total number of PCI-X functions
578 * on the bus
579 * bs_pcix_split_tot: total number of outstanding split
580 * transactions requested by all functions on the bus
581 * bs_pcix_rbar_percent_allowed: the percentage of the
582 * total number of buffers a function requested that are
583 * available to it, not including the 1 RBAR guaranteed
584 * to it.
585 * bs_pcix_rbar_inuse: number of RBARs in use.
586 * bs_pcix_rbar_avail: number of RBARs available. NOTE:
587 * this value can go negative if we oversubscribe the
588 * RBARs. (i.e. We have 16 RBARs but 17 functions).
590 int bs_pcix_num_funcs;
591 int bs_pcix_split_tot;
592 int bs_pcix_rbar_percent_allowed;
594 int bs_pcix_rbar_inuse;
595 int bs_pcix_rbar_avail;
598 /* RRB MANAGEMENT
599 * bs_rrb_fixed: bitmap of slots whose RRB
600 * allocations we should not "automatically" change
601 * bs_rrb_avail: number of RRBs that have not
602 * been allocated or reserved for {even,odd} slots
603 * bs_rrb_res: number of RRBs currently reserved for the
604 * use of the index slot number
605 * bs_rrb_res_dflt: number of RRBs reserved at boot
606 * time for the use of the index slot number
607 * bs_rrb_valid: number of RRBs currently marked valid
608 * for the indexed slot/vchan number; array[slot][vchan]
609 * bs_rrb_valid_dflt: number of RRBs marked valid at boot
610 * time for the indexed slot/vchan number; array[slot][vchan]
612 int bs_rrb_fixed;
613 int bs_rrb_avail[2];
614 int bs_rrb_res[8];
615 int bs_rrb_res_dflt[8];
616 int bs_rrb_valid[8][4];
617 int bs_rrb_valid_dflt[8][4];
618 struct {
619 /* Each Bridge interrupt bit has a single XIO
620 * interrupt channel allocated.
622 xtalk_intr_t bsi_xtalk_intr;
624 * A wrapper structure is associated with each
625 * Bridge interrupt bit.
627 struct pcibr_intr_wrap_s bsi_pcibr_intr_wrap;
628 /* The bus and interrupt bit, used for pcibr_setpciint().
629 * The pci busnum is bit3, int_bits bit2:0
631 uint32_t bsi_int_bit;
633 } bs_intr[8];
635 xtalk_intr_t bsi_err_intr;
638 * We stash away some information in this structure on getting
639 * an error interrupt. This information is used during PIO read/
640 * write error handling.
642 * As it stands now, we do not re-enable the error interrupt
643 * till the error is resolved. Error resolution happens either at
644 * bus error time for PIO Read errors (~100 microseconds), or at
645 * the scheduled timeout time for PIO write errors (~milliseconds).
646 * If this delay causes problems, we may need to move towards
647 * a different scheme..
649 * Note that there is no locking while looking at this data structure.
650 * There should not be any race between bus error code and
651 * error interrupt code.. will look into this if needed.
653 * NOTE: The above discussion of error interrupt processing is
654 * no longer true. Whether it should again be true, is
655 * being looked into.
657 struct br_errintr_info {
658 int bserr_toutcnt;
659 iopaddr_t bserr_addr; /* Address where error occured */
660 uint64_t bserr_intstat; /* interrupts active at error dump */
661 } bs_errinfo;
664 * PCI Bus Space allocation data structure.
666 * The resource mapping functions rmalloc() and rmfree() are used
667 * to manage the PCI bus I/O, small window, and memory address
668 * spaces.
670 * This info is used to assign PCI bus space addresses to cards
671 * via their BARs and to the callers of the pcibr_piospace_alloc()
672 * interface.
674 * Users of the pcibr_piospace_alloc() interface, such as the VME
675 * Universe chip, need PCI bus space that is not acquired by BARs.
676 * Most of these users need "large" amounts of PIO space (typically
677 * in Megabytes), and they generally tend to take once and never
678 * release.
680 struct pciio_win_map_s bs_io_win_map; /* I/O addr space */
681 struct pciio_win_map_s bs_swin_map; /* Small window addr space */
682 struct pciio_win_map_s bs_mem_win_map; /* Memory addr space */
684 struct resource bs_io_win_root_resource; /* I/O addr space */
685 struct resource bs_swin_root_resource; /* Small window addr space */
686 struct resource bs_mem_win_root_resource; /* Memory addr space */
688 int bs_bus_addr_status; /* Bus space status */
690 #define PCIBR_BUS_ADDR_MEM_FREED 1 /* Reserved PROM mem addr freed */
691 #define PCIBR_BUS_ADDR_IO_FREED 2 /* Reserved PROM I/O addr freed */
693 struct bs_errintr_stat_s {
694 uint32_t bs_errcount_total;
695 uint32_t bs_lasterr_timestamp;
696 uint32_t bs_lasterr_snapshot;
697 } bs_errintr_stat[PCIBR_ISR_MAX_ERRS];
700 * Bridge-wide endianness control for
701 * large-window PIO mappings
703 * These fields are set to PCIIO_BYTE_SWAP
704 * or PCIIO_WORD_VALUES once the swapper
705 * has been configured, one way or the other,
706 * for the direct windows. If they are zero,
707 * nobody has a PIO mapping through that window,
708 * and the swapper can be set either way.
710 unsigned bs_pio_end_io;
711 unsigned bs_pio_end_mem;
714 #define PCIBR_ERRTIME_THRESHOLD (100)
715 #define PCIBR_ERRRATE_THRESHOLD (100)
718 * pcibr will respond to hints dropped in its vertex
719 * using the following structure.
721 struct pcibr_hints_s {
722 /* ph_host_slot is actually +1 so "0" means "no host" */
723 pciio_slot_t ph_host_slot[8]; /* REQ/GNT/INT in use by ... */
724 unsigned int ph_rrb_fixed; /* do not change RRB allocations */
725 unsigned int ph_hands_off; /* prevent further pcibr operations */
726 rrb_alloc_funct_t rrb_alloc_funct; /* do dynamic rrb allocation */
727 pcibr_intr_bits_f *ph_intr_bits; /* map PCI INT[ABCD] to Bridge Int(n) */
731 * Number of bridge non-fatal error interrupts we can see before
732 * we decide to disable that interrupt.
734 #define PCIBR_ERRINTR_DISABLE_LEVEL 10000
736 /* =====================================================================
737 * Bridge (pcibr) state management functions
739 * pcibr_soft_get is here because we do it in a lot
740 * of places and I want to make sure they all stay
741 * in step with each other.
743 * pcibr_soft_set is here because I want it to be
744 * closely associated with pcibr_soft_get, even
745 * though it is only called in one place.
748 #define pcibr_soft_get(v) ((pcibr_soft_t)hwgraph_fastinfo_get((v)))
749 #define pcibr_soft_set(v,i) (hwgraph_fastinfo_set((v), (arbitrary_info_t)(i)))
752 * Additional PIO spaces per slot are
753 * recorded in this structure.
755 struct pciio_piospace_s {
756 pciio_piospace_t next; /* another space for this device */
757 char free; /* 1 if free, 0 if in use */
758 pciio_space_t space; /* Which space is in use */
759 iopaddr_t start; /* Starting address of the PIO space */
760 size_t count; /* size of PIO space */
764 * pcibr_soft structure locking macros
766 inline static unsigned long
767 pcibr_lock(pcibr_soft_t pcibr_soft)
769 unsigned long flag;
770 spin_lock_irqsave(&pcibr_soft->bs_lock, flag);
771 return(flag);
773 #define pcibr_unlock(pcibr_soft, flag) spin_unlock_irqrestore(&pcibr_soft->bs_lock, flag)
775 #define PCIBR_VALID_SLOT(ps, s) (s < PCIBR_NUM_SLOTS(ps))
776 #define PCIBR_D64_BASE_UNSET (0xFFFFFFFFFFFFFFFF)
777 #define PCIBR_D32_BASE_UNSET (0xFFFFFFFF)
778 #define INFO_LBL_PCIBR_ASIC_REV "_pcibr_asic_rev"
780 #define PCIBR_SOFT_LIST 1
781 #if PCIBR_SOFT_LIST
782 typedef struct pcibr_list_s *pcibr_list_p;
783 struct pcibr_list_s {
784 pcibr_list_p bl_next;
785 pcibr_soft_t bl_soft;
786 vertex_hdl_t bl_vhdl;
788 #endif /* PCIBR_SOFT_LIST */
790 /* Devices per widget: 2 buses, 2 slots per bus, 8 functions per slot. */
791 #define DEV_PER_WIDGET (2*2*8)
793 struct sn_flush_device_list {
794 int bus;
795 int slot;
796 int pin;
797 struct bar_list {
798 unsigned long start;
799 unsigned long end;
800 } bar_list[PCI_ROM_RESOURCE];
801 unsigned long force_int_addr;
802 volatile unsigned long flush_addr;
803 spinlock_t flush_lock;
806 struct sn_flush_nasid_entry {
807 struct sn_flush_device_list **widget_p;
808 unsigned long iio_itte[8];
811 #endif /* _ASM_SN_PCI_PCIBR_PRIVATE_H */