diff options
Diffstat (limited to 'include/linux/pci.h')
| -rw-r--r-- | include/linux/pci.h | 80 |
1 files changed, 49 insertions, 31 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 5faa8310eec9..ee2179546c63 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -13,32 +13,9 @@ | |||
| 13 | * PCI to PCI Bridge Specification | 13 | * PCI to PCI Bridge Specification |
| 14 | * PCI System Design Guide | 14 | * PCI System Design Guide |
| 15 | */ | 15 | */ |
| 16 | |||
| 17 | #ifndef LINUX_PCI_H | 16 | #ifndef LINUX_PCI_H |
| 18 | #define LINUX_PCI_H | 17 | #define LINUX_PCI_H |
| 19 | 18 | ||
| 20 | #include <linux/pci_regs.h> /* The pci register defines */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * The PCI interface treats multi-function devices as independent | ||
| 24 | * devices. The slot/function address of each device is encoded | ||
| 25 | * in a single byte as follows: | ||
| 26 | * | ||
| 27 | * 7:3 = slot | ||
| 28 | * 2:0 = function | ||
| 29 | */ | ||
| 30 | #define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) | ||
| 31 | #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) | ||
| 32 | #define PCI_FUNC(devfn) ((devfn) & 0x07) | ||
| 33 | |||
| 34 | /* Ioctls for /proc/bus/pci/X/Y nodes. */ | ||
| 35 | #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8) | ||
| 36 | #define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) /* Get controller for PCI device. */ | ||
| 37 | #define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) /* Set mmap state to I/O space. */ | ||
| 38 | #define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) /* Set mmap state to MEM space. */ | ||
| 39 | #define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) /* Enable/disable write-combining. */ | ||
| 40 | |||
| 41 | #ifdef __KERNEL__ | ||
| 42 | 19 | ||
| 43 | #include <linux/mod_devicetable.h> | 20 | #include <linux/mod_devicetable.h> |
| 44 | 21 | ||
| @@ -53,6 +30,7 @@ | |||
| 53 | #include <linux/device.h> | 30 | #include <linux/device.h> |
| 54 | #include <linux/io.h> | 31 | #include <linux/io.h> |
| 55 | #include <linux/irqreturn.h> | 32 | #include <linux/irqreturn.h> |
| 33 | #include <uapi/linux/pci.h> | ||
| 56 | 34 | ||
| 57 | /* Include the ID list */ | 35 | /* Include the ID list */ |
| 58 | #include <linux/pci_ids.h> | 36 | #include <linux/pci_ids.h> |
| @@ -254,10 +232,10 @@ struct pci_dev { | |||
| 254 | u8 revision; /* PCI revision, low byte of class word */ | 232 | u8 revision; /* PCI revision, low byte of class word */ |
| 255 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ | 233 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ |
| 256 | u8 pcie_cap; /* PCI-E capability offset */ | 234 | 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 */ | 235 | u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */ |
| 259 | u8 rom_base_reg; /* which config register controls the ROM */ | 236 | u8 rom_base_reg; /* which config register controls the ROM */ |
| 260 | u8 pin; /* which interrupt pin this device uses */ | 237 | u8 pin; /* which interrupt pin this device uses */ |
| 238 | u16 pcie_flags_reg; /* cached PCI-E Capabilities Register */ | ||
| 261 | 239 | ||
| 262 | struct pci_driver *driver; /* which driver has allocated this device */ | 240 | struct pci_driver *driver; /* which driver has allocated this device */ |
| 263 | u64 dma_mask; /* Mask of the bits of bus address this | 241 | u64 dma_mask; /* Mask of the bits of bus address this |
| @@ -369,7 +347,6 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev) | |||
| 369 | 347 | ||
| 370 | extern struct pci_dev *alloc_pci_dev(void); | 348 | extern struct pci_dev *alloc_pci_dev(void); |
| 371 | 349 | ||
| 372 | #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) | ||
| 373 | #define to_pci_dev(n) container_of(n, struct pci_dev, dev) | 350 | #define to_pci_dev(n) container_of(n, struct pci_dev, dev) |
| 374 | #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) | 351 | #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) |
| 375 | 352 | ||
| @@ -596,7 +573,7 @@ struct pci_driver { | |||
| 596 | int (*resume_early) (struct pci_dev *dev); | 573 | int (*resume_early) (struct pci_dev *dev); |
| 597 | int (*resume) (struct pci_dev *dev); /* Device woken up */ | 574 | int (*resume) (struct pci_dev *dev); /* Device woken up */ |
| 598 | void (*shutdown) (struct pci_dev *dev); | 575 | void (*shutdown) (struct pci_dev *dev); |
| 599 | struct pci_error_handlers *err_handler; | 576 | const struct pci_error_handlers *err_handler; |
| 600 | struct device_driver driver; | 577 | struct device_driver driver; |
| 601 | struct pci_dynids dynids; | 578 | struct pci_dynids dynids; |
| 602 | }; | 579 | }; |
| @@ -734,9 +711,7 @@ u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp); | |||
| 734 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); | 711 | extern struct pci_dev *pci_dev_get(struct pci_dev *dev); |
| 735 | extern void pci_dev_put(struct pci_dev *dev); | 712 | extern void pci_dev_put(struct pci_dev *dev); |
| 736 | extern void pci_remove_bus(struct pci_bus *b); | 713 | extern void pci_remove_bus(struct pci_bus *b); |
| 737 | extern void __pci_remove_bus_device(struct pci_dev *dev); | ||
| 738 | extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); | 714 | extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); |
| 739 | extern void pci_stop_bus_device(struct pci_dev *dev); | ||
| 740 | void pci_setup_cardbus(struct pci_bus *bus); | 715 | void pci_setup_cardbus(struct pci_bus *bus); |
| 741 | extern void pci_sort_breadthfirst(void); | 716 | extern void pci_sort_breadthfirst(void); |
| 742 | #define dev_is_pci(d) ((d)->bus == &pci_bus_type) | 717 | #define dev_is_pci(d) ((d)->bus == &pci_bus_type) |
| @@ -755,6 +730,7 @@ enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev); | |||
| 755 | int pci_find_capability(struct pci_dev *dev, int cap); | 730 | int pci_find_capability(struct pci_dev *dev, int cap); |
| 756 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); | 731 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); |
| 757 | int pci_find_ext_capability(struct pci_dev *dev, int cap); | 732 | int pci_find_ext_capability(struct pci_dev *dev, int cap); |
| 733 | int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap); | ||
| 758 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); | 734 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); |
| 759 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); | 735 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); |
| 760 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); | 736 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); |
| @@ -816,6 +792,39 @@ static inline int pci_write_config_dword(const struct pci_dev *dev, int where, | |||
| 816 | return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); | 792 | return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); |
| 817 | } | 793 | } |
| 818 | 794 | ||
| 795 | int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val); | ||
| 796 | int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val); | ||
| 797 | int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val); | ||
| 798 | int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val); | ||
| 799 | int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, | ||
| 800 | u16 clear, u16 set); | ||
| 801 | int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, | ||
| 802 | u32 clear, u32 set); | ||
| 803 | |||
| 804 | static inline int pcie_capability_set_word(struct pci_dev *dev, int pos, | ||
| 805 | u16 set) | ||
| 806 | { | ||
| 807 | return pcie_capability_clear_and_set_word(dev, pos, 0, set); | ||
| 808 | } | ||
| 809 | |||
| 810 | static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos, | ||
| 811 | u32 set) | ||
| 812 | { | ||
| 813 | return pcie_capability_clear_and_set_dword(dev, pos, 0, set); | ||
| 814 | } | ||
| 815 | |||
| 816 | static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos, | ||
| 817 | u16 clear) | ||
| 818 | { | ||
| 819 | return pcie_capability_clear_and_set_word(dev, pos, clear, 0); | ||
| 820 | } | ||
| 821 | |||
| 822 | static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos, | ||
| 823 | u32 clear) | ||
| 824 | { | ||
| 825 | return pcie_capability_clear_and_set_dword(dev, pos, clear, 0); | ||
| 826 | } | ||
| 827 | |||
| 819 | /* user-space driven config access */ | 828 | /* user-space driven config access */ |
| 820 | int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); | 829 | int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); |
| 821 | int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); | 830 | int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); |
| @@ -1013,7 +1022,6 @@ void pci_unregister_driver(struct pci_driver *dev); | |||
| 1013 | module_driver(__pci_driver, pci_register_driver, \ | 1022 | module_driver(__pci_driver, pci_register_driver, \ |
| 1014 | pci_unregister_driver) | 1023 | pci_unregister_driver) |
| 1015 | 1024 | ||
| 1016 | void pci_stop_and_remove_behind_bridge(struct pci_dev *dev); | ||
| 1017 | struct pci_driver *pci_dev_driver(const struct pci_dev *dev); | 1025 | struct pci_driver *pci_dev_driver(const struct pci_dev *dev); |
| 1018 | int pci_add_dynid(struct pci_driver *drv, | 1026 | int pci_add_dynid(struct pci_driver *drv, |
| 1019 | unsigned int vendor, unsigned int device, | 1027 | unsigned int vendor, unsigned int device, |
| @@ -1031,6 +1039,8 @@ int pci_cfg_space_size_ext(struct pci_dev *dev); | |||
| 1031 | int pci_cfg_space_size(struct pci_dev *dev); | 1039 | int pci_cfg_space_size(struct pci_dev *dev); |
| 1032 | unsigned char pci_bus_max_busnr(struct pci_bus *bus); | 1040 | unsigned char pci_bus_max_busnr(struct pci_bus *bus); |
| 1033 | void pci_setup_bridge(struct pci_bus *bus); | 1041 | void pci_setup_bridge(struct pci_bus *bus); |
| 1042 | resource_size_t pcibios_window_alignment(struct pci_bus *bus, | ||
| 1043 | unsigned long type); | ||
| 1034 | 1044 | ||
| 1035 | #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0) | 1045 | #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0) |
| 1036 | #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1) | 1046 | #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1) |
| @@ -1472,7 +1482,7 @@ enum pci_fixup_pass { | |||
| 1472 | /* Anonymous variables would be nice... */ | 1482 | /* Anonymous variables would be nice... */ |
| 1473 | #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ | 1483 | #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ |
| 1474 | class_shift, hook) \ | 1484 | class_shift, hook) \ |
| 1475 | static const struct pci_fixup const __pci_fixup_##name __used \ | 1485 | static const struct pci_fixup __pci_fixup_##name __used \ |
| 1476 | __attribute__((__section__(#section), aligned((sizeof(void *))))) \ | 1486 | __attribute__((__section__(#section), aligned((sizeof(void *))))) \ |
| 1477 | = { vendor, device, class, class_shift, hook }; | 1487 | = { vendor, device, class, class_shift, hook }; |
| 1478 | 1488 | ||
| @@ -1650,6 +1660,15 @@ static inline bool pci_is_pcie(struct pci_dev *dev) | |||
| 1650 | return !!pci_pcie_cap(dev); | 1660 | return !!pci_pcie_cap(dev); |
| 1651 | } | 1661 | } |
| 1652 | 1662 | ||
| 1663 | /** | ||
| 1664 | * pci_pcie_type - get the PCIe device/port type | ||
| 1665 | * @dev: PCI device | ||
| 1666 | */ | ||
| 1667 | static inline int pci_pcie_type(const struct pci_dev *dev) | ||
| 1668 | { | ||
| 1669 | return (dev->pcie_flags_reg & PCI_EXP_FLAGS_TYPE) >> 4; | ||
| 1670 | } | ||
| 1671 | |||
| 1653 | void pci_request_acs(void); | 1672 | void pci_request_acs(void); |
| 1654 | bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); | 1673 | bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); |
| 1655 | bool pci_acs_path_enabled(struct pci_dev *start, | 1674 | bool pci_acs_path_enabled(struct pci_dev *start, |
| @@ -1790,5 +1809,4 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev) | |||
| 1790 | */ | 1809 | */ |
| 1791 | struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); | 1810 | struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); |
| 1792 | 1811 | ||
| 1793 | #endif /* __KERNEL__ */ | ||
| 1794 | #endif /* LINUX_PCI_H */ | 1812 | #endif /* LINUX_PCI_H */ |
