Glauber Costa | 22456b9 | 2008-03-25 18:36:21 -0300 | [diff] [blame] | 1 | #include <linux/mm.h> |
| 2 | #include <linux/kernel.h> |
| 3 | #include <linux/module.h> |
| 4 | #include <linux/dma-mapping.h> |
| 5 | #include <asm/dma-mapping.h> |
| 6 | |
| 7 | static dma_addr_t pci32_map_single(struct device *dev, void *ptr, |
| 8 | size_t size, int direction) |
| 9 | { |
| 10 | WARN_ON(size == 0); |
| 11 | flush_write_buffers(); |
| 12 | return virt_to_phys(ptr); |
| 13 | } |
| 14 | |
Glauber Costa | 16a3ce9 | 2008-03-25 18:36:23 -0300 | [diff] [blame] | 15 | static int pci32_dma_map_sg(struct device *dev, struct scatterlist *sglist, |
| 16 | int nents, int direction) |
| 17 | { |
| 18 | struct scatterlist *sg; |
| 19 | int i; |
| 20 | |
| 21 | WARN_ON(nents == 0 || sglist[0].length == 0); |
| 22 | |
| 23 | for_each_sg(sglist, sg, nents, i) { |
| 24 | BUG_ON(!sg_page(sg)); |
| 25 | |
| 26 | sg->dma_address = sg_phys(sg); |
| 27 | } |
| 28 | |
| 29 | flush_write_buffers(); |
| 30 | return nents; |
| 31 | } |
| 32 | |
Glauber Costa | 22456b9 | 2008-03-25 18:36:21 -0300 | [diff] [blame] | 33 | static const struct dma_mapping_ops pci32_dma_ops = { |
| 34 | .map_single = pci32_map_single, |
Glauber Costa | 0cb0ae6 | 2008-03-25 18:36:22 -0300 | [diff] [blame] | 35 | .unmap_single = NULL, |
Glauber Costa | 16a3ce9 | 2008-03-25 18:36:23 -0300 | [diff] [blame] | 36 | .map_sg = pci32_dma_map_sg, |
Glauber Costa | 72c784f | 2008-03-25 18:36:24 -0300 | [diff] [blame] | 37 | .unmap_sg = NULL, |
Glauber Costa | c01dd8c | 2008-03-25 18:36:25 -0300 | [diff] [blame^] | 38 | .sync_single_for_cpu = NULL, |
Glauber Costa | 22456b9 | 2008-03-25 18:36:21 -0300 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | const struct dma_mapping_ops *dma_ops = &pci32_dma_ops; |
| 42 | EXPORT_SYMBOL(dma_ops); |