Rev 1870 | Rev 1970 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1870 | Rev 1964 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /* |
|
- | 2 | * pci.h |
|
- | 3 | * |
|
- | 4 | * PCI defines and function prototypes |
|
- | 5 | * Copyright 1994, Drew Eckhardt |
|
- | 6 | * Copyright 1997--1999 Martin Mares |
|
1 | #ifndef __PCI_H__ |
7 | * |
- | 8 | * For more information, please consult the following manuals (look at |
|
- | 9 | * http://www.pcisig.com/ for how to get them): |
|
- | 10 | * |
|
2 | #define __PCI_H__ |
11 | * PCI BIOS Specification |
- | 12 | * PCI Local Bus Specification |
|
- | 13 | * PCI to PCI Bridge Specification |
|
3 | 14 | * PCI System Design Guide |
|
- | 15 | */ |
|
Line 4... | Line 16... | ||
4 | #include |
16 | |
5 | #include |
17 | #include |
6 | #include |
- | |
7 | #include |
- | |
8 | #include |
- | |
9 | - | ||
10 | /* pci_slot represents a physical slot */ |
- | |
11 | struct pci_slot { |
- | |
12 | struct pci_bus *bus; /* The bus this slot is on */ |
- | |
13 | struct list_head list; /* node in list of slots on this bus */ |
- | |
14 | // struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ |
- | |
15 | unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ |
- | |
16 | // struct kobject kobj; |
- | |
17 | }; |
- | |
Line -... | Line 18... | ||
- | 18 | #include |
|
- | 19 | ||
Line 18... | Line 20... | ||
18 | 20 | #ifndef __PCI_H__ |
|
Line 19... | Line 21... | ||
19 | 21 | #define __PCI_H__ |
|
Line 145... | Line 147... | ||
145 | 147 | #define PCI_CLASS_SP_OTHER 0x1180 |
|
Line 146... | Line 148... | ||
146 | #define PCI_CLASS_OTHERS 0xff |
148 | |
Line -... | Line 149... | ||
- | 149 | #define PCI_CLASS_OTHERS 0xff |
|
- | 150 | ||
- | 151 | ||
- | 152 | /* |
|
- | 153 | * Under PCI, each device has 256 bytes of configuration address space, |
|
- | 154 | * of which the first 64 bytes are standardized as follows: |
|
- | 155 | */ |
|
- | 156 | #define PCI_VENDOR_ID 0x000 /* 16 bits */ |
|
- | 157 | #define PCI_DEVICE_ID 0x002 /* 16 bits */ |
|
- | 158 | #define PCI_COMMAND 0x004 /* 16 bits */ |
|
- | 159 | #define PCI_COMMAND_IO 0x001 /* Enable response in I/O space */ |
|
- | 160 | #define PCI_COMMAND_MEMORY 0x002 /* Enable response in Memory space */ |
|
- | 161 | #define PCI_COMMAND_MASTER 0x004 /* Enable bus mastering */ |
|
- | 162 | #define PCI_COMMAND_SPECIAL 0x008 /* Enable response to special cycles */ |
|
- | 163 | #define PCI_COMMAND_INVALIDATE 0x010 /* Use memory write and invalidate */ |
|
- | 164 | #define PCI_COMMAND_VGA_PALETTE 0x020 /* Enable palette snooping */ |
|
- | 165 | #define PCI_COMMAND_PARITY 0x040 /* Enable parity checking */ |
|
- | 166 | #define PCI_COMMAND_WAIT 0x080 /* Enable address/data stepping */ |
|
- | 167 | #define PCI_COMMAND_SERR 0x100 /* Enable SERR */ |
|
- | 168 | #define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ |
|
- | 169 | #define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ |
|
- | 170 | ||
- | 171 | #define PCI_STATUS 0x006 /* 16 bits */ |
|
- | 172 | #define PCI_STATUS_CAP_LIST 0x010 /* Support Capability List */ |
|
- | 173 | #define PCI_STATUS_66MHZ 0x020 /* Support 66 Mhz PCI 2.1 bus */ |
|
- | 174 | #define PCI_STATUS_UDF 0x040 /* Support User Definable Features [obsolete] */ |
|
- | 175 | #define PCI_STATUS_FAST_BACK 0x080 /* Accept fast-back to back */ |
|
- | 176 | #define PCI_STATUS_PARITY 0x100 /* Detected parity error */ |
|
- | 177 | #define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ |
|
- | 178 | #define PCI_STATUS_DEVSEL_FAST 0x000 |
|
- | 179 | #define PCI_STATUS_DEVSEL_MEDIUM 0x200 |
|
- | 180 | #define PCI_STATUS_DEVSEL_SLOW 0x400 |
|
- | 181 | #define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ |
|
- | 182 | #define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ |
|
- | 183 | #define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ |
|
- | 184 | #define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ |
|
- | 185 | #define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ |
|
- | 186 | ||
- | 187 | #define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ |
|
- | 188 | #define PCI_REVISION_ID 0x08 /* Revision ID */ |
|
- | 189 | #define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ |
|
- | 190 | #define PCI_CLASS_DEVICE 0x0a /* Device class */ |
|
- | 191 | ||
- | 192 | #define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ |
|
- | 193 | #define PCI_LATENCY_TIMER 0x0d /* 8 bits */ |
|
- | 194 | #define PCI_HEADER_TYPE 0x0e /* 8 bits */ |
|
- | 195 | #define PCI_HEADER_TYPE_NORMAL 0 |
|
- | 196 | #define PCI_HEADER_TYPE_BRIDGE 1 |
|
- | 197 | #define PCI_HEADER_TYPE_CARDBUS 2 |
|
- | 198 | ||
- | 199 | #define PCI_BIST 0x0f /* 8 bits */ |
|
- | 200 | #define PCI_BIST_CODE_MASK 0x0f /* Return result */ |
|
- | 201 | #define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ |
|
- | 202 | #define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ |
|
- | 203 | ||
- | 204 | /* |
|
- | 205 | * Base addresses specify locations in memory or I/O space. |
|
- | 206 | * Decoded size can be determined by writing a value of |
|
- | 207 | * 0xffffffff to the register, and reading it back. Only |
|
- | 208 | * 1 bits are decoded. |
|
- | 209 | */ |
|
- | 210 | #define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ |
|
- | 211 | #define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ |
|
- | 212 | #define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ |
|
- | 213 | #define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ |
|
- | 214 | #define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ |
|
- | 215 | #define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ |
|
- | 216 | #define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ |
|
- | 217 | #define PCI_BASE_ADDRESS_SPACE_IO 0x01 |
|
- | 218 | #define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 |
|
- | 219 | #define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 |
|
- | 220 | #define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ |
|
- | 221 | #define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ |
|
- | 222 | #define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ |
|
- | 223 | #define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ |
|
- | 224 | #define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) |
|
- | 225 | #define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) |
|
- | 226 | /* bit 1 is reserved if address_space = 1 */ |
|
- | 227 | ||
- | 228 | #define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ |
|
- | 229 | ||
- | 230 | /* Header type 0 (normal devices) */ |
|
- | 231 | #define PCI_CARDBUS_CIS 0x28 |
|
- | 232 | #define PCI_SUBSYSTEM_VENDOR_ID 0x2c |
|
- | 233 | #define PCI_SUBSYSTEM_ID 0x2e |
|
- | 234 | #define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ |
|
- | 235 | #define PCI_ROM_ADDRESS_ENABLE 0x01 |
|
- | 236 | #define PCI_ROM_ADDRESS_MASK (~0x7ffUL) |
|
- | 237 | ||
- | 238 | #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ |
|
- | 239 | #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ |
|
- | 240 | ||
- | 241 | ||
- | 242 | #define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 |
|
- | 243 | #define PCI_CB_SUBSYSTEM_ID 0x42 |
|
- | 244 | ||
- | 245 | #define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ |
|
- | 246 | #define PCI_CB_CAPABILITY_LIST 0x14 |
|
- | 247 | /* Capability lists */ |
|
- | 248 | ||
- | 249 | #define PCI_CAP_LIST_ID 0 /* Capability ID */ |
|
- | 250 | #define PCI_CAP_ID_PM 0x01 /* Power Management */ |
|
- | 251 | #define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ |
|
- | 252 | #define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ |
|
- | 253 | #define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ |
|
- | 254 | #define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ |
|
- | 255 | #define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ |
|
- | 256 | #define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ |
|
- | 257 | #define PCI_CAP_ID_HT 0x08 /* HyperTransport */ |
|
- | 258 | #define PCI_CAP_ID_VNDR 0x09 /* Vendor specific capability */ |
|
- | 259 | #define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ |
|
- | 260 | #define PCI_CAP_ID_EXP 0x10 /* PCI Express */ |
|
- | 261 | #define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ |
|
- | 262 | #define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ |
|
- | 263 | #define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ |
|
- | 264 | #define PCI_CAP_SIZEOF 4 |
|
- | 265 | ||
- | 266 | ||
- | 267 | /* AGP registers */ |
|
- | 268 | ||
- | 269 | #define PCI_AGP_VERSION 2 /* BCD version number */ |
|
- | 270 | #define PCI_AGP_RFU 3 /* Rest of capability flags */ |
|
- | 271 | #define PCI_AGP_STATUS 4 /* Status register */ |
|
- | 272 | #define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ |
|
- | 273 | #define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ |
|
- | 274 | #define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ |
|
- | 275 | #define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ |
|
- | 276 | #define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ |
|
- | 277 | #define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ |
|
- | 278 | #define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ |
|
- | 279 | #define PCI_AGP_COMMAND 8 /* Control register */ |
|
- | 280 | #define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ |
|
- | 281 | #define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ |
|
- | 282 | #define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ |
|
- | 283 | #define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ |
|
- | 284 | #define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ |
|
- | 285 | #define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ |
|
- | 286 | #define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ |
|
Line 147... | Line 287... | ||
147 | 287 | #define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ |
|
148 | 288 | #define PCI_AGP_SIZEOF 12 |
|
149 | 289 | ||
Line 207... | Line 347... | ||
207 | #define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) |
347 | |
208 | #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) |
348 | #define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) |
209 | #define PCI_FUNC(devfn) ((devfn) & 0x07) |
349 | #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) |
Line 210... | Line -... | ||
210 | - | ||
211 | /* Ioctls for /proc/bus/pci/X/Y nodes. */ |
- | |
212 | #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8) |
- | |
213 | #define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) /* Get controller for PCI device. */ |
- | |
214 | #define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) /* Set mmap state to I/O space. */ |
- | |
215 | #define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) /* Set mmap state to MEM space. */ |
- | |
216 | #define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) /* Enable/disable write-combining. */ |
- | |
217 | - | ||
218 | - | ||
219 | typedef unsigned int __bitwise pci_channel_state_t; |
- | |
220 | - | ||
221 | enum pci_channel_state { |
- | |
222 | /* I/O channel is in normal state */ |
- | |
223 | pci_channel_io_normal = (__force pci_channel_state_t) 1, |
- | |
224 | - | ||
225 | /* I/O to channel is blocked */ |
- | |
226 | pci_channel_io_frozen = (__force pci_channel_state_t) 2, |
- | |
227 | - | ||
228 | /* PCI card is dead */ |
- | |
229 | pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, |
- | |
Line 230... | Line 350... | ||
230 | }; |
350 | #define PCI_FUNC(devfn) ((devfn) & 0x07) |
Line 231... | Line 351... | ||
231 | 351 | ||
232 | 352 | ||
233 | typedef unsigned int PCITAG; |
353 | |
234 | 354 | typedef unsigned int PCITAG; |
|
235 | extern inline PCITAG |
355 | |
Line -... | Line 356... | ||
- | 356 | extern inline PCITAG |
|
236 | pciTag(int busnum, int devnum, int funcnum) |
357 | pciTag(int busnum, int devnum, int funcnum) |
- | 358 | { |
|
237 | { |
359 | return(PCI_MAKE_TAG(busnum,devnum,funcnum)); |
238 | return(PCI_MAKE_TAG(busnum,devnum,funcnum)); |
360 | } |
239 | } |
361 | |
240 | 362 | ||
- | 363 | struct resource |
|
- | 364 | { |
|
Line 241... | Line 365... | ||
241 | /* This defines the direction arg to the DMA mapping routines. */ |
365 | resource_size_t start; |
242 | #define PCI_DMA_BIDIRECTIONAL 0 |
366 | resource_size_t end; |
243 | #define PCI_DMA_TODEVICE 1 |
367 | // const char *name; |
244 | #define PCI_DMA_FROMDEVICE 2 |
- | |
245 | #define PCI_DMA_NONE 3 |
- | |
246 | - | ||
247 | /* |
- | |
248 | * For PCI devices, the region numbers are assigned this way: |
- | |
249 | */ |
- | |
250 | enum { |
- | |
251 | /* #0-5: standard PCI resources */ |
- | |
252 | PCI_STD_RESOURCES, |
- | |
253 | PCI_STD_RESOURCE_END = 5, |
- | |
254 | - | ||
255 | /* #6: expansion ROM resource */ |
368 | unsigned long flags; |
256 | PCI_ROM_RESOURCE, |
- | |
257 | - | ||
258 | /* device specific resources */ |
- | |
259 | #ifdef CONFIG_PCI_IOV |
- | |
260 | PCI_IOV_RESOURCES, |
- | |
261 | PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1, |
- | |
262 | #endif |
- | |
263 | - | ||
Line -... | Line 369... | ||
- | 369 | // struct resource *parent, *sibling, *child; |
|
- | 370 | }; |
|
- | 371 | ||
- | 372 | /* |
|
- | 373 | * IO resources have these defined flags. |
|
- | 374 | */ |
|
- | 375 | #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ |
|
- | 376 | ||
- | 377 | #define IORESOURCE_IO 0x00000100 /* Resource type */ |
|
- | 378 | #define IORESOURCE_MEM 0x00000200 |
|
- | 379 | #define IORESOURCE_IRQ 0x00000400 |
|
- | 380 | #define IORESOURCE_DMA 0x00000800 |
|
- | 381 | ||
- | 382 | #define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ |
|
- | 383 | #define IORESOURCE_READONLY 0x00002000 |
|
- | 384 | #define IORESOURCE_CACHEABLE 0x00004000 |
|
- | 385 | #define IORESOURCE_RANGELENGTH 0x00008000 |
|
- | 386 | #define IORESOURCE_SHADOWABLE 0x00010000 |
|
- | 387 | #define IORESOURCE_BUS_HAS_VGA 0x00080000 |
|
- | 388 | ||
- | 389 | #define IORESOURCE_DISABLED 0x10000000 |
|
- | 390 | #define IORESOURCE_UNSET 0x20000000 |
|
- | 391 | #define IORESOURCE_AUTO 0x40000000 |
|
- | 392 | #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ |
|
- | 393 | ||
- | 394 | /* ISA PnP IRQ specific bits (IORESOURCE_BITS) */ |
|
- | 395 | #define IORESOURCE_IRQ_HIGHEDGE (1<<0) |
|
- | 396 | #define IORESOURCE_IRQ_LOWEDGE (1<<1) |
|
- | 397 | #define IORESOURCE_IRQ_HIGHLEVEL (1<<2) |
|
- | 398 | #define IORESOURCE_IRQ_LOWLEVEL (1<<3) |
|
- | 399 | #define IORESOURCE_IRQ_SHAREABLE (1<<4) |
|
- | 400 | ||
- | 401 | /* ISA PnP DMA specific bits (IORESOURCE_BITS) */ |
|
- | 402 | #define IORESOURCE_DMA_TYPE_MASK (3<<0) |
|
- | 403 | #define IORESOURCE_DMA_8BIT (0<<0) |
|
- | 404 | #define IORESOURCE_DMA_8AND16BIT (1<<0) |
|
- | 405 | #define IORESOURCE_DMA_16BIT (2<<0) |
|
- | 406 | ||
- | 407 | #define IORESOURCE_DMA_MASTER (1<<2) |
|
- | 408 | #define IORESOURCE_DMA_BYTE (1<<3) |
|
264 | /* resources assigned to buses behind the bridge */ |
409 | #define IORESOURCE_DMA_WORD (1<<4) |
- | 410 | ||
- | 411 | #define IORESOURCE_DMA_SPEED_MASK (3<<6) |
|
- | 412 | #define IORESOURCE_DMA_COMPATIBLE (0<<6) |
|
- | 413 | #define IORESOURCE_DMA_TYPEA (1<<6) |
|
- | 414 | #define IORESOURCE_DMA_TYPEB (2<<6) |
|
- | 415 | #define IORESOURCE_DMA_TYPEF (3<<6) |
|
- | 416 | ||
- | 417 | /* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */ |
|
- | 418 | #define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ |
|
- | 419 | #define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ |
|
- | 420 | #define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ |
|
265 | #define PCI_BRIDGE_RESOURCE_NUM 4 |
421 | #define IORESOURCE_MEM_TYPE_MASK (3<<3) |
- | 422 | #define IORESOURCE_MEM_8BIT (0<<3) |
|
- | 423 | #define IORESOURCE_MEM_16BIT (1<<3) |
|
- | 424 | #define IORESOURCE_MEM_8AND16BIT (2<<3) |
|
- | 425 | #define IORESOURCE_MEM_32BIT (3<<3) |
|
Line 266... | Line 426... | ||
266 | 426 | #define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ |
|
267 | PCI_BRIDGE_RESOURCES, |
427 | #define IORESOURCE_MEM_EXPANSIONROM (1<<6) |
268 | PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES + |
- | |
Line 269... | Line 428... | ||
269 | PCI_BRIDGE_RESOURCE_NUM - 1, |
428 | |
270 | 429 | /* PCI ROM control bits (IORESOURCE_BITS) */ |
|
271 | /* total resources associated with a PCI device */ |
430 | #define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ |
Line 293... | Line 452... | ||
293 | #endif |
452 | #define PCI_BUS_NUM_RESOURCES 8 |
294 | 453 | #endif |
|
Line 295... | Line 454... | ||
295 | #define DEVICE_COUNT_RESOURCE 12 |
454 | |
Line 296... | Line -... | ||
296 | - | ||
297 | - | ||
298 | #define PCI_CFG_SPACE_SIZE 256 |
- | |
299 | #define PCI_CFG_SPACE_EXP_SIZE 4096 |
- | |
300 | - | ||
301 | - | ||
302 | typedef int __bitwise pci_power_t; |
- | |
303 | - | ||
304 | #define PCI_D0 ((pci_power_t __force) 0) |
- | |
305 | #define PCI_D1 ((pci_power_t __force) 1) |
- | |
306 | #define PCI_D2 ((pci_power_t __force) 2) |
- | |
307 | #define PCI_D3hot ((pci_power_t __force) 3) |
- | |
308 | #define PCI_D3cold ((pci_power_t __force) 4) |
- | |
309 | #define PCI_UNKNOWN ((pci_power_t __force) 5) |
- | |
310 | #define PCI_POWER_ERROR ((pci_power_t __force) -1) |
- | |
311 | - | ||
312 | - | ||
313 | enum pci_bar_type { |
- | |
314 | pci_bar_unknown, /* Standard PCI BAR probe */ |
- | |
315 | pci_bar_io, /* An io port BAR */ |
- | |
316 | pci_bar_mem32, /* A 32-bit memory BAR */ |
- | |
317 | pci_bar_mem64, /* A 64-bit memory BAR */ |
- | |
318 | }; |
- | |
319 | 455 | #define DEVICE_COUNT_RESOURCE 12 |
|
320 | /* |
456 | |
321 | * The pci_dev structure is used to describe PCI devices. |
457 | /* |
322 | */ |
458 | * The pci_dev structure is used to describe PCI devices. |
323 | struct pci_dev { |
459 | */ |
324 | struct list_head bus_list; /* node in per-bus list */ |
460 | struct pci_dev { |
325 | struct pci_bus *bus; /* bus this device is on */ |
461 | // struct list_head bus_list; /* node in per-bus list */ |
Line 326... | Line 462... | ||
326 | struct pci_bus *subordinate; /* bus this device bridges to */ |
462 | // struct pci_bus *bus; /* bus this device is on */ |
327 | 463 | // struct pci_bus *subordinate; /* bus this device bridges to */ |
|
328 | void *sysdata; /* hook for sys-specific extension */ |
464 | |
329 | // struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ |
465 | // void *sysdata; /* hook for sys-specific extension */ |
330 | struct pci_slot *slot; /* Physical slot this device is in */ |
466 | // struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ |
331 | u32_t busnr; |
467 | // struct pci_slot *slot; /* Physical slot this device is in */ |
332 | unsigned int devfn; /* encoded device & function index */ |
468 | u32_t bus; |
333 | unsigned short vendor; |
469 | u32_t devfn; /* encoded device & function index */ |
334 | unsigned short device; |
470 | u16_t vendor; |
335 | unsigned short subsystem_vendor; |
471 | u16_t device; |
336 | unsigned short subsystem_device; |
472 | u16_t subsystem_vendor; |
337 | unsigned int class; /* 3 bytes: (base,sub,prog-if) */ |
473 | u16_t subsystem_device; |
338 | u8 revision; /* PCI revision, low byte of class word */ |
- | |
339 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ |
474 | u32_t class; /* 3 bytes: (base,sub,prog-if) */ |
340 | u8 pcie_cap; /* PCI-E capability offset */ |
475 | uint8_t revision; /* PCI revision, low byte of class word */ |
341 | u8 pcie_type; /* PCI-E device/port type */ |
476 | uint8_t hdr_type; /* PCI header type (`multi' flag masked out) */ |
Line 342... | Line 477... | ||
342 | u8 rom_base_reg; /* which config register controls the ROM */ |
477 | uint8_t pcie_type; /* PCI-E device/port type */ |
343 | u8 pin; /* which interrupt pin this device uses */ |
478 | uint8_t rom_base_reg; /* which config register controls the ROM */ |
344 | 479 | uint8_t pin; /* which interrupt pin this device uses */ |
|
345 | // struct pci_driver *driver; /* which driver has allocated this device */ |
480 | |
346 | u64 dma_mask; /* Mask of the bits of bus address this |
481 | // struct pci_driver *driver; /* which driver has allocated this device */ |
347 | device implements. Normally this is |
482 | uint64_t dma_mask; /* Mask of the bits of bus address this |
Line 348... | Line 483... | ||
348 | 0xffffffff. You only need to change |
483 | device implements. Normally this is |
Line 349... | Line 484... | ||
349 | this if your device has broken DMA |
484 | 0xffffffff. You only need to change |
350 | or supports 64-bit transfers. */ |
485 | this if your device has broken DMA |
351 | 486 | or supports 64-bit transfers. */ |
|
352 | // struct device_dma_parameters dma_parms; |
487 | |
353 | 488 | // struct device_dma_parameters dma_parms; |
|
354 | pci_power_t current_state; /* Current operating state. In ACPI-speak, |
489 | |
355 | this is D0-D3, D0 being fully functional, |
490 | // pci_power_t current_state; /* Current operating state. In ACPI-speak, |
356 | and D3 being off. */ |
- | |
357 | int pm_cap; /* PM capability offset in the |
491 | // this is D0-D3, D0 being fully functional, |
358 | configuration space */ |
492 | // and D3 being off. */ |
359 | unsigned int pme_support:5; /* Bitmask of states from which PME# |
493 | // int pm_cap; /* PM capability offset in the |
360 | can be generated */ |
- | |
361 | unsigned int pme_interrupt:1; |
- | |
362 | unsigned int d1_support:1; /* Low power state D1 is supported */ |
- | |
363 | unsigned int d2_support:1; /* Low power state D2 is supported */ |
- | |
Line 364... | Line 494... | ||
364 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ |
494 | // configuration space */ |
365 | unsigned int mmio_always_on:1; /* disallow turning off io/mem |
495 | unsigned int pme_support:5; /* Bitmask of states from which PME# |
Line 366... | Line -... | ||
366 | decoding during bar sizing */ |
- | |
367 | unsigned int wakeup_prepared:1; |
- | |
368 | unsigned int d3_delay; /* D3->D0 transition time in ms */ |
496 | can be generated */ |
Line 369... | Line 497... | ||
369 | 497 | unsigned int d1_support:1; /* Low power state D1 is supported */ |
|
370 | pci_channel_state_t error_state; /* current connectivity state */ |
498 | unsigned int d2_support:1; /* Low power state D2 is supported */ |
371 | struct device dev; /* Generic device interface */ |
499 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ |
372 | 500 | ||
Line 394... | Line 522... | ||
394 | unsigned int msi_enabled:1; |
522 | unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */ |
395 | unsigned int msix_enabled:1; |
523 | unsigned int msi_enabled:1; |
396 | unsigned int ari_enabled:1; /* ARI forwarding */ |
524 | unsigned int msix_enabled:1; |
397 | unsigned int is_managed:1; |
525 | unsigned int ari_enabled:1; /* ARI forwarding */ |
398 | unsigned int is_pcie:1; /* Obsolete. Will be removed. |
526 | unsigned int is_managed:1; |
399 | Use pci_is_pcie() instead */ |
- | |
400 | unsigned int needs_freset:1; /* Dev requires fundamental reset */ |
527 | unsigned int is_pcie:1; |
401 | unsigned int state_saved:1; |
- | |
402 | unsigned int is_physfn:1; |
528 | unsigned int state_saved:1; |
403 | unsigned int is_virtfn:1; |
529 | unsigned int is_physfn:1; |
404 | unsigned int reset_fn:1; |
530 | unsigned int is_virtfn:1; |
405 | unsigned int is_hotplug_bridge:1; |
- | |
406 | unsigned int __aer_firmware_first_valid:1; |
531 | // pci_dev_flags_t dev_flags; |
407 | unsigned int __aer_firmware_first:1; |
532 | // atomic_t enable_cnt; /* pci_enable_device has been called */ |
408 | - | ||
409 | - | ||
Line 410... | Line 533... | ||
410 | // u32 saved_config_space[16]; /* config space saved at suspend time */ |
533 | |
411 | // struct hlist_head saved_cap_space; |
534 | // u32 saved_config_space[16]; /* config space saved at suspend time */ |
412 | // struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ |
535 | // struct hlist_head saved_cap_space; |
413 | int rom_attr_enabled; /* has display of the rom attribute been enabled? */ |
536 | // struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ |
414 | // struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ |
537 | // int rom_attr_enabled; /* has display of the rom attribute been enabled? */ |
415 | // struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */ |
538 | // struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ |
416 | }; |
539 | // struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */ |
Line 417... | Line 540... | ||
417 | 540 | }; |
|
Line 425... | Line 548... | ||
425 | \ |
548 | pci_resource_start((dev), (bar))) ? 0 : \ |
426 | (pci_resource_end((dev), (bar)) - \ |
549 | \ |
427 | pci_resource_start((dev), (bar)) + 1)) |
550 | (pci_resource_end((dev), (bar)) - \ |
428 | 551 | pci_resource_start((dev), (bar)) + 1)) |
|
Line 429... | Line -... | ||
429 | struct pci_device_id |
- | |
430 | { |
552 | |
431 | u16_t vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ |
- | |
432 | u16_t subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ |
- | |
433 | u32_t class, class_mask; /* (class,subclass,prog-if) triplet */ |
- | |
434 | u32_t driver_data; /* Data private to the driver */ |
- | |
435 | }; |
553 | |
Line 436... | Line 554... | ||
436 | 554 | ||
437 | typedef struct |
555 | |
438 | { |
556 | typedef struct |
439 | struct list_head link; |
557 | { |
440 | struct pci_dev pci_dev; |
558 | struct list_head link; |
Line 441... | Line -... | ||
441 | }pci_dev_t; |
- | |
442 | - | ||
443 | - | ||
444 | typedef unsigned short __bitwise pci_bus_flags_t; |
- | |
445 | enum pci_bus_flags { |
- | |
446 | PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, |
- | |
447 | PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2, |
- | |
448 | }; |
- | |
449 | - | ||
450 | struct pci_sysdata |
- | |
451 | { |
- | |
452 | int domain; /* PCI domain */ |
- | |
453 | int node; /* NUMA node */ |
- | |
454 | #ifdef CONFIG_X86_64 |
- | |
455 | void *iommu; /* IOMMU private data */ |
- | |
456 | #endif |
- | |
457 | }; |
- | |
458 | - | ||
459 | struct pci_bus; |
- | |
460 | - | ||
461 | struct pci_ops |
- | |
462 | { |
- | |
463 | int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); |
- | |
464 | int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val); |
- | |
465 | }; |
- | |
466 | - | ||
467 | /* |
- | |
468 | * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond |
- | |
469 | * to P2P or CardBus bridge windows) go in a table. Additional ones (for |
- | |
470 | * buses below host bridges or subtractive decode bridges) go in the list. |
- | |
471 | * Use pci_bus_for_each_resource() to iterate through all the resources. |
- | |
472 | */ |
- | |
473 | - | ||
474 | /* |
- | |
475 | * PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly |
- | |
476 | * and there's no way to program the bridge with the details of the window. |
- | |
477 | * This does not apply to ACPI _CRS windows, even with the _DEC subtractive- |
- | |
478 | * decode bit set, because they are explicit and can be programmed with _SRS. |
- | |
479 | */ |
- | |
480 | #define PCI_SUBTRACTIVE_DECODE 0x1 |
- | |
481 | - | ||
482 | struct pci_bus_resource { |
- | |
483 | struct list_head list; |
- | |
484 | struct resource *res; |
- | |
485 | unsigned int flags; |
- | |
486 | }; |
- | |
487 | - | ||
488 | #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ |
- | |
489 | - | ||
490 | struct pci_bus { |
- | |
491 | struct list_head node; /* node in list of buses */ |
- | |
492 | struct pci_bus *parent; /* parent bus this bridge is on */ |
- | |
493 | struct list_head children; /* list of child buses */ |
- | |
494 | struct list_head devices; /* list of devices on this bus */ |
- | |
495 | struct pci_dev *self; /* bridge device as seen by parent */ |
- | |
496 | struct list_head slots; /* list of slots on this bus */ |
- | |
497 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; |
- | |
498 | struct list_head resources; /* address space routed to this bus */ |
- | |
499 | - | ||
500 | struct pci_ops *ops; /* configuration access functions */ |
- | |
501 | void *sysdata; /* hook for sys-specific extension */ |
- | |
502 | - | ||
503 | unsigned char number; /* bus number */ |
- | |
504 | unsigned char primary; /* number of primary bridge */ |
- | |
505 | unsigned char secondary; /* number of secondary bridge */ |
- | |
506 | unsigned char subordinate; /* max number of subordinate buses */ |
- | |
507 | - | ||
508 | char name[48]; |
- | |
509 | - | ||
510 | unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ |
- | |
511 | pci_bus_flags_t bus_flags; /* Inherited by child busses */ |
- | |
512 | // struct device *bridge; |
- | |
513 | // struct device dev; |
- | |
514 | // struct bin_attribute *legacy_io; /* legacy I/O for this bus */ |
- | |
515 | // struct bin_attribute *legacy_mem; /* legacy mem */ |
- | |
516 | unsigned int is_added:1; |
- | |
517 | }; |
- | |
518 | - | ||
519 | #define pci_bus_b(n) list_entry(n, struct pci_bus, node) |
- | |
520 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) |
- | |
521 | #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) |
- | |
522 | #define to_pci_dev(n) container_of(n, struct pci_dev, dev) |
- | |
523 | #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) |
- | |
524 | - | ||
525 | - | ||
526 | static inline int pci_domain_nr(struct pci_bus *bus) |
- | |
527 | { |
- | |
528 | struct pci_sysdata *sd = bus->sysdata; |
- | |
529 | return sd->domain; |
- | |
530 | } |
- | |
531 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; } |
- | |
532 | - | ||
533 | /* |
- | |
534 | * Error values that may be returned by PCI functions. |
- | |
535 | */ |
- | |
536 | #define PCIBIOS_SUCCESSFUL 0x00 |
- | |
537 | #define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 |
- | |
538 | #define PCIBIOS_BAD_VENDOR_ID 0x83 |
- | |
539 | #define PCIBIOS_DEVICE_NOT_FOUND 0x86 |
- | |
540 | #define PCIBIOS_BAD_REGISTER_NUMBER 0x87 |
- | |
541 | #define PCIBIOS_SET_FAILED 0x88 |
- | |
542 | #define PCIBIOS_BUFFER_TOO_SMALL 0x89 |
- | |
543 | - | ||
544 | /* Low-level architecture-dependent routines */ |
- | |
545 | - | ||
546 | struct pci_bus_region { |
- | |
547 | resource_size_t start; |
- | |
548 | resource_size_t end; |
- | |
549 | }; |
- | |
550 | - | ||
551 | - | ||
552 | - | ||
553 | - | ||
554 | - | ||
555 | - | ||
556 | extern struct list_head pci_root_buses; /* list of all known PCI buses */ |
- | |
557 | 559 | struct pci_dev pci_dev; |
|
Line 558... | Line 560... | ||
558 | 560 | }pci_dev_t; |
|
559 | int enum_pci_devices(void); |
561 | |
Line 560... | Line 562... | ||
560 | 562 | int enum_pci_devices(void); |
|
Line 561... | Line 563... | ||
561 | struct pci_device_id* |
563 | |
Line 562... | Line -... | ||
562 | find_pci_device(pci_dev_t* pdev, struct pci_device_id *idlist); |
- | |
563 | - | ||
564 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) |
- | |
565 | - | ||
566 | int pci_set_dma_mask(struct pci_dev *dev, u64 mask); |
- | |
567 | - | ||
568 | struct pci_bus * pci_create_bus(int bus, struct pci_ops *ops, void *sysdata); |
- | |
569 | struct pci_bus * pci_find_bus(int domain, int busnr); |
- | |
570 | int pci_find_capability(struct pci_dev *dev, int cap); |
- | |
571 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); |
- | |
572 | int pci_find_ext_capability(struct pci_dev *dev, int cap); |
- | |
573 | int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn, |
- | |
574 | int cap); |
- | |
575 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); |
- | |
576 | struct pci_bus * pci_find_next_bus(const struct pci_bus *from); |
- | |
577 | unsigned int pci_scan_child_bus(struct pci_bus *bus); |
- | |
578 | void pcibios_fixup_bus(struct pci_bus *b); |
- | |
579 | u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin); |
- | |
580 | - | ||
581 | struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn); |
- | |
582 | - | ||
583 | static inline bool pci_is_root_bus(struct pci_bus *pbus) |
- | |
584 | { |
- | |
585 | return !(pbus->parent); |
- | |
586 | } |
- | |
587 | - | ||
588 | /** |
- | |
589 | * pci_pcie_cap - get the saved PCIe capability offset |
- | |
590 | * @dev: PCI device |
- | |
591 | * |
- | |
592 | * PCIe capability offset is calculated at PCI device initialization |
- | |
593 | * time and saved in the data structure. This function returns saved |
- | |
594 | * PCIe capability offset. Using this instead of pci_find_capability() |
- | |
595 | * reduces unnecessary search in the PCI configuration space. If you |
- | |
596 | * need to calculate PCIe capability offset from raw device for some |
- | |
597 | * reasons, please use pci_find_capability() instead. |
- | |
598 | */ |
- | |
599 | static inline int pci_pcie_cap(struct pci_dev *dev) |
- | |
600 | { |
- | |
601 | return dev->pcie_cap; |
- | |
602 | } |
- | |
603 | - | ||
604 | /** |
- | |
605 | * pci_is_pcie - check if the PCI device is PCI Express capable |
- | |
606 | * @dev: PCI device |
- | |
607 | * |
- | |
608 | * Retrun true if the PCI device is PCI Express capable, false otherwise. |
- | |
609 | */ |
- | |
610 | static inline bool pci_is_pcie(struct pci_dev *dev) |
- | |
611 | { |
- | |
612 | return !!pci_pcie_cap(dev); |
- | |
613 | } |
- | |
614 | - | ||
615 | - | ||
616 | int pci_read_config_dyte(struct pci_dev *dev, int where, u16 *val); |
- | |
617 | int pci_read_config_word(struct pci_dev *dev, int where, u16 *val); |
- | |
618 | int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val); |
- | |
619 | - | ||
620 | - | ||
621 | static inline int pci_iov_init(struct pci_dev *dev) |
- | |
622 | { |
- | |
623 | return -ENODEV; |
- | |
624 | } |
- | |
625 | static inline void pci_iov_release(struct pci_dev *dev) |
- | |
626 | - | ||
627 | { |
- | |
628 | } |
- | |
629 | static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno, |
- | |
630 | enum pci_bar_type *type) |
- | |
631 | { |
- | |
632 | return 0; |
- | |
633 | } |
- | |
634 | static inline void pci_restore_iov_state(struct pci_dev *dev) |
- | |
635 | { |
- | |
636 | } |
- | |
637 | static inline int pci_iov_bus_range(struct pci_bus *bus) |
- | |
638 | { |
- | |
639 | return 0; |
- | |
640 | } |
- | |
641 | - | ||
642 | static inline int pci_enable_ats(struct pci_dev *dev, int ps) |
- | |
643 | { |
- | |
644 | return -ENODEV; |
- | |
645 | } |
- | |
646 | static inline void pci_disable_ats(struct pci_dev *dev) |
- | |
647 | { |
- | |
648 | } |
- | |
649 | static inline int pci_ats_queue_depth(struct pci_dev *dev) |
- | |
650 | { |
- | |
651 | return -ENODEV; |
- | |
652 | } |
- | |
Line 653... | Line 564... | ||
653 | static inline int pci_ats_enabled(struct pci_dev *dev) |
564 | struct pci_device_id* |
Line 654... | Line 565... | ||
654 | { |
565 | find_pci_device(pci_dev_t* pdev, struct pci_device_id *idlist); |