pci.h 3.6 KB
Newer Older
H
H. Peter Anvin 已提交
1 2
#ifndef _ASM_X86_PCI_H
#define _ASM_X86_PCI_H
3 4 5 6 7

#include <linux/mm.h> /* for struct page */
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/string.h>
C
Christoph Hellwig 已提交
8
#include <linux/scatterlist.h>
9
#include <asm/io.h>
S
Stefano Stabellini 已提交
10
#include <asm/x86_init.h>
11 12 13 14 15 16

#ifdef __KERNEL__

struct pci_sysdata {
	int		domain;		/* PCI domain */
	int		node;		/* NUMA node */
17
#ifdef CONFIG_ACPI
18
	struct acpi_device *companion;	/* ACPI companion device */
19
#endif
20
#ifdef CONFIG_X86_64
21
	void		*iommu;		/* IOMMU private data */
22
#endif
23 24 25
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
	void		*fwnode;	/* IRQ domain for MSI assignment */
#endif
26 27
};

28
extern int pci_routeirq;
29
extern int noioapicquirk;
30
extern int noioapicreroute;
31

32 33 34
#ifdef CONFIG_PCI

#ifdef CONFIG_PCI_DOMAINS
35 36 37
static inline int pci_domain_nr(struct pci_bus *bus)
{
	struct pci_sysdata *sd = bus->sysdata;
38

39 40 41 42 43 44 45
	return sd->domain;
}

static inline int pci_proc_domain(struct pci_bus *bus)
{
	return pci_domain_nr(bus);
}
46
#endif
47

48 49 50 51 52 53 54 55 56 57 58
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
static inline void *_pci_root_bus_fwnode(struct pci_bus *bus)
{
	struct pci_sysdata *sd = bus->sysdata;

	return sd->fwnode;
}

#define pci_root_bus_fwnode	_pci_root_bus_fwnode
#endif

59 60 61 62 63
/* Can be used to override the logic in pci_scan_bus for skipping
   already-configured bus numbers - to be used for buggy BIOSes
   or architectures with incomplete PCI setup by the loader */

extern unsigned int pcibios_assign_all_busses(void);
64 65 66 67 68 69
extern int pci_legacy_init(void);
# ifdef CONFIG_ACPI
#  define x86_default_pci_init pci_acpi_init
# else
#  define x86_default_pci_init pci_legacy_init
# endif
70
#else
71 72
# define pcibios_assign_all_busses()	0
# define x86_default_pci_init		NULL
73 74 75 76 77 78 79 80
#endif

extern unsigned long pci_mem_start;
#define PCIBIOS_MIN_IO		0x1000
#define PCIBIOS_MIN_MEM		(pci_mem_start)

#define PCIBIOS_MIN_CARDBUS_IO	0x4000

81
extern int pcibios_enabled;
82
void pcibios_config_init(void);
83
void pcibios_scan_root(int bus);
84 85 86 87 88 89 90 91

void pcibios_set_master(struct pci_dev *dev);
struct irq_routing_table *pcibios_get_irq_routing_table(void);
int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);


#define HAVE_PCI_MMAP
extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
92 93
			       enum pci_mmap_state mmap_state,
			       int write_combine);
94 95 96


#ifdef CONFIG_PCI
97 98 99
extern void early_quirks(void);
#else
static inline void early_quirks(void) { }
100 101
#endif

102 103
extern void pci_iommu_alloc(void);

S
Stefano Stabellini 已提交
104 105
#ifdef CONFIG_PCI_MSI
/* implemented in arch/x86/kernel/apic/io_apic. */
106
struct msi_desc;
S
Stefano Stabellini 已提交
107 108
int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void native_teardown_msi_irq(unsigned int irq);
109
void native_restore_msi_irqs(struct pci_dev *dev);
S
Stefano Stabellini 已提交
110 111 112 113
#else
#define native_setup_msi_irqs		NULL
#define native_teardown_msi_irq		NULL
#endif
114

115 116 117 118 119
#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)

#endif  /* __KERNEL__ */

#ifdef CONFIG_X86_64
120
#include <asm/pci_64.h>
121 122 123 124 125 126 127 128
#endif

/* implement the pci_ DMA API in terms of the generic device dma_ one */
#include <asm-generic/pci-dma-compat.h>

/* generic pci stuff */
#include <asm-generic/pci.h>

129 130
#ifdef CONFIG_NUMA
/* Returns the node based on pci bus */
131
static inline int __pcibus_to_node(const struct pci_bus *bus)
132
{
133
	const struct pci_sysdata *sd = bus->sysdata;
134 135 136

	return sd->node;
}
137

138 139 140
static inline const struct cpumask *
cpumask_of_pcibus(const struct pci_bus *bus)
{
141 142 143 144 145
	int node;

	node = __pcibus_to_node(bus);
	return (node == -1) ? cpu_online_mask :
			      cpumask_of_node(node);
146
}
147
#endif
148

149 150 151 152 153 154 155 156 157 158 159 160
struct pci_setup_rom {
	struct setup_data data;
	uint16_t vendor;
	uint16_t devid;
	uint64_t pcilen;
	unsigned long segment;
	unsigned long bus;
	unsigned long device;
	unsigned long function;
	uint8_t romdata[0];
};

H
H. Peter Anvin 已提交
161
#endif /* _ASM_X86_PCI_H */