Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 1 | /* 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 | |
| 13 | int swiotlb __read_mostly; |
| 14 | EXPORT_SYMBOL(swiotlb); |
| 15 | |
FUJITA Tomonori | c82e441 | 2009-01-05 23:36:11 +0900 | [diff] [blame^] | 16 | /* Set this to 1 if there is a HW IOMMU in the system */ |
| 17 | int iommu_detected __read_mostly; |
| 18 | |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 19 | struct dma_mapping_ops swiotlb_dma_ops = { |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 20 | .alloc_coherent = swiotlb_alloc_coherent, |
| 21 | .free_coherent = swiotlb_free_coherent, |
| 22 | .map_single = swiotlb_map_single, |
| 23 | .unmap_single = swiotlb_unmap_single, |
FUJITA Tomonori | c82e441 | 2009-01-05 23:36:11 +0900 | [diff] [blame^] | 24 | .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 Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 28 | .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 Tomonori | c82e441 | 2009-01-05 23:36:11 +0900 | [diff] [blame^] | 37 | .mapping_error = swiotlb_dma_mapping_error, |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | void __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 | } |