diff options
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r-- | include/linux/pci.h | 123 |
1 files changed, 73 insertions, 50 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 2461033a7987..3a24e4ff3248 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 */ |
39 | struct pci_slot { | 54 | struct 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 | ||
351 | extern struct pci_dev *alloc_pci_dev(void); | 367 | struct 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 | */ |
507 | extern int raw_pci_read(unsigned int domain, unsigned int bus, | 523 | int 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); |
509 | extern int raw_pci_write(unsigned int domain, unsigned int bus, | 525 | int 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 | ||
512 | struct pci_bus_region { | 528 | struct 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 | ||
661 | extern void pcie_bus_configure_settings(struct pci_bus *bus, u8 smpss); | 677 | void pcie_bus_configure_settings(struct pci_bus *bus, u8 smpss); |
662 | 678 | ||
663 | enum pcie_bus_config_types { | 679 | enum 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. */ |
676 | extern struct list_head pci_root_buses; /* list of all known PCI buses */ | 692 | extern 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 */ |
678 | extern int no_pci_devices(void); | 694 | int no_pci_devices(void); |
679 | 695 | ||
680 | void pcibios_resource_survey_bus(struct pci_bus *bus); | 696 | void pcibios_resource_survey_bus(struct pci_bus *bus); |
697 | void pcibios_add_bus(struct pci_bus *bus); | ||
698 | void pcibios_remove_bus(struct pci_bus *bus); | ||
681 | void pcibios_fixup_bus(struct pci_bus *); | 699 | void pcibios_fixup_bus(struct pci_bus *); |
682 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); | 700 | int __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, | |||
699 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | 717 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, |
700 | struct pci_bus_region *region); | 718 | struct pci_bus_region *region); |
701 | void pcibios_scan_specific_bus(int busn); | 719 | void pcibios_scan_specific_bus(int busn); |
702 | extern struct pci_bus *pci_find_bus(int domain, int busnr); | 720 | struct pci_bus *pci_find_bus(int domain, int busnr); |
703 | void pci_bus_add_devices(const struct pci_bus *bus); | 721 | void pci_bus_add_devices(const struct pci_bus *bus); |
704 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, | 722 | struct 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, | |||
732 | u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin); | 750 | u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin); |
733 | int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); | 751 | int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); |
734 | u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp); | 752 | u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp); |
735 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); | 753 | struct pci_dev *pci_dev_get(struct pci_dev *dev); |
736 | extern void pci_dev_put(struct pci_dev *dev); | 754 | void pci_dev_put(struct pci_dev *dev); |
737 | extern void pci_remove_bus(struct pci_bus *b); | 755 | void pci_remove_bus(struct pci_bus *b); |
738 | extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); | 756 | void pci_stop_and_remove_bus_device(struct pci_dev *dev); |
739 | void pci_stop_root_bus(struct pci_bus *bus); | 757 | void pci_stop_root_bus(struct pci_bus *bus); |
740 | void pci_remove_root_bus(struct pci_bus *bus); | 758 | void pci_remove_root_bus(struct pci_bus *bus); |
741 | void pci_setup_cardbus(struct pci_bus *bus); | 759 | void pci_setup_cardbus(struct pci_bus *bus); |
742 | extern void pci_sort_breadthfirst(void); | 760 | void 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)) |
@@ -916,6 +934,7 @@ void pci_disable_rom(struct pci_dev *pdev); | |||
916 | void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); | 934 | void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); |
917 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); | 935 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); |
918 | size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size); | 936 | size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size); |
937 | void __iomem __must_check *pci_platform_rom(struct pci_dev *pdev, size_t *size); | ||
919 | 938 | ||
920 | /* Power management related routines */ | 939 | /* Power management related routines */ |
921 | int pci_save_state(struct pci_dev *dev); | 940 | int pci_save_state(struct pci_dev *dev); |
@@ -1141,18 +1160,17 @@ static inline int pci_msi_enabled(void) | |||
1141 | return 0; | 1160 | return 0; |
1142 | } | 1161 | } |
1143 | #else | 1162 | #else |
1144 | extern int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec); | 1163 | int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec); |
1145 | extern int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec); | 1164 | int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec); |
1146 | extern void pci_msi_shutdown(struct pci_dev *dev); | 1165 | void pci_msi_shutdown(struct pci_dev *dev); |
1147 | extern void pci_disable_msi(struct pci_dev *dev); | 1166 | void pci_disable_msi(struct pci_dev *dev); |
1148 | extern int pci_msix_table_size(struct pci_dev *dev); | 1167 | int pci_msix_table_size(struct pci_dev *dev); |
1149 | extern int pci_enable_msix(struct pci_dev *dev, | 1168 | int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec); |
1150 | struct msix_entry *entries, int nvec); | 1169 | void pci_msix_shutdown(struct pci_dev *dev); |
1151 | extern void pci_msix_shutdown(struct pci_dev *dev); | 1170 | void pci_disable_msix(struct pci_dev *dev); |
1152 | extern void pci_disable_msix(struct pci_dev *dev); | 1171 | void msi_remove_pci_irq_vectors(struct pci_dev *dev); |
1153 | extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); | 1172 | void pci_restore_msi_state(struct pci_dev *dev); |
1154 | extern void pci_restore_msi_state(struct pci_dev *dev); | 1173 | int pci_msi_enabled(void); |
1155 | extern int pci_msi_enabled(void); | ||
1156 | #endif | 1174 | #endif |
1157 | 1175 | ||
1158 | #ifdef CONFIG_PCIEPORTBUS | 1176 | #ifdef CONFIG_PCIEPORTBUS |
@@ -1167,8 +1185,8 @@ extern bool pcie_ports_auto; | |||
1167 | static inline int pcie_aspm_enabled(void) { return 0; } | 1185 | static inline int pcie_aspm_enabled(void) { return 0; } |
1168 | static inline bool pcie_aspm_support_enabled(void) { return false; } | 1186 | static inline bool pcie_aspm_support_enabled(void) { return false; } |
1169 | #else | 1187 | #else |
1170 | extern int pcie_aspm_enabled(void); | 1188 | int pcie_aspm_enabled(void); |
1171 | extern bool pcie_aspm_support_enabled(void); | 1189 | bool pcie_aspm_support_enabled(void); |
1172 | #endif | 1190 | #endif |
1173 | 1191 | ||
1174 | #ifdef CONFIG_PCIEAER | 1192 | #ifdef CONFIG_PCIEAER |
@@ -1186,8 +1204,8 @@ static inline void pcie_set_ecrc_checking(struct pci_dev *dev) | |||
1186 | } | 1204 | } |
1187 | static inline void pcie_ecrc_get_policy(char *str) {}; | 1205 | static inline void pcie_ecrc_get_policy(char *str) {}; |
1188 | #else | 1206 | #else |
1189 | extern void pcie_set_ecrc_checking(struct pci_dev *dev); | 1207 | void pcie_set_ecrc_checking(struct pci_dev *dev); |
1190 | extern void pcie_ecrc_get_policy(char *str); | 1208 | void pcie_ecrc_get_policy(char *str); |
1191 | #endif | 1209 | #endif |
1192 | 1210 | ||
1193 | #define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1) | 1211 | #define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1) |
@@ -1198,9 +1216,9 @@ int ht_create_irq(struct pci_dev *dev, int idx); | |||
1198 | void ht_destroy_irq(unsigned int irq); | 1216 | void ht_destroy_irq(unsigned int irq); |
1199 | #endif /* CONFIG_HT_IRQ */ | 1217 | #endif /* CONFIG_HT_IRQ */ |
1200 | 1218 | ||
1201 | extern void pci_cfg_access_lock(struct pci_dev *dev); | 1219 | void pci_cfg_access_lock(struct pci_dev *dev); |
1202 | extern bool pci_cfg_access_trylock(struct pci_dev *dev); | 1220 | bool pci_cfg_access_trylock(struct pci_dev *dev); |
1203 | extern void pci_cfg_access_unlock(struct pci_dev *dev); | 1221 | void pci_cfg_access_unlock(struct pci_dev *dev); |
1204 | 1222 | ||
1205 | /* | 1223 | /* |
1206 | * PCI domain support. Sometimes called PCI segment (eg by ACPI), | 1224 | * PCI domain support. Sometimes called PCI segment (eg by ACPI), |
@@ -1225,7 +1243,7 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
1225 | /* some architectures require additional setup to direct VGA traffic */ | 1243 | /* some architectures require additional setup to direct VGA traffic */ |
1226 | typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, | 1244 | typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, |
1227 | unsigned int command_bits, u32 flags); | 1245 | unsigned int command_bits, u32 flags); |
1228 | extern void pci_register_set_vga_state(arch_set_vga_state_t func); | 1246 | void pci_register_set_vga_state(arch_set_vga_state_t func); |
1229 | 1247 | ||
1230 | #else /* CONFIG_PCI is not enabled */ | 1248 | #else /* CONFIG_PCI is not enabled */ |
1231 | 1249 | ||
@@ -1627,8 +1645,8 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, | |||
1627 | int pcibios_add_device(struct pci_dev *dev); | 1645 | int pcibios_add_device(struct pci_dev *dev); |
1628 | 1646 | ||
1629 | #ifdef CONFIG_PCI_MMCONFIG | 1647 | #ifdef CONFIG_PCI_MMCONFIG |
1630 | extern void __init pci_mmcfg_early_init(void); | 1648 | void __init pci_mmcfg_early_init(void); |
1631 | extern void __init pci_mmcfg_late_init(void); | 1649 | void __init pci_mmcfg_late_init(void); |
1632 | #else | 1650 | #else |
1633 | static inline void pci_mmcfg_early_init(void) { } | 1651 | static inline void pci_mmcfg_early_init(void) { } |
1634 | static inline void pci_mmcfg_late_init(void) { } | 1652 | static inline void pci_mmcfg_late_init(void) { } |
@@ -1639,12 +1657,13 @@ int pci_ext_cfg_avail(void); | |||
1639 | void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); | 1657 | void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); |
1640 | 1658 | ||
1641 | #ifdef CONFIG_PCI_IOV | 1659 | #ifdef CONFIG_PCI_IOV |
1642 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 1660 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
1643 | extern void pci_disable_sriov(struct pci_dev *dev); | 1661 | void pci_disable_sriov(struct pci_dev *dev); |
1644 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); | 1662 | irqreturn_t pci_sriov_migration(struct pci_dev *dev); |
1645 | extern int pci_num_vf(struct pci_dev *dev); | 1663 | int pci_num_vf(struct pci_dev *dev); |
1646 | extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); | 1664 | int pci_vfs_assigned(struct pci_dev *dev); |
1647 | extern int pci_sriov_get_totalvfs(struct pci_dev *dev); | 1665 | int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); |
1666 | int pci_sriov_get_totalvfs(struct pci_dev *dev); | ||
1648 | #else | 1667 | #else |
1649 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) | 1668 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) |
1650 | { | 1669 | { |
@@ -1661,6 +1680,10 @@ static inline int pci_num_vf(struct pci_dev *dev) | |||
1661 | { | 1680 | { |
1662 | return 0; | 1681 | return 0; |
1663 | } | 1682 | } |
1683 | static inline int pci_vfs_assigned(struct pci_dev *dev) | ||
1684 | { | ||
1685 | return 0; | ||
1686 | } | ||
1664 | static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) | 1687 | static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) |
1665 | { | 1688 | { |
1666 | return 0; | 1689 | return 0; |
@@ -1672,8 +1695,8 @@ static inline int pci_sriov_get_totalvfs(struct pci_dev *dev) | |||
1672 | #endif | 1695 | #endif |
1673 | 1696 | ||
1674 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) | 1697 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) |
1675 | extern void pci_hp_create_module_link(struct pci_slot *pci_slot); | 1698 | void pci_hp_create_module_link(struct pci_slot *pci_slot); |
1676 | extern void pci_hp_remove_module_link(struct pci_slot *pci_slot); | 1699 | void pci_hp_remove_module_link(struct pci_slot *pci_slot); |
1677 | #endif | 1700 | #endif |
1678 | 1701 | ||
1679 | /** | 1702 | /** |
@@ -1817,13 +1840,13 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, | |||
1817 | /* PCI <-> OF binding helpers */ | 1840 | /* PCI <-> OF binding helpers */ |
1818 | #ifdef CONFIG_OF | 1841 | #ifdef CONFIG_OF |
1819 | struct device_node; | 1842 | struct device_node; |
1820 | extern void pci_set_of_node(struct pci_dev *dev); | 1843 | void pci_set_of_node(struct pci_dev *dev); |
1821 | extern void pci_release_of_node(struct pci_dev *dev); | 1844 | void pci_release_of_node(struct pci_dev *dev); |
1822 | extern void pci_set_bus_of_node(struct pci_bus *bus); | 1845 | void pci_set_bus_of_node(struct pci_bus *bus); |
1823 | extern void pci_release_bus_of_node(struct pci_bus *bus); | 1846 | void pci_release_bus_of_node(struct pci_bus *bus); |
1824 | 1847 | ||
1825 | /* Arch may override this (weak) */ | 1848 | /* Arch may override this (weak) */ |
1826 | extern struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus); | 1849 | struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); |
1827 | 1850 | ||
1828 | static inline struct device_node * | 1851 | static inline struct device_node * |
1829 | pci_device_to_OF_node(const struct pci_dev *pdev) | 1852 | pci_device_to_OF_node(const struct pci_dev *pdev) |