]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/x86/include/asm/pci.h
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[karo-tx-linux.git] / arch / x86 / include / asm / pci.h
1 #ifndef _ASM_X86_PCI_H
2 #define _ASM_X86_PCI_H
3
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>
12
13 #ifdef __KERNEL__
14
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
30 };
31
32 extern int pci_routeirq;
33 extern int noioapicquirk;
34 extern int noioapicreroute;
35
36 #ifdef CONFIG_PCI
37
38 #ifdef CONFIG_PCI_DOMAINS
39 static inline int pci_domain_nr(struct pci_bus *bus)
40 {
41         struct pci_sysdata *sd = bus->sysdata;
42
43         return sd->domain;
44 }
45
46 static inline int pci_proc_domain(struct pci_bus *bus)
47 {
48         return pci_domain_nr(bus);
49 }
50 #endif
51
52 #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
53 static inline void *_pci_root_bus_fwnode(struct pci_bus *bus)
54 {
55         struct pci_sysdata *sd = bus->sysdata;
56
57         return sd->fwnode;
58 }
59
60 #define pci_root_bus_fwnode     _pci_root_bus_fwnode
61 #endif
62
63 static inline bool is_vmd(struct pci_bus *bus)
64 {
65 #if IS_ENABLED(CONFIG_VMD)
66         struct pci_sysdata *sd = bus->sysdata;
67
68         return sd->vmd_domain;
69 #else
70         return false;
71 #endif
72 }
73
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 */
77
78 extern unsigned int pcibios_assign_all_busses(void);
79 extern int pci_legacy_init(void);
80 # ifdef CONFIG_ACPI
81 #  define x86_default_pci_init pci_acpi_init
82 # else
83 #  define x86_default_pci_init pci_legacy_init
84 # endif
85 #else
86 # define pcibios_assign_all_busses()    0
87 # define x86_default_pci_init           NULL
88 #endif
89
90 extern unsigned long pci_mem_start;
91 #define PCIBIOS_MIN_IO          0x1000
92 #define PCIBIOS_MIN_MEM         (pci_mem_start)
93
94 #define PCIBIOS_MIN_CARDBUS_IO  0x4000
95
96 extern int pcibios_enabled;
97 void pcibios_config_init(void);
98 void pcibios_scan_root(int bus);
99
100 void pcibios_set_master(struct pci_dev *dev);
101 struct irq_routing_table *pcibios_get_irq_routing_table(void);
102 int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
103
104
105 #define HAVE_PCI_MMAP
106 #define arch_can_pci_mmap_wc()  pat_enabled()
107 #define ARCH_GENERIC_PCI_MMAP_RESOURCE
108
109 #ifdef CONFIG_PCI
110 extern void early_quirks(void);
111 #else
112 static inline void early_quirks(void) { }
113 #endif
114
115 extern void pci_iommu_alloc(void);
116
117 #ifdef CONFIG_PCI_MSI
118 /* implemented in arch/x86/kernel/apic/io_apic. */
119 struct msi_desc;
120 int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
121 void native_teardown_msi_irq(unsigned int irq);
122 void native_restore_msi_irqs(struct pci_dev *dev);
123 #else
124 #define native_setup_msi_irqs           NULL
125 #define native_teardown_msi_irq         NULL
126 #endif
127
128 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
129
130 #endif  /* __KERNEL__ */
131
132 #ifdef CONFIG_X86_64
133 #include <asm/pci_64.h>
134 #endif
135
136 /* generic pci stuff */
137 #include <asm-generic/pci.h>
138
139 #ifdef CONFIG_NUMA
140 /* Returns the node based on pci bus */
141 static inline int __pcibus_to_node(const struct pci_bus *bus)
142 {
143         const struct pci_sysdata *sd = bus->sysdata;
144
145         return sd->node;
146 }
147
148 static inline const struct cpumask *
149 cpumask_of_pcibus(const struct pci_bus *bus)
150 {
151         int node;
152
153         node = __pcibus_to_node(bus);
154         return (node == -1) ? cpu_online_mask :
155                               cpumask_of_node(node);
156 }
157 #endif
158
159 struct pci_setup_rom {
160         struct setup_data data;
161         uint16_t vendor;
162         uint16_t devid;
163         uint64_t pcilen;
164         unsigned long segment;
165         unsigned long bus;
166         unsigned long device;
167         unsigned long function;
168         uint8_t romdata[0];
169 };
170
171 #endif /* _ASM_X86_PCI_H */