diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-07-16 06:02:54 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-07-28 05:10:35 -0400 |
commit | 1eca5c92729a83f64826d15a9ecb1652dda54bcb (patch) | |
tree | 95753726159c945deccef68d4b54de9f4d5ec756 | |
parent | 714750dd5c6aef8e204d35ba28c1be9641418671 (diff) |
sh: Add memory chunks to SH-Mobile UIO devices
This patch adds physically contiguous memory chunks to the UIO devices.
The same strategy can be used in the future for the CEU as well.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7343.c | 8 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7366.c | 12 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7722.c | 8 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7723.c | 12 | ||||
-rw-r--r-- | arch/sh/mm/consistent.c | 30 | ||||
-rw-r--r-- | include/asm-sh/device.h | 5 |
6 files changed, 75 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c index bcc4255acd84..79ce34e19a2e 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c | |||
@@ -66,6 +66,9 @@ static struct resource vpu_resources[] = { | |||
66 | .end = 0xfe9022eb, | 66 | .end = 0xfe9022eb, |
67 | .flags = IORESOURCE_MEM, | 67 | .flags = IORESOURCE_MEM, |
68 | }, | 68 | }, |
69 | [1] = { | ||
70 | /* place holder for contiguous memory */ | ||
71 | }, | ||
69 | }; | 72 | }; |
70 | 73 | ||
71 | static struct platform_device vpu_device = { | 74 | static struct platform_device vpu_device = { |
@@ -91,6 +94,9 @@ static struct resource veu_resources[] = { | |||
91 | .end = 0xfe9200b7, | 94 | .end = 0xfe9200b7, |
92 | .flags = IORESOURCE_MEM, | 95 | .flags = IORESOURCE_MEM, |
93 | }, | 96 | }, |
97 | [1] = { | ||
98 | /* place holder for contiguous memory */ | ||
99 | }, | ||
94 | }; | 100 | }; |
95 | 101 | ||
96 | static struct platform_device veu_device = { | 102 | static struct platform_device veu_device = { |
@@ -132,6 +138,8 @@ static struct platform_device *sh7343_devices[] __initdata = { | |||
132 | 138 | ||
133 | static int __init sh7343_devices_setup(void) | 139 | static int __init sh7343_devices_setup(void) |
134 | { | 140 | { |
141 | platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20); | ||
142 | platform_resource_setup_memory(&veu_device, "veu", 2 << 20); | ||
135 | return platform_add_devices(sh7343_devices, | 143 | return platform_add_devices(sh7343_devices, |
136 | ARRAY_SIZE(sh7343_devices)); | 144 | ARRAY_SIZE(sh7343_devices)); |
137 | } | 145 | } |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c index 2a0fbc3ed9c2..7ee01757f3fe 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c | |||
@@ -48,6 +48,9 @@ static struct resource vpu_resources[] = { | |||
48 | .end = 0xfe902807, | 48 | .end = 0xfe902807, |
49 | .flags = IORESOURCE_MEM, | 49 | .flags = IORESOURCE_MEM, |
50 | }, | 50 | }, |
51 | [1] = { | ||
52 | /* place holder for contiguous memory */ | ||
53 | }, | ||
51 | }; | 54 | }; |
52 | 55 | ||
53 | static struct platform_device vpu_device = { | 56 | static struct platform_device vpu_device = { |
@@ -73,6 +76,9 @@ static struct resource veu0_resources[] = { | |||
73 | .end = 0xfe9200b7, | 76 | .end = 0xfe9200b7, |
74 | .flags = IORESOURCE_MEM, | 77 | .flags = IORESOURCE_MEM, |
75 | }, | 78 | }, |
79 | [1] = { | ||
80 | /* place holder for contiguous memory */ | ||
81 | }, | ||
76 | }; | 82 | }; |
77 | 83 | ||
78 | static struct platform_device veu0_device = { | 84 | static struct platform_device veu0_device = { |
@@ -98,6 +104,9 @@ static struct resource veu1_resources[] = { | |||
98 | .end = 0xfe9240b7, | 104 | .end = 0xfe9240b7, |
99 | .flags = IORESOURCE_MEM, | 105 | .flags = IORESOURCE_MEM, |
100 | }, | 106 | }, |
107 | [1] = { | ||
108 | /* place holder for contiguous memory */ | ||
109 | }, | ||
101 | }; | 110 | }; |
102 | 111 | ||
103 | static struct platform_device veu1_device = { | 112 | static struct platform_device veu1_device = { |
@@ -139,6 +148,9 @@ static struct platform_device *sh7366_devices[] __initdata = { | |||
139 | 148 | ||
140 | static int __init sh7366_devices_setup(void) | 149 | static int __init sh7366_devices_setup(void) |
141 | { | 150 | { |
151 | platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20); | ||
152 | platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20); | ||
153 | platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20); | ||
142 | return platform_add_devices(sh7366_devices, | 154 | return platform_add_devices(sh7366_devices, |
143 | ARRAY_SIZE(sh7366_devices)); | 155 | ARRAY_SIZE(sh7366_devices)); |
144 | } | 156 | } |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c index 39854d9413cf..6015f842edad 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c | |||
@@ -73,6 +73,9 @@ static struct resource vpu_resources[] = { | |||
73 | .end = 0xfe9022eb, | 73 | .end = 0xfe9022eb, |
74 | .flags = IORESOURCE_MEM, | 74 | .flags = IORESOURCE_MEM, |
75 | }, | 75 | }, |
76 | [1] = { | ||
77 | /* place holder for contiguous memory */ | ||
78 | }, | ||
76 | }; | 79 | }; |
77 | 80 | ||
78 | static struct platform_device vpu_device = { | 81 | static struct platform_device vpu_device = { |
@@ -98,6 +101,9 @@ static struct resource veu_resources[] = { | |||
98 | .end = 0xfe9200b7, | 101 | .end = 0xfe9200b7, |
99 | .flags = IORESOURCE_MEM, | 102 | .flags = IORESOURCE_MEM, |
100 | }, | 103 | }, |
104 | [1] = { | ||
105 | /* place holder for contiguous memory */ | ||
106 | }, | ||
101 | }; | 107 | }; |
102 | 108 | ||
103 | static struct platform_device veu_device = { | 109 | static struct platform_device veu_device = { |
@@ -152,6 +158,8 @@ static struct platform_device *sh7722_devices[] __initdata = { | |||
152 | 158 | ||
153 | static int __init sh7722_devices_setup(void) | 159 | static int __init sh7722_devices_setup(void) |
154 | { | 160 | { |
161 | platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20); | ||
162 | platform_resource_setup_memory(&veu_device, "veu", 2 << 20); | ||
155 | return platform_add_devices(sh7722_devices, | 163 | return platform_add_devices(sh7722_devices, |
156 | ARRAY_SIZE(sh7722_devices)); | 164 | ARRAY_SIZE(sh7722_devices)); |
157 | } | 165 | } |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c index 1f3137ad0136..cb5e6f822e64 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c | |||
@@ -28,6 +28,9 @@ static struct resource vpu_resources[] = { | |||
28 | .end = 0xfe902807, | 28 | .end = 0xfe902807, |
29 | .flags = IORESOURCE_MEM, | 29 | .flags = IORESOURCE_MEM, |
30 | }, | 30 | }, |
31 | [1] = { | ||
32 | /* place holder for contiguous memory */ | ||
33 | }, | ||
31 | }; | 34 | }; |
32 | 35 | ||
33 | static struct platform_device vpu_device = { | 36 | static struct platform_device vpu_device = { |
@@ -53,6 +56,9 @@ static struct resource veu0_resources[] = { | |||
53 | .end = 0xfe92027b, | 56 | .end = 0xfe92027b, |
54 | .flags = IORESOURCE_MEM, | 57 | .flags = IORESOURCE_MEM, |
55 | }, | 58 | }, |
59 | [1] = { | ||
60 | /* place holder for contiguous memory */ | ||
61 | }, | ||
56 | }; | 62 | }; |
57 | 63 | ||
58 | static struct platform_device veu0_device = { | 64 | static struct platform_device veu0_device = { |
@@ -78,6 +84,9 @@ static struct resource veu1_resources[] = { | |||
78 | .end = 0xfe92427b, | 84 | .end = 0xfe92427b, |
79 | .flags = IORESOURCE_MEM, | 85 | .flags = IORESOURCE_MEM, |
80 | }, | 86 | }, |
87 | [1] = { | ||
88 | /* place holder for contiguous memory */ | ||
89 | }, | ||
81 | }; | 90 | }; |
82 | 91 | ||
83 | static struct platform_device veu1_device = { | 92 | static struct platform_device veu1_device = { |
@@ -221,6 +230,9 @@ static struct platform_device *sh7723_devices[] __initdata = { | |||
221 | 230 | ||
222 | static int __init sh7723_devices_setup(void) | 231 | static int __init sh7723_devices_setup(void) |
223 | { | 232 | { |
233 | platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20); | ||
234 | platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20); | ||
235 | platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20); | ||
224 | return platform_add_devices(sh7723_devices, | 236 | return platform_add_devices(sh7723_devices, |
225 | ARRAY_SIZE(sh7723_devices)); | 237 | ARRAY_SIZE(sh7723_devices)); |
226 | } | 238 | } |
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index d3c33fc5b1c2..8277982d0938 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * for more details. | 10 | * for more details. |
11 | */ | 11 | */ |
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/platform_device.h> | ||
13 | #include <linux/dma-mapping.h> | 14 | #include <linux/dma-mapping.h> |
14 | #include <asm/cacheflush.h> | 15 | #include <asm/cacheflush.h> |
15 | #include <asm/addrspace.h> | 16 | #include <asm/addrspace.h> |
@@ -185,3 +186,32 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | |||
185 | } | 186 | } |
186 | } | 187 | } |
187 | EXPORT_SYMBOL(dma_cache_sync); | 188 | EXPORT_SYMBOL(dma_cache_sync); |
189 | |||
190 | int platform_resource_setup_memory(struct platform_device *pdev, | ||
191 | char *name, unsigned long memsize) | ||
192 | { | ||
193 | struct resource *r; | ||
194 | dma_addr_t dma_handle; | ||
195 | void *buf; | ||
196 | |||
197 | r = pdev->resource + pdev->num_resources - 1; | ||
198 | if (r->flags) { | ||
199 | pr_warning("%s: unable to find empty space for resource\n", | ||
200 | name); | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL); | ||
205 | if (!buf) { | ||
206 | pr_warning("%s: unable to allocate memory\n", name); | ||
207 | return -ENOMEM; | ||
208 | } | ||
209 | |||
210 | memset(buf, 0, memsize); | ||
211 | |||
212 | r->flags = IORESOURCE_MEM; | ||
213 | r->start = dma_handle; | ||
214 | r->end = r->start + memsize - 1; | ||
215 | r->name = name; | ||
216 | return 0; | ||
217 | } | ||
diff --git a/include/asm-sh/device.h b/include/asm-sh/device.h index d8f9872b0e2d..efd511d0803a 100644 --- a/include/asm-sh/device.h +++ b/include/asm-sh/device.h | |||
@@ -5,3 +5,8 @@ | |||
5 | */ | 5 | */ |
6 | #include <asm-generic/device.h> | 6 | #include <asm-generic/device.h> |
7 | 7 | ||
8 | struct platform_device; | ||
9 | /* allocate contiguous memory chunk and fill in struct resource */ | ||
10 | int platform_resource_setup_memory(struct platform_device *pdev, | ||
11 | char *name, unsigned long memsize); | ||
12 | |||