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.h84
1 files changed, 54 insertions, 30 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index f27be8432e82..33c2b0b77429 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -28,6 +28,7 @@
28#include <linux/kobject.h> 28#include <linux/kobject.h>
29#include <linux/atomic.h> 29#include <linux/atomic.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/interrupt.h>
31#include <linux/io.h> 32#include <linux/io.h>
32#include <linux/resource_ext.h> 33#include <linux/resource_ext.h>
33#include <uapi/linux/pci.h> 34#include <uapi/linux/pci.h>
@@ -178,6 +179,10 @@ enum pci_dev_flags {
178 PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7), 179 PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7),
179 /* Get VPD from function 0 VPD */ 180 /* Get VPD from function 0 VPD */
180 PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8), 181 PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8),
182 /* a non-root bridge where translation occurs, stop alias search here */
183 PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9),
184 /* Do not use FLR even if device advertises PCI_AF_CAP */
185 PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10),
181}; 186};
182 187
183enum pci_irq_reroute_variant { 188enum pci_irq_reroute_variant {
@@ -397,6 +402,8 @@ struct pci_dev {
397 phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */ 402 phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
398 size_t romlen; /* Length of ROM if it's not from the BAR */ 403 size_t romlen; /* Length of ROM if it's not from the BAR */
399 char *driver_override; /* Driver name to force a match */ 404 char *driver_override; /* Driver name to force a match */
405
406 unsigned long priv_flags; /* Private flags for the pci driver */
400}; 407};
401 408
402static inline struct pci_dev *pci_physfn(struct pci_dev *dev) 409static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@ -941,32 +948,12 @@ int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn,
941 948
942struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops); 949struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops);
943 950
944static inline int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val) 951int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val);
945{ 952int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val);
946 return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val); 953int pci_read_config_dword(const struct pci_dev *dev, int where, u32 *val);
947} 954int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val);
948static inline int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val) 955int pci_write_config_word(const struct pci_dev *dev, int where, u16 val);
949{ 956int pci_write_config_dword(const struct pci_dev *dev, int where, u32 val);
950 return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
951}
952static inline int pci_read_config_dword(const struct pci_dev *dev, int where,
953 u32 *val)
954{
955 return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
956}
957static inline int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
958{
959 return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
960}
961static inline int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
962{
963 return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
964}
965static inline int pci_write_config_dword(const struct pci_dev *dev, int where,
966 u32 val)
967{
968 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
969}
970 957
971int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val); 958int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
972int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val); 959int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
@@ -1053,6 +1040,7 @@ int pcie_get_mps(struct pci_dev *dev);
1053int pcie_set_mps(struct pci_dev *dev, int mps); 1040int pcie_set_mps(struct pci_dev *dev, int mps);
1054int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, 1041int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
1055 enum pcie_link_width *width); 1042 enum pcie_link_width *width);
1043void pcie_flr(struct pci_dev *dev);
1056int __pci_reset_function(struct pci_dev *dev); 1044int __pci_reset_function(struct pci_dev *dev);
1057int __pci_reset_function_locked(struct pci_dev *dev); 1045int __pci_reset_function_locked(struct pci_dev *dev);
1058int pci_reset_function(struct pci_dev *dev); 1046int pci_reset_function(struct pci_dev *dev);
@@ -1073,6 +1061,11 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags);
1073bool pci_device_is_present(struct pci_dev *pdev); 1061bool pci_device_is_present(struct pci_dev *pdev);
1074void pci_ignore_hotplug(struct pci_dev *dev); 1062void pci_ignore_hotplug(struct pci_dev *dev);
1075 1063
1064int __printf(6, 7) pci_request_irq(struct pci_dev *dev, unsigned int nr,
1065 irq_handler_t handler, irq_handler_t thread_fn, void *dev_id,
1066 const char *fmt, ...);
1067void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id);
1068
1076/* ROM control related routines */ 1069/* ROM control related routines */
1077int pci_enable_rom(struct pci_dev *pdev); 1070int pci_enable_rom(struct pci_dev *pdev);
1078void pci_disable_rom(struct pci_dev *pdev); 1071void pci_disable_rom(struct pci_dev *pdev);
@@ -1200,6 +1193,11 @@ unsigned long pci_address_to_pio(phys_addr_t addr);
1200phys_addr_t pci_pio_to_address(unsigned long pio); 1193phys_addr_t pci_pio_to_address(unsigned long pio);
1201int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr); 1194int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr);
1202void pci_unmap_iospace(struct resource *res); 1195void pci_unmap_iospace(struct resource *res);
1196void __iomem *devm_pci_remap_cfgspace(struct device *dev,
1197 resource_size_t offset,
1198 resource_size_t size);
1199void __iomem *devm_pci_remap_cfg_resource(struct device *dev,
1200 struct resource *res);
1203 1201
1204static inline pci_bus_addr_t pci_bus_address(struct pci_dev *pdev, int bar) 1202static inline pci_bus_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
1205{ 1203{
@@ -1298,10 +1296,8 @@ struct msix_entry {
1298 1296
1299#ifdef CONFIG_PCI_MSI 1297#ifdef CONFIG_PCI_MSI
1300int pci_msi_vec_count(struct pci_dev *dev); 1298int pci_msi_vec_count(struct pci_dev *dev);
1301void pci_msi_shutdown(struct pci_dev *dev);
1302void pci_disable_msi(struct pci_dev *dev); 1299void pci_disable_msi(struct pci_dev *dev);
1303int pci_msix_vec_count(struct pci_dev *dev); 1300int pci_msix_vec_count(struct pci_dev *dev);
1304void pci_msix_shutdown(struct pci_dev *dev);
1305void pci_disable_msix(struct pci_dev *dev); 1301void pci_disable_msix(struct pci_dev *dev);
1306void pci_restore_msi_state(struct pci_dev *dev); 1302void pci_restore_msi_state(struct pci_dev *dev);
1307int pci_msi_enabled(void); 1303int pci_msi_enabled(void);
@@ -1327,10 +1323,8 @@ int pci_irq_get_node(struct pci_dev *pdev, int vec);
1327 1323
1328#else 1324#else
1329static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } 1325static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
1330static inline void pci_msi_shutdown(struct pci_dev *dev) { }
1331static inline void pci_disable_msi(struct pci_dev *dev) { } 1326static inline void pci_disable_msi(struct pci_dev *dev) { }
1332static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; } 1327static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
1333static inline void pci_msix_shutdown(struct pci_dev *dev) { }
1334static inline void pci_disable_msix(struct pci_dev *dev) { } 1328static inline void pci_disable_msix(struct pci_dev *dev) { }
1335static inline void pci_restore_msi_state(struct pci_dev *dev) { } 1329static inline void pci_restore_msi_state(struct pci_dev *dev) { }
1336static inline int pci_msi_enabled(void) { return 0; } 1330static inline int pci_msi_enabled(void) { return 0; }
@@ -1623,6 +1617,36 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
1623 1617
1624#include <asm/pci.h> 1618#include <asm/pci.h>
1625 1619
1620/* These two functions provide almost identical functionality. Depennding
1621 * on the architecture, one will be implemented as a wrapper around the
1622 * other (in drivers/pci/mmap.c).
1623 *
1624 * pci_mmap_resource_range() maps a specific BAR, and vm->vm_pgoff
1625 * is expected to be an offset within that region.
1626 *
1627 * pci_mmap_page_range() is the legacy architecture-specific interface,
1628 * which accepts a "user visible" resource address converted by
1629 * pci_resource_to_user(), as used in the legacy mmap() interface in
1630 * /proc/bus/pci/.
1631 */
1632int pci_mmap_resource_range(struct pci_dev *dev, int bar,
1633 struct vm_area_struct *vma,
1634 enum pci_mmap_state mmap_state, int write_combine);
1635int pci_mmap_page_range(struct pci_dev *pdev, int bar,
1636 struct vm_area_struct *vma,
1637 enum pci_mmap_state mmap_state, int write_combine);
1638
1639#ifndef arch_can_pci_mmap_wc
1640#define arch_can_pci_mmap_wc() 0
1641#endif
1642
1643#ifndef arch_can_pci_mmap_io
1644#define arch_can_pci_mmap_io() 0
1645#define pci_iobar_pfn(pdev, bar, vma) (-EINVAL)
1646#else
1647int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
1648#endif
1649
1626#ifndef pci_root_bus_fwnode 1650#ifndef pci_root_bus_fwnode
1627#define pci_root_bus_fwnode(bus) NULL 1651#define pci_root_bus_fwnode(bus) NULL
1628#endif 1652#endif