blob: 3d2d2e7b841c17bb5325a0270f4ae44b1bf602a1 [file] [log] [blame]
Stepan Moskovchenko69e21362011-02-11 12:28:17 -08001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070011 */
12
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/bootmem.h>
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080016#include <mach/irqs.h>
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070017#include <mach/iommu.h>
Joel King41d594e2011-10-14 13:18:20 -070018#include <mach/socinfo.h>
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070019
20static struct resource msm_iommu_jpegd_resources[] = {
21 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080022 .start = 0x07300000,
23 .end = 0x07300000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070024 .name = "physbase",
25 .flags = IORESOURCE_MEM,
26 },
27 {
28 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070029 .start = 98,
30 .end = 98,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070031 .flags = IORESOURCE_IRQ,
32 },
33 {
34 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070035 .start = 97,
36 .end = 97,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070037 .flags = IORESOURCE_IRQ,
38 },
39};
40
41static struct resource msm_iommu_vpe_resources[] = {
42 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080043 .start = 0x07400000,
44 .end = 0x07400000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070045 .name = "physbase",
46 .flags = IORESOURCE_MEM,
47 },
48 {
49 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070050 .start = 84,
51 .end = 84,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070052 .flags = IORESOURCE_IRQ,
53 },
54 {
55 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070056 .start = 83,
57 .end = 83,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070058 .flags = IORESOURCE_IRQ,
59 },
60};
61
62static struct resource msm_iommu_mdp0_resources[] = {
63 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080064 .start = 0x07500000,
65 .end = 0x07500000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070066 .name = "physbase",
67 .flags = IORESOURCE_MEM,
68 },
69 {
70 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070071 .start = 96,
72 .end = 96,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070073 .flags = IORESOURCE_IRQ,
74 },
75 {
76 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070077 .start = 95,
78 .end = 95,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070079 .flags = IORESOURCE_IRQ,
80 },
81};
82
83static struct resource msm_iommu_mdp1_resources[] = {
84 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080085 .start = 0x07600000,
86 .end = 0x07600000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070087 .name = "physbase",
88 .flags = IORESOURCE_MEM,
89 },
90 {
91 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070092 .start = 94,
93 .end = 94,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070094 .flags = IORESOURCE_IRQ,
95 },
96 {
97 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -070098 .start = 93,
99 .end = 93,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700100 .flags = IORESOURCE_IRQ,
101 },
102};
103
104static struct resource msm_iommu_rot_resources[] = {
105 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800106 .start = 0x07700000,
107 .end = 0x07700000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700108 .name = "physbase",
109 .flags = IORESOURCE_MEM,
110 },
111 {
112 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700113 .start = 92,
114 .end = 92,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700115 .flags = IORESOURCE_IRQ,
116 },
117 {
118 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700119 .start = 91,
120 .end = 91,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700121 .flags = IORESOURCE_IRQ,
122 },
123};
124
125static struct resource msm_iommu_ijpeg_resources[] = {
126 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800127 .start = 0x07800000,
128 .end = 0x07800000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700129 .name = "physbase",
130 .flags = IORESOURCE_MEM,
131 },
132 {
133 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700134 .start = 100,
135 .end = 100,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700136 .flags = IORESOURCE_IRQ,
137 },
138 {
139 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700140 .start = 99,
141 .end = 99,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700142 .flags = IORESOURCE_IRQ,
143 },
144};
145
146static struct resource msm_iommu_vfe_resources[] = {
147 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800148 .start = 0x07900000,
149 .end = 0x07900000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700150 .name = "physbase",
151 .flags = IORESOURCE_MEM,
152 },
153 {
154 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700155 .start = 86,
156 .end = 86,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700157 .flags = IORESOURCE_IRQ,
158 },
159 {
160 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700161 .start = 85,
162 .end = 85,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700163 .flags = IORESOURCE_IRQ,
164 },
165};
166
167static struct resource msm_iommu_vcodec_a_resources[] = {
168 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800169 .start = 0x07A00000,
170 .end = 0x07A00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700171 .name = "physbase",
172 .flags = IORESOURCE_MEM,
173 },
174 {
175 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700176 .start = 90,
177 .end = 90,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700178 .flags = IORESOURCE_IRQ,
179 },
180 {
181 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700182 .start = 89,
183 .end = 89,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700184 .flags = IORESOURCE_IRQ,
185 },
186};
187
188static struct resource msm_iommu_vcodec_b_resources[] = {
189 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800190 .start = 0x07B00000,
191 .end = 0x07B00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700192 .name = "physbase",
193 .flags = IORESOURCE_MEM,
194 },
195 {
196 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700197 .start = 88,
198 .end = 88,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700199 .flags = IORESOURCE_IRQ,
200 },
201 {
202 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700203 .start = 87,
204 .end = 87,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700205 .flags = IORESOURCE_IRQ,
206 },
207};
208
209static struct resource msm_iommu_gfx3d_resources[] = {
210 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800211 .start = 0x07C00000,
212 .end = 0x07C00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700213 .name = "physbase",
214 .flags = IORESOURCE_MEM,
215 },
216 {
217 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700218 .start = 102,
219 .end = 102,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700220 .flags = IORESOURCE_IRQ,
221 },
222 {
223 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700224 .start = 101,
225 .end = 101,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700226 .flags = IORESOURCE_IRQ,
227 },
228};
229
Joel King41d594e2011-10-14 13:18:20 -0700230static struct resource msm_iommu_gfx3d1_resources[] = {
231 {
232 .start = 0x07D00000,
233 .end = 0x07D00000 + SZ_1M - 1,
234 .name = "physbase",
235 .flags = IORESOURCE_MEM,
236 },
237 {
238 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700239 .start = 243,
240 .end = 243,
Joel King41d594e2011-10-14 13:18:20 -0700241 .flags = IORESOURCE_IRQ,
242 },
243 {
244 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700245 .start = 242,
246 .end = 242,
Joel King41d594e2011-10-14 13:18:20 -0700247 .flags = IORESOURCE_IRQ,
248 },
249};
250
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700251static struct resource msm_iommu_gfx2d0_resources[] = {
252 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800253 .start = 0x07D00000,
254 .end = 0x07D00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700255 .name = "physbase",
256 .flags = IORESOURCE_MEM,
257 },
258 {
259 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700260 .start = 104,
261 .end = 104,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700262 .flags = IORESOURCE_IRQ,
263 },
264 {
265 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700266 .start = 103,
267 .end = 103,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700268 .flags = IORESOURCE_IRQ,
269 },
270};
271
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800272static struct resource msm_iommu_gfx2d1_resources[] = {
273 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800274 .start = 0x07E00000,
275 .end = 0x07E00000 + SZ_1M - 1,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800276 .name = "physbase",
277 .flags = IORESOURCE_MEM,
278 },
279 {
280 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700281 .start = 243,
282 .end = 243,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800283 .flags = IORESOURCE_IRQ,
284 },
285 {
286 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700287 .start = 242,
288 .end = 242,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800289 .flags = IORESOURCE_IRQ,
290 },
291};
292
Joel King41d594e2011-10-14 13:18:20 -0700293static struct resource msm_iommu_vcap_resources[] = {
294 {
295 .start = 0x07200000,
296 .end = 0x07200000 + SZ_1M - 1,
297 .name = "physbase",
298 .flags = IORESOURCE_MEM,
299 },
300 {
301 .name = "nonsecure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700302 .start = 269,
303 .end = 269,
Joel King41d594e2011-10-14 13:18:20 -0700304 .flags = IORESOURCE_IRQ,
305 },
306 {
307 .name = "secure_irq",
Stepan Moskovchenkoc64fd942011-10-27 17:47:58 -0700308 .start = 268,
309 .end = 268,
Joel King41d594e2011-10-14 13:18:20 -0700310 .flags = IORESOURCE_IRQ,
311 },
312};
313
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700314static struct platform_device msm_root_iommu_dev = {
315 .name = "msm_iommu",
316 .id = -1,
317};
318
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800319static struct msm_iommu_dev jpegd_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700320 .name = "jpegd",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800321 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700322};
323
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800324static struct msm_iommu_dev vpe_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800325 .name = "vpe",
326 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700327};
328
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800329static struct msm_iommu_dev mdp0_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800330 .name = "mdp0",
331 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700332};
333
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800334static struct msm_iommu_dev mdp1_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800335 .name = "mdp1",
336 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700337};
338
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800339static struct msm_iommu_dev rot_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800340 .name = "rot",
341 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700342};
343
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800344static struct msm_iommu_dev ijpeg_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800345 .name = "ijpeg",
346 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700347};
348
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800349static struct msm_iommu_dev vfe_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700350 .name = "vfe",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800351 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700352};
353
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800354static struct msm_iommu_dev vcodec_a_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800355 .name = "vcodec_a",
356 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700357};
358
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800359static struct msm_iommu_dev vcodec_b_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800360 .name = "vcodec_b",
361 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700362};
363
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800364static struct msm_iommu_dev gfx3d_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700365 .name = "gfx3d",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800366 .ncb = 3,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700367};
368
Joel King41d594e2011-10-14 13:18:20 -0700369static struct msm_iommu_dev gfx3d1_iommu = {
370 .name = "gfx3d1",
371 .ncb = 3,
372};
373
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800374static struct msm_iommu_dev gfx2d0_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700375 .name = "gfx2d0",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800376 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700377};
378
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800379static struct msm_iommu_dev gfx2d1_iommu = {
380 .name = "gfx2d1",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800381 .ncb = 2,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800382};
383
Joel King41d594e2011-10-14 13:18:20 -0700384static struct msm_iommu_dev vcap_iommu = {
385 .name = "vcap",
386 .ncb = 2,
387};
388
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800389static struct platform_device msm_device_iommu_jpegd = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700390 .name = "msm_iommu",
391 .id = 0,
392 .dev = {
393 .parent = &msm_root_iommu_dev.dev,
394 },
395 .num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
396 .resource = msm_iommu_jpegd_resources,
397};
398
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800399static struct platform_device msm_device_iommu_vpe = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700400 .name = "msm_iommu",
401 .id = 1,
402 .dev = {
403 .parent = &msm_root_iommu_dev.dev,
404 },
405 .num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
406 .resource = msm_iommu_vpe_resources,
407};
408
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800409static struct platform_device msm_device_iommu_mdp0 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700410 .name = "msm_iommu",
411 .id = 2,
412 .dev = {
413 .parent = &msm_root_iommu_dev.dev,
414 },
415 .num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
416 .resource = msm_iommu_mdp0_resources,
417};
418
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800419static struct platform_device msm_device_iommu_mdp1 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700420 .name = "msm_iommu",
421 .id = 3,
422 .dev = {
423 .parent = &msm_root_iommu_dev.dev,
424 },
425 .num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
426 .resource = msm_iommu_mdp1_resources,
427};
428
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800429static struct platform_device msm_device_iommu_rot = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700430 .name = "msm_iommu",
431 .id = 4,
432 .dev = {
433 .parent = &msm_root_iommu_dev.dev,
434 },
435 .num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
436 .resource = msm_iommu_rot_resources,
437};
438
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800439static struct platform_device msm_device_iommu_ijpeg = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700440 .name = "msm_iommu",
441 .id = 5,
442 .dev = {
443 .parent = &msm_root_iommu_dev.dev,
444 },
445 .num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),
446 .resource = msm_iommu_ijpeg_resources,
447};
448
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800449static struct platform_device msm_device_iommu_vfe = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700450 .name = "msm_iommu",
451 .id = 6,
452 .dev = {
453 .parent = &msm_root_iommu_dev.dev,
454 },
455 .num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
456 .resource = msm_iommu_vfe_resources,
457};
458
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800459static struct platform_device msm_device_iommu_vcodec_a = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700460 .name = "msm_iommu",
461 .id = 7,
462 .dev = {
463 .parent = &msm_root_iommu_dev.dev,
464 },
465 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
466 .resource = msm_iommu_vcodec_a_resources,
467};
468
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800469static struct platform_device msm_device_iommu_vcodec_b = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700470 .name = "msm_iommu",
471 .id = 8,
472 .dev = {
473 .parent = &msm_root_iommu_dev.dev,
474 },
475 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
476 .resource = msm_iommu_vcodec_b_resources,
477};
478
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800479static struct platform_device msm_device_iommu_gfx3d = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700480 .name = "msm_iommu",
481 .id = 9,
482 .dev = {
483 .parent = &msm_root_iommu_dev.dev,
484 },
485 .num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
486 .resource = msm_iommu_gfx3d_resources,
487};
488
Joel King41d594e2011-10-14 13:18:20 -0700489static struct platform_device msm_device_iommu_gfx3d1 = {
490 .name = "msm_iommu",
491 .id = 10,
492 .dev = {
493 .parent = &msm_root_iommu_dev.dev,
494 },
495 .num_resources = ARRAY_SIZE(msm_iommu_gfx3d1_resources),
496 .resource = msm_iommu_gfx3d1_resources,
497};
498
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800499static struct platform_device msm_device_iommu_gfx2d0 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700500 .name = "msm_iommu",
501 .id = 10,
502 .dev = {
503 .parent = &msm_root_iommu_dev.dev,
504 },
505 .num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
506 .resource = msm_iommu_gfx2d0_resources,
507};
508
Joel King41d594e2011-10-14 13:18:20 -0700509static struct platform_device msm_device_iommu_gfx2d1 = {
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800510 .name = "msm_iommu",
511 .id = 11,
512 .dev = {
513 .parent = &msm_root_iommu_dev.dev,
514 },
515 .num_resources = ARRAY_SIZE(msm_iommu_gfx2d1_resources),
516 .resource = msm_iommu_gfx2d1_resources,
517};
518
Joel King41d594e2011-10-14 13:18:20 -0700519static struct platform_device msm_device_iommu_vcap = {
520 .name = "msm_iommu",
521 .id = 11,
522 .dev = {
523 .parent = &msm_root_iommu_dev.dev,
524 },
525 .num_resources = ARRAY_SIZE(msm_iommu_vcap_resources),
526 .resource = msm_iommu_vcap_resources,
527};
528
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700529static struct msm_iommu_ctx_dev jpegd_src_ctx = {
530 .name = "jpegd_src",
531 .num = 0,
532 .mids = {0, -1}
533};
534
535static struct msm_iommu_ctx_dev jpegd_dst_ctx = {
536 .name = "jpegd_dst",
537 .num = 1,
538 .mids = {1, -1}
539};
540
541static struct msm_iommu_ctx_dev vpe_src_ctx = {
542 .name = "vpe_src",
543 .num = 0,
544 .mids = {0, -1}
545};
546
547static struct msm_iommu_ctx_dev vpe_dst_ctx = {
548 .name = "vpe_dst",
549 .num = 1,
550 .mids = {1, -1}
551};
552
553static struct msm_iommu_ctx_dev mdp_vg1_ctx = {
554 .name = "mdp_vg1",
555 .num = 0,
556 .mids = {0, 2, -1}
557};
558
559static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {
560 .name = "mdp_rgb1",
561 .num = 1,
562 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
563};
564
565static struct msm_iommu_ctx_dev mdp_vg2_ctx = {
566 .name = "mdp_vg2",
567 .num = 0,
568 .mids = {0, 2, -1}
569};
570
571static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {
572 .name = "mdp_rgb2",
573 .num = 1,
574 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
575};
576
577static struct msm_iommu_ctx_dev rot_src_ctx = {
578 .name = "rot_src",
579 .num = 0,
580 .mids = {0, -1}
581};
582
583static struct msm_iommu_ctx_dev rot_dst_ctx = {
584 .name = "rot_dst",
585 .num = 1,
586 .mids = {1, -1}
587};
588
589static struct msm_iommu_ctx_dev ijpeg_src_ctx = {
590 .name = "ijpeg_src",
591 .num = 0,
592 .mids = {0, -1}
593};
594
595static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {
596 .name = "ijpeg_dst",
597 .num = 1,
598 .mids = {1, -1}
599};
600
601static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {
602 .name = "vfe_imgwr",
603 .num = 0,
604 .mids = {2, 3, 4, 5, 6, 7, 8, -1}
605};
606
607static struct msm_iommu_ctx_dev vfe_misc_ctx = {
608 .name = "vfe_misc",
609 .num = 1,
610 .mids = {0, 1, 9, -1}
611};
612
613static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {
614 .name = "vcodec_a_stream",
615 .num = 0,
616 .mids = {2, 5, -1}
617};
618
619static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {
620 .name = "vcodec_a_mm1",
621 .num = 1,
622 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
623};
624
625static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {
626 .name = "vcodec_b_mm2",
627 .num = 0,
628 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
629};
630
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800631static struct msm_iommu_ctx_dev gfx3d_user_ctx = {
632 .name = "gfx3d_user",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700633 .num = 0,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800634 .mids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700635};
636
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800637static struct msm_iommu_ctx_dev gfx3d_priv_ctx = {
638 .name = "gfx3d_priv",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700639 .num = 1,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800640 .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
641 31, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700642};
643
Joel King41d594e2011-10-14 13:18:20 -0700644static struct msm_iommu_ctx_dev gfx3d1_user_ctx = {
645 .name = "gfx3d1_user",
646 .num = 0,
647 .mids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
648};
649
650static struct msm_iommu_ctx_dev gfx3d1_priv_ctx = {
651 .name = "gfx3d1_priv",
652 .num = 1,
653 .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
654 31, -1}
655};
656
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800657static struct msm_iommu_ctx_dev gfx2d0_2d0_ctx = {
658 .name = "gfx2d0_2d0",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700659 .num = 0,
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800660 .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700661};
662
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800663static struct msm_iommu_ctx_dev gfx2d1_2d1_ctx = {
664 .name = "gfx2d1_2d1",
665 .num = 0,
666 .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
667};
668
Joel King41d594e2011-10-14 13:18:20 -0700669static struct msm_iommu_ctx_dev vcap_vc_ctx = {
670 .name = "vcap_vc",
671 .num = 0,
672 .mids = {0, -1}
673};
674
675static struct msm_iommu_ctx_dev vcap_vp_ctx = {
676 .name = "vcap_vp",
677 .num = 1,
678 .mids = {1, -1}
679};
680
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700681static struct platform_device msm_device_jpegd_src_ctx = {
682 .name = "msm_iommu_ctx",
683 .id = 0,
684 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800685 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700686 },
687};
688
689static struct platform_device msm_device_jpegd_dst_ctx = {
690 .name = "msm_iommu_ctx",
691 .id = 1,
692 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800693 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700694 },
695};
696
697static struct platform_device msm_device_vpe_src_ctx = {
698 .name = "msm_iommu_ctx",
699 .id = 2,
700 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800701 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700702 },
703};
704
705static struct platform_device msm_device_vpe_dst_ctx = {
706 .name = "msm_iommu_ctx",
707 .id = 3,
708 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800709 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700710 },
711};
712
713static struct platform_device msm_device_mdp_vg1_ctx = {
714 .name = "msm_iommu_ctx",
715 .id = 4,
716 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800717 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700718 },
719};
720
721static struct platform_device msm_device_mdp_rgb1_ctx = {
722 .name = "msm_iommu_ctx",
723 .id = 5,
724 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800725 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700726 },
727};
728
729static struct platform_device msm_device_mdp_vg2_ctx = {
730 .name = "msm_iommu_ctx",
731 .id = 6,
732 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800733 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700734 },
735};
736
737static struct platform_device msm_device_mdp_rgb2_ctx = {
738 .name = "msm_iommu_ctx",
739 .id = 7,
740 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800741 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700742 },
743};
744
745static struct platform_device msm_device_rot_src_ctx = {
746 .name = "msm_iommu_ctx",
747 .id = 8,
748 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800749 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700750 },
751};
752
753static struct platform_device msm_device_rot_dst_ctx = {
754 .name = "msm_iommu_ctx",
755 .id = 9,
756 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800757 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700758 },
759};
760
761static struct platform_device msm_device_ijpeg_src_ctx = {
762 .name = "msm_iommu_ctx",
763 .id = 10,
764 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800765 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700766 },
767};
768
769static struct platform_device msm_device_ijpeg_dst_ctx = {
770 .name = "msm_iommu_ctx",
771 .id = 11,
772 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800773 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700774 },
775};
776
777static struct platform_device msm_device_vfe_imgwr_ctx = {
778 .name = "msm_iommu_ctx",
779 .id = 12,
780 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800781 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700782 },
783};
784
785static struct platform_device msm_device_vfe_misc_ctx = {
786 .name = "msm_iommu_ctx",
787 .id = 13,
788 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800789 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700790 },
791};
792
793static struct platform_device msm_device_vcodec_a_stream_ctx = {
794 .name = "msm_iommu_ctx",
795 .id = 14,
796 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800797 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700798 },
799};
800
801static struct platform_device msm_device_vcodec_a_mm1_ctx = {
802 .name = "msm_iommu_ctx",
803 .id = 15,
804 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800805 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700806 },
807};
808
809static struct platform_device msm_device_vcodec_b_mm2_ctx = {
810 .name = "msm_iommu_ctx",
811 .id = 16,
812 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800813 .parent = &msm_device_iommu_vcodec_b.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700814 },
815};
816
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800817static struct platform_device msm_device_gfx3d_user_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700818 .name = "msm_iommu_ctx",
819 .id = 17,
820 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800821 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700822 },
823};
824
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800825static struct platform_device msm_device_gfx3d_priv_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700826 .name = "msm_iommu_ctx",
827 .id = 18,
828 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800829 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700830 },
831};
832
Joel King41d594e2011-10-14 13:18:20 -0700833static struct platform_device msm_device_gfx3d1_user_ctx = {
834 .name = "msm_iommu_ctx",
835 .id = 19,
836 .dev = {
837 .parent = &msm_device_iommu_gfx3d1.dev,
838 },
839};
840
841static struct platform_device msm_device_gfx3d1_priv_ctx = {
842 .name = "msm_iommu_ctx",
843 .id = 20,
844 .dev = {
845 .parent = &msm_device_iommu_gfx3d1.dev,
846 },
847};
848
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800849static struct platform_device msm_device_gfx2d0_2d0_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700850 .name = "msm_iommu_ctx",
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800851 .id = 19,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700852 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800853 .parent = &msm_device_iommu_gfx2d0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700854 },
855};
856
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800857static struct platform_device msm_device_gfx2d1_2d1_ctx = {
858 .name = "msm_iommu_ctx",
859 .id = 20,
860 .dev = {
861 .parent = &msm_device_iommu_gfx2d1.dev,
862 },
863};
864
Joel King41d594e2011-10-14 13:18:20 -0700865static struct platform_device msm_device_vcap_vc_ctx = {
866 .name = "msm_iommu_ctx",
867 .id = 21,
868 .dev = {
869 .parent = &msm_device_iommu_vcap.dev,
870 },
871};
872
873static struct platform_device msm_device_vcap_vp_ctx = {
874 .name = "msm_iommu_ctx",
875 .id = 22,
876 .dev = {
877 .parent = &msm_device_iommu_vcap.dev,
878 },
879};
880
881static struct platform_device *msm_iommu_common_devs[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800882 &msm_device_iommu_jpegd,
883 &msm_device_iommu_vpe,
884 &msm_device_iommu_mdp0,
885 &msm_device_iommu_mdp1,
886 &msm_device_iommu_rot,
887 &msm_device_iommu_ijpeg,
888 &msm_device_iommu_vfe,
889 &msm_device_iommu_vcodec_a,
890 &msm_device_iommu_vcodec_b,
891 &msm_device_iommu_gfx3d,
Joel King41d594e2011-10-14 13:18:20 -0700892};
893
894static struct platform_device *msm_iommu_gfx2d_devs[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800895 &msm_device_iommu_gfx2d0,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800896 &msm_device_iommu_gfx2d1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700897};
898
Joel King41d594e2011-10-14 13:18:20 -0700899static struct platform_device *msm_iommu_8064_devs[] = {
900 &msm_device_iommu_gfx3d1,
901 &msm_device_iommu_vcap,
902};
903
904static struct msm_iommu_dev *msm_iommu_common_data[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800905 &jpegd_iommu,
906 &vpe_iommu,
907 &mdp0_iommu,
908 &mdp1_iommu,
909 &rot_iommu,
910 &ijpeg_iommu,
911 &vfe_iommu,
912 &vcodec_a_iommu,
913 &vcodec_b_iommu,
914 &gfx3d_iommu,
Joel King41d594e2011-10-14 13:18:20 -0700915};
916
917static struct msm_iommu_dev *msm_iommu_gfx2d_data[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800918 &gfx2d0_iommu,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800919 &gfx2d1_iommu,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700920};
921
Joel King41d594e2011-10-14 13:18:20 -0700922static struct msm_iommu_dev *msm_iommu_8064_data[] = {
923 &gfx3d1_iommu,
924 &vcap_iommu,
925};
926
927static struct platform_device *msm_iommu_common_ctx_devs[] = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700928 &msm_device_jpegd_src_ctx,
929 &msm_device_jpegd_dst_ctx,
930 &msm_device_vpe_src_ctx,
931 &msm_device_vpe_dst_ctx,
932 &msm_device_mdp_vg1_ctx,
933 &msm_device_mdp_rgb1_ctx,
934 &msm_device_mdp_vg2_ctx,
935 &msm_device_mdp_rgb2_ctx,
936 &msm_device_rot_src_ctx,
937 &msm_device_rot_dst_ctx,
938 &msm_device_ijpeg_src_ctx,
939 &msm_device_ijpeg_dst_ctx,
940 &msm_device_vfe_imgwr_ctx,
941 &msm_device_vfe_misc_ctx,
942 &msm_device_vcodec_a_stream_ctx,
943 &msm_device_vcodec_a_mm1_ctx,
944 &msm_device_vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800945 &msm_device_gfx3d_user_ctx,
946 &msm_device_gfx3d_priv_ctx,
Joel King41d594e2011-10-14 13:18:20 -0700947};
948
949static struct platform_device *msm_iommu_gfx2d_ctx_devs[] = {
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800950 &msm_device_gfx2d0_2d0_ctx,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800951 &msm_device_gfx2d1_2d1_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700952};
953
Joel King41d594e2011-10-14 13:18:20 -0700954static struct platform_device *msm_iommu_8064_ctx_devs[] = {
955 &msm_device_gfx3d1_user_ctx,
956 &msm_device_gfx3d1_priv_ctx,
957 &msm_device_vcap_vc_ctx,
958 &msm_device_vcap_vp_ctx,
959};
960
961static struct msm_iommu_ctx_dev *msm_iommu_common_ctx_data[] = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700962 &jpegd_src_ctx,
963 &jpegd_dst_ctx,
964 &vpe_src_ctx,
965 &vpe_dst_ctx,
966 &mdp_vg1_ctx,
967 &mdp_rgb1_ctx,
968 &mdp_vg2_ctx,
969 &mdp_rgb2_ctx,
970 &rot_src_ctx,
971 &rot_dst_ctx,
972 &ijpeg_src_ctx,
973 &ijpeg_dst_ctx,
974 &vfe_imgwr_ctx,
975 &vfe_misc_ctx,
976 &vcodec_a_stream_ctx,
977 &vcodec_a_mm1_ctx,
978 &vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800979 &gfx3d_user_ctx,
980 &gfx3d_priv_ctx,
Joel King41d594e2011-10-14 13:18:20 -0700981};
982
983static struct msm_iommu_ctx_dev *msm_iommu_gfx2d_ctx_data[] = {
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800984 &gfx2d0_2d0_ctx,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800985 &gfx2d1_2d1_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700986};
987
Joel King41d594e2011-10-14 13:18:20 -0700988static struct msm_iommu_ctx_dev *msm_iommu_8064_ctx_data[] = {
989 &gfx3d1_user_ctx,
990 &gfx3d1_priv_ctx,
991 &vcap_vc_ctx,
992 &vcap_vp_ctx,
993};
994
995static int iommu_init_devs(struct platform_device *devs[],
996 struct msm_iommu_dev *data[], int size)
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700997{
998 int ret, i;
999
Joel King41d594e2011-10-14 13:18:20 -07001000 for (i = 0; i < size; i++) {
1001 ret = platform_device_add_data(devs[i],
1002 data[i], sizeof(struct msm_iommu_dev));
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001003 if (ret != 0) {
1004 pr_err("platform_device_add_data failed, "
1005 "i = %d\n", i);
1006 goto failure_unwind;
1007 }
1008
Joel King41d594e2011-10-14 13:18:20 -07001009 ret = platform_device_register(devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001010
1011 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -08001012 pr_err("platform_device_register iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001013 "i = %d\n", i);
1014 goto failure_unwind;
1015 }
1016 }
Joel King41d594e2011-10-14 13:18:20 -07001017 return 0;
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001018
Joel King41d594e2011-10-14 13:18:20 -07001019failure_unwind:
1020 while (--i >= 0)
1021 platform_device_unregister(devs[i]);
1022
1023 return ret;
1024}
1025
1026
1027static int iommu_init_ctx_devs(struct platform_device *ctx_devs[],
1028 struct msm_iommu_ctx_dev *ctx_data[], int size)
1029{
1030 int ret, i;
1031
1032 for (i = 0; i < size; i++) {
1033 ret = platform_device_add_data(ctx_devs[i],
1034 ctx_data[i], sizeof(struct msm_iommu_ctx_dev));
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001035 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -08001036 pr_err("platform_device_add_data iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001037 "i = %d\n", i);
Joel King41d594e2011-10-14 13:18:20 -07001038 goto failure_unwind;
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001039 }
1040
Joel King41d594e2011-10-14 13:18:20 -07001041 ret = platform_device_register(ctx_devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001042 if (ret != 0) {
1043 pr_err("platform_device_register ctx failed, "
1044 "i = %d\n", i);
Joel King41d594e2011-10-14 13:18:20 -07001045 goto failure_unwind;
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001046 }
1047 }
1048 return 0;
1049
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001050failure_unwind:
1051 while (--i >= 0)
Joel King41d594e2011-10-14 13:18:20 -07001052 platform_device_unregister(ctx_devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001053
Joel King41d594e2011-10-14 13:18:20 -07001054 return ret;
1055}
1056
1057static int __init iommu_init(void)
1058{
1059 int ret;
Stepan Moskovchenko15f209c2011-10-31 15:32:44 -07001060 if (!msm_soc_version_supports_iommu()) {
Stepan Moskovchenko75f1e672011-10-21 19:49:44 -07001061 pr_err("IOMMU is not supported on this SoC version.\n");
1062 return -ENODEV;
1063 }
1064
Joel King41d594e2011-10-14 13:18:20 -07001065 ret = platform_device_register(&msm_root_iommu_dev);
1066 if (ret != 0) {
1067 pr_err("Failed to register root IOMMU device!\n");
1068 goto failure;
1069 }
1070
1071 /* Initialize common devs */
1072 ret = iommu_init_devs(msm_iommu_common_devs,
1073 msm_iommu_common_data,
1074 ARRAY_SIZE(msm_iommu_common_devs));
1075 if (ret != 0)
1076 goto failure2;
1077
1078 /* Initialize soc-specific devs */
1079 if (cpu_is_apq8064()) {
1080 ret = iommu_init_devs(msm_iommu_8064_devs,
1081 msm_iommu_8064_data,
1082 ARRAY_SIZE(msm_iommu_8064_devs));
1083 } else {
1084 ret = iommu_init_devs(msm_iommu_gfx2d_devs,
1085 msm_iommu_gfx2d_data,
1086 ARRAY_SIZE(msm_iommu_gfx2d_devs));
1087 }
1088 if (ret != 0)
1089 goto failure2;
1090
1091 /* Initialize common ctx_devs */
1092 ret = iommu_init_ctx_devs(msm_iommu_common_ctx_devs,
1093 msm_iommu_common_ctx_data,
1094 ARRAY_SIZE(msm_iommu_common_ctx_devs));
1095 if (ret != 0)
1096 goto failure2;
1097
1098 /* Initialize soc-specific ctx_devs */
1099 if (cpu_is_apq8064()) {
1100 ret = iommu_init_ctx_devs(msm_iommu_8064_ctx_devs,
1101 msm_iommu_8064_ctx_data,
1102 ARRAY_SIZE(msm_iommu_8064_ctx_devs));
1103 } else {
1104 ret = iommu_init_ctx_devs(msm_iommu_gfx2d_ctx_devs,
1105 msm_iommu_gfx2d_ctx_data,
1106 ARRAY_SIZE(msm_iommu_gfx2d_ctx_devs));
1107 }
1108 if (ret != 0)
1109 goto failure2;
1110
1111 return 0;
1112
1113failure2:
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001114 platform_device_unregister(&msm_root_iommu_dev);
1115failure:
1116 return ret;
1117}
1118
Joel King41d594e2011-10-14 13:18:20 -07001119static void __exit iommu_exit(void)
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001120{
1121 int i;
1122
Joel King41d594e2011-10-14 13:18:20 -07001123 /* Common ctx_devs */
1124 for (i = 0; i < ARRAY_SIZE(msm_iommu_common_ctx_devs); i++)
1125 platform_device_unregister(msm_iommu_common_ctx_devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001126
Joel King41d594e2011-10-14 13:18:20 -07001127 /* soc-specific ctx_devs. */
1128 if (cpu_is_apq8064()) {
1129 for (i = 0; i < ARRAY_SIZE(msm_iommu_8064_ctx_devs); i++)
1130 platform_device_unregister(msm_iommu_8064_ctx_devs[i]);
1131 } else {
1132 for (i = 0; i < ARRAY_SIZE(msm_iommu_gfx2d_ctx_devs); i++)
1133 platform_device_unregister(msm_iommu_gfx2d_ctx_devs[i]);
1134 }
1135
1136 /* Common devs. */
1137 for (i = 0; i < ARRAY_SIZE(msm_iommu_common_devs); ++i)
1138 platform_device_unregister(msm_iommu_common_devs[i]);
1139
1140 /* soc-specific devs. */
1141 if (cpu_is_apq8064()) {
1142 for (i = 0; i < ARRAY_SIZE(msm_iommu_8064_devs); i++)
1143 platform_device_unregister(msm_iommu_8064_devs[i]);
1144 } else {
1145 for (i = 0; i < ARRAY_SIZE(msm_iommu_gfx2d_devs); i++)
1146 platform_device_unregister(msm_iommu_gfx2d_devs[i]);
1147 }
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001148
1149 platform_device_unregister(&msm_root_iommu_dev);
1150}
1151
Joel King41d594e2011-10-14 13:18:20 -07001152subsys_initcall(iommu_init);
1153module_exit(iommu_exit);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001154
1155MODULE_LICENSE("GPL v2");
1156MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");