convert brcm-2.4 to the new target structure
[openwrt/svn-archive/archive.git] / target / linux / brcm-2.4 / files / arch / mips / bcm947xx / include / pcicfg.h
1 /*
2 * pcicfg.h: PCI configuration constants and structures.
3 *
4 * Copyright 2006, Broadcom Corporation
5 * All Rights Reserved.
6 *
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 *
12 * $Id: pcicfg.h,v 1.1.1.11 2006/04/08 06:13:40 honor Exp $
13 */
14
15 #ifndef _h_pcicfg_
16 #define _h_pcicfg_
17
18 /* The following inside ifndef's so we don't collide with NTDDK.H */
19 #ifndef PCI_MAX_BUS
20 #define PCI_MAX_BUS 0x100
21 #endif
22 #ifndef PCI_MAX_DEVICES
23 #define PCI_MAX_DEVICES 0x20
24 #endif
25 #ifndef PCI_MAX_FUNCTION
26 #define PCI_MAX_FUNCTION 0x8
27 #endif
28
29 #ifndef PCI_INVALID_VENDORID
30 #define PCI_INVALID_VENDORID 0xffff
31 #endif
32 #ifndef PCI_INVALID_DEVICEID
33 #define PCI_INVALID_DEVICEID 0xffff
34 #endif
35
36
37 /* Convert between bus-slot-function-register and config addresses */
38
39 #define PCICFG_BUS_SHIFT 16 /* Bus shift */
40 #define PCICFG_SLOT_SHIFT 11 /* Slot shift */
41 #define PCICFG_FUN_SHIFT 8 /* Function shift */
42 #define PCICFG_OFF_SHIFT 0 /* Register shift */
43
44 #define PCICFG_BUS_MASK 0xff /* Bus mask */
45 #define PCICFG_SLOT_MASK 0x1f /* Slot mask */
46 #define PCICFG_FUN_MASK 7 /* Function mask */
47 #define PCICFG_OFF_MASK 0xff /* Bus mask */
48
49 #define PCI_CONFIG_ADDR(b, s, f, o) \
50 ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
51 | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
52 | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
53 | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
54
55 #define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
56 #define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
57 #define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
58 #define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
59
60 /* PCIE Config space accessing MACROS */
61
62 #define PCIECFG_BUS_SHIFT 24 /* Bus shift */
63 #define PCIECFG_SLOT_SHIFT 19 /* Slot/Device shift */
64 #define PCIECFG_FUN_SHIFT 16 /* Function shift */
65 #define PCIECFG_OFF_SHIFT 0 /* Register shift */
66
67 #define PCIECFG_BUS_MASK 0xff /* Bus mask */
68 #define PCIECFG_SLOT_MASK 0x1f /* Slot/Device mask */
69 #define PCIECFG_FUN_MASK 7 /* Function mask */
70 #define PCIECFG_OFF_MASK 0x3ff /* Register mask */
71
72 #define PCIE_CONFIG_ADDR(b, s, f, o) \
73 ((((b) & PCIECFG_BUS_MASK) << PCIECFG_BUS_SHIFT) \
74 | (((s) & PCIECFG_SLOT_MASK) << PCIECFG_SLOT_SHIFT) \
75 | (((f) & PCIECFG_FUN_MASK) << PCIECFG_FUN_SHIFT) \
76 | (((o) & PCIECFG_OFF_MASK) << PCIECFG_OFF_SHIFT))
77
78 #define PCIE_CONFIG_BUS(a) (((a) >> PCIECFG_BUS_SHIFT) & PCIECFG_BUS_MASK)
79 #define PCIE_CONFIG_SLOT(a) (((a) >> PCIECFG_SLOT_SHIFT) & PCIECFG_SLOT_MASK)
80 #define PCIE_CONFIG_FUN(a) (((a) >> PCIECFG_FUN_SHIFT) & PCIECFG_FUN_MASK)
81 #define PCIE_CONFIG_OFF(a) (((a) >> PCIECFG_OFF_SHIFT) & PCIECFG_OFF_MASK)
82
83 /* The actual config space */
84
85 #define PCI_BAR_MAX 6
86
87 #define PCI_ROM_BAR 8
88
89 #define PCR_RSVDA_MAX 2
90
91 /* Bits in PCI bars' flags */
92
93 #define PCIBAR_FLAGS 0xf
94 #define PCIBAR_IO 0x1
95 #define PCIBAR_MEM1M 0x2
96 #define PCIBAR_MEM64 0x4
97 #define PCIBAR_PREFETCH 0x8
98 #define PCIBAR_MEM32_MASK 0xFFFFFF80
99
100 /* pci config status reg has a bit to indicate that capability ptr is present */
101
102 #define PCI_CAPPTR_PRESENT 0x0010
103
104 typedef struct _pci_config_regs {
105 unsigned short vendor;
106 unsigned short device;
107 unsigned short command;
108 unsigned short status;
109 unsigned char rev_id;
110 unsigned char prog_if;
111 unsigned char sub_class;
112 unsigned char base_class;
113 unsigned char cache_line_size;
114 unsigned char latency_timer;
115 unsigned char header_type;
116 unsigned char bist;
117 unsigned long base[PCI_BAR_MAX];
118 unsigned long cardbus_cis;
119 unsigned short subsys_vendor;
120 unsigned short subsys_id;
121 unsigned long baserom;
122 unsigned long rsvd_a[PCR_RSVDA_MAX];
123 unsigned char int_line;
124 unsigned char int_pin;
125 unsigned char min_gnt;
126 unsigned char max_lat;
127 unsigned char dev_dep[192];
128 } pci_config_regs;
129
130 #define SZPCR (sizeof (pci_config_regs))
131 #define MINSZPCR 64 /* offsetof (dev_dep[0] */
132
133 /* A structure for the config registers is nice, but in most
134 * systems the config space is not memory mapped, so we need
135 * filed offsetts. :-(
136 */
137 #define PCI_CFG_VID 0
138 #define PCI_CFG_DID 2
139 #define PCI_CFG_CMD 4
140 #define PCI_CFG_STAT 6
141 #define PCI_CFG_REV 8
142 #define PCI_CFG_PROGIF 9
143 #define PCI_CFG_SUBCL 0xa
144 #define PCI_CFG_BASECL 0xb
145 #define PCI_CFG_CLSZ 0xc
146 #define PCI_CFG_LATTIM 0xd
147 #define PCI_CFG_HDR 0xe
148 #define PCI_CFG_BIST 0xf
149 #define PCI_CFG_BAR0 0x10
150 #define PCI_CFG_BAR1 0x14
151 #define PCI_CFG_BAR2 0x18
152 #define PCI_CFG_BAR3 0x1c
153 #define PCI_CFG_BAR4 0x20
154 #define PCI_CFG_BAR5 0x24
155 #define PCI_CFG_CIS 0x28
156 #define PCI_CFG_SVID 0x2c
157 #define PCI_CFG_SSID 0x2e
158 #define PCI_CFG_ROMBAR 0x30
159 #define PCI_CFG_CAPPTR 0x34
160 #define PCI_CFG_INT 0x3c
161 #define PCI_CFG_PIN 0x3d
162 #define PCI_CFG_MINGNT 0x3e
163 #define PCI_CFG_MAXLAT 0x3f
164
165 #ifdef __NetBSD__
166 #undef PCI_CLASS_DISPLAY
167 #undef PCI_CLASS_MEMORY
168 #undef PCI_CLASS_BRIDGE
169 #undef PCI_CLASS_INPUT
170 #undef PCI_CLASS_DOCK
171 #endif /* __NetBSD__ */
172
173 /* Classes and subclasses */
174
175 typedef enum {
176 PCI_CLASS_OLD = 0,
177 PCI_CLASS_DASDI,
178 PCI_CLASS_NET,
179 PCI_CLASS_DISPLAY,
180 PCI_CLASS_MMEDIA,
181 PCI_CLASS_MEMORY,
182 PCI_CLASS_BRIDGE,
183 PCI_CLASS_COMM,
184 PCI_CLASS_BASE,
185 PCI_CLASS_INPUT,
186 PCI_CLASS_DOCK,
187 PCI_CLASS_CPU,
188 PCI_CLASS_SERIAL,
189 PCI_CLASS_INTELLIGENT = 0xe,
190 PCI_CLASS_SATELLITE,
191 PCI_CLASS_CRYPT,
192 PCI_CLASS_DSP,
193 PCI_CLASS_XOR = 0xfe
194 } pci_classes;
195
196 typedef enum {
197 PCI_DASDI_SCSI,
198 PCI_DASDI_IDE,
199 PCI_DASDI_FLOPPY,
200 PCI_DASDI_IPI,
201 PCI_DASDI_RAID,
202 PCI_DASDI_OTHER = 0x80
203 } pci_dasdi_subclasses;
204
205 typedef enum {
206 PCI_NET_ETHER,
207 PCI_NET_TOKEN,
208 PCI_NET_FDDI,
209 PCI_NET_ATM,
210 PCI_NET_OTHER = 0x80
211 } pci_net_subclasses;
212
213 typedef enum {
214 PCI_DISPLAY_VGA,
215 PCI_DISPLAY_XGA,
216 PCI_DISPLAY_3D,
217 PCI_DISPLAY_OTHER = 0x80
218 } pci_display_subclasses;
219
220 typedef enum {
221 PCI_MMEDIA_VIDEO,
222 PCI_MMEDIA_AUDIO,
223 PCI_MMEDIA_PHONE,
224 PCI_MEDIA_OTHER = 0x80
225 } pci_mmedia_subclasses;
226
227 typedef enum {
228 PCI_MEMORY_RAM,
229 PCI_MEMORY_FLASH,
230 PCI_MEMORY_OTHER = 0x80
231 } pci_memory_subclasses;
232
233 typedef enum {
234 PCI_BRIDGE_HOST,
235 PCI_BRIDGE_ISA,
236 PCI_BRIDGE_EISA,
237 PCI_BRIDGE_MC,
238 PCI_BRIDGE_PCI,
239 PCI_BRIDGE_PCMCIA,
240 PCI_BRIDGE_NUBUS,
241 PCI_BRIDGE_CARDBUS,
242 PCI_BRIDGE_RACEWAY,
243 PCI_BRIDGE_OTHER = 0x80
244 } pci_bridge_subclasses;
245
246 typedef enum {
247 PCI_COMM_UART,
248 PCI_COMM_PARALLEL,
249 PCI_COMM_MULTIUART,
250 PCI_COMM_MODEM,
251 PCI_COMM_OTHER = 0x80
252 } pci_comm_subclasses;
253
254 typedef enum {
255 PCI_BASE_PIC,
256 PCI_BASE_DMA,
257 PCI_BASE_TIMER,
258 PCI_BASE_RTC,
259 PCI_BASE_PCI_HOTPLUG,
260 PCI_BASE_OTHER = 0x80
261 } pci_base_subclasses;
262
263 typedef enum {
264 PCI_INPUT_KBD,
265 PCI_INPUT_PEN,
266 PCI_INPUT_MOUSE,
267 PCI_INPUT_SCANNER,
268 PCI_INPUT_GAMEPORT,
269 PCI_INPUT_OTHER = 0x80
270 } pci_input_subclasses;
271
272 typedef enum {
273 PCI_DOCK_GENERIC,
274 PCI_DOCK_OTHER = 0x80
275 } pci_dock_subclasses;
276
277 typedef enum {
278 PCI_CPU_386,
279 PCI_CPU_486,
280 PCI_CPU_PENTIUM,
281 PCI_CPU_ALPHA = 0x10,
282 PCI_CPU_POWERPC = 0x20,
283 PCI_CPU_MIPS = 0x30,
284 PCI_CPU_COPROC = 0x40,
285 PCI_CPU_OTHER = 0x80
286 } pci_cpu_subclasses;
287
288 typedef enum {
289 PCI_SERIAL_IEEE1394,
290 PCI_SERIAL_ACCESS,
291 PCI_SERIAL_SSA,
292 PCI_SERIAL_USB,
293 PCI_SERIAL_FIBER,
294 PCI_SERIAL_SMBUS,
295 PCI_SERIAL_OTHER = 0x80
296 } pci_serial_subclasses;
297
298 typedef enum {
299 PCI_INTELLIGENT_I2O
300 } pci_intelligent_subclasses;
301
302 typedef enum {
303 PCI_SATELLITE_TV,
304 PCI_SATELLITE_AUDIO,
305 PCI_SATELLITE_VOICE,
306 PCI_SATELLITE_DATA,
307 PCI_SATELLITE_OTHER = 0x80
308 } pci_satellite_subclasses;
309
310 typedef enum {
311 PCI_CRYPT_NETWORK,
312 PCI_CRYPT_ENTERTAINMENT,
313 PCI_CRYPT_OTHER = 0x80
314 } pci_crypt_subclasses;
315
316 typedef enum {
317 PCI_DSP_DPIO,
318 PCI_DSP_OTHER = 0x80
319 } pci_dsp_subclasses;
320
321 typedef enum {
322 PCI_XOR_QDMA,
323 PCI_XOR_OTHER = 0x80
324 } pci_xor_subclasses;
325
326 /* Header types */
327 typedef enum {
328 PCI_HEADER_NORMAL,
329 PCI_HEADER_BRIDGE,
330 PCI_HEADER_CARDBUS
331 } pci_header_types;
332
333
334 /* Overlay for a PCI-to-PCI bridge */
335
336 #define PPB_RSVDA_MAX 2
337 #define PPB_RSVDD_MAX 8
338
339 typedef struct _ppb_config_regs {
340 unsigned short vendor;
341 unsigned short device;
342 unsigned short command;
343 unsigned short status;
344 unsigned char rev_id;
345 unsigned char prog_if;
346 unsigned char sub_class;
347 unsigned char base_class;
348 unsigned char cache_line_size;
349 unsigned char latency_timer;
350 unsigned char header_type;
351 unsigned char bist;
352 unsigned long rsvd_a[PPB_RSVDA_MAX];
353 unsigned char prim_bus;
354 unsigned char sec_bus;
355 unsigned char sub_bus;
356 unsigned char sec_lat;
357 unsigned char io_base;
358 unsigned char io_lim;
359 unsigned short sec_status;
360 unsigned short mem_base;
361 unsigned short mem_lim;
362 unsigned short pf_mem_base;
363 unsigned short pf_mem_lim;
364 unsigned long pf_mem_base_hi;
365 unsigned long pf_mem_lim_hi;
366 unsigned short io_base_hi;
367 unsigned short io_lim_hi;
368 unsigned short subsys_vendor;
369 unsigned short subsys_id;
370 unsigned long rsvd_b;
371 unsigned char rsvd_c;
372 unsigned char int_pin;
373 unsigned short bridge_ctrl;
374 unsigned char chip_ctrl;
375 unsigned char diag_ctrl;
376 unsigned short arb_ctrl;
377 unsigned long rsvd_d[PPB_RSVDD_MAX];
378 unsigned char dev_dep[192];
379 } ppb_config_regs;
380
381
382 /* PCI CAPABILITY DEFINES */
383 #define PCI_CAP_POWERMGMTCAP_ID 0x01
384 #define PCI_CAP_MSICAP_ID 0x05
385 #define PCI_CAP_PCIECAP_ID 0x10
386
387 /* Data structure to define the Message Signalled Interrupt facility
388 * Valid for PCI and PCIE configurations
389 */
390 typedef struct _pciconfig_cap_msi {
391 unsigned char capID;
392 unsigned char nextptr;
393 unsigned short msgctrl;
394 unsigned int msgaddr;
395 } pciconfig_cap_msi;
396
397 /* Data structure to define the Power managment facility
398 * Valid for PCI and PCIE configurations
399 */
400 typedef struct _pciconfig_cap_pwrmgmt {
401 unsigned char capID;
402 unsigned char nextptr;
403 unsigned short pme_cap;
404 unsigned short pme_sts_ctrl;
405 unsigned char pme_bridge_ext;
406 unsigned char data;
407 } pciconfig_cap_pwrmgmt;
408
409 /* Data structure to define the PCIE capability */
410 typedef struct _pciconfig_cap_pcie {
411 unsigned char capID;
412 unsigned char nextptr;
413 unsigned short pcie_cap;
414 unsigned int dev_cap;
415 unsigned short dev_ctrl;
416 unsigned short dev_status;
417 unsigned int link_cap;
418 unsigned short link_ctrl;
419 unsigned short link_status;
420 } pciconfig_cap_pcie;
421
422 /* PCIE Enhanced CAPABILITY DEFINES */
423 #define PCIE_EXTCFG_OFFSET 0x100
424 #define PCIE_ADVERRREP_CAPID 0x0001
425 #define PCIE_VC_CAPID 0x0002
426 #define PCIE_DEVSNUM_CAPID 0x0003
427 #define PCIE_PWRBUDGET_CAPID 0x0004
428
429 /* Header to define the PCIE specific capabilities in the extended config space */
430 typedef struct _pcie_enhanced_caphdr {
431 unsigned short capID;
432 unsigned short cap_ver : 4;
433 unsigned short next_ptr : 12;
434 } pcie_enhanced_caphdr;
435
436
437 /* Everything below is BRCM HND proprietary */
438
439
440 /* Brcm PCI configuration registers */
441 #define cap_list rsvd_a[0]
442 #define bar0_window dev_dep[0x80 - 0x40]
443 #define bar1_window dev_dep[0x84 - 0x40]
444 #define sprom_control dev_dep[0x88 - 0x40]
445
446 #define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
447 #define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
448 #define PCI_SPROM_CONTROL 0x88 /* sprom property control */
449 #define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
450 #define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
451 #define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
452 #define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
453 #define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
454 #define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address */
455 #define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
456 #define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
457 #define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
458
459 #define PCI_BAR0_SHADOW_OFFSET (2 * 1024) /* bar0 + 2K accesses sprom shadow (in pci core) */
460 #define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
461 #define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
462 #define PCI_BAR0_PCISBR_OFFSET (4 * 1024) /* pci core SB registers are at the end of the
463 * 8KB window, so their address is the "regular"
464 * address plus 4K
465 */
466 #define PCI_BAR0_WINSZ 8192 /* bar0 window size */
467
468 /* On pci corerev >= 13 and all pcie, the bar0 is now 16KB and it maps: */
469 #define PCI_16KB0_PCIREGS_OFFSET (8 * 1024) /* bar0 + 8K accesses pci/pcie core registers */
470 #define PCI_16KB0_CCREGS_OFFSET (12 * 1024) /* bar0 + 12K accesses chipc core registers */
471 #define PCI_16KBB0_WINSZ (16 * 1024) /* bar0 window size */
472
473 /* PCI_INT_STATUS */
474 #define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
475
476 /* PCI_INT_MASK */
477 #define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
478 #define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
479 #define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
480
481 /* PCI_SPROM_CONTROL */
482 #define SPROM_SZ_MSK 0x02 /* SPROM Size Mask */
483 #define SPROM_LOCKED 0x08 /* SPROM Locked */
484 #define SPROM_BLANK 0x04 /* indicating a blank SPROM */
485 #define SPROM_WRITEEN 0x10 /* SPROM write enable */
486 #define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
487 #define SPROM_OTPIN_USE 0x80 /* device OTP In use */
488
489 #define SPROM_SIZE 256 /* sprom size in 16-bit */
490 #define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
491
492 /* PCI_CFG_CMD_STAT */
493 #define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
494
495 #endif /* _h_pcicfg_ */