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.h117
1 files changed, 67 insertions, 50 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 710067f3618c..e73dfa308b87 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -35,6 +35,21 @@
35/* Include the ID list */ 35/* Include the ID list */
36#include <linux/pci_ids.h> 36#include <linux/pci_ids.h>
37 37
38/*
39 * The PCI interface treats multi-function devices as independent
40 * devices. The slot/function address of each device is encoded
41 * in a single byte as follows:
42 *
43 * 7:3 = slot
44 * 2:0 = function
45 * PCI_DEVFN(), PCI_SLOT(), and PCI_FUNC() are defined uapi/linux/pci.h
46 * In the interest of not exposing interfaces to user-space unnecessarily,
47 * the following kernel only defines are being added here.
48 */
49#define PCI_DEVID(bus, devfn) ((((u16)bus) << 8) | devfn)
50/* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
51#define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
52
38/* pci_slot represents a physical slot */ 53/* pci_slot represents a physical slot */
39struct pci_slot { 54struct pci_slot {
40 struct pci_bus *bus; /* The bus this slot is on */ 55 struct pci_bus *bus; /* The bus this slot is on */
@@ -232,6 +247,8 @@ struct pci_dev {
232 u8 revision; /* PCI revision, low byte of class word */ 247 u8 revision; /* PCI revision, low byte of class word */
233 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 248 u8 hdr_type; /* PCI header type (`multi' flag masked out) */
234 u8 pcie_cap; /* PCI-E capability offset */ 249 u8 pcie_cap; /* PCI-E capability offset */
250 u8 msi_cap; /* MSI capability offset */
251 u8 msix_cap; /* MSI-X capability offset */
235 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */ 252 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */
236 u8 rom_base_reg; /* which config register controls the ROM */ 253 u8 rom_base_reg; /* which config register controls the ROM */
237 u8 pin; /* which interrupt pin this device uses */ 254 u8 pin; /* which interrupt pin this device uses */
@@ -249,8 +266,7 @@ struct pci_dev {
249 pci_power_t current_state; /* Current operating state. In ACPI-speak, 266 pci_power_t current_state; /* Current operating state. In ACPI-speak,
250 this is D0-D3, D0 being fully functional, 267 this is D0-D3, D0 being fully functional,
251 and D3 being off. */ 268 and D3 being off. */
252 int pm_cap; /* PM capability offset in the 269 u8 pm_cap; /* PM capability offset */
253 configuration space */
254 unsigned int pme_support:5; /* Bitmask of states from which PME# 270 unsigned int pme_support:5; /* Bitmask of states from which PME#
255 can be generated */ 271 can be generated */
256 unsigned int pme_interrupt:1; 272 unsigned int pme_interrupt:1;
@@ -348,7 +364,7 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
348 return dev; 364 return dev;
349} 365}
350 366
351extern struct pci_dev *alloc_pci_dev(void); 367struct pci_dev *alloc_pci_dev(void);
352 368
353#define to_pci_dev(n) container_of(n, struct pci_dev, dev) 369#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
354#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) 370#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
@@ -504,10 +520,10 @@ struct pci_ops {
504 * ACPI needs to be able to access PCI config space before we've done a 520 * ACPI needs to be able to access PCI config space before we've done a
505 * PCI bus scan and created pci_bus structures. 521 * PCI bus scan and created pci_bus structures.
506 */ 522 */
507extern int raw_pci_read(unsigned int domain, unsigned int bus, 523int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
508 unsigned int devfn, int reg, int len, u32 *val); 524 int reg, int len, u32 *val);
509extern int raw_pci_write(unsigned int domain, unsigned int bus, 525int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
510 unsigned int devfn, int reg, int len, u32 val); 526 int reg, int len, u32 val);
511 527
512struct pci_bus_region { 528struct pci_bus_region {
513 resource_size_t start; 529 resource_size_t start;
@@ -658,7 +674,7 @@ struct pci_driver {
658/* these external functions are only available when PCI support is enabled */ 674/* these external functions are only available when PCI support is enabled */
659#ifdef CONFIG_PCI 675#ifdef CONFIG_PCI
660 676
661extern void pcie_bus_configure_settings(struct pci_bus *bus, u8 smpss); 677void pcie_bus_configure_settings(struct pci_bus *bus, u8 smpss);
662 678
663enum pcie_bus_config_types { 679enum pcie_bus_config_types {
664 PCIE_BUS_TUNE_OFF, 680 PCIE_BUS_TUNE_OFF,
@@ -675,9 +691,11 @@ extern struct bus_type pci_bus_type;
675 * code, or pci core code. */ 691 * code, or pci core code. */
676extern struct list_head pci_root_buses; /* list of all known PCI buses */ 692extern struct list_head pci_root_buses; /* list of all known PCI buses */
677/* Some device drivers need know if pci is initiated */ 693/* Some device drivers need know if pci is initiated */
678extern int no_pci_devices(void); 694int no_pci_devices(void);
679 695
680void pcibios_resource_survey_bus(struct pci_bus *bus); 696void pcibios_resource_survey_bus(struct pci_bus *bus);
697void pcibios_add_bus(struct pci_bus *bus);
698void pcibios_remove_bus(struct pci_bus *bus);
681void pcibios_fixup_bus(struct pci_bus *); 699void pcibios_fixup_bus(struct pci_bus *);
682int __must_check pcibios_enable_device(struct pci_dev *, int mask); 700int __must_check pcibios_enable_device(struct pci_dev *, int mask);
683/* Architecture specific versions may override this (weak) */ 701/* Architecture specific versions may override this (weak) */
@@ -699,7 +717,7 @@ void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
699void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 717void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
700 struct pci_bus_region *region); 718 struct pci_bus_region *region);
701void pcibios_scan_specific_bus(int busn); 719void pcibios_scan_specific_bus(int busn);
702extern struct pci_bus *pci_find_bus(int domain, int busnr); 720struct pci_bus *pci_find_bus(int domain, int busnr);
703void pci_bus_add_devices(const struct pci_bus *bus); 721void pci_bus_add_devices(const struct pci_bus *bus);
704struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, 722struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
705 struct pci_ops *ops, void *sysdata); 723 struct pci_ops *ops, void *sysdata);
@@ -732,14 +750,14 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev,
732u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin); 750u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin);
733int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); 751int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
734u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp); 752u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
735extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 753struct pci_dev *pci_dev_get(struct pci_dev *dev);
736extern void pci_dev_put(struct pci_dev *dev); 754void pci_dev_put(struct pci_dev *dev);
737extern void pci_remove_bus(struct pci_bus *b); 755void pci_remove_bus(struct pci_bus *b);
738extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); 756void pci_stop_and_remove_bus_device(struct pci_dev *dev);
739void pci_stop_root_bus(struct pci_bus *bus); 757void pci_stop_root_bus(struct pci_bus *bus);
740void pci_remove_root_bus(struct pci_bus *bus); 758void pci_remove_root_bus(struct pci_bus *bus);
741void pci_setup_cardbus(struct pci_bus *bus); 759void pci_setup_cardbus(struct pci_bus *bus);
742extern void pci_sort_breadthfirst(void); 760void pci_sort_breadthfirst(void);
743#define dev_is_pci(d) ((d)->bus == &pci_bus_type) 761#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
744#define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false)) 762#define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
745#define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0)) 763#define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
@@ -1142,18 +1160,17 @@ static inline int pci_msi_enabled(void)
1142 return 0; 1160 return 0;
1143} 1161}
1144#else 1162#else
1145extern int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec); 1163int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
1146extern int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec); 1164int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec);
1147extern void pci_msi_shutdown(struct pci_dev *dev); 1165void pci_msi_shutdown(struct pci_dev *dev);
1148extern void pci_disable_msi(struct pci_dev *dev); 1166void pci_disable_msi(struct pci_dev *dev);
1149extern int pci_msix_table_size(struct pci_dev *dev); 1167int pci_msix_table_size(struct pci_dev *dev);
1150extern int pci_enable_msix(struct pci_dev *dev, 1168int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
1151 struct msix_entry *entries, int nvec); 1169void pci_msix_shutdown(struct pci_dev *dev);
1152extern void pci_msix_shutdown(struct pci_dev *dev); 1170void pci_disable_msix(struct pci_dev *dev);
1153extern void pci_disable_msix(struct pci_dev *dev); 1171void msi_remove_pci_irq_vectors(struct pci_dev *dev);
1154extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 1172void pci_restore_msi_state(struct pci_dev *dev);
1155extern void pci_restore_msi_state(struct pci_dev *dev); 1173int pci_msi_enabled(void);
1156extern int pci_msi_enabled(void);
1157#endif 1174#endif
1158 1175
1159#ifdef CONFIG_PCIEPORTBUS 1176#ifdef CONFIG_PCIEPORTBUS
@@ -1168,8 +1185,8 @@ extern bool pcie_ports_auto;
1168static inline int pcie_aspm_enabled(void) { return 0; } 1185static inline int pcie_aspm_enabled(void) { return 0; }
1169static inline bool pcie_aspm_support_enabled(void) { return false; } 1186static inline bool pcie_aspm_support_enabled(void) { return false; }
1170#else 1187#else
1171extern int pcie_aspm_enabled(void); 1188int pcie_aspm_enabled(void);
1172extern bool pcie_aspm_support_enabled(void); 1189bool pcie_aspm_support_enabled(void);
1173#endif 1190#endif
1174 1191
1175#ifdef CONFIG_PCIEAER 1192#ifdef CONFIG_PCIEAER
@@ -1187,8 +1204,8 @@ static inline void pcie_set_ecrc_checking(struct pci_dev *dev)
1187} 1204}
1188static inline void pcie_ecrc_get_policy(char *str) {}; 1205static inline void pcie_ecrc_get_policy(char *str) {};
1189#else 1206#else
1190extern void pcie_set_ecrc_checking(struct pci_dev *dev); 1207void pcie_set_ecrc_checking(struct pci_dev *dev);
1191extern void pcie_ecrc_get_policy(char *str); 1208void pcie_ecrc_get_policy(char *str);
1192#endif 1209#endif
1193 1210
1194#define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1) 1211#define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1)
@@ -1199,9 +1216,9 @@ int ht_create_irq(struct pci_dev *dev, int idx);
1199void ht_destroy_irq(unsigned int irq); 1216void ht_destroy_irq(unsigned int irq);
1200#endif /* CONFIG_HT_IRQ */ 1217#endif /* CONFIG_HT_IRQ */
1201 1218
1202extern void pci_cfg_access_lock(struct pci_dev *dev); 1219void pci_cfg_access_lock(struct pci_dev *dev);
1203extern bool pci_cfg_access_trylock(struct pci_dev *dev); 1220bool pci_cfg_access_trylock(struct pci_dev *dev);
1204extern void pci_cfg_access_unlock(struct pci_dev *dev); 1221void pci_cfg_access_unlock(struct pci_dev *dev);
1205 1222
1206/* 1223/*
1207 * PCI domain support. Sometimes called PCI segment (eg by ACPI), 1224 * PCI domain support. Sometimes called PCI segment (eg by ACPI),
@@ -1226,7 +1243,7 @@ static inline int pci_proc_domain(struct pci_bus *bus)
1226/* some architectures require additional setup to direct VGA traffic */ 1243/* some architectures require additional setup to direct VGA traffic */
1227typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, 1244typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode,
1228 unsigned int command_bits, u32 flags); 1245 unsigned int command_bits, u32 flags);
1229extern void pci_register_set_vga_state(arch_set_vga_state_t func); 1246void pci_register_set_vga_state(arch_set_vga_state_t func);
1230 1247
1231#else /* CONFIG_PCI is not enabled */ 1248#else /* CONFIG_PCI is not enabled */
1232 1249
@@ -1628,8 +1645,8 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev,
1628int pcibios_add_device(struct pci_dev *dev); 1645int pcibios_add_device(struct pci_dev *dev);
1629 1646
1630#ifdef CONFIG_PCI_MMCONFIG 1647#ifdef CONFIG_PCI_MMCONFIG
1631extern void __init pci_mmcfg_early_init(void); 1648void __init pci_mmcfg_early_init(void);
1632extern void __init pci_mmcfg_late_init(void); 1649void __init pci_mmcfg_late_init(void);
1633#else 1650#else
1634static inline void pci_mmcfg_early_init(void) { } 1651static inline void pci_mmcfg_early_init(void) { }
1635static inline void pci_mmcfg_late_init(void) { } 1652static inline void pci_mmcfg_late_init(void) { }
@@ -1640,12 +1657,12 @@ int pci_ext_cfg_avail(void);
1640void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); 1657void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1641 1658
1642#ifdef CONFIG_PCI_IOV 1659#ifdef CONFIG_PCI_IOV
1643extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); 1660int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1644extern void pci_disable_sriov(struct pci_dev *dev); 1661void pci_disable_sriov(struct pci_dev *dev);
1645extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); 1662irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1646extern int pci_num_vf(struct pci_dev *dev); 1663int pci_num_vf(struct pci_dev *dev);
1647extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); 1664int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
1648extern int pci_sriov_get_totalvfs(struct pci_dev *dev); 1665int pci_sriov_get_totalvfs(struct pci_dev *dev);
1649#else 1666#else
1650static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) 1667static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
1651{ 1668{
@@ -1673,8 +1690,8 @@ static inline int pci_sriov_get_totalvfs(struct pci_dev *dev)
1673#endif 1690#endif
1674 1691
1675#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) 1692#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
1676extern void pci_hp_create_module_link(struct pci_slot *pci_slot); 1693void pci_hp_create_module_link(struct pci_slot *pci_slot);
1677extern void pci_hp_remove_module_link(struct pci_slot *pci_slot); 1694void pci_hp_remove_module_link(struct pci_slot *pci_slot);
1678#endif 1695#endif
1679 1696
1680/** 1697/**
@@ -1818,13 +1835,13 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
1818/* PCI <-> OF binding helpers */ 1835/* PCI <-> OF binding helpers */
1819#ifdef CONFIG_OF 1836#ifdef CONFIG_OF
1820struct device_node; 1837struct device_node;
1821extern void pci_set_of_node(struct pci_dev *dev); 1838void pci_set_of_node(struct pci_dev *dev);
1822extern void pci_release_of_node(struct pci_dev *dev); 1839void pci_release_of_node(struct pci_dev *dev);
1823extern void pci_set_bus_of_node(struct pci_bus *bus); 1840void pci_set_bus_of_node(struct pci_bus *bus);
1824extern void pci_release_bus_of_node(struct pci_bus *bus); 1841void pci_release_bus_of_node(struct pci_bus *bus);
1825 1842
1826/* Arch may override this (weak) */ 1843/* Arch may override this (weak) */
1827extern struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus); 1844struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
1828 1845
1829static inline struct device_node * 1846static inline struct device_node *
1830pci_device_to_OF_node(const struct pci_dev *pdev) 1847pci_device_to_OF_node(const struct pci_dev *pdev)