blob: b62fb932b99aca5212cbe75e3c2f63784ff92362 [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
Fenghua Yu62fdd762008-10-17 12:14:13 -070019struct dma_mapping_ops swiotlb_dma_ops = {
Fenghua Yu62fdd762008-10-17 12:14:13 -070020 .alloc_coherent = swiotlb_alloc_coherent,
21 .free_coherent = swiotlb_free_coherent,
22 .map_single = swiotlb_map_single,
23 .unmap_single = swiotlb_unmap_single,
FUJITA Tomonoric82e4412009-01-05 23:36:11 +090024 .map_single_attrs = swiotlb_map_single_attrs,
25 .unmap_single_attrs = swiotlb_unmap_single_attrs,
26 .map_sg_attrs = swiotlb_map_sg_attrs,
27 .unmap_sg_attrs = swiotlb_unmap_sg_attrs,
Fenghua Yu62fdd762008-10-17 12:14:13 -070028 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
29 .sync_single_for_device = swiotlb_sync_single_for_device,
30 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
31 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
32 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
33 .sync_sg_for_device = swiotlb_sync_sg_for_device,
34 .map_sg = swiotlb_map_sg,
35 .unmap_sg = swiotlb_unmap_sg,
36 .dma_supported_op = swiotlb_dma_supported,
FUJITA Tomonoric82e4412009-01-05 23:36:11 +090037 .mapping_error = swiotlb_dma_mapping_error,
Fenghua Yu62fdd762008-10-17 12:14:13 -070038};
39
40void __init pci_swiotlb_init(void)
41{
42 if (!iommu_detected) {
43#ifdef CONFIG_IA64_GENERIC
44 swiotlb = 1;
45 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
46 machvec_init("dig");
47 swiotlb_init();
48 dma_ops = &swiotlb_dma_ops;
49#else
50 panic("Unable to find Intel IOMMU");
51#endif
52 }
53}