diff options
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r-- | include/linux/pci.h | 91 |
1 files changed, 62 insertions, 29 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 03b0b8c3c81b..80f8b8b65fde 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -82,7 +82,30 @@ enum pci_mmap_state { | |||
82 | #define PCI_DMA_FROMDEVICE 2 | 82 | #define PCI_DMA_FROMDEVICE 2 |
83 | #define PCI_DMA_NONE 3 | 83 | #define PCI_DMA_NONE 3 |
84 | 84 | ||
85 | #define DEVICE_COUNT_RESOURCE 12 | 85 | /* |
86 | * For PCI devices, the region numbers are assigned this way: | ||
87 | */ | ||
88 | enum { | ||
89 | /* #0-5: standard PCI resources */ | ||
90 | PCI_STD_RESOURCES, | ||
91 | PCI_STD_RESOURCE_END = 5, | ||
92 | |||
93 | /* #6: expansion ROM resource */ | ||
94 | PCI_ROM_RESOURCE, | ||
95 | |||
96 | /* resources assigned to buses behind the bridge */ | ||
97 | #define PCI_BRIDGE_RESOURCE_NUM 4 | ||
98 | |||
99 | PCI_BRIDGE_RESOURCES, | ||
100 | PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES + | ||
101 | PCI_BRIDGE_RESOURCE_NUM - 1, | ||
102 | |||
103 | /* total resources associated with a PCI device */ | ||
104 | PCI_NUM_RESOURCES, | ||
105 | |||
106 | /* preserve this for compatibility */ | ||
107 | DEVICE_COUNT_RESOURCE | ||
108 | }; | ||
86 | 109 | ||
87 | typedef int __bitwise pci_power_t; | 110 | typedef int __bitwise pci_power_t; |
88 | 111 | ||
@@ -274,18 +297,6 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev, | |||
274 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); | 297 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); |
275 | } | 298 | } |
276 | 299 | ||
277 | /* | ||
278 | * For PCI devices, the region numbers are assigned this way: | ||
279 | * | ||
280 | * 0-5 standard PCI regions | ||
281 | * 6 expansion ROM | ||
282 | * 7-10 bridges: address space assigned to buses behind the bridge | ||
283 | */ | ||
284 | |||
285 | #define PCI_ROM_RESOURCE 6 | ||
286 | #define PCI_BRIDGE_RESOURCES 7 | ||
287 | #define PCI_NUM_RESOURCES 11 | ||
288 | |||
289 | #ifndef PCI_BUS_NUM_RESOURCES | 300 | #ifndef PCI_BUS_NUM_RESOURCES |
290 | #define PCI_BUS_NUM_RESOURCES 16 | 301 | #define PCI_BUS_NUM_RESOURCES 16 |
291 | #endif | 302 | #endif |
@@ -325,6 +336,15 @@ struct pci_bus { | |||
325 | #define pci_bus_b(n) list_entry(n, struct pci_bus, node) | 336 | #define pci_bus_b(n) list_entry(n, struct pci_bus, node) |
326 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) | 337 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) |
327 | 338 | ||
339 | #ifdef CONFIG_PCI_MSI | ||
340 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) | ||
341 | { | ||
342 | return pci_dev->msi_enabled || pci_dev->msix_enabled; | ||
343 | } | ||
344 | #else | ||
345 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; } | ||
346 | #endif | ||
347 | |||
328 | /* | 348 | /* |
329 | * Error values that may be returned by PCI functions. | 349 | * Error values that may be returned by PCI functions. |
330 | */ | 350 | */ |
@@ -421,7 +441,6 @@ struct pci_driver { | |||
421 | int (*resume_early) (struct pci_dev *dev); | 441 | int (*resume_early) (struct pci_dev *dev); |
422 | int (*resume) (struct pci_dev *dev); /* Device woken up */ | 442 | int (*resume) (struct pci_dev *dev); /* Device woken up */ |
423 | void (*shutdown) (struct pci_dev *dev); | 443 | void (*shutdown) (struct pci_dev *dev); |
424 | struct pm_ext_ops *pm; | ||
425 | struct pci_error_handlers *err_handler; | 444 | struct pci_error_handlers *err_handler; |
426 | struct device_driver driver; | 445 | struct device_driver driver; |
427 | struct pci_dynids dynids; | 446 | struct pci_dynids dynids; |
@@ -533,7 +552,9 @@ int __must_check pci_bus_add_device(struct pci_dev *dev); | |||
533 | void pci_read_bridge_bases(struct pci_bus *child); | 552 | void pci_read_bridge_bases(struct pci_bus *child); |
534 | struct resource *pci_find_parent_resource(const struct pci_dev *dev, | 553 | struct resource *pci_find_parent_resource(const struct pci_dev *dev, |
535 | struct resource *res); | 554 | struct resource *res); |
555 | u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin); | ||
536 | int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); | 556 | int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); |
557 | u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp); | ||
537 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); | 558 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); |
538 | extern void pci_dev_put(struct pci_dev *dev); | 559 | extern void pci_dev_put(struct pci_dev *dev); |
539 | extern void pci_remove_bus(struct pci_bus *b); | 560 | extern void pci_remove_bus(struct pci_bus *b); |
@@ -630,6 +651,7 @@ static inline int pci_is_managed(struct pci_dev *pdev) | |||
630 | 651 | ||
631 | void pci_disable_device(struct pci_dev *dev); | 652 | void pci_disable_device(struct pci_dev *dev); |
632 | void pci_set_master(struct pci_dev *dev); | 653 | void pci_set_master(struct pci_dev *dev); |
654 | void pci_clear_master(struct pci_dev *dev); | ||
633 | int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); | 655 | int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); |
634 | #define HAVE_PCI_SET_MWI | 656 | #define HAVE_PCI_SET_MWI |
635 | int __must_check pci_set_mwi(struct pci_dev *dev); | 657 | int __must_check pci_set_mwi(struct pci_dev *dev); |
@@ -648,7 +670,7 @@ int pcie_get_readrq(struct pci_dev *dev); | |||
648 | int pcie_set_readrq(struct pci_dev *dev, int rq); | 670 | int pcie_set_readrq(struct pci_dev *dev, int rq); |
649 | int pci_reset_function(struct pci_dev *dev); | 671 | int pci_reset_function(struct pci_dev *dev); |
650 | int pci_execute_reset_function(struct pci_dev *dev); | 672 | int pci_execute_reset_function(struct pci_dev *dev); |
651 | void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); | 673 | void pci_update_resource(struct pci_dev *dev, int resno); |
652 | int __must_check pci_assign_resource(struct pci_dev *dev, int i); | 674 | int __must_check pci_assign_resource(struct pci_dev *dev, int i); |
653 | int pci_select_bars(struct pci_dev *dev, unsigned long flags); | 675 | int pci_select_bars(struct pci_dev *dev, unsigned long flags); |
654 | 676 | ||
@@ -675,6 +697,11 @@ int pci_back_from_sleep(struct pci_dev *dev); | |||
675 | /* Functions for PCI Hotplug drivers to use */ | 697 | /* Functions for PCI Hotplug drivers to use */ |
676 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); | 698 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); |
677 | 699 | ||
700 | /* Vital product data routines */ | ||
701 | ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf); | ||
702 | ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf); | ||
703 | int pci_vpd_truncate(struct pci_dev *dev, size_t size); | ||
704 | |||
678 | /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ | 705 | /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ |
679 | void pci_bus_assign_resources(struct pci_bus *bus); | 706 | void pci_bus_assign_resources(struct pci_bus *bus); |
680 | void pci_bus_size_bridges(struct pci_bus *bus); | 707 | void pci_bus_size_bridges(struct pci_bus *bus); |
@@ -687,10 +714,13 @@ void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), | |||
687 | int (*)(struct pci_dev *, u8, u8)); | 714 | int (*)(struct pci_dev *, u8, u8)); |
688 | #define HAVE_PCI_REQ_REGIONS 2 | 715 | #define HAVE_PCI_REQ_REGIONS 2 |
689 | int __must_check pci_request_regions(struct pci_dev *, const char *); | 716 | int __must_check pci_request_regions(struct pci_dev *, const char *); |
717 | int __must_check pci_request_regions_exclusive(struct pci_dev *, const char *); | ||
690 | void pci_release_regions(struct pci_dev *); | 718 | void pci_release_regions(struct pci_dev *); |
691 | int __must_check pci_request_region(struct pci_dev *, int, const char *); | 719 | int __must_check pci_request_region(struct pci_dev *, int, const char *); |
720 | int __must_check pci_request_region_exclusive(struct pci_dev *, int, const char *); | ||
692 | void pci_release_region(struct pci_dev *, int); | 721 | void pci_release_region(struct pci_dev *, int); |
693 | int pci_request_selected_regions(struct pci_dev *, int, const char *); | 722 | int pci_request_selected_regions(struct pci_dev *, int, const char *); |
723 | int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *); | ||
694 | void pci_release_selected_regions(struct pci_dev *, int); | 724 | void pci_release_selected_regions(struct pci_dev *, int); |
695 | 725 | ||
696 | /* drivers/pci/bus.c */ | 726 | /* drivers/pci/bus.c */ |
@@ -780,6 +810,10 @@ static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) | |||
780 | 810 | ||
781 | static inline void pci_restore_msi_state(struct pci_dev *dev) | 811 | static inline void pci_restore_msi_state(struct pci_dev *dev) |
782 | { } | 812 | { } |
813 | static inline int pci_msi_enabled(void) | ||
814 | { | ||
815 | return 0; | ||
816 | } | ||
783 | #else | 817 | #else |
784 | extern int pci_enable_msi(struct pci_dev *dev); | 818 | extern int pci_enable_msi(struct pci_dev *dev); |
785 | extern void pci_msi_shutdown(struct pci_dev *dev); | 819 | extern void pci_msi_shutdown(struct pci_dev *dev); |
@@ -790,6 +824,16 @@ extern void pci_msix_shutdown(struct pci_dev *dev); | |||
790 | extern void pci_disable_msix(struct pci_dev *dev); | 824 | extern void pci_disable_msix(struct pci_dev *dev); |
791 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); | 825 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); |
792 | extern void pci_restore_msi_state(struct pci_dev *dev); | 826 | extern void pci_restore_msi_state(struct pci_dev *dev); |
827 | extern int pci_msi_enabled(void); | ||
828 | #endif | ||
829 | |||
830 | #ifndef CONFIG_PCIEASPM | ||
831 | static inline int pcie_aspm_enabled(void) | ||
832 | { | ||
833 | return 0; | ||
834 | } | ||
835 | #else | ||
836 | extern int pcie_aspm_enabled(void); | ||
793 | #endif | 837 | #endif |
794 | 838 | ||
795 | #ifdef CONFIG_HT_IRQ | 839 | #ifdef CONFIG_HT_IRQ |
@@ -1141,20 +1185,9 @@ static inline void pci_mmcfg_early_init(void) { } | |||
1141 | static inline void pci_mmcfg_late_init(void) { } | 1185 | static inline void pci_mmcfg_late_init(void) { } |
1142 | #endif | 1186 | #endif |
1143 | 1187 | ||
1144 | #ifdef CONFIG_HAS_IOMEM | 1188 | int pci_ext_cfg_avail(struct pci_dev *dev); |
1145 | static inline void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) | 1189 | |
1146 | { | 1190 | void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); |
1147 | /* | ||
1148 | * Make sure the BAR is actually a memory resource, not an IO resource | ||
1149 | */ | ||
1150 | if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { | ||
1151 | WARN_ON(1); | ||
1152 | return NULL; | ||
1153 | } | ||
1154 | return ioremap_nocache(pci_resource_start(pdev, bar), | ||
1155 | pci_resource_len(pdev, bar)); | ||
1156 | } | ||
1157 | #endif | ||
1158 | 1191 | ||
1159 | #endif /* __KERNEL__ */ | 1192 | #endif /* __KERNEL__ */ |
1160 | #endif /* LINUX_PCI_H */ | 1193 | #endif /* LINUX_PCI_H */ |