blob: eeb3088a1c9e3d2fbbff1140b94fad85c69777f9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __x8664_PCI_H
2#define __x8664_PCI_H
3
4#include <linux/config.h>
5#include <asm/io.h>
6
7#ifdef __KERNEL__
8
9#include <linux/mm.h> /* for struct page */
10
11/* Can be used to override the logic in pci_scan_bus for skipping
12 already-configured bus numbers - to be used for buggy BIOSes
13 or architectures with incomplete PCI setup by the loader */
14
15#ifdef CONFIG_PCI
16extern unsigned int pcibios_assign_all_busses(void);
17#else
18#define pcibios_assign_all_busses() 0
19#endif
20#define pcibios_scan_all_fns(a, b) 0
21
22extern int no_iommu, force_iommu;
23
24extern unsigned long pci_mem_start;
Linus Torvalds2ba84682005-08-14 18:21:30 -070025#define PCIBIOS_MIN_IO 0x1000
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#define PCIBIOS_MIN_MEM (pci_mem_start)
27
Linus Torvalds2ba84682005-08-14 18:21:30 -070028#define PCIBIOS_MIN_CARDBUS_IO 0x4000
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030void pcibios_config_init(void);
31struct pci_bus * pcibios_scan_root(int bus);
32extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
33extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
34
35void pcibios_set_master(struct pci_dev *dev);
David Shaohua Lic9c3e452005-04-01 00:07:31 -050036void pcibios_penalize_isa_irq(int irq, int active);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037struct irq_routing_table *pcibios_get_irq_routing_table(void);
38int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
39
40#include <linux/types.h>
41#include <linux/slab.h>
42#include <asm/scatterlist.h>
43#include <linux/string.h>
44#include <asm/page.h>
45
46extern int iommu_setup(char *opt);
47
48#ifdef CONFIG_GART_IOMMU
49/* The PCI address space does equal the physical memory
50 * address space. The networking and block device layers use
51 * this boolean for bounce buffer decisions
52 *
Linus Torvalds79b95a42005-10-27 16:28:39 -070053 * On AMD64 it mostly equals, but we set it to zero to tell some subsystems
54 * that an IOMMU is available.
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 */
Linus Torvalds79b95a42005-10-27 16:28:39 -070056#define PCI_DMA_BUS_IS_PHYS (no_iommu ? 1 : 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/*
59 * x86-64 always supports DAC, but sometimes it is useful to force
60 * devices through the IOMMU to get automatic sg list merging.
61 * Optional right now.
62 */
63extern int iommu_sac_force;
64#define pci_dac_dma_supported(pci_dev, mask) (!iommu_sac_force)
65
66#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
67 dma_addr_t ADDR_NAME;
68#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
69 __u32 LEN_NAME;
70#define pci_unmap_addr(PTR, ADDR_NAME) \
71 ((PTR)->ADDR_NAME)
72#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
73 (((PTR)->ADDR_NAME) = (VAL))
74#define pci_unmap_len(PTR, LEN_NAME) \
75 ((PTR)->LEN_NAME)
76#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
77 (((PTR)->LEN_NAME) = (VAL))
78
79#else
80/* No IOMMU */
81
82#define PCI_DMA_BUS_IS_PHYS 1
83#define pci_dac_dma_supported(pci_dev, mask) 1
84
85#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
86#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
87#define pci_unmap_addr(PTR, ADDR_NAME) (0)
88#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
89#define pci_unmap_len(PTR, LEN_NAME) (0)
90#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
91
92#endif
93
94#include <asm-generic/pci-dma-compat.h>
95
96static inline dma64_addr_t
97pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
98{
99 return ((dma64_addr_t) page_to_phys(page) +
100 (dma64_addr_t) offset);
101}
102
103static inline struct page *
104pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
105{
106 return virt_to_page(__va(dma_addr));
107}
108
109static inline unsigned long
110pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
111{
112 return (dma_addr & ~PAGE_MASK);
113}
114
115static inline void
116pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
117{
118}
119
120static inline void
121pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
122{
123 flush_write_buffers();
124}
125
Andrew Mortonbb4a61b2005-06-06 23:07:46 -0700126#ifdef CONFIG_PCI
David S. Millere24c2d92005-06-02 12:55:50 -0700127static inline void pci_dma_burst_advice(struct pci_dev *pdev,
128 enum pci_dma_burst_strategy *strat,
129 unsigned long *strategy_parameter)
130{
131 *strat = PCI_DMA_BURST_INFINITY;
132 *strategy_parameter = ~0UL;
133}
Andrew Mortonbb4a61b2005-06-06 23:07:46 -0700134#endif
David S. Millere24c2d92005-06-02 12:55:50 -0700135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136#define HAVE_PCI_MMAP
137extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
138 enum pci_mmap_state mmap_state, int write_combine);
139
140static inline void pcibios_add_platform_entries(struct pci_dev *dev)
141{
142}
143
144#endif /* __KERNEL__ */
145
146/* generic pci stuff */
147#ifdef CONFIG_PCI
148#include <asm-generic/pci.h>
149#endif
150
151#endif /* __x8664_PCI_H */