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 | |
FUJITA Tomonori | 160c1d8 | 2009-01-05 23:59:02 +0900 | [diff] [blame] | 19 | struct dma_map_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, |
FUJITA Tomonori | 160c1d8 | 2009-01-05 23:59:02 +0900 | [diff] [blame] | 22 | .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 Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 26 | .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 Tomonori | 160c1d8 | 2009-01-05 23:59:02 +0900 | [diff] [blame] | 32 | .dma_supported = swiotlb_dma_supported, |
FUJITA Tomonori | c82e441 | 2009-01-05 23:36:11 +0900 | [diff] [blame] | 33 | .mapping_error = swiotlb_dma_mapping_error, |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
Luck, Tony | 07716e4 | 2009-01-06 10:25:25 -0800 | [diff] [blame^] | 36 | void __init swiotlb_dma_init(void) |
FUJITA Tomonori | 4d9b977 | 2009-01-05 23:36:12 +0900 | [diff] [blame] | 37 | { |
| 38 | dma_ops = &swiotlb_dma_ops; |
| 39 | swiotlb_init(); |
| 40 | } |
| 41 | |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 42 | void __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 | } |