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.h91
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 */
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 */
@@ -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);
533void pci_read_bridge_bases(struct pci_bus *child); 552void pci_read_bridge_bases(struct pci_bus *child);
534struct resource *pci_find_parent_resource(const struct pci_dev *dev, 553struct resource *pci_find_parent_resource(const struct pci_dev *dev,
535 struct resource *res); 554 struct resource *res);
555u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin);
536int 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);
537extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 558extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
538extern void pci_dev_put(struct pci_dev *dev); 559extern void pci_dev_put(struct pci_dev *dev);
539extern void pci_remove_bus(struct pci_bus *b); 560extern void pci_remove_bus(struct pci_bus *b);
@@ -630,6 +651,7 @@ static inline int pci_is_managed(struct pci_dev *pdev)
630 651
631void pci_disable_device(struct pci_dev *dev); 652void pci_disable_device(struct pci_dev *dev);
632void pci_set_master(struct pci_dev *dev); 653void pci_set_master(struct pci_dev *dev);
654void pci_clear_master(struct pci_dev *dev);
633int 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);
634#define HAVE_PCI_SET_MWI 656#define HAVE_PCI_SET_MWI
635int __must_check pci_set_mwi(struct pci_dev *dev); 657int __must_check pci_set_mwi(struct pci_dev *dev);
@@ -648,7 +670,7 @@ int pcie_get_readrq(struct pci_dev *dev);
648int pcie_set_readrq(struct pci_dev *dev, int rq); 670int pcie_set_readrq(struct pci_dev *dev, int rq);
649int pci_reset_function(struct pci_dev *dev); 671int pci_reset_function(struct pci_dev *dev);
650int pci_execute_reset_function(struct pci_dev *dev); 672int pci_execute_reset_function(struct pci_dev *dev);
651void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 673void pci_update_resource(struct pci_dev *dev, int resno);
652int __must_check pci_assign_resource(struct pci_dev *dev, int i); 674int __must_check pci_assign_resource(struct pci_dev *dev, int i);
653int pci_select_bars(struct pci_dev *dev, unsigned long flags); 675int 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 */
676int 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);
677 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
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) */
679void pci_bus_assign_resources(struct pci_bus *bus); 706void pci_bus_assign_resources(struct pci_bus *bus);
680void pci_bus_size_bridges(struct pci_bus *bus); 707void 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
689int __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 *);
690void pci_release_regions(struct pci_dev *); 718void pci_release_regions(struct pci_dev *);
691int __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 *);
692void pci_release_region(struct pci_dev *, int); 721void pci_release_region(struct pci_dev *, int);
693int 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 *);
694void pci_release_selected_regions(struct pci_dev *, int); 724void 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
781static inline void pci_restore_msi_state(struct pci_dev *dev) 811static inline void pci_restore_msi_state(struct pci_dev *dev)
782{ } 812{ }
813static inline int pci_msi_enabled(void)
814{
815 return 0;
816}
783#else 817#else
784extern int pci_enable_msi(struct pci_dev *dev); 818extern int pci_enable_msi(struct pci_dev *dev);
785extern void pci_msi_shutdown(struct pci_dev *dev); 819extern void pci_msi_shutdown(struct pci_dev *dev);
@@ -790,6 +824,16 @@ extern void pci_msix_shutdown(struct pci_dev *dev);
790extern void pci_disable_msix(struct pci_dev *dev); 824extern void pci_disable_msix(struct pci_dev *dev);
791extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 825extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
792extern 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);
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) { }
1141static inline void pci_mmcfg_late_init(void) { } 1185static inline void pci_mmcfg_late_init(void) { }
1142#endif 1186#endif
1143 1187
1144#ifdef CONFIG_HAS_IOMEM 1188int pci_ext_cfg_avail(struct pci_dev *dev);
1145static inline void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) 1189
1146{ 1190void __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 */