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.h123
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 */
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))
@@ -916,6 +934,7 @@ void pci_disable_rom(struct pci_dev *pdev);
916void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); 934void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
917void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); 935void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
918size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size); 936size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size);
937void __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 */
921int pci_save_state(struct pci_dev *dev); 940int 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
1144extern int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec); 1163int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
1145extern 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);
1146extern void pci_msi_shutdown(struct pci_dev *dev); 1165void pci_msi_shutdown(struct pci_dev *dev);
1147extern void pci_disable_msi(struct pci_dev *dev); 1166void pci_disable_msi(struct pci_dev *dev);
1148extern int pci_msix_table_size(struct pci_dev *dev); 1167int pci_msix_table_size(struct pci_dev *dev);
1149extern int pci_enable_msix(struct pci_dev *dev, 1168int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
1150 struct msix_entry *entries, int nvec); 1169void pci_msix_shutdown(struct pci_dev *dev);
1151extern void pci_msix_shutdown(struct pci_dev *dev); 1170void pci_disable_msix(struct pci_dev *dev);
1152extern void pci_disable_msix(struct pci_dev *dev); 1171void msi_remove_pci_irq_vectors(struct pci_dev *dev);
1153extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 1172void pci_restore_msi_state(struct pci_dev *dev);
1154extern void pci_restore_msi_state(struct pci_dev *dev); 1173int pci_msi_enabled(void);
1155extern 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;
1167static inline int pcie_aspm_enabled(void) { return 0; } 1185static inline int pcie_aspm_enabled(void) { return 0; }
1168static inline bool pcie_aspm_support_enabled(void) { return false; } 1186static inline bool pcie_aspm_support_enabled(void) { return false; }
1169#else 1187#else
1170extern int pcie_aspm_enabled(void); 1188int pcie_aspm_enabled(void);
1171extern bool pcie_aspm_support_enabled(void); 1189bool 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}
1187static inline void pcie_ecrc_get_policy(char *str) {}; 1205static inline void pcie_ecrc_get_policy(char *str) {};
1188#else 1206#else
1189extern void pcie_set_ecrc_checking(struct pci_dev *dev); 1207void pcie_set_ecrc_checking(struct pci_dev *dev);
1190extern void pcie_ecrc_get_policy(char *str); 1208void 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);
1198void ht_destroy_irq(unsigned int irq); 1216void ht_destroy_irq(unsigned int irq);
1199#endif /* CONFIG_HT_IRQ */ 1217#endif /* CONFIG_HT_IRQ */
1200 1218
1201extern void pci_cfg_access_lock(struct pci_dev *dev); 1219void pci_cfg_access_lock(struct pci_dev *dev);
1202extern bool pci_cfg_access_trylock(struct pci_dev *dev); 1220bool pci_cfg_access_trylock(struct pci_dev *dev);
1203extern void pci_cfg_access_unlock(struct pci_dev *dev); 1221void 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 */
1226typedef 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,
1227 unsigned int command_bits, u32 flags); 1245 unsigned int command_bits, u32 flags);
1228extern void pci_register_set_vga_state(arch_set_vga_state_t func); 1246void 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,
1627int pcibios_add_device(struct pci_dev *dev); 1645int pcibios_add_device(struct pci_dev *dev);
1628 1646
1629#ifdef CONFIG_PCI_MMCONFIG 1647#ifdef CONFIG_PCI_MMCONFIG
1630extern void __init pci_mmcfg_early_init(void); 1648void __init pci_mmcfg_early_init(void);
1631extern void __init pci_mmcfg_late_init(void); 1649void __init pci_mmcfg_late_init(void);
1632#else 1650#else
1633static inline void pci_mmcfg_early_init(void) { } 1651static inline void pci_mmcfg_early_init(void) { }
1634static inline void pci_mmcfg_late_init(void) { } 1652static inline void pci_mmcfg_late_init(void) { }
@@ -1639,12 +1657,13 @@ int pci_ext_cfg_avail(void);
1639void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); 1657void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1640 1658
1641#ifdef CONFIG_PCI_IOV 1659#ifdef CONFIG_PCI_IOV
1642extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); 1660int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1643extern void pci_disable_sriov(struct pci_dev *dev); 1661void pci_disable_sriov(struct pci_dev *dev);
1644extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); 1662irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1645extern int pci_num_vf(struct pci_dev *dev); 1663int pci_num_vf(struct pci_dev *dev);
1646extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); 1664int pci_vfs_assigned(struct pci_dev *dev);
1647extern int pci_sriov_get_totalvfs(struct pci_dev *dev); 1665int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
1666int pci_sriov_get_totalvfs(struct pci_dev *dev);
1648#else 1667#else
1649static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) 1668static 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}
1683static inline int pci_vfs_assigned(struct pci_dev *dev)
1684{
1685 return 0;
1686}
1664static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) 1687static 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)
1675extern void pci_hp_create_module_link(struct pci_slot *pci_slot); 1698void pci_hp_create_module_link(struct pci_slot *pci_slot);
1676extern void pci_hp_remove_module_link(struct pci_slot *pci_slot); 1699void 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
1819struct device_node; 1842struct device_node;
1820extern void pci_set_of_node(struct pci_dev *dev); 1843void pci_set_of_node(struct pci_dev *dev);
1821extern void pci_release_of_node(struct pci_dev *dev); 1844void pci_release_of_node(struct pci_dev *dev);
1822extern void pci_set_bus_of_node(struct pci_bus *bus); 1845void pci_set_bus_of_node(struct pci_bus *bus);
1823extern void pci_release_bus_of_node(struct pci_bus *bus); 1846void pci_release_bus_of_node(struct pci_bus *bus);
1824 1847
1825/* Arch may override this (weak) */ 1848/* Arch may override this (weak) */
1826extern struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus); 1849struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
1827 1850
1828static inline struct device_node * 1851static inline struct device_node *
1829pci_device_to_OF_node(const struct pci_dev *pdev) 1852pci_device_to_OF_node(const struct pci_dev *pdev)