blob: 0a123d6a820f91ebd83b6eefb173fd5e072fab2d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __x8664_PCI_H
2#define __x8664_PCI_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/io.h>
5
6#ifdef __KERNEL__
7
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +03008struct pci_sysdata {
Jeff Garzika79e4192007-10-11 16:58:30 -04009 int domain; /* PCI domain */
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +030010 int node; /* NUMA node */
11 void* iommu; /* IOMMU private data */
12};
13
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -070014extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
15
Jeff Garzika79e4192007-10-11 16:58:30 -040016static inline int pci_domain_nr(struct pci_bus *bus)
17{
18 struct pci_sysdata *sd = bus->sysdata;
19 return sd->domain;
20}
21
22static inline int pci_proc_domain(struct pci_bus *bus)
23{
24 return pci_domain_nr(bus);
25}
26
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +030027#ifdef CONFIG_CALGARY_IOMMU
28static inline void* pci_iommu(struct pci_bus *bus)
29{
30 struct pci_sysdata *sd = bus->sysdata;
31 return sd->iommu;
32}
33
34static inline void set_pci_iommu(struct pci_bus *bus, void *val)
35{
36 struct pci_sysdata *sd = bus->sysdata;
37 sd->iommu = val;
38}
39#endif /* CONFIG_CALGARY_IOMMU */
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/mm.h> /* for struct page */
42
43/* Can be used to override the logic in pci_scan_bus for skipping
44 already-configured bus numbers - to be used for buggy BIOSes
45 or architectures with incomplete PCI setup by the loader */
46
47#ifdef CONFIG_PCI
48extern unsigned int pcibios_assign_all_busses(void);
49#else
50#define pcibios_assign_all_busses() 0
51#endif
52#define pcibios_scan_all_fns(a, b) 0
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054extern unsigned long pci_mem_start;
Linus Torvalds2ba84682005-08-14 18:21:30 -070055#define PCIBIOS_MIN_IO 0x1000
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#define PCIBIOS_MIN_MEM (pci_mem_start)
57
Linus Torvalds2ba84682005-08-14 18:21:30 -070058#define PCIBIOS_MIN_CARDBUS_IO 0x4000
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060void pcibios_config_init(void);
61struct pci_bus * pcibios_scan_root(int bus);
62extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
63extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
64
65void pcibios_set_master(struct pci_dev *dev);
David Shaohua Lic9c3e452005-04-01 00:07:31 -050066void pcibios_penalize_isa_irq(int irq, int active);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067struct irq_routing_table *pcibios_get_irq_routing_table(void);
68int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
69
70#include <linux/types.h>
71#include <linux/slab.h>
72#include <asm/scatterlist.h>
73#include <linux/string.h>
74#include <asm/page.h>
75
Jon Mason0dc243a2006-06-26 13:58:11 +020076extern void pci_iommu_alloc(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077extern int iommu_setup(char *opt);
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079/* The PCI address space does equal the physical memory
80 * address space. The networking and block device layers use
81 * this boolean for bounce buffer decisions
82 *
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010083 * On AMD64 it mostly equals, but we set it to zero if a hardware
84 * IOMMU (gart) of sotware IOMMU (swiotlb) is available.
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 */
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010086#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
87
Jon Masone4650582006-06-26 13:58:14 +020088#if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
91 dma_addr_t ADDR_NAME;
92#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
93 __u32 LEN_NAME;
94#define pci_unmap_addr(PTR, ADDR_NAME) \
95 ((PTR)->ADDR_NAME)
96#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
97 (((PTR)->ADDR_NAME) = (VAL))
98#define pci_unmap_len(PTR, LEN_NAME) \
99 ((PTR)->LEN_NAME)
100#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
101 (((PTR)->LEN_NAME) = (VAL))
102
103#else
104/* No IOMMU */
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
107#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
108#define pci_unmap_addr(PTR, ADDR_NAME) (0)
109#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
110#define pci_unmap_len(PTR, LEN_NAME) (0)
111#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
112
113#endif
114
115#include <asm-generic/pci-dma-compat.h>
116
Andrew Mortonbb4a61b2005-06-06 23:07:46 -0700117#ifdef CONFIG_PCI
David S. Millere24c2d92005-06-02 12:55:50 -0700118static inline void pci_dma_burst_advice(struct pci_dev *pdev,
119 enum pci_dma_burst_strategy *strat,
120 unsigned long *strategy_parameter)
121{
122 *strat = PCI_DMA_BURST_INFINITY;
123 *strategy_parameter = ~0UL;
124}
Andrew Mortonbb4a61b2005-06-06 23:07:46 -0700125#endif
David S. Millere24c2d92005-06-02 12:55:50 -0700126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127#define HAVE_PCI_MMAP
128extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
129 enum pci_mmap_state mmap_state, int write_combine);
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#endif /* __KERNEL__ */
132
133/* generic pci stuff */
134#ifdef CONFIG_PCI
135#include <asm-generic/pci.h>
136#endif
137
138#endif /* __x8664_PCI_H */