blob: df867e5d80b197a220c8cd84967a8adf9b6c88db [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#ifdef __KERNEL__
5
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +03006#ifdef CONFIG_CALGARY_IOMMU
Joe Perches3cb47d72008-03-23 01:03:02 -07007static inline void *pci_iommu(struct pci_bus *bus)
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +03008{
9 struct pci_sysdata *sd = bus->sysdata;
10 return sd->iommu;
11}
12
13static inline void set_pci_iommu(struct pci_bus *bus, void *val)
14{
15 struct pci_sysdata *sd = bus->sysdata;
16 sd->iommu = val;
17}
18#endif /* CONFIG_CALGARY_IOMMU */
19
Joe Perches3cb47d72008-03-23 01:03:02 -070020extern int (*pci_config_read)(int seg, int bus, int dev, int fn,
21 int reg, int len, u32 *value);
22extern int (*pci_config_write)(int seg, int bus, int dev, int fn,
23 int reg, int len, u32 value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Jon Mason0dc243a2006-06-26 13:58:11 +020025extern void pci_iommu_alloc(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027/* The PCI address space does equal the physical memory
28 * address space. The networking and block device layers use
29 * this boolean for bounce buffer decisions
30 *
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010031 * On AMD64 it mostly equals, but we set it to zero if a hardware
32 * IOMMU (gart) of sotware IOMMU (swiotlb) is available.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 */
Muli Ben-Yehuda17a941d2006-01-11 22:44:42 +010034#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
35
Joerg Roedel966396d2007-10-24 12:49:48 +020036#if defined(CONFIG_GART_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
39 dma_addr_t ADDR_NAME;
40#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
41 __u32 LEN_NAME;
42#define pci_unmap_addr(PTR, ADDR_NAME) \
43 ((PTR)->ADDR_NAME)
44#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
45 (((PTR)->ADDR_NAME) = (VAL))
46#define pci_unmap_len(PTR, LEN_NAME) \
47 ((PTR)->LEN_NAME)
48#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
49 (((PTR)->LEN_NAME) = (VAL))
50
51#else
52/* No IOMMU */
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
55#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
56#define pci_unmap_addr(PTR, ADDR_NAME) (0)
57#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
58#define pci_unmap_len(PTR, LEN_NAME) (0)
59#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
60
61#endif
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#endif /* __KERNEL__ */
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#endif /* __x8664_PCI_H */