Rev 1627 | Rev 1631 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1408 | serge | 1 | |
2 | #include |
||
3 | #include |
||
1628 | serge | 4 | |
1408 | serge | 5 | |
6 | #define __PCI_H__ |
||
7 | |||
8 | |||
1628 | serge | 9 | |
10 | struct pci_slot { |
||
11 | struct pci_bus *bus; /* The bus this slot is on */ |
||
12 | struct list_head list; /* node in list of slots on this bus */ |
||
13 | // struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ |
||
14 | unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ |
||
15 | // struct kobject kobj; |
||
16 | }; |
||
17 | |||
18 | |||
19 | |||
1408 | serge | 20 | |
21 | |||
22 | |||
23 | #define PCI_CLASS_NOT_DEFINED_VGA 0x0001 |
||
24 | |||
25 | |||
26 | #define PCI_CLASS_STORAGE_SCSI 0x0100 |
||
27 | #define PCI_CLASS_STORAGE_IDE 0x0101 |
||
28 | #define PCI_CLASS_STORAGE_FLOPPY 0x0102 |
||
29 | #define PCI_CLASS_STORAGE_IPI 0x0103 |
||
30 | #define PCI_CLASS_STORAGE_RAID 0x0104 |
||
31 | #define PCI_CLASS_STORAGE_SATA 0x0106 |
||
32 | #define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 |
||
33 | #define PCI_CLASS_STORAGE_SAS 0x0107 |
||
34 | #define PCI_CLASS_STORAGE_OTHER 0x0180 |
||
35 | |||
36 | |||
37 | #define PCI_CLASS_NETWORK_ETHERNET 0x0200 |
||
38 | #define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 |
||
39 | #define PCI_CLASS_NETWORK_FDDI 0x0202 |
||
40 | #define PCI_CLASS_NETWORK_ATM 0x0203 |
||
41 | #define PCI_CLASS_NETWORK_OTHER 0x0280 |
||
42 | |||
43 | |||
44 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
||
45 | #define PCI_CLASS_DISPLAY_XGA 0x0301 |
||
46 | #define PCI_CLASS_DISPLAY_3D 0x0302 |
||
47 | #define PCI_CLASS_DISPLAY_OTHER 0x0380 |
||
48 | |||
49 | |||
50 | #define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 |
||
51 | #define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 |
||
52 | #define PCI_CLASS_MULTIMEDIA_PHONE 0x0402 |
||
53 | #define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 |
||
54 | |||
55 | |||
56 | #define PCI_CLASS_MEMORY_RAM 0x0500 |
||
57 | #define PCI_CLASS_MEMORY_FLASH 0x0501 |
||
58 | #define PCI_CLASS_MEMORY_OTHER 0x0580 |
||
59 | |||
60 | |||
61 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
||
62 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
||
63 | #define PCI_CLASS_BRIDGE_EISA 0x0602 |
||
64 | #define PCI_CLASS_BRIDGE_MC 0x0603 |
||
65 | #define PCI_CLASS_BRIDGE_PCI 0x0604 |
||
66 | #define PCI_CLASS_BRIDGE_PCMCIA 0x0605 |
||
67 | #define PCI_CLASS_BRIDGE_NUBUS 0x0606 |
||
68 | #define PCI_CLASS_BRIDGE_CARDBUS 0x0607 |
||
69 | #define PCI_CLASS_BRIDGE_RACEWAY 0x0608 |
||
70 | #define PCI_CLASS_BRIDGE_OTHER 0x0680 |
||
71 | |||
72 | |||
73 | #define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 |
||
74 | #define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701 |
||
75 | #define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702 |
||
76 | #define PCI_CLASS_COMMUNICATION_MODEM 0x0703 |
||
77 | #define PCI_CLASS_COMMUNICATION_OTHER 0x0780 |
||
78 | |||
79 | |||
80 | #define PCI_CLASS_SYSTEM_PIC 0x0800 |
||
81 | #define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010 |
||
82 | #define PCI_CLASS_SYSTEM_PIC_IOXAPIC 0x080020 |
||
83 | #define PCI_CLASS_SYSTEM_DMA 0x0801 |
||
84 | #define PCI_CLASS_SYSTEM_TIMER 0x0802 |
||
85 | #define PCI_CLASS_SYSTEM_RTC 0x0803 |
||
86 | #define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804 |
||
87 | #define PCI_CLASS_SYSTEM_SDHCI 0x0805 |
||
88 | #define PCI_CLASS_SYSTEM_OTHER 0x0880 |
||
89 | |||
90 | |||
91 | #define PCI_CLASS_INPUT_KEYBOARD 0x0900 |
||
92 | #define PCI_CLASS_INPUT_PEN 0x0901 |
||
93 | #define PCI_CLASS_INPUT_MOUSE 0x0902 |
||
94 | #define PCI_CLASS_INPUT_SCANNER 0x0903 |
||
95 | #define PCI_CLASS_INPUT_GAMEPORT 0x0904 |
||
96 | #define PCI_CLASS_INPUT_OTHER 0x0980 |
||
97 | |||
98 | |||
99 | #define PCI_CLASS_DOCKING_GENERIC 0x0a00 |
||
100 | #define PCI_CLASS_DOCKING_OTHER 0x0a80 |
||
101 | |||
102 | |||
103 | #define PCI_CLASS_PROCESSOR_386 0x0b00 |
||
104 | #define PCI_CLASS_PROCESSOR_486 0x0b01 |
||
105 | #define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02 |
||
106 | #define PCI_CLASS_PROCESSOR_ALPHA 0x0b10 |
||
107 | #define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 |
||
108 | #define PCI_CLASS_PROCESSOR_MIPS 0x0b30 |
||
109 | #define PCI_CLASS_PROCESSOR_CO 0x0b40 |
||
110 | |||
111 | |||
112 | #define PCI_CLASS_SERIAL_FIREWIRE 0x0c00 |
||
113 | #define PCI_CLASS_SERIAL_FIREWIRE_OHCI 0x0c0010 |
||
114 | #define PCI_CLASS_SERIAL_ACCESS 0x0c01 |
||
115 | #define PCI_CLASS_SERIAL_SSA 0x0c02 |
||
116 | #define PCI_CLASS_SERIAL_USB 0x0c03 |
||
117 | #define PCI_CLASS_SERIAL_USB_UHCI 0x0c0300 |
||
118 | #define PCI_CLASS_SERIAL_USB_OHCI 0x0c0310 |
||
119 | #define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 |
||
120 | #define PCI_CLASS_SERIAL_FIBER 0x0c04 |
||
121 | #define PCI_CLASS_SERIAL_SMBUS 0x0c05 |
||
122 | |||
123 | |||
124 | #define PCI_CLASS_WIRELESS_RF_CONTROLLER 0x0d10 |
||
125 | #define PCI_CLASS_WIRELESS_WHCI 0x0d1010 |
||
126 | |||
127 | |||
128 | #define PCI_CLASS_INTELLIGENT_I2O 0x0e00 |
||
129 | |||
130 | |||
131 | #define PCI_CLASS_SATELLITE_TV 0x0f00 |
||
132 | #define PCI_CLASS_SATELLITE_AUDIO 0x0f01 |
||
133 | #define PCI_CLASS_SATELLITE_VOICE 0x0f03 |
||
134 | #define PCI_CLASS_SATELLITE_DATA 0x0f04 |
||
135 | |||
136 | |||
137 | #define PCI_CLASS_CRYPT_NETWORK 0x1000 |
||
138 | #define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001 |
||
139 | #define PCI_CLASS_CRYPT_OTHER 0x1080 |
||
140 | |||
141 | |||
142 | #define PCI_CLASS_SP_DPIO 0x1100 |
||
143 | #define PCI_CLASS_SP_OTHER 0x1180 |
||
144 | |||
145 | |||
146 | |||
147 | |||
148 | |||
149 | |||
150 | #define PCI_MAP_REG_END 0x28 |
||
151 | #define PCI_MAP_ROM_REG 0x30 |
||
152 | |||
153 | |||
154 | #define PCI_MAP_IO 0x00000001 |
||
155 | |||
156 | |||
157 | #define PCI_MAP_IO_TYPE 0x00000003 |
||
158 | |||
159 | |||
160 | #define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 |
||
161 | #define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 |
||
162 | #define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 |
||
163 | #define PCI_MAP_MEMORY_CACHABLE 0x00000008 |
||
164 | #define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e |
||
165 | #define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 |
||
166 | |||
167 | |||
168 | |||
169 | |||
170 | |||
171 | |||
172 | #define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b)) |
||
173 | |||
174 | |||
175 | (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT) |
||
176 | |||
177 | |||
178 | #define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1)) |
||
179 | #define PCIGETMEMORY64(b) \ |
||
180 | (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32)) |
||
181 | |||
182 | |||
183 | |||
184 | |||
185 | |||
186 | |||
187 | #define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800 |
||
188 | |||
189 | |||
190 | |||
191 | |||
192 | |||
193 | # define PCI_DOM_MASK 0x0ffu |
||
194 | #endif |
||
195 | #define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) |
||
196 | |||
197 | |||
198 | (((d) & 0x00001fu) << 11) | \ |
||
199 | (((f) & 0x000007u) << 8)) |
||
200 | |||
201 | |||
202 | #define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) |
||
203 | #define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) |
||
204 | #define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) |
||
205 | |||
206 | |||
207 | #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) |
||
208 | #define PCI_FUNC(devfn) ((devfn) & 0x07) |
||
209 | |||
210 | |||
1628 | serge | 211 | #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8) |
212 | #define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) /* Get controller for PCI device. */ |
||
213 | #define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) /* Set mmap state to I/O space. */ |
||
214 | #define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) /* Set mmap state to MEM space. */ |
||
215 | #define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) /* Enable/disable write-combining. */ |
||
216 | |||
1408 | serge | 217 | |
218 | |||
1628 | serge | 219 | |
220 | |||
221 | /* I/O channel is in normal state */ |
||
222 | pci_channel_io_normal = (__force pci_channel_state_t) 1, |
||
223 | |||
224 | |||
225 | pci_channel_io_frozen = (__force pci_channel_state_t) 2, |
||
226 | |||
227 | |||
228 | pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, |
||
229 | }; |
||
230 | |||
231 | |||
232 | |||
1408 | serge | 233 | |
234 | |||
235 | pciTag(int busnum, int devnum, int funcnum) |
||
236 | { |
||
237 | return(PCI_MAKE_TAG(busnum,devnum,funcnum)); |
||
238 | } |
||
239 | |||
240 | |||
241 | |||
242 | { |
||
243 | resource_size_t start; |
||
244 | resource_size_t end; |
||
245 | const char *name; |
||
1627 | serge | 246 | unsigned long flags; |
1408 | serge | 247 | struct resource *parent, *sibling, *child; |
1627 | serge | 248 | }; |
1408 | serge | 249 | |
250 | |||
1628 | serge | 251 | #define PCI_DMA_BIDIRECTIONAL 0 |
252 | #define PCI_DMA_TODEVICE 1 |
||
253 | #define PCI_DMA_FROMDEVICE 2 |
||
254 | #define PCI_DMA_NONE 3 |
||
255 | |||
1627 | serge | 256 | |
1408 | serge | 257 | * For PCI devices, the region numbers are assigned this way: |
1627 | serge | 258 | */ |
259 | enum { |
||
260 | /* #0-5: standard PCI resources */ |
||
261 | PCI_STD_RESOURCES, |
||
262 | PCI_STD_RESOURCE_END = 5, |
||
263 | |||
264 | |||
265 | PCI_ROM_RESOURCE, |
||
266 | |||
267 | |||
268 | #ifdef CONFIG_PCI_IOV |
||
269 | PCI_IOV_RESOURCES, |
||
270 | PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1, |
||
271 | #endif |
||
272 | |||
273 | |||
274 | #define PCI_BRIDGE_RESOURCE_NUM 4 |
||
275 | |||
276 | |||
277 | PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES + |
||
278 | PCI_BRIDGE_RESOURCE_NUM - 1, |
||
279 | |||
280 | |||
281 | PCI_NUM_RESOURCES, |
||
282 | |||
283 | |||
284 | DEVICE_COUNT_RESOURCE |
||
285 | }; |
||
286 | |||
287 | |||
288 | |||
289 | * IO resources have these defined flags. |
||
1408 | serge | 290 | */ |
291 | #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ |
||
292 | |||
293 | |||
294 | #define IORESOURCE_MEM 0x00000200 |
||
295 | #define IORESOURCE_IRQ 0x00000400 |
||
296 | #define IORESOURCE_DMA 0x00000800 |
||
297 | |||
298 | |||
299 | #define IORESOURCE_READONLY 0x00002000 |
||
300 | #define IORESOURCE_CACHEABLE 0x00004000 |
||
301 | #define IORESOURCE_RANGELENGTH 0x00008000 |
||
302 | #define IORESOURCE_SHADOWABLE 0x00010000 |
||
303 | #define IORESOURCE_BUS_HAS_VGA 0x00080000 |
||
304 | |||
305 | |||
306 | #define IORESOURCE_UNSET 0x20000000 |
||
307 | #define IORESOURCE_AUTO 0x40000000 |
||
308 | #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ |
||
309 | |||
310 | |||
311 | #define IORESOURCE_IRQ_HIGHEDGE (1<<0) |
||
312 | #define IORESOURCE_IRQ_LOWEDGE (1<<1) |
||
313 | #define IORESOURCE_IRQ_HIGHLEVEL (1<<2) |
||
314 | #define IORESOURCE_IRQ_LOWLEVEL (1<<3) |
||
315 | #define IORESOURCE_IRQ_SHAREABLE (1<<4) |
||
316 | |||
317 | |||
318 | #define IORESOURCE_DMA_TYPE_MASK (3<<0) |
||
319 | #define IORESOURCE_DMA_8BIT (0<<0) |
||
320 | #define IORESOURCE_DMA_8AND16BIT (1<<0) |
||
321 | #define IORESOURCE_DMA_16BIT (2<<0) |
||
322 | |||
323 | |||
324 | #define IORESOURCE_DMA_BYTE (1<<3) |
||
325 | #define IORESOURCE_DMA_WORD (1<<4) |
||
326 | |||
327 | |||
328 | #define IORESOURCE_DMA_COMPATIBLE (0<<6) |
||
329 | #define IORESOURCE_DMA_TYPEA (1<<6) |
||
330 | #define IORESOURCE_DMA_TYPEB (2<<6) |
||
331 | #define IORESOURCE_DMA_TYPEF (3<<6) |
||
332 | |||
333 | |||
334 | #define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ |
||
335 | #define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ |
||
336 | #define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ |
||
337 | #define IORESOURCE_MEM_TYPE_MASK (3<<3) |
||
338 | #define IORESOURCE_MEM_8BIT (0<<3) |
||
339 | #define IORESOURCE_MEM_16BIT (1<<3) |
||
340 | #define IORESOURCE_MEM_8AND16BIT (2<<3) |
||
341 | #define IORESOURCE_MEM_32BIT (3<<3) |
||
342 | #define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ |
||
343 | #define IORESOURCE_MEM_EXPANSIONROM (1<<6) |
||
344 | |||
345 | |||
346 | #define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ |
||
347 | #define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */ |
||
348 | #define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */ |
||
349 | #define IORESOURCE_ROM_BIOS_COPY (1<<3) /* ROM is BIOS copy, resource field overlaid */ |
||
350 | |||
351 | |||
352 | #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */ |
||
353 | |||
354 | |||
355 | |||
1628 | serge | 356 | |
357 | |||
1408 | serge | 358 | * For PCI devices, the region numbers are assigned this way: |
359 | * |
||
360 | * 0-5 standard PCI regions |
||
361 | * 6 expansion ROM |
||
362 | * 7-10 bridges: address space assigned to buses behind the bridge |
||
363 | */ |
||
364 | |||
365 | |||
366 | #define PCI_BRIDGE_RESOURCES 7 |
||
367 | #define PCI_NUM_RESOURCES 11 |
||
368 | |||
369 | |||
370 | #define PCI_BUS_NUM_RESOURCES 8 |
||
371 | #endif |
||
372 | |||
373 | |||
374 | |||
375 | |||
1628 | serge | 376 | |
377 | #define PCI_CFG_SPACE_EXP_SIZE 4096 |
||
378 | |||
379 | |||
380 | |||
381 | |||
382 | |||
383 | #define PCI_D1 ((pci_power_t __force) 1) |
||
384 | #define PCI_D2 ((pci_power_t __force) 2) |
||
385 | #define PCI_D3hot ((pci_power_t __force) 3) |
||
386 | #define PCI_D3cold ((pci_power_t __force) 4) |
||
387 | #define PCI_UNKNOWN ((pci_power_t __force) 5) |
||
388 | #define PCI_POWER_ERROR ((pci_power_t __force) -1) |
||
389 | |||
390 | |||
1408 | serge | 391 | * The pci_dev structure is used to describe PCI devices. |
392 | */ |
||
393 | struct pci_dev { |
||
394 | struct list_head bus_list; /* node in per-bus list */ |
||
1628 | serge | 395 | struct pci_bus *bus; /* bus this device is on */ |
396 | struct pci_bus *subordinate; /* bus this device bridges to */ |
||
397 | |||
1408 | serge | 398 | |
1628 | serge | 399 | // struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ |
1408 | serge | 400 | struct pci_slot *slot; /* Physical slot this device is in */ |
1628 | serge | 401 | u32_t busnr; |
402 | unsigned int devfn; /* encoded device & function index */ |
||
403 | unsigned short vendor; |
||
404 | unsigned short device; |
||
405 | unsigned short subsystem_vendor; |
||
406 | unsigned short subsystem_device; |
||
407 | unsigned int class; /* 3 bytes: (base,sub,prog-if) */ |
||
408 | u8 revision; /* PCI revision, low byte of class word */ |
||
409 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ |
||
410 | u8 pcie_cap; /* PCI-E capability offset */ |
||
411 | u8 pcie_type; /* PCI-E device/port type */ |
||
412 | u8 rom_base_reg; /* which config register controls the ROM */ |
||
413 | u8 pin; /* which interrupt pin this device uses */ |
||
414 | |||
1408 | serge | 415 | |
416 | u64 dma_mask; /* Mask of the bits of bus address this |
||
1628 | serge | 417 | device implements. Normally this is |
1408 | serge | 418 | 0xffffffff. You only need to change |
419 | this if your device has broken DMA |
||
420 | or supports 64-bit transfers. */ |
||
421 | |||
422 | |||
423 | |||
424 | |||
1628 | serge | 425 | this is D0-D3, D0 being fully functional, |
426 | and D3 being off. */ |
||
427 | int pm_cap; /* PM capability offset in the |
||
428 | configuration space */ |
||
429 | unsigned int pme_support:5; /* Bitmask of states from which PME# |
||
1408 | serge | 430 | can be generated */ |
431 | unsigned int pme_interrupt:1; |
||
1628 | serge | 432 | unsigned int d1_support:1; /* Low power state D1 is supported */ |
1408 | serge | 433 | unsigned int d2_support:1; /* Low power state D2 is supported */ |
434 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ |
||
435 | unsigned int mmio_always_on:1; /* disallow turning off io/mem |
||
1628 | serge | 436 | decoding during bar sizing */ |
437 | unsigned int wakeup_prepared:1; |
||
438 | unsigned int d3_delay; /* D3->D0 transition time in ms */ |
||
439 | |||
1408 | serge | 440 | |
1628 | serge | 441 | struct device dev; /* Generic device interface */ |
1430 | serge | 442 | |
1408 | serge | 443 | |
1628 | serge | 444 | |
1408 | serge | 445 | |
446 | * Instead of touching interrupt line and base address registers |
||
447 | * directly, use the values stored here. They might be different! |
||
448 | */ |
||
449 | unsigned int irq; |
||
450 | struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ |
||
451 | |||
452 | |||
453 | unsigned int transparent:1; /* Transparent PCI bridge */ |
||
454 | unsigned int multifunction:1;/* Part of multi-function device */ |
||
455 | /* keep track of device state */ |
||
456 | unsigned int is_added:1; |
||
457 | unsigned int is_busmaster:1; /* device is busmaster */ |
||
458 | unsigned int no_msi:1; /* device may not use msi */ |
||
459 | unsigned int block_ucfg_access:1; /* userspace config space access is blocked */ |
||
460 | unsigned int broken_parity_status:1; /* Device generates false positive parity */ |
||
461 | unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */ |
||
462 | unsigned int msi_enabled:1; |
||
463 | unsigned int msix_enabled:1; |
||
464 | unsigned int ari_enabled:1; /* ARI forwarding */ |
||
465 | unsigned int is_managed:1; |
||
466 | unsigned int is_pcie:1; /* Obsolete. Will be removed. |
||
1628 | serge | 467 | Use pci_is_pcie() instead */ |
468 | unsigned int needs_freset:1; /* Dev requires fundamental reset */ |
||
469 | unsigned int state_saved:1; |
||
1408 | serge | 470 | unsigned int is_physfn:1; |
471 | unsigned int is_virtfn:1; |
||
472 | unsigned int reset_fn:1; |
||
1628 | serge | 473 | unsigned int is_hotplug_bridge:1; |
474 | unsigned int __aer_firmware_first_valid:1; |
||
475 | unsigned int __aer_firmware_first:1; |
||
476 | |||
1408 | serge | 477 | |
1628 | serge | 478 | |
1408 | serge | 479 | // struct hlist_head saved_cap_space; |
480 | // struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ |
||
481 | // int rom_attr_enabled; /* has display of the rom attribute been enabled? */ |
||
482 | // struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ |
||
483 | // struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */ |
||
484 | }; |
||
485 | |||
486 | |||
487 | #define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) |
||
488 | #define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) |
||
489 | #define pci_resource_len(dev,bar) \ |
||
490 | ((pci_resource_start((dev), (bar)) == 0 && \ |
||
491 | pci_resource_end((dev), (bar)) == \ |
||
492 | pci_resource_start((dev), (bar))) ? 0 : \ |
||
493 | \ |
||
494 | (pci_resource_end((dev), (bar)) - \ |
||
495 | pci_resource_start((dev), (bar)) + 1)) |
||
496 | |||
497 | |||
498 | { |
||
499 | u16_t vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ |
||
500 | u16_t subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ |
||
501 | u32_t class, class_mask; /* (class,subclass,prog-if) triplet */ |
||
502 | u32_t driver_data; /* Data private to the driver */ |
||
503 | }; |
||
504 | |||
505 | |||
506 | { |
||
507 | struct list_head link; |
||
508 | struct pci_dev pci_dev; |
||
509 | }pci_dev_t; |
||
510 | |||
511 | |||
1627 | serge | 512 | |
513 | enum pci_bus_flags { |
||
514 | PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, |
||
515 | PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2, |
||
516 | }; |
||
517 | |||
518 | |||
519 | { |
||
520 | int domain; /* PCI domain */ |
||
521 | int node; /* NUMA node */ |
||
522 | #ifdef CONFIG_X86_64 |
||
523 | void *iommu; /* IOMMU private data */ |
||
524 | #endif |
||
525 | }; |
||
526 | |||
527 | |||
528 | |||
529 | |||
530 | { |
||
531 | int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); |
||
532 | int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val); |
||
533 | }; |
||
534 | |||
535 | |||
1628 | serge | 536 | * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond |
537 | * to P2P or CardBus bridge windows) go in a table. Additional ones (for |
||
538 | * buses below host bridges or subtractive decode bridges) go in the list. |
||
539 | * Use pci_bus_for_each_resource() to iterate through all the resources. |
||
540 | */ |
||
541 | |||
1627 | serge | 542 | |
1628 | serge | 543 | * PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly |
544 | * and there's no way to program the bridge with the details of the window. |
||
545 | * This does not apply to ACPI _CRS windows, even with the _DEC subtractive- |
||
546 | * decode bit set, because they are explicit and can be programmed with _SRS. |
||
547 | */ |
||
548 | #define PCI_SUBTRACTIVE_DECODE 0x1 |
||
549 | |||
550 | |||
551 | struct list_head list; |
||
552 | struct resource *res; |
||
553 | unsigned int flags; |
||
554 | }; |
||
555 | |||
556 | |||
557 | |||
558 | |||
1627 | serge | 559 | struct list_head node; /* node in list of buses */ |
560 | struct pci_bus *parent; /* parent bus this bridge is on */ |
||
561 | struct list_head children; /* list of child buses */ |
||
562 | struct list_head devices; /* list of devices on this bus */ |
||
563 | struct pci_dev *self; /* bridge device as seen by parent */ |
||
564 | struct list_head slots; /* list of slots on this bus */ |
||
565 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; |
||
566 | struct list_head resources; /* address space routed to this bus */ |
||
567 | |||
568 | |||
569 | void *sysdata; /* hook for sys-specific extension */ |
||
570 | |||
571 | |||
572 | unsigned char primary; /* number of primary bridge */ |
||
573 | unsigned char secondary; /* number of secondary bridge */ |
||
574 | unsigned char subordinate; /* max number of subordinate buses */ |
||
575 | |||
576 | |||
577 | |||
578 | |||
579 | pci_bus_flags_t bus_flags; /* Inherited by child busses */ |
||
580 | // struct device *bridge; |
||
581 | // struct device dev; |
||
582 | // struct bin_attribute *legacy_io; /* legacy I/O for this bus */ |
||
583 | // struct bin_attribute *legacy_mem; /* legacy mem */ |
||
584 | unsigned int is_added:1; |
||
585 | }; |
||
586 | |||
587 | |||
588 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) |
||
589 | #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) |
||
1628 | serge | 590 | #define to_pci_dev(n) container_of(n, struct pci_dev, dev) |
591 | #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) |
||
592 | |||
1627 | serge | 593 | |
594 | |||
595 | { |
||
596 | struct pci_sysdata *sd = bus->sysdata; |
||
597 | return sd->domain; |
||
598 | } |
||
599 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; } |
||
1628 | serge | 600 | |
1627 | serge | 601 | |
1628 | serge | 602 | * Error values that may be returned by PCI functions. |
603 | */ |
||
604 | #define PCIBIOS_SUCCESSFUL 0x00 |
||
605 | #define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 |
||
606 | #define PCIBIOS_BAD_VENDOR_ID 0x83 |
||
607 | #define PCIBIOS_DEVICE_NOT_FOUND 0x86 |
||
608 | #define PCIBIOS_BAD_REGISTER_NUMBER 0x87 |
||
609 | #define PCIBIOS_SET_FAILED 0x88 |
||
610 | #define PCIBIOS_BUFFER_TOO_SMALL 0x89 |
||
611 | |||
1627 | serge | 612 | |
1628 | serge | 613 | |
614 | |||
615 | resource_size_t start; |
||
616 | resource_size_t end; |
||
617 | }; |
||
618 | |||
619 | |||
620 | |||
621 | |||
622 | |||
623 | |||
624 | |||
625 | |||
626 | |||
1408 | serge | 627 | |
628 | |||
629 | find_pci_device(pci_dev_t* pdev, struct pci_device_id *idlist); |
||
630 | |||
631 | |||
632 | |||
633 | |||
634 | |||
635 | |||
1627 | serge | 636 | struct pci_bus * pci_find_bus(int domain, int busnr); |
637 | int pci_find_capability(struct pci_dev *dev, int cap); |
||
1628 | serge | 638 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); |
639 | int pci_find_ext_capability(struct pci_dev *dev, int cap); |
||
640 | int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn, |
||
641 | int cap); |
||
642 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); |
||
643 | struct pci_bus * pci_find_next_bus(const struct pci_bus *from); |
||
1627 | serge | 644 | |
1408 | serge | 645 | |
1628 | serge | 646 | { |
647 | return !(pbus->parent); |
||
648 | } |
||
649 | |||
1627 | serge | 650 | |
1628 | serge | 651 | * pci_pcie_cap - get the saved PCIe capability offset |
652 | * @dev: PCI device |
||
653 | * |
||
654 | * PCIe capability offset is calculated at PCI device initialization |
||
655 | * time and saved in the data structure. This function returns saved |
||
656 | * PCIe capability offset. Using this instead of pci_find_capability() |
||
657 | * reduces unnecessary search in the PCI configuration space. If you |
||
658 | * need to calculate PCIe capability offset from raw device for some |
||
659 | * reasons, please use pci_find_capability() instead. |
||
660 | */ |
||
661 | static inline int pci_pcie_cap(struct pci_dev *dev) |
||
662 | { |
||
663 | return dev->pcie_cap; |
||
664 | } |
||
665 | |||
1627 | serge | 666 | |
1628 | serge | 667 | * pci_is_pcie - check if the PCI device is PCI Express capable |
668 | * @dev: PCI device |
||
669 | * |
||
670 | * Retrun true if the PCI device is PCI Express capable, false otherwise. |
||
671 | */ |
||
672 | static inline bool pci_is_pcie(struct pci_dev *dev) |
||
673 | { |
||
674 | return !!pci_pcie_cap(dev); |
||
675 | } |
||
676 | |||
677 | |||
1408 | serge | 678 | |
679 | |||
680 | |||
681 | |||
682 |