diff options
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r-- | include/linux/pci.h | 383 |
1 files changed, 262 insertions, 121 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 5d2281f661f7..4f96f1d94ac4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -28,7 +28,7 @@ | |||
28 | * 7:3 = slot | 28 | * 7:3 = slot |
29 | * 2:0 = function | 29 | * 2:0 = function |
30 | */ | 30 | */ |
31 | #define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) | 31 | #define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) |
32 | #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) | 32 | #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) |
33 | #define PCI_FUNC(devfn) ((devfn) & 0x07) | 33 | #define PCI_FUNC(devfn) ((devfn) & 0x07) |
34 | 34 | ||
@@ -66,7 +66,6 @@ enum pci_mmap_state { | |||
66 | #define PCI_DMA_FROMDEVICE 2 | 66 | #define PCI_DMA_FROMDEVICE 2 |
67 | #define PCI_DMA_NONE 3 | 67 | #define PCI_DMA_NONE 3 |
68 | 68 | ||
69 | #define DEVICE_COUNT_COMPATIBLE 4 | ||
70 | #define DEVICE_COUNT_RESOURCE 12 | 69 | #define DEVICE_COUNT_RESOURCE 12 |
71 | 70 | ||
72 | typedef int __bitwise pci_power_t; | 71 | typedef int __bitwise pci_power_t; |
@@ -109,6 +108,14 @@ enum pcie_reset_state { | |||
109 | pcie_hot_reset = (__force pcie_reset_state_t) 3 | 108 | pcie_hot_reset = (__force pcie_reset_state_t) 3 |
110 | }; | 109 | }; |
111 | 110 | ||
111 | typedef unsigned short __bitwise pci_dev_flags_t; | ||
112 | enum pci_dev_flags { | ||
113 | /* INTX_DISABLE in PCI_COMMAND register disables MSI | ||
114 | * generation too. | ||
115 | */ | ||
116 | PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1, | ||
117 | }; | ||
118 | |||
112 | typedef unsigned short __bitwise pci_bus_flags_t; | 119 | typedef unsigned short __bitwise pci_bus_flags_t; |
113 | enum pci_bus_flags { | 120 | enum pci_bus_flags { |
114 | PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, | 121 | PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, |
@@ -121,6 +128,7 @@ struct pci_cap_saved_state { | |||
121 | u32 data[0]; | 128 | u32 data[0]; |
122 | }; | 129 | }; |
123 | 130 | ||
131 | struct pcie_link_state; | ||
124 | /* | 132 | /* |
125 | * The pci_dev structure is used to describe PCI devices. | 133 | * The pci_dev structure is used to describe PCI devices. |
126 | */ | 134 | */ |
@@ -156,13 +164,13 @@ struct pci_dev { | |||
156 | this is D0-D3, D0 being fully functional, | 164 | this is D0-D3, D0 being fully functional, |
157 | and D3 being off. */ | 165 | and D3 being off. */ |
158 | 166 | ||
167 | #ifdef CONFIG_PCIEASPM | ||
168 | struct pcie_link_state *link_state; /* ASPM link state. */ | ||
169 | #endif | ||
170 | |||
159 | pci_channel_state_t error_state; /* current connectivity state */ | 171 | pci_channel_state_t error_state; /* current connectivity state */ |
160 | struct device dev; /* Generic device interface */ | 172 | struct device dev; /* Generic device interface */ |
161 | 173 | ||
162 | /* device is compatible with these IDs */ | ||
163 | unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE]; | ||
164 | unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE]; | ||
165 | |||
166 | int cfg_size; /* Size of configuration space */ | 174 | int cfg_size; /* Size of configuration space */ |
167 | 175 | ||
168 | /* | 176 | /* |
@@ -185,6 +193,7 @@ struct pci_dev { | |||
185 | unsigned int msix_enabled:1; | 193 | unsigned int msix_enabled:1; |
186 | unsigned int is_managed:1; | 194 | unsigned int is_managed:1; |
187 | unsigned int is_pcie:1; | 195 | unsigned int is_pcie:1; |
196 | pci_dev_flags_t dev_flags; | ||
188 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 197 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
189 | 198 | ||
190 | u32 saved_config_space[16]; /* config space saved at suspend time */ | 199 | u32 saved_config_space[16]; /* config space saved at suspend time */ |
@@ -210,7 +219,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev) | |||
210 | } | 219 | } |
211 | 220 | ||
212 | static inline struct pci_cap_saved_state *pci_find_saved_cap( | 221 | static inline struct pci_cap_saved_state *pci_find_saved_cap( |
213 | struct pci_dev *pci_dev,char cap) | 222 | struct pci_dev *pci_dev, char cap) |
214 | { | 223 | { |
215 | struct pci_cap_saved_state *tmp; | 224 | struct pci_cap_saved_state *tmp; |
216 | struct hlist_node *pos; | 225 | struct hlist_node *pos; |
@@ -269,13 +278,13 @@ struct pci_bus { | |||
269 | unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ | 278 | unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ |
270 | pci_bus_flags_t bus_flags; /* Inherited by child busses */ | 279 | pci_bus_flags_t bus_flags; /* Inherited by child busses */ |
271 | struct device *bridge; | 280 | struct device *bridge; |
272 | struct class_device class_dev; | 281 | struct device dev; |
273 | struct bin_attribute *legacy_io; /* legacy I/O for this bus */ | 282 | struct bin_attribute *legacy_io; /* legacy I/O for this bus */ |
274 | struct bin_attribute *legacy_mem; /* legacy mem */ | 283 | struct bin_attribute *legacy_mem; /* legacy mem */ |
275 | }; | 284 | }; |
276 | 285 | ||
277 | #define pci_bus_b(n) list_entry(n, struct pci_bus, node) | 286 | #define pci_bus_b(n) list_entry(n, struct pci_bus, node) |
278 | #define to_pci_bus(n) container_of(n, struct pci_bus, class_dev) | 287 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) |
279 | 288 | ||
280 | /* | 289 | /* |
281 | * Error values that may be returned by PCI functions. | 290 | * Error values that may be returned by PCI functions. |
@@ -305,8 +314,8 @@ struct pci_raw_ops { | |||
305 | extern struct pci_raw_ops *raw_pci_ops; | 314 | extern struct pci_raw_ops *raw_pci_ops; |
306 | 315 | ||
307 | struct pci_bus_region { | 316 | struct pci_bus_region { |
308 | unsigned long start; | 317 | resource_size_t start; |
309 | unsigned long end; | 318 | resource_size_t end; |
310 | }; | 319 | }; |
311 | 320 | ||
312 | struct pci_dynids { | 321 | struct pci_dynids { |
@@ -342,11 +351,10 @@ enum pci_ers_result { | |||
342 | }; | 351 | }; |
343 | 352 | ||
344 | /* PCI bus error event callbacks */ | 353 | /* PCI bus error event callbacks */ |
345 | struct pci_error_handlers | 354 | struct pci_error_handlers { |
346 | { | ||
347 | /* PCI bus error detected on this device */ | 355 | /* PCI bus error detected on this device */ |
348 | pci_ers_result_t (*error_detected)(struct pci_dev *dev, | 356 | pci_ers_result_t (*error_detected)(struct pci_dev *dev, |
349 | enum pci_channel_state error); | 357 | enum pci_channel_state error); |
350 | 358 | ||
351 | /* MMIO has been re-enabled, but not DMA */ | 359 | /* MMIO has been re-enabled, but not DMA */ |
352 | pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev); | 360 | pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev); |
@@ -381,7 +389,7 @@ struct pci_driver { | |||
381 | struct pci_dynids dynids; | 389 | struct pci_dynids dynids; |
382 | }; | 390 | }; |
383 | 391 | ||
384 | #define to_pci_driver(drv) container_of(drv,struct pci_driver, driver) | 392 | #define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) |
385 | 393 | ||
386 | /** | 394 | /** |
387 | * PCI_DEVICE - macro used to describe a specific pci device | 395 | * PCI_DEVICE - macro used to describe a specific pci device |
@@ -439,7 +447,7 @@ extern int no_pci_devices(void); | |||
439 | 447 | ||
440 | void pcibios_fixup_bus(struct pci_bus *); | 448 | void pcibios_fixup_bus(struct pci_bus *); |
441 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); | 449 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); |
442 | char *pcibios_setup (char *str); | 450 | char *pcibios_setup(char *str); |
443 | 451 | ||
444 | /* Used only when drivers/pci/setup.c is used */ | 452 | /* Used only when drivers/pci/setup.c is used */ |
445 | void pcibios_align_resource(void *, struct resource *, resource_size_t, | 453 | void pcibios_align_resource(void *, struct resource *, resource_size_t, |
@@ -450,8 +458,10 @@ void pcibios_update_irq(struct pci_dev *, int irq); | |||
450 | 458 | ||
451 | extern struct pci_bus *pci_find_bus(int domain, int busnr); | 459 | extern struct pci_bus *pci_find_bus(int domain, int busnr); |
452 | void pci_bus_add_devices(struct pci_bus *bus); | 460 | void pci_bus_add_devices(struct pci_bus *bus); |
453 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); | 461 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, |
454 | static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) | 462 | struct pci_ops *ops, void *sysdata); |
463 | static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, | ||
464 | void *sysdata) | ||
455 | { | 465 | { |
456 | struct pci_bus *root_bus; | 466 | struct pci_bus *root_bus; |
457 | root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata); | 467 | root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata); |
@@ -459,15 +469,18 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s | |||
459 | pci_bus_add_devices(root_bus); | 469 | pci_bus_add_devices(root_bus); |
460 | return root_bus; | 470 | return root_bus; |
461 | } | 471 | } |
462 | struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); | 472 | struct pci_bus *pci_create_bus(struct device *parent, int bus, |
463 | struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); | 473 | struct pci_ops *ops, void *sysdata); |
474 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | ||
475 | int busnr); | ||
464 | int pci_scan_slot(struct pci_bus *bus, int devfn); | 476 | int pci_scan_slot(struct pci_bus *bus, int devfn); |
465 | struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); | 477 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); |
466 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); | 478 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); |
467 | unsigned int pci_scan_child_bus(struct pci_bus *bus); | 479 | unsigned int pci_scan_child_bus(struct pci_bus *bus); |
468 | int __must_check pci_bus_add_device(struct pci_dev *dev); | 480 | int __must_check pci_bus_add_device(struct pci_dev *dev); |
469 | void pci_read_bridge_bases(struct pci_bus *child); | 481 | void pci_read_bridge_bases(struct pci_bus *child); |
470 | struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); | 482 | struct resource *pci_find_parent_resource(const struct pci_dev *dev, |
483 | struct resource *res); | ||
471 | int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); | 484 | int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); |
472 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); | 485 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); |
473 | extern void pci_dev_put(struct pci_dev *dev); | 486 | extern void pci_dev_put(struct pci_dev *dev); |
@@ -479,13 +492,20 @@ extern void pci_sort_breadthfirst(void); | |||
479 | 492 | ||
480 | /* Generic PCI functions exported to card drivers */ | 493 | /* Generic PCI functions exported to card drivers */ |
481 | 494 | ||
482 | struct pci_dev __deprecated *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from); | 495 | #ifdef CONFIG_PCI_LEGACY |
483 | struct pci_dev __deprecated *pci_find_slot (unsigned int bus, unsigned int devfn); | 496 | struct pci_dev __deprecated *pci_find_device(unsigned int vendor, |
484 | int pci_find_capability (struct pci_dev *dev, int cap); | 497 | unsigned int device, |
485 | int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); | 498 | const struct pci_dev *from); |
486 | int pci_find_ext_capability (struct pci_dev *dev, int cap); | 499 | struct pci_dev __deprecated *pci_find_slot(unsigned int bus, |
487 | int pci_find_ht_capability (struct pci_dev *dev, int ht_cap); | 500 | unsigned int devfn); |
488 | int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap); | 501 | #endif /* CONFIG_PCI_LEGACY */ |
502 | |||
503 | int pci_find_capability(struct pci_dev *dev, int cap); | ||
504 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); | ||
505 | int pci_find_ext_capability(struct pci_dev *dev, int cap); | ||
506 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); | ||
507 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); | ||
508 | void pcie_wait_pending_transaction(struct pci_dev *dev); | ||
489 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); | 509 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); |
490 | 510 | ||
491 | struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, | 511 | struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, |
@@ -493,49 +513,58 @@ struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, | |||
493 | struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device, | 513 | struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device, |
494 | struct pci_dev *from); | 514 | struct pci_dev *from); |
495 | 515 | ||
496 | struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, | 516 | struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, |
497 | unsigned int ss_vendor, unsigned int ss_device, | 517 | unsigned int ss_vendor, unsigned int ss_device, |
498 | struct pci_dev *from); | 518 | struct pci_dev *from); |
499 | struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn); | 519 | struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); |
500 | struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn); | 520 | struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn); |
501 | struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); | 521 | struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from); |
502 | int pci_dev_present(const struct pci_device_id *ids); | 522 | int pci_dev_present(const struct pci_device_id *ids); |
503 | const struct pci_device_id *pci_find_present(const struct pci_device_id *ids); | 523 | const struct pci_device_id *pci_find_present(const struct pci_device_id *ids); |
504 | 524 | ||
505 | int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); | 525 | int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn, |
506 | int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); | 526 | int where, u8 *val); |
507 | int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); | 527 | int pci_bus_read_config_word(struct pci_bus *bus, unsigned int devfn, |
508 | int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); | 528 | int where, u16 *val); |
509 | int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); | 529 | int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn, |
510 | int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); | 530 | int where, u32 *val); |
531 | int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn, | ||
532 | int where, u8 val); | ||
533 | int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn, | ||
534 | int where, u16 val); | ||
535 | int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn, | ||
536 | int where, u32 val); | ||
511 | 537 | ||
512 | static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) | 538 | static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) |
513 | { | 539 | { |
514 | return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); | 540 | return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val); |
515 | } | 541 | } |
516 | static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) | 542 | static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) |
517 | { | 543 | { |
518 | return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); | 544 | return pci_bus_read_config_word(dev->bus, dev->devfn, where, val); |
519 | } | 545 | } |
520 | static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) | 546 | static inline int pci_read_config_dword(struct pci_dev *dev, int where, |
547 | u32 *val) | ||
521 | { | 548 | { |
522 | return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); | 549 | return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val); |
523 | } | 550 | } |
524 | static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) | 551 | static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) |
525 | { | 552 | { |
526 | return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); | 553 | return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val); |
527 | } | 554 | } |
528 | static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) | 555 | static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) |
529 | { | 556 | { |
530 | return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); | 557 | return pci_bus_write_config_word(dev->bus, dev->devfn, where, val); |
531 | } | 558 | } |
532 | static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) | 559 | static inline int pci_write_config_dword(struct pci_dev *dev, int where, |
560 | u32 val) | ||
533 | { | 561 | { |
534 | return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); | 562 | return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); |
535 | } | 563 | } |
536 | 564 | ||
537 | int __must_check pci_enable_device(struct pci_dev *dev); | 565 | int __must_check pci_enable_device(struct pci_dev *dev); |
538 | int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); | 566 | int __must_check pci_enable_device_io(struct pci_dev *dev); |
567 | int __must_check pci_enable_device_mem(struct pci_dev *dev); | ||
539 | int __must_check pci_reenable_device(struct pci_dev *); | 568 | int __must_check pci_reenable_device(struct pci_dev *); |
540 | int __must_check pcim_enable_device(struct pci_dev *pdev); | 569 | int __must_check pcim_enable_device(struct pci_dev *pdev); |
541 | void pcim_pin_device(struct pci_dev *pdev); | 570 | void pcim_pin_device(struct pci_dev *pdev); |
@@ -564,14 +593,11 @@ int pcie_set_readrq(struct pci_dev *dev, int rq); | |||
564 | void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); | 593 | void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); |
565 | int __must_check pci_assign_resource(struct pci_dev *dev, int i); | 594 | int __must_check pci_assign_resource(struct pci_dev *dev, int i); |
566 | int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i); | 595 | int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i); |
567 | void pci_restore_bars(struct pci_dev *dev); | ||
568 | int pci_select_bars(struct pci_dev *dev, unsigned long flags); | 596 | int pci_select_bars(struct pci_dev *dev, unsigned long flags); |
569 | 597 | ||
570 | /* ROM control related routines */ | 598 | /* ROM control related routines */ |
571 | void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); | 599 | void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); |
572 | void __iomem __must_check *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); | ||
573 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); | 600 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); |
574 | void pci_remove_rom(struct pci_dev *pdev); | ||
575 | size_t pci_get_rom_size(void __iomem *rom, size_t size); | 601 | size_t pci_get_rom_size(void __iomem *rom, size_t size); |
576 | 602 | ||
577 | /* Power management related routines */ | 603 | /* Power management related routines */ |
@@ -582,7 +608,7 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); | |||
582 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); | 608 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); |
583 | 609 | ||
584 | /* Functions for PCI Hotplug drivers to use */ | 610 | /* Functions for PCI Hotplug drivers to use */ |
585 | int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); | 611 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); |
586 | 612 | ||
587 | /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ | 613 | /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ |
588 | void pci_bus_assign_resources(struct pci_bus *bus); | 614 | void pci_bus_assign_resources(struct pci_bus *bus); |
@@ -619,17 +645,18 @@ static inline int __must_check pci_register_driver(struct pci_driver *driver) | |||
619 | return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); | 645 | return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); |
620 | } | 646 | } |
621 | 647 | ||
622 | void pci_unregister_driver(struct pci_driver *); | 648 | void pci_unregister_driver(struct pci_driver *dev); |
623 | void pci_remove_behind_bridge(struct pci_dev *); | 649 | void pci_remove_behind_bridge(struct pci_dev *dev); |
624 | struct pci_driver *pci_dev_driver(const struct pci_dev *); | 650 | struct pci_driver *pci_dev_driver(const struct pci_dev *dev); |
625 | const struct pci_device_id *pci_match_device(struct pci_driver *drv, struct pci_dev *dev); | 651 | const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, |
626 | const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev); | 652 | struct pci_dev *dev); |
627 | int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass); | 653 | int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, |
654 | int pass); | ||
628 | 655 | ||
629 | void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), | 656 | void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), |
630 | void *userdata); | 657 | void *userdata); |
631 | int pci_cfg_space_size(struct pci_dev *dev); | 658 | int pci_cfg_space_size(struct pci_dev *dev); |
632 | unsigned char pci_bus_max_busnr(struct pci_bus* bus); | 659 | unsigned char pci_bus_max_busnr(struct pci_bus *bus); |
633 | 660 | ||
634 | /* kmem_cache style wrapper around pci_alloc_consistent() */ | 661 | /* kmem_cache style wrapper around pci_alloc_consistent() */ |
635 | 662 | ||
@@ -658,19 +685,36 @@ struct msix_entry { | |||
658 | 685 | ||
659 | 686 | ||
660 | #ifndef CONFIG_PCI_MSI | 687 | #ifndef CONFIG_PCI_MSI |
661 | static inline int pci_enable_msi(struct pci_dev *dev) {return -1;} | 688 | static inline int pci_enable_msi(struct pci_dev *dev) |
662 | static inline void pci_disable_msi(struct pci_dev *dev) {} | 689 | { |
663 | static inline int pci_enable_msix(struct pci_dev* dev, | 690 | return -1; |
664 | struct msix_entry *entries, int nvec) {return -1;} | 691 | } |
665 | static inline void pci_disable_msix(struct pci_dev *dev) {} | 692 | |
666 | static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {} | 693 | static inline void pci_disable_msi(struct pci_dev *dev) |
694 | { } | ||
695 | |||
696 | static inline int pci_enable_msix(struct pci_dev *dev, | ||
697 | struct msix_entry *entries, int nvec) | ||
698 | { | ||
699 | return -1; | ||
700 | } | ||
701 | |||
702 | static inline void pci_disable_msix(struct pci_dev *dev) | ||
703 | { } | ||
704 | |||
705 | static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) | ||
706 | { } | ||
707 | |||
708 | static inline void pci_restore_msi_state(struct pci_dev *dev) | ||
709 | { } | ||
667 | #else | 710 | #else |
668 | extern int pci_enable_msi(struct pci_dev *dev); | 711 | extern int pci_enable_msi(struct pci_dev *dev); |
669 | extern void pci_disable_msi(struct pci_dev *dev); | 712 | extern void pci_disable_msi(struct pci_dev *dev); |
670 | extern int pci_enable_msix(struct pci_dev* dev, | 713 | extern int pci_enable_msix(struct pci_dev *dev, |
671 | struct msix_entry *entries, int nvec); | 714 | struct msix_entry *entries, int nvec); |
672 | extern void pci_disable_msix(struct pci_dev *dev); | 715 | extern void pci_disable_msix(struct pci_dev *dev); |
673 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); | 716 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); |
717 | extern void pci_restore_msi_state(struct pci_dev *dev); | ||
674 | #endif | 718 | #endif |
675 | 719 | ||
676 | #ifdef CONFIG_HT_IRQ | 720 | #ifdef CONFIG_HT_IRQ |
@@ -691,7 +735,11 @@ extern void pci_unblock_user_cfg_access(struct pci_dev *dev); | |||
691 | extern int pci_domains_supported; | 735 | extern int pci_domains_supported; |
692 | #else | 736 | #else |
693 | enum { pci_domains_supported = 0 }; | 737 | enum { pci_domains_supported = 0 }; |
694 | static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } | 738 | static inline int pci_domain_nr(struct pci_bus *bus) |
739 | { | ||
740 | return 0; | ||
741 | } | ||
742 | |||
695 | static inline int pci_proc_domain(struct pci_bus *bus) | 743 | static inline int pci_proc_domain(struct pci_bus *bus) |
696 | { | 744 | { |
697 | return 0; | 745 | return 0; |
@@ -705,68 +753,161 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
705 | * these as simple inline functions to avoid hair in drivers. | 753 | * these as simple inline functions to avoid hair in drivers. |
706 | */ | 754 | */ |
707 | 755 | ||
708 | #define _PCI_NOP(o,s,t) \ | 756 | #define _PCI_NOP(o, s, t) \ |
709 | static inline int pci_##o##_config_##s (struct pci_dev *dev, int where, t val) \ | 757 | static inline int pci_##o##_config_##s(struct pci_dev *dev, \ |
758 | int where, t val) \ | ||
710 | { return PCIBIOS_FUNC_NOT_SUPPORTED; } | 759 | { return PCIBIOS_FUNC_NOT_SUPPORTED; } |
711 | #define _PCI_NOP_ALL(o,x) _PCI_NOP(o,byte,u8 x) \ | 760 | |
712 | _PCI_NOP(o,word,u16 x) \ | 761 | #define _PCI_NOP_ALL(o, x) _PCI_NOP(o, byte, u8 x) \ |
713 | _PCI_NOP(o,dword,u32 x) | 762 | _PCI_NOP(o, word, u16 x) \ |
763 | _PCI_NOP(o, dword, u32 x) | ||
714 | _PCI_NOP_ALL(read, *) | 764 | _PCI_NOP_ALL(read, *) |
715 | _PCI_NOP_ALL(write,) | 765 | _PCI_NOP_ALL(write,) |
716 | 766 | ||
717 | static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from) | 767 | static inline struct pci_dev *pci_find_device(unsigned int vendor, |
718 | { return NULL; } | 768 | unsigned int device, |
769 | const struct pci_dev *from) | ||
770 | { | ||
771 | return NULL; | ||
772 | } | ||
719 | 773 | ||
720 | static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) | 774 | static inline struct pci_dev *pci_find_slot(unsigned int bus, |
721 | { return NULL; } | 775 | unsigned int devfn) |
776 | { | ||
777 | return NULL; | ||
778 | } | ||
722 | 779 | ||
723 | static inline struct pci_dev *pci_get_device(unsigned int vendor, | 780 | static inline struct pci_dev *pci_get_device(unsigned int vendor, |
724 | unsigned int device, struct pci_dev *from) | 781 | unsigned int device, |
725 | { return NULL; } | 782 | struct pci_dev *from) |
783 | { | ||
784 | return NULL; | ||
785 | } | ||
726 | 786 | ||
727 | static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor, | 787 | static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor, |
728 | unsigned int device, struct pci_dev *from) | 788 | unsigned int device, |
729 | { return NULL; } | 789 | struct pci_dev *from) |
790 | { | ||
791 | return NULL; | ||
792 | } | ||
730 | 793 | ||
731 | static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, | 794 | static inline struct pci_dev *pci_get_subsys(unsigned int vendor, |
732 | unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) | 795 | unsigned int device, |
733 | { return NULL; } | 796 | unsigned int ss_vendor, |
797 | unsigned int ss_device, | ||
798 | struct pci_dev *from) | ||
799 | { | ||
800 | return NULL; | ||
801 | } | ||
734 | 802 | ||
735 | static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) | 803 | static inline struct pci_dev *pci_get_class(unsigned int class, |
736 | { return NULL; } | 804 | struct pci_dev *from) |
805 | { | ||
806 | return NULL; | ||
807 | } | ||
737 | 808 | ||
738 | #define pci_dev_present(ids) (0) | 809 | #define pci_dev_present(ids) (0) |
739 | #define no_pci_devices() (1) | 810 | #define no_pci_devices() (1) |
740 | #define pci_find_present(ids) (NULL) | 811 | #define pci_find_present(ids) (NULL) |
741 | #define pci_dev_put(dev) do { } while (0) | 812 | #define pci_dev_put(dev) do { } while (0) |
742 | 813 | ||
743 | static inline void pci_set_master(struct pci_dev *dev) { } | 814 | static inline void pci_set_master(struct pci_dev *dev) |
744 | static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } | 815 | { } |
745 | static inline void pci_disable_device(struct pci_dev *dev) { } | 816 | |
746 | static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } | 817 | static inline int pci_enable_device(struct pci_dev *dev) |
747 | static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} | 818 | { |
748 | static inline int __pci_register_driver(struct pci_driver *drv, struct module *owner) { return 0;} | 819 | return -EIO; |
749 | static inline int pci_register_driver(struct pci_driver *drv) { return 0;} | 820 | } |
750 | static inline void pci_unregister_driver(struct pci_driver *drv) { } | 821 | |
751 | static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } | 822 | static inline void pci_disable_device(struct pci_dev *dev) |
752 | static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } | 823 | { } |
753 | static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } | 824 | |
754 | static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; } | 825 | static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) |
826 | { | ||
827 | return -EIO; | ||
828 | } | ||
829 | |||
830 | static inline int pci_assign_resource(struct pci_dev *dev, int i) | ||
831 | { | ||
832 | return -EBUSY; | ||
833 | } | ||
834 | |||
835 | static inline int __pci_register_driver(struct pci_driver *drv, | ||
836 | struct module *owner) | ||
837 | { | ||
838 | return 0; | ||
839 | } | ||
840 | |||
841 | static inline int pci_register_driver(struct pci_driver *drv) | ||
842 | { | ||
843 | return 0; | ||
844 | } | ||
845 | |||
846 | static inline void pci_unregister_driver(struct pci_driver *drv) | ||
847 | { } | ||
848 | |||
849 | static inline int pci_find_capability(struct pci_dev *dev, int cap) | ||
850 | { | ||
851 | return 0; | ||
852 | } | ||
853 | |||
854 | static inline int pci_find_next_capability(struct pci_dev *dev, u8 post, | ||
855 | int cap) | ||
856 | { | ||
857 | return 0; | ||
858 | } | ||
859 | |||
860 | static inline int pci_find_ext_capability(struct pci_dev *dev, int cap) | ||
861 | { | ||
862 | return 0; | ||
863 | } | ||
864 | |||
865 | static inline void pcie_wait_pending_transaction(struct pci_dev *dev) | ||
866 | { } | ||
755 | 867 | ||
756 | /* Power management related routines */ | 868 | /* Power management related routines */ |
757 | static inline int pci_save_state(struct pci_dev *dev) { return 0; } | 869 | static inline int pci_save_state(struct pci_dev *dev) |
758 | static inline int pci_restore_state(struct pci_dev *dev) { return 0; } | 870 | { |
759 | static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; } | 871 | return 0; |
760 | static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; } | 872 | } |
761 | static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } | 873 | |
874 | static inline int pci_restore_state(struct pci_dev *dev) | ||
875 | { | ||
876 | return 0; | ||
877 | } | ||
878 | |||
879 | static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) | ||
880 | { | ||
881 | return 0; | ||
882 | } | ||
883 | |||
884 | static inline pci_power_t pci_choose_state(struct pci_dev *dev, | ||
885 | pm_message_t state) | ||
886 | { | ||
887 | return PCI_D0; | ||
888 | } | ||
889 | |||
890 | static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, | ||
891 | int enable) | ||
892 | { | ||
893 | return 0; | ||
894 | } | ||
895 | |||
896 | static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) | ||
897 | { | ||
898 | return -EIO; | ||
899 | } | ||
762 | 900 | ||
763 | static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) { return -EIO; } | 901 | static inline void pci_release_regions(struct pci_dev *dev) |
764 | static inline void pci_release_regions(struct pci_dev *dev) { } | 902 | { } |
765 | 903 | ||
766 | #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) | 904 | #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) |
767 | 905 | ||
768 | static inline void pci_block_user_cfg_access(struct pci_dev *dev) { } | 906 | static inline void pci_block_user_cfg_access(struct pci_dev *dev) |
769 | static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) { } | 907 | { } |
908 | |||
909 | static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) | ||
910 | { } | ||
770 | 911 | ||
771 | static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) | 912 | static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) |
772 | { return NULL; } | 913 | { return NULL; } |
@@ -787,27 +928,27 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | |||
787 | 928 | ||
788 | /* these helpers provide future and backwards compatibility | 929 | /* these helpers provide future and backwards compatibility |
789 | * for accessing popular PCI BAR info */ | 930 | * for accessing popular PCI BAR info */ |
790 | #define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) | 931 | #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) |
791 | #define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) | 932 | #define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) |
792 | #define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) | 933 | #define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) |
793 | #define pci_resource_len(dev,bar) \ | 934 | #define pci_resource_len(dev,bar) \ |
794 | ((pci_resource_start((dev),(bar)) == 0 && \ | 935 | ((pci_resource_start((dev), (bar)) == 0 && \ |
795 | pci_resource_end((dev),(bar)) == \ | 936 | pci_resource_end((dev), (bar)) == \ |
796 | pci_resource_start((dev),(bar))) ? 0 : \ | 937 | pci_resource_start((dev), (bar))) ? 0 : \ |
797 | \ | 938 | \ |
798 | (pci_resource_end((dev),(bar)) - \ | 939 | (pci_resource_end((dev), (bar)) - \ |
799 | pci_resource_start((dev),(bar)) + 1)) | 940 | pci_resource_start((dev), (bar)) + 1)) |
800 | 941 | ||
801 | /* Similar to the helpers above, these manipulate per-pci_dev | 942 | /* Similar to the helpers above, these manipulate per-pci_dev |
802 | * driver-specific data. They are really just a wrapper around | 943 | * driver-specific data. They are really just a wrapper around |
803 | * the generic device structure functions of these calls. | 944 | * the generic device structure functions of these calls. |
804 | */ | 945 | */ |
805 | static inline void *pci_get_drvdata (struct pci_dev *pdev) | 946 | static inline void *pci_get_drvdata(struct pci_dev *pdev) |
806 | { | 947 | { |
807 | return dev_get_drvdata(&pdev->dev); | 948 | return dev_get_drvdata(&pdev->dev); |
808 | } | 949 | } |
809 | 950 | ||
810 | static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) | 951 | static inline void pci_set_drvdata(struct pci_dev *pdev, void *data) |
811 | { | 952 | { |
812 | dev_set_drvdata(&pdev->dev, data); | 953 | dev_set_drvdata(&pdev->dev, data); |
813 | } | 954 | } |
@@ -826,7 +967,7 @@ static inline char *pci_name(struct pci_dev *pdev) | |||
826 | */ | 967 | */ |
827 | #ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER | 968 | #ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER |
828 | static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, | 969 | static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, |
829 | const struct resource *rsrc, resource_size_t *start, | 970 | const struct resource *rsrc, resource_size_t *start, |
830 | resource_size_t *end) | 971 | resource_size_t *end) |
831 | { | 972 | { |
832 | *start = rsrc->start; | 973 | *start = rsrc->start; |
@@ -857,7 +998,7 @@ enum pci_fixup_pass { | |||
857 | 998 | ||
858 | /* Anonymous variables would be nice... */ | 999 | /* Anonymous variables would be nice... */ |
859 | #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ | 1000 | #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ |
860 | static const struct pci_fixup __pci_fixup_##name __attribute_used__ \ | 1001 | static const struct pci_fixup __pci_fixup_##name __used \ |
861 | __attribute__((__section__(#section))) = { vendor, device, hook }; | 1002 | __attribute__((__section__(#section))) = { vendor, device, hook }; |
862 | #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ | 1003 | #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ |
863 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ | 1004 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ |
@@ -878,9 +1019,9 @@ enum pci_fixup_pass { | |||
878 | 1019 | ||
879 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1020 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
880 | 1021 | ||
881 | void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); | 1022 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); |
882 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); | 1023 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); |
883 | void __iomem * const * pcim_iomap_table(struct pci_dev *pdev); | 1024 | void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); |
884 | int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); | 1025 | int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); |
885 | void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); | 1026 | void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); |
886 | 1027 | ||