Merge tag 'pm-4.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
[linux/fpc-iii.git] / arch / x86 / include / asm / pci.h
blob473a7295ab1028cc82a105476c3fee2597fdaa3e
1 #ifndef _ASM_X86_PCI_H
2 #define _ASM_X86_PCI_H
4 #include <linux/mm.h> /* for struct page */
5 #include <linux/types.h>
6 #include <linux/slab.h>
7 #include <linux/string.h>
8 #include <linux/scatterlist.h>
9 #include <asm/io.h>
10 #include <asm/pat.h>
11 #include <asm/x86_init.h>
13 #ifdef __KERNEL__
15 struct pci_sysdata {
16 int domain; /* PCI domain */
17 int node; /* NUMA node */
18 #ifdef CONFIG_ACPI
19 struct acpi_device *companion; /* ACPI companion device */
20 #endif
21 #ifdef CONFIG_X86_64
22 void *iommu; /* IOMMU private data */
23 #endif
24 #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
25 void *fwnode; /* IRQ domain for MSI assignment */
26 #endif
27 #if IS_ENABLED(CONFIG_VMD)
28 bool vmd_domain; /* True if in Intel VMD domain */
29 #endif
32 extern int pci_routeirq;
33 extern int noioapicquirk;
34 extern int noioapicreroute;
36 #ifdef CONFIG_PCI
38 #ifdef CONFIG_PCI_DOMAINS
39 static inline int pci_domain_nr(struct pci_bus *bus)
41 struct pci_sysdata *sd = bus->sysdata;
43 return sd->domain;
46 static inline int pci_proc_domain(struct pci_bus *bus)
48 return pci_domain_nr(bus);
50 #endif
52 #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
53 static inline void *_pci_root_bus_fwnode(struct pci_bus *bus)
55 struct pci_sysdata *sd = bus->sysdata;
57 return sd->fwnode;
60 #define pci_root_bus_fwnode _pci_root_bus_fwnode
61 #endif
63 static inline bool is_vmd(struct pci_bus *bus)
65 #if IS_ENABLED(CONFIG_VMD)
66 struct pci_sysdata *sd = bus->sysdata;
68 return sd->vmd_domain;
69 #else
70 return false;
71 #endif
74 /* Can be used to override the logic in pci_scan_bus for skipping
75 already-configured bus numbers - to be used for buggy BIOSes
76 or architectures with incomplete PCI setup by the loader */
78 extern unsigned int pcibios_assign_all_busses(void);
79 extern int pci_legacy_init(void);
80 #else
81 static inline int pcibios_assign_all_busses(void) { return 0; }
82 #endif
84 extern unsigned long pci_mem_start;
85 #define PCIBIOS_MIN_IO 0x1000
86 #define PCIBIOS_MIN_MEM (pci_mem_start)
88 #define PCIBIOS_MIN_CARDBUS_IO 0x4000
90 extern int pcibios_enabled;
91 void pcibios_config_init(void);
92 void pcibios_scan_root(int bus);
94 void pcibios_set_master(struct pci_dev *dev);
95 struct irq_routing_table *pcibios_get_irq_routing_table(void);
96 int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
99 #define HAVE_PCI_MMAP
100 #define arch_can_pci_mmap_wc() pat_enabled()
101 #define ARCH_GENERIC_PCI_MMAP_RESOURCE
103 #ifdef CONFIG_PCI
104 extern void early_quirks(void);
105 #else
106 static inline void early_quirks(void) { }
107 #endif
109 extern void pci_iommu_alloc(void);
111 #ifdef CONFIG_PCI_MSI
112 /* implemented in arch/x86/kernel/apic/io_apic. */
113 struct msi_desc;
114 int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
115 void native_teardown_msi_irq(unsigned int irq);
116 void native_restore_msi_irqs(struct pci_dev *dev);
117 #else
118 #define native_setup_msi_irqs NULL
119 #define native_teardown_msi_irq NULL
120 #endif
122 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
124 #endif /* __KERNEL__ */
126 #ifdef CONFIG_X86_64
127 #include <asm/pci_64.h>
128 #endif
130 /* generic pci stuff */
131 #include <asm-generic/pci.h>
133 #ifdef CONFIG_NUMA
134 /* Returns the node based on pci bus */
135 static inline int __pcibus_to_node(const struct pci_bus *bus)
137 const struct pci_sysdata *sd = bus->sysdata;
139 return sd->node;
142 static inline const struct cpumask *
143 cpumask_of_pcibus(const struct pci_bus *bus)
145 int node;
147 node = __pcibus_to_node(bus);
148 return (node == -1) ? cpu_online_mask :
149 cpumask_of_node(node);
151 #endif
153 struct pci_setup_rom {
154 struct setup_data data;
155 uint16_t vendor;
156 uint16_t devid;
157 uint64_t pcilen;
158 unsigned long segment;
159 unsigned long bus;
160 unsigned long device;
161 unsigned long function;
162 uint8_t romdata[0];
165 #endif /* _ASM_X86_PCI_H */