1#ifndef _ASM_X86_PCI_H
2#define _ASM_X86_PCI_H
3
4#include <linux/mm.h>
5#include <linux/types.h>
6#include <linux/slab.h>
7#include <linux/string.h>
8#include <asm/scatterlist.h>
9#include <asm/io.h>
10#include <asm/x86_init.h>
11
12#ifdef __KERNEL__
13
14struct pci_sysdata {
15 int domain;
16 int node;
17#ifdef CONFIG_ACPI
18 struct acpi_device *companion;
19#endif
20#ifdef CONFIG_X86_64
21 void *iommu;
22#endif
23#ifdef CONFIG_PCI_MSI
24 struct x86_msi_ops *msi_ops;
25#endif
26#if IS_ENABLED(CONFIG_VMD)
27 bool vmd_domain;
28#endif
29};
30
31extern int pci_routeirq;
32extern int noioapicquirk;
33extern int noioapicreroute;
34
35#ifdef CONFIG_PCI
36
37#ifdef CONFIG_PCI_DOMAINS
38static inline int pci_domain_nr(struct pci_bus *bus)
39{
40 struct pci_sysdata *sd = bus->sysdata;
41 return sd->domain;
42}
43
44static inline int pci_proc_domain(struct pci_bus *bus)
45{
46 return pci_domain_nr(bus);
47}
48#endif
49
50static inline bool is_vmd(struct pci_bus *bus)
51{
52#if IS_ENABLED(CONFIG_VMD)
53 struct pci_sysdata *sd = bus->sysdata;
54
55 return sd->vmd_domain;
56#else
57 return false;
58#endif
59}
60
61
62
63
64
65extern unsigned int pcibios_assign_all_busses(void);
66extern int pci_legacy_init(void);
67# ifdef CONFIG_ACPI
68# define x86_default_pci_init pci_acpi_init
69# else
70# define x86_default_pci_init pci_legacy_init
71# endif
72#else
73# define pcibios_assign_all_busses() 0
74# define x86_default_pci_init NULL
75#endif
76
77extern unsigned long pci_mem_start;
78#define PCIBIOS_MIN_IO 0x1000
79#define PCIBIOS_MIN_MEM (pci_mem_start)
80
81#define PCIBIOS_MIN_CARDBUS_IO 0x4000
82
83extern int pcibios_enabled;
84void pcibios_config_init(void);
85void pcibios_scan_root(int bus);
86
87void pcibios_set_master(struct pci_dev *dev);
88struct irq_routing_table *pcibios_get_irq_routing_table(void);
89int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
90
91
92#define HAVE_PCI_MMAP
93extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
94 enum pci_mmap_state mmap_state,
95 int write_combine);
96
97
98#ifdef CONFIG_PCI
99extern void early_quirks(void);
100#else
101static inline void early_quirks(void) { }
102#endif
103
104extern void pci_iommu_alloc(void);
105
106#ifdef CONFIG_PCI_MSI
107
108struct msi_desc;
109int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
110void native_teardown_msi_irq(unsigned int irq);
111void native_restore_msi_irqs(struct pci_dev *dev);
112int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
113 unsigned int irq_base, unsigned int irq_offset);
114#else
115#define native_setup_msi_irqs NULL
116#define native_teardown_msi_irq NULL
117#endif
118
119#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
120
121#endif
122
123#ifdef CONFIG_X86_64
124#include <asm/pci_64.h>
125#endif
126
127
128#include <asm-generic/pci.h>
129
130#ifdef CONFIG_NUMA
131
132static inline int __pcibus_to_node(const struct pci_bus *bus)
133{
134 const struct pci_sysdata *sd = bus->sysdata;
135
136 return sd->node;
137}
138
139static inline const struct cpumask *
140cpumask_of_pcibus(const struct pci_bus *bus)
141{
142 int node;
143
144 node = __pcibus_to_node(bus);
145 return (node == -1) ? cpu_online_mask :
146 cpumask_of_node(node);
147}
148#endif
149
150struct pci_setup_rom {
151 struct setup_data data;
152 uint16_t vendor;
153 uint16_t devid;
154 uint64_t pcilen;
155 unsigned long segment;
156 unsigned long bus;
157 unsigned long device;
158 unsigned long function;
159 uint8_t romdata[0];
160};
161
162#endif
163