aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h90
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 */
88enum {
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
87typedef int __bitwise pci_power_t; 110typedef 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
340static 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
345static 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);
532void pci_read_bridge_bases(struct pci_bus *child); 552void pci_read_bridge_bases(struct pci_bus *child);
533struct resource *pci_find_parent_resource(const struct pci_dev *dev, 553struct resource *pci_find_parent_resource(const struct pci_dev *dev,
534 struct resource *res); 554 struct resource *res);
555u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin);
535int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); 556int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
557u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
536extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 558extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
537extern void pci_dev_put(struct pci_dev *dev); 559extern void pci_dev_put(struct pci_dev *dev);
538extern void pci_remove_bus(struct pci_bus *b); 560extern void pci_remove_bus(struct pci_bus *b);
@@ -629,6 +651,7 @@ static inline int pci_is_managed(struct pci_dev *pdev)
629 651
630void pci_disable_device(struct pci_dev *dev); 652void pci_disable_device(struct pci_dev *dev);
631void pci_set_master(struct pci_dev *dev); 653void pci_set_master(struct pci_dev *dev);
654void pci_clear_master(struct pci_dev *dev);
632int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); 655int 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
634int __must_check pci_set_mwi(struct pci_dev *dev); 657int __must_check pci_set_mwi(struct pci_dev *dev);
@@ -647,7 +670,7 @@ int pcie_get_readrq(struct pci_dev *dev);
647int pcie_set_readrq(struct pci_dev *dev, int rq); 670int pcie_set_readrq(struct pci_dev *dev, int rq);
648int pci_reset_function(struct pci_dev *dev); 671int pci_reset_function(struct pci_dev *dev);
649int pci_execute_reset_function(struct pci_dev *dev); 672int pci_execute_reset_function(struct pci_dev *dev);
650void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 673void pci_update_resource(struct pci_dev *dev, int resno);
651int __must_check pci_assign_resource(struct pci_dev *dev, int i); 674int __must_check pci_assign_resource(struct pci_dev *dev, int i);
652int pci_select_bars(struct pci_dev *dev, unsigned long flags); 675int 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 */
675int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); 698int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
676 699
700/* Vital product data routines */
701ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
702ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
703int 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) */
678void pci_bus_assign_resources(struct pci_bus *bus); 706void pci_bus_assign_resources(struct pci_bus *bus);
679void pci_bus_size_bridges(struct pci_bus *bus); 707void 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
688int __must_check pci_request_regions(struct pci_dev *, const char *); 716int __must_check pci_request_regions(struct pci_dev *, const char *);
717int __must_check pci_request_regions_exclusive(struct pci_dev *, const char *);
689void pci_release_regions(struct pci_dev *); 718void pci_release_regions(struct pci_dev *);
690int __must_check pci_request_region(struct pci_dev *, int, const char *); 719int __must_check pci_request_region(struct pci_dev *, int, const char *);
720int __must_check pci_request_region_exclusive(struct pci_dev *, int, const char *);
691void pci_release_region(struct pci_dev *, int); 721void pci_release_region(struct pci_dev *, int);
692int pci_request_selected_regions(struct pci_dev *, int, const char *); 722int pci_request_selected_regions(struct pci_dev *, int, const char *);
723int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
693void pci_release_selected_regions(struct pci_dev *, int); 724void 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
780static inline void pci_restore_msi_state(struct pci_dev *dev) 811static inline void pci_restore_msi_state(struct pci_dev *dev)
781{ } 812{ }
813static inline int pci_msi_enabled(void)
814{
815 return 0;
816}
782#else 817#else
783extern int pci_enable_msi(struct pci_dev *dev); 818extern int pci_enable_msi(struct pci_dev *dev);
784extern void pci_msi_shutdown(struct pci_dev *dev); 819extern void pci_msi_shutdown(struct pci_dev *dev);
@@ -789,6 +824,16 @@ extern void pci_msix_shutdown(struct pci_dev *dev);
789extern void pci_disable_msix(struct pci_dev *dev); 824extern void pci_disable_msix(struct pci_dev *dev);
790extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 825extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
791extern void pci_restore_msi_state(struct pci_dev *dev); 826extern void pci_restore_msi_state(struct pci_dev *dev);
827extern int pci_msi_enabled(void);
828#endif
829
830#ifndef CONFIG_PCIEASPM
831static inline int pcie_aspm_enabled(void)
832{
833 return 0;
834}
835#else
836extern 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) { }
1140static inline void pci_mmcfg_late_init(void) { } 1185static inline void pci_mmcfg_late_init(void) { }
1141#endif 1186#endif
1142 1187
1143#ifdef CONFIG_HAS_IOMEM 1188int pci_ext_cfg_avail(struct pci_dev *dev);
1144static inline void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) 1189
1145{ 1190void __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 */