diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-10-19 23:55:56 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-10-19 23:55:56 -0400 |
commit | 73c926bee0e4b7739bbb992a0a3df561178dd522 (patch) | |
tree | 1b57464ef1a105911ddd9dab514e404fa2aa7cb2 /arch/sh/kernel | |
parent | 14c011deb4cb906d72b6b2b6880e21c3cc110fcc (diff) |
sh: Convert to asm-generic/dma-mapping-common.h
This converts the old DMA mapping support to the new generic
dma-mapping-common.h abstraction.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel')
-rw-r--r-- | arch/sh/kernel/Makefile | 3 | ||||
-rw-r--r-- | arch/sh/kernel/dma-nommu.c | 76 |
2 files changed, 78 insertions, 1 deletions
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index 6fe0fcdaf531..097ae5ceb0e3 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile | |||
@@ -11,7 +11,8 @@ endif | |||
11 | 11 | ||
12 | CFLAGS_REMOVE_return_address.o = -pg | 12 | CFLAGS_REMOVE_return_address.o = -pg |
13 | 13 | ||
14 | obj-y := debugtraps.o dumpstack.o idle.o io.o io_generic.o irq.o \ | 14 | obj-y := debugtraps.o dma-nommu.o dumpstack.o \ |
15 | idle.o io.o io_generic.o irq.o \ | ||
15 | irq_$(BITS).o machvec.o nmi_debug.o process_$(BITS).o \ | 16 | irq_$(BITS).o machvec.o nmi_debug.o process_$(BITS).o \ |
16 | ptrace_$(BITS).o return_address.o \ | 17 | ptrace_$(BITS).o return_address.o \ |
17 | setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \ | 18 | setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \ |
diff --git a/arch/sh/kernel/dma-nommu.c b/arch/sh/kernel/dma-nommu.c new file mode 100644 index 000000000000..e88fcebf860c --- /dev/null +++ b/arch/sh/kernel/dma-nommu.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * DMA mapping support for platforms lacking IOMMUs. | ||
3 | * | ||
4 | * Copyright (C) 2009 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #include <linux/dma-mapping.h> | ||
11 | #include <linux/io.h> | ||
12 | |||
13 | static dma_addr_t nommu_map_page(struct device *dev, struct page *page, | ||
14 | unsigned long offset, size_t size, | ||
15 | enum dma_data_direction dir, | ||
16 | struct dma_attrs *attrs) | ||
17 | { | ||
18 | dma_addr_t addr = page_to_phys(page) + offset; | ||
19 | |||
20 | WARN_ON(size == 0); | ||
21 | dma_cache_sync(dev, page_address(page) + offset, size, dir); | ||
22 | |||
23 | return addr; | ||
24 | } | ||
25 | |||
26 | static int nommu_map_sg(struct device *dev, struct scatterlist *sg, | ||
27 | int nents, enum dma_data_direction dir, | ||
28 | struct dma_attrs *attrs) | ||
29 | { | ||
30 | struct scatterlist *s; | ||
31 | int i; | ||
32 | |||
33 | WARN_ON(nents == 0 || sg[0].length == 0); | ||
34 | |||
35 | for_each_sg(sg, s, nents, i) { | ||
36 | BUG_ON(!sg_page(s)); | ||
37 | |||
38 | dma_cache_sync(dev, sg_virt(s), s->length, dir); | ||
39 | |||
40 | s->dma_address = sg_phys(s); | ||
41 | s->dma_length = s->length; | ||
42 | } | ||
43 | |||
44 | return nents; | ||
45 | } | ||
46 | |||
47 | static void nommu_sync_single(struct device *dev, dma_addr_t addr, | ||
48 | size_t size, enum dma_data_direction dir) | ||
49 | { | ||
50 | dma_cache_sync(dev, phys_to_virt(addr), size, dir); | ||
51 | } | ||
52 | |||
53 | static void nommu_sync_sg(struct device *dev, struct scatterlist *sg, | ||
54 | int nelems, enum dma_data_direction dir) | ||
55 | { | ||
56 | struct scatterlist *s; | ||
57 | int i; | ||
58 | |||
59 | for_each_sg(sg, s, nelems, i) | ||
60 | dma_cache_sync(dev, sg_virt(s), s->length, dir); | ||
61 | } | ||
62 | |||
63 | struct dma_map_ops nommu_dma_ops = { | ||
64 | .map_page = nommu_map_page, | ||
65 | .map_sg = nommu_map_sg, | ||
66 | .sync_single_for_device = nommu_sync_single, | ||
67 | .sync_sg_for_device = nommu_sync_sg, | ||
68 | .is_phys = 1, | ||
69 | }; | ||
70 | |||
71 | void __init no_iommu_init(void) | ||
72 | { | ||
73 | if (dma_ops) | ||
74 | return; | ||
75 | dma_ops = &nommu_dma_ops; | ||
76 | } | ||