blob: 374690314539c6858ad465396e6ba8397048f8da [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
5#ifdef __KERNEL__
6
Jeff Garzika79e4192007-10-11 16:58:30 -04007
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +03008#ifdef CONFIG_CALGARY_IOMMU
9static inline void* pci_iommu(struct pci_bus *bus)
10{
11 struct pci_sysdata *sd = bus->sysdata;
12 return sd->iommu;
13}
14
15static inline void set_pci_iommu(struct pci_bus *bus, void *val)
16{
17 struct pci_sysdata *sd = bus->sysdata;
18 sd->iommu = val;
19}
20#endif /* CONFIG_CALGARY_IOMMU */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Linus Torvalds1da177e2005-04-16 15:20:36 -070023extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
24extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Jon Mason0dc243a2006-06-26 13:58:11 +020028extern void pci_iommu_alloc(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030/* The PCI address space does equal the physical memory
31 * address space. The networking and block device layers use
32 * this boolean for bounce buffer decisions
33 *
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010034 * On AMD64 it mostly equals, but we set it to zero if a hardware
35 * IOMMU (gart) of sotware IOMMU (swiotlb) is available.
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 */
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010037#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
38
Joerg Roedel966396d2007-10-24 12:49:48 +020039#if defined(CONFIG_GART_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
42 dma_addr_t ADDR_NAME;
43#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
44 __u32 LEN_NAME;
45#define pci_unmap_addr(PTR, ADDR_NAME) \
46 ((PTR)->ADDR_NAME)
47#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
48 (((PTR)->ADDR_NAME) = (VAL))
49#define pci_unmap_len(PTR, LEN_NAME) \
50 ((PTR)->LEN_NAME)
51#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
52 (((PTR)->LEN_NAME) = (VAL))
53
54#else
55/* No IOMMU */
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
58#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
59#define pci_unmap_addr(PTR, ADDR_NAME) (0)
60#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
61#define pci_unmap_len(PTR, LEN_NAME) (0)
62#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
63
64#endif
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#endif /* __KERNEL__ */
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69#endif /* __x8664_PCI_H */