diff options
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r-- | include/linux/pci.h | 90 |
1 files changed, 62 insertions, 28 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 4bb156ba854a..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 | */ |
@@ -532,7 +552,9 @@ int __must_check pci_bus_add_device(struct pci_dev *dev); | |||
532 | void pci_read_bridge_bases(struct pci_bus *child); | 552 | void pci_read_bridge_bases(struct pci_bus *child); |
533 | struct resource *pci_find_parent_resource(const struct pci_dev *dev, | 553 | struct resource *pci_find_parent_resource(const struct pci_dev *dev, |
534 | struct resource *res); | 554 | struct resource *res); |
555 | u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin); | ||
535 | 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); | ||
536 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); | 558 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); |
537 | extern void pci_dev_put(struct pci_dev *dev); | 559 | extern void pci_dev_put(struct pci_dev *dev); |
538 | extern void pci_remove_bus(struct pci_bus *b); | 560 | extern void pci_remove_bus(struct pci_bus *b); |
@@ -629,6 +651,7 @@ static inline int pci_is_managed(struct pci_dev *pdev) | |||
629 | 651 | ||
630 | void pci_disable_device(struct pci_dev *dev); | 652 | void pci_disable_device(struct pci_dev *dev); |
631 | 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); | ||
632 | 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); |
633 | #define HAVE_PCI_SET_MWI | 656 | #define HAVE_PCI_SET_MWI |
634 | int __must_check pci_set_mwi(struct pci_dev *dev); | 657 | int __must_check pci_set_mwi(struct pci_dev *dev); |
@@ -647,7 +670,7 @@ int pcie_get_readrq(struct pci_dev *dev); | |||
647 | int pcie_set_readrq(struct pci_dev *dev, int rq); | 670 | int pcie_set_readrq(struct pci_dev *dev, int rq); |
648 | int pci_reset_function(struct pci_dev *dev); | 671 | int pci_reset_function(struct pci_dev *dev); |
649 | int pci_execute_reset_function(struct pci_dev *dev); | 672 | int pci_execute_reset_function(struct pci_dev *dev); |
650 | void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); | 673 | void pci_update_resource(struct pci_dev *dev, int resno); |
651 | 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); |
652 | int pci_select_bars(struct pci_dev *dev, unsigned long flags); | 675 | int pci_select_bars(struct pci_dev *dev, unsigned long flags); |
653 | 676 | ||
@@ -674,6 +697,11 @@ int pci_back_from_sleep(struct pci_dev *dev); | |||
674 | /* Functions for PCI Hotplug drivers to use */ | 697 | /* Functions for PCI Hotplug drivers to use */ |
675 | 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); |
676 | 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 | |||
677 | /* 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) */ |
678 | void pci_bus_assign_resources(struct pci_bus *bus); | 706 | void pci_bus_assign_resources(struct pci_bus *bus); |
679 | void pci_bus_size_bridges(struct pci_bus *bus); | 707 | void pci_bus_size_bridges(struct pci_bus *bus); |
@@ -686,10 +714,13 @@ void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), | |||
686 | int (*)(struct pci_dev *, u8, u8)); | 714 | int (*)(struct pci_dev *, u8, u8)); |
687 | #define HAVE_PCI_REQ_REGIONS 2 | 715 | #define HAVE_PCI_REQ_REGIONS 2 |
688 | 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 *); | ||
689 | void pci_release_regions(struct pci_dev *); | 718 | void pci_release_regions(struct pci_dev *); |
690 | 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 *); | ||
691 | void pci_release_region(struct pci_dev *, int); | 721 | void pci_release_region(struct pci_dev *, int); |
692 | 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 *); | ||
693 | void pci_release_selected_regions(struct pci_dev *, int); | 724 | void pci_release_selected_regions(struct pci_dev *, int); |
694 | 725 | ||
695 | /* drivers/pci/bus.c */ | 726 | /* drivers/pci/bus.c */ |
@@ -779,6 +810,10 @@ static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) | |||
779 | 810 | ||
780 | static inline void pci_restore_msi_state(struct pci_dev *dev) | 811 | static inline void pci_restore_msi_state(struct pci_dev *dev) |
781 | { } | 812 | { } |
813 | static inline int pci_msi_enabled(void) | ||
814 | { | ||
815 | return 0; | ||
816 | } | ||
782 | #else | 817 | #else |
783 | extern int pci_enable_msi(struct pci_dev *dev); | 818 | extern int pci_enable_msi(struct pci_dev *dev); |
784 | extern void pci_msi_shutdown(struct pci_dev *dev); | 819 | extern void pci_msi_shutdown(struct pci_dev *dev); |
@@ -789,6 +824,16 @@ extern void pci_msix_shutdown(struct pci_dev *dev); | |||
789 | extern void pci_disable_msix(struct pci_dev *dev); | 824 | extern void pci_disable_msix(struct pci_dev *dev); |
790 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); | 825 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); |
791 | 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); | ||
792 | #endif | 837 | #endif |
793 | 838 | ||
794 | #ifdef CONFIG_HT_IRQ | 839 | #ifdef CONFIG_HT_IRQ |
@@ -1140,20 +1185,9 @@ static inline void pci_mmcfg_early_init(void) { } | |||
1140 | static inline void pci_mmcfg_late_init(void) { } | 1185 | static inline void pci_mmcfg_late_init(void) { } |
1141 | #endif | 1186 | #endif |
1142 | 1187 | ||
1143 | #ifdef CONFIG_HAS_IOMEM | 1188 | int pci_ext_cfg_avail(struct pci_dev *dev); |
1144 | static inline void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) | 1189 | |
1145 | { | 1190 | void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); |
1146 | /* | ||
1147 | * Make sure the BAR is actually a memory resource, not an IO resource | ||
1148 | */ | ||
1149 | if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { | ||
1150 | WARN_ON(1); | ||
1151 | return NULL; | ||
1152 | } | ||
1153 | return ioremap_nocache(pci_resource_start(pdev, bar), | ||
1154 | pci_resource_len(pdev, bar)); | ||
1155 | } | ||
1156 | #endif | ||
1157 | 1191 | ||
1158 | #endif /* __KERNEL__ */ | 1192 | #endif /* __KERNEL__ */ |
1159 | #endif /* LINUX_PCI_H */ | 1193 | #endif /* LINUX_PCI_H */ |