blob: d21dea44e76fa45407526dbb374ef7207fd8ef49 [file] [log] [blame]
Fenghua Yu62fdd762008-10-17 12:14:13 -07001/* Glue code to lib/swiotlb.c */
2
3#include <linux/pci.h>
4#include <linux/cache.h>
5#include <linux/module.h>
6#include <linux/dma-mapping.h>
7
8#include <asm/swiotlb.h>
9#include <asm/dma.h>
10#include <asm/iommu.h>
11#include <asm/machvec.h>
12
13int swiotlb __read_mostly;
14EXPORT_SYMBOL(swiotlb);
15
FUJITA Tomonoric82e4412009-01-05 23:36:11 +090016/* Set this to 1 if there is a HW IOMMU in the system */
17int iommu_detected __read_mostly;
18
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090019struct dma_map_ops swiotlb_dma_ops = {
Fenghua Yu62fdd762008-10-17 12:14:13 -070020 .alloc_coherent = swiotlb_alloc_coherent,
21 .free_coherent = swiotlb_free_coherent,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090022 .map_page = swiotlb_map_page,
23 .unmap_page = swiotlb_unmap_page,
24 .map_sg = swiotlb_map_sg_attrs,
25 .unmap_sg = swiotlb_unmap_sg_attrs,
Fenghua Yu62fdd762008-10-17 12:14:13 -070026 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
27 .sync_single_for_device = swiotlb_sync_single_for_device,
28 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
29 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
30 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
31 .sync_sg_for_device = swiotlb_sync_sg_for_device,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090032 .dma_supported = swiotlb_dma_supported,
FUJITA Tomonoric82e4412009-01-05 23:36:11 +090033 .mapping_error = swiotlb_dma_mapping_error,
Fenghua Yu62fdd762008-10-17 12:14:13 -070034};
35
Luck, Tony07716e42009-01-06 10:25:25 -080036void __init swiotlb_dma_init(void)
FUJITA Tomonori4d9b9772009-01-05 23:36:12 +090037{
38 dma_ops = &swiotlb_dma_ops;
39 swiotlb_init();
40}
41
Fenghua Yu62fdd762008-10-17 12:14:13 -070042void __init pci_swiotlb_init(void)
43{
44 if (!iommu_detected) {
45#ifdef CONFIG_IA64_GENERIC
46 swiotlb = 1;
47 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
48 machvec_init("dig");
49 swiotlb_init();
50 dma_ops = &swiotlb_dma_ops;
51#else
52 panic("Unable to find Intel IOMMU");
53#endif
54 }
55}