blob: 04eb5681448c8ade147b71296531488bd56c93f6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ALPHA_DMA_MAPPING_H
2#define _ALPHA_DMA_MAPPING_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
5#ifdef CONFIG_PCI
6
7#include <linux/pci.h>
8
9#define dma_map_single(dev, va, size, dir) \
10 pci_map_single(alpha_gendev_to_pci(dev), va, size, dir)
11#define dma_unmap_single(dev, addr, size, dir) \
12 pci_unmap_single(alpha_gendev_to_pci(dev), addr, size, dir)
13#define dma_alloc_coherent(dev, size, addr, gfp) \
Ivan Kokshayskyc143d432008-04-02 13:04:43 -070014 __pci_alloc_consistent(alpha_gendev_to_pci(dev), size, addr, gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#define dma_free_coherent(dev, size, va, addr) \
16 pci_free_consistent(alpha_gendev_to_pci(dev), size, va, addr)
17#define dma_map_page(dev, page, off, size, dir) \
Andrew Morton817c41d2006-01-06 00:09:50 -080018 pci_map_page(alpha_gendev_to_pci(dev), page, off, size, dir)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#define dma_unmap_page(dev, addr, size, dir) \
20 pci_unmap_page(alpha_gendev_to_pci(dev), addr, size, dir)
21#define dma_map_sg(dev, sg, nents, dir) \
22 pci_map_sg(alpha_gendev_to_pci(dev), sg, nents, dir)
23#define dma_unmap_sg(dev, sg, nents, dir) \
24 pci_unmap_sg(alpha_gendev_to_pci(dev), sg, nents, dir)
25#define dma_supported(dev, mask) \
26 pci_dma_supported(alpha_gendev_to_pci(dev), mask)
FUJITA Tomonori8d8bb392008-07-25 19:44:49 -070027#define dma_mapping_error(dev, addr) \
28 pci_dma_mapping_error(alpha_gendev_to_pci(dev), addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30#else /* no PCI - no IOMMU. */
31
Ivan Kokshayskyee0c4682009-01-29 14:25:19 -080032#include <asm/io.h> /* for virt_to_phys() */
33
Alexey Dobriyance5f8d72006-02-01 03:04:56 -080034struct scatterlist;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035void *dma_alloc_coherent(struct device *dev, size_t size,
Al Viro55c5d742005-10-21 03:21:08 -040036 dma_addr_t *dma_handle, gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
38 enum dma_data_direction direction);
39
40#define dma_free_coherent(dev, size, va, addr) \
41 free_pages((unsigned long)va, get_order(size))
42#define dma_supported(dev, mask) (mask < 0x00ffffffUL ? 0 : 1)
43#define dma_map_single(dev, va, size, dir) virt_to_phys(va)
44#define dma_map_page(dev, page, off, size, dir) (page_to_pa(page) + off)
45
Al Viro6a13f662007-01-30 13:24:00 +000046#define dma_unmap_single(dev, addr, size, dir) ((void)0)
47#define dma_unmap_page(dev, addr, size, dir) ((void)0)
48#define dma_unmap_sg(dev, sg, nents, dir) ((void)0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
FUJITA Tomonori8d8bb392008-07-25 19:44:49 -070050#define dma_mapping_error(dev, addr) (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#endif /* !CONFIG_PCI */
53
54#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
55#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
Ralf Baechlef67637e2006-12-06 20:38:54 -080056#define dma_is_consistent(d, h) (1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58int dma_set_mask(struct device *dev, u64 mask);
59
Al Virod0a23392007-01-30 13:23:55 +000060#define dma_sync_single_for_cpu(dev, addr, size, dir) ((void)0)
61#define dma_sync_single_for_device(dev, addr, size, dir) ((void)0)
62#define dma_sync_single_range(dev, addr, off, size, dir) ((void)0)
63#define dma_sync_sg_for_cpu(dev, sg, nents, dir) ((void)0)
64#define dma_sync_sg_for_device(dev, sg, nents, dir) ((void)0)
65#define dma_cache_sync(dev, va, size, dir) ((void)0)
66#define dma_sync_single_range_for_cpu(dev, addr, offset, size, dir) ((void)0)
67#define dma_sync_single_range_for_device(dev, addr, offset, size, dir) ((void)0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69#define dma_get_cache_alignment() L1_CACHE_BYTES
70
71#endif /* _ALPHA_DMA_MAPPING_H */