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.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 65c503cdec3b..57a08da824e0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -254,10 +254,10 @@ struct pci_dev {
254 u8 revision; /* PCI revision, low byte of class word */ 254 u8 revision; /* PCI revision, low byte of class word */
255 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 255 u8 hdr_type; /* PCI header type (`multi' flag masked out) */
256 u8 pcie_cap; /* PCI-E capability offset */ 256 u8 pcie_cap; /* PCI-E capability offset */
257 u8 pcie_type:4; /* PCI-E device/port type */
258 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */ 257 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */
259 u8 rom_base_reg; /* which config register controls the ROM */ 258 u8 rom_base_reg; /* which config register controls the ROM */
260 u8 pin; /* which interrupt pin this device uses */ 259 u8 pin; /* which interrupt pin this device uses */
260 u16 pcie_flags_reg; /* cached PCI-E Capabilities Register */
261 261
262 struct pci_driver *driver; /* which driver has allocated this device */ 262 struct pci_driver *driver; /* which driver has allocated this device */
263 u64 dma_mask; /* Mask of the bits of bus address this 263 u64 dma_mask; /* Mask of the bits of bus address this
@@ -817,6 +817,39 @@ static inline int pci_write_config_dword(const struct pci_dev *dev, int where,
817 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); 817 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
818} 818}
819 819
820int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
821int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
822int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val);
823int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val);
824int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
825 u16 clear, u16 set);
826int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
827 u32 clear, u32 set);
828
829static inline int pcie_capability_set_word(struct pci_dev *dev, int pos,
830 u16 set)
831{
832 return pcie_capability_clear_and_set_word(dev, pos, 0, set);
833}
834
835static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
836 u32 set)
837{
838 return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
839}
840
841static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos,
842 u16 clear)
843{
844 return pcie_capability_clear_and_set_word(dev, pos, clear, 0);
845}
846
847static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
848 u32 clear)
849{
850 return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
851}
852
820/* user-space driven config access */ 853/* user-space driven config access */
821int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); 854int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
822int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); 855int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
@@ -1651,6 +1684,15 @@ static inline bool pci_is_pcie(struct pci_dev *dev)
1651 return !!pci_pcie_cap(dev); 1684 return !!pci_pcie_cap(dev);
1652} 1685}
1653 1686
1687/**
1688 * pci_pcie_type - get the PCIe device/port type
1689 * @dev: PCI device
1690 */
1691static inline int pci_pcie_type(const struct pci_dev *dev)
1692{
1693 return (dev->pcie_flags_reg & PCI_EXP_FLAGS_TYPE) >> 4;
1694}
1695
1654void pci_request_acs(void); 1696void pci_request_acs(void);
1655bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); 1697bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
1656bool pci_acs_path_enabled(struct pci_dev *start, 1698bool pci_acs_path_enabled(struct pci_dev *start,