blob: b04bc11e9db425e410b4ca51f894b01728f5303b [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>
19#include <mach/irqs-8960.h>
20#include <mach/irqs-8064.h>
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070021
22static struct resource msm_iommu_jpegd_resources[] = {
23 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080024 .start = 0x07300000,
25 .end = 0x07300000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070026 .name = "physbase",
27 .flags = IORESOURCE_MEM,
28 },
29 {
30 .name = "nonsecure_irq",
31 .start = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
32 .end = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
33 .flags = IORESOURCE_IRQ,
34 },
35 {
36 .name = "secure_irq",
37 .start = SMMU_JPEGD_CB_SC_SECURE_IRQ,
38 .end = SMMU_JPEGD_CB_SC_SECURE_IRQ,
39 .flags = IORESOURCE_IRQ,
40 },
41};
42
43static struct resource msm_iommu_vpe_resources[] = {
44 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080045 .start = 0x07400000,
46 .end = 0x07400000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070047 .name = "physbase",
48 .flags = IORESOURCE_MEM,
49 },
50 {
51 .name = "nonsecure_irq",
52 .start = SMMU_VPE_CB_SC_NON_SECURE_IRQ,
53 .end = SMMU_VPE_CB_SC_NON_SECURE_IRQ,
54 .flags = IORESOURCE_IRQ,
55 },
56 {
57 .name = "secure_irq",
58 .start = SMMU_VPE_CB_SC_SECURE_IRQ,
59 .end = SMMU_VPE_CB_SC_SECURE_IRQ,
60 .flags = IORESOURCE_IRQ,
61 },
62};
63
64static struct resource msm_iommu_mdp0_resources[] = {
65 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080066 .start = 0x07500000,
67 .end = 0x07500000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070068 .name = "physbase",
69 .flags = IORESOURCE_MEM,
70 },
71 {
72 .name = "nonsecure_irq",
73 .start = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
74 .end = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
75 .flags = IORESOURCE_IRQ,
76 },
77 {
78 .name = "secure_irq",
79 .start = SMMU_MDP0_CB_SC_SECURE_IRQ,
80 .end = SMMU_MDP0_CB_SC_SECURE_IRQ,
81 .flags = IORESOURCE_IRQ,
82 },
83};
84
85static struct resource msm_iommu_mdp1_resources[] = {
86 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -080087 .start = 0x07600000,
88 .end = 0x07600000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -070089 .name = "physbase",
90 .flags = IORESOURCE_MEM,
91 },
92 {
93 .name = "nonsecure_irq",
94 .start = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
95 .end = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
96 .flags = IORESOURCE_IRQ,
97 },
98 {
99 .name = "secure_irq",
100 .start = SMMU_MDP1_CB_SC_SECURE_IRQ,
101 .end = SMMU_MDP1_CB_SC_SECURE_IRQ,
102 .flags = IORESOURCE_IRQ,
103 },
104};
105
106static struct resource msm_iommu_rot_resources[] = {
107 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800108 .start = 0x07700000,
109 .end = 0x07700000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700110 .name = "physbase",
111 .flags = IORESOURCE_MEM,
112 },
113 {
114 .name = "nonsecure_irq",
115 .start = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
116 .end = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
117 .flags = IORESOURCE_IRQ,
118 },
119 {
120 .name = "secure_irq",
121 .start = SMMU_ROT_CB_SC_SECURE_IRQ,
122 .end = SMMU_ROT_CB_SC_SECURE_IRQ,
123 .flags = IORESOURCE_IRQ,
124 },
125};
126
127static struct resource msm_iommu_ijpeg_resources[] = {
128 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800129 .start = 0x07800000,
130 .end = 0x07800000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700131 .name = "physbase",
132 .flags = IORESOURCE_MEM,
133 },
134 {
135 .name = "nonsecure_irq",
136 .start = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
137 .end = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
138 .flags = IORESOURCE_IRQ,
139 },
140 {
141 .name = "secure_irq",
142 .start = SMMU_IJPEG_CB_SC_SECURE_IRQ,
143 .end = SMMU_IJPEG_CB_SC_SECURE_IRQ,
144 .flags = IORESOURCE_IRQ,
145 },
146};
147
148static struct resource msm_iommu_vfe_resources[] = {
149 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800150 .start = 0x07900000,
151 .end = 0x07900000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700152 .name = "physbase",
153 .flags = IORESOURCE_MEM,
154 },
155 {
156 .name = "nonsecure_irq",
157 .start = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
158 .end = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
159 .flags = IORESOURCE_IRQ,
160 },
161 {
162 .name = "secure_irq",
163 .start = SMMU_VFE_CB_SC_SECURE_IRQ,
164 .end = SMMU_VFE_CB_SC_SECURE_IRQ,
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
169static struct resource msm_iommu_vcodec_a_resources[] = {
170 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800171 .start = 0x07A00000,
172 .end = 0x07A00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700173 .name = "physbase",
174 .flags = IORESOURCE_MEM,
175 },
176 {
177 .name = "nonsecure_irq",
178 .start = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
179 .end = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
180 .flags = IORESOURCE_IRQ,
181 },
182 {
183 .name = "secure_irq",
184 .start = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
185 .end = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
186 .flags = IORESOURCE_IRQ,
187 },
188};
189
190static struct resource msm_iommu_vcodec_b_resources[] = {
191 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800192 .start = 0x07B00000,
193 .end = 0x07B00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700194 .name = "physbase",
195 .flags = IORESOURCE_MEM,
196 },
197 {
198 .name = "nonsecure_irq",
199 .start = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
200 .end = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
201 .flags = IORESOURCE_IRQ,
202 },
203 {
204 .name = "secure_irq",
205 .start = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
206 .end = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
207 .flags = IORESOURCE_IRQ,
208 },
209};
210
211static struct resource msm_iommu_gfx3d_resources[] = {
212 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800213 .start = 0x07C00000,
214 .end = 0x07C00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700215 .name = "physbase",
216 .flags = IORESOURCE_MEM,
217 },
218 {
219 .name = "nonsecure_irq",
220 .start = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
221 .end = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
222 .flags = IORESOURCE_IRQ,
223 },
224 {
225 .name = "secure_irq",
226 .start = SMMU_GFX3D_CB_SC_SECURE_IRQ,
227 .end = SMMU_GFX3D_CB_SC_SECURE_IRQ,
228 .flags = IORESOURCE_IRQ,
229 },
230};
231
Joel King41d594e2011-10-14 13:18:20 -0700232static struct resource msm_iommu_gfx3d1_resources[] = {
233 {
234 .start = 0x07D00000,
235 .end = 0x07D00000 + SZ_1M - 1,
236 .name = "physbase",
237 .flags = IORESOURCE_MEM,
238 },
239 {
240 .name = "nonsecure_irq",
241 .start = SMMU_GFX3D1_CB_SC_NON_SECURE_IRQ,
242 .end = SMMU_GFX3D1_CB_SC_NON_SECURE_IRQ,
243 .flags = IORESOURCE_IRQ,
244 },
245 {
246 .name = "secure_irq",
247 .start = SMMU_GFX3D1_CB_SC_SECURE_IRQ,
248 .end = SMMU_GFX3D1_CB_SC_SECURE_IRQ,
249 .flags = IORESOURCE_IRQ,
250 },
251};
252
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700253static struct resource msm_iommu_gfx2d0_resources[] = {
254 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800255 .start = 0x07D00000,
256 .end = 0x07D00000 + SZ_1M - 1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700257 .name = "physbase",
258 .flags = IORESOURCE_MEM,
259 },
260 {
261 .name = "nonsecure_irq",
262 .start = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
263 .end = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
264 .flags = IORESOURCE_IRQ,
265 },
266 {
267 .name = "secure_irq",
268 .start = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
269 .end = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
270 .flags = IORESOURCE_IRQ,
271 },
272};
273
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800274static struct resource msm_iommu_gfx2d1_resources[] = {
275 {
Stepan Moskovchenko69e21362011-02-11 12:28:17 -0800276 .start = 0x07E00000,
277 .end = 0x07E00000 + SZ_1M - 1,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800278 .name = "physbase",
279 .flags = IORESOURCE_MEM,
280 },
281 {
282 .name = "nonsecure_irq",
283 .start = SMMU_GFX2D1_CB_SC_NON_SECURE_IRQ,
284 .end = SMMU_GFX2D1_CB_SC_NON_SECURE_IRQ,
285 .flags = IORESOURCE_IRQ,
286 },
287 {
288 .name = "secure_irq",
289 .start = SMMU_GFX2D1_CB_SC_SECURE_IRQ,
290 .end = SMMU_GFX2D1_CB_SC_SECURE_IRQ,
291 .flags = IORESOURCE_IRQ,
292 },
293};
294
Joel King41d594e2011-10-14 13:18:20 -0700295static struct resource msm_iommu_vcap_resources[] = {
296 {
297 .start = 0x07200000,
298 .end = 0x07200000 + SZ_1M - 1,
299 .name = "physbase",
300 .flags = IORESOURCE_MEM,
301 },
302 {
303 .name = "nonsecure_irq",
304 .start = SMMU_VCAP_CB_SC_NON_SECURE_IRQ,
305 .end = SMMU_VCAP_CB_SC_NON_SECURE_IRQ,
306 .flags = IORESOURCE_IRQ,
307 },
308 {
309 .name = "secure_irq",
310 .start = SMMU_VCAP_CB_SC_SECURE_IRQ,
311 .end = SMMU_VCAP_CB_SC_SECURE_IRQ,
312 .flags = IORESOURCE_IRQ,
313 },
314};
315
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700316static struct platform_device msm_root_iommu_dev = {
317 .name = "msm_iommu",
318 .id = -1,
319};
320
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800321static struct msm_iommu_dev jpegd_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700322 .name = "jpegd",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800323 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700324};
325
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800326static struct msm_iommu_dev vpe_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800327 .name = "vpe",
328 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700329};
330
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800331static struct msm_iommu_dev mdp0_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800332 .name = "mdp0",
333 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700334};
335
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800336static struct msm_iommu_dev mdp1_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800337 .name = "mdp1",
338 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700339};
340
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800341static struct msm_iommu_dev rot_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800342 .name = "rot",
343 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700344};
345
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800346static struct msm_iommu_dev ijpeg_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800347 .name = "ijpeg",
348 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700349};
350
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800351static struct msm_iommu_dev vfe_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700352 .name = "vfe",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800353 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700354};
355
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800356static struct msm_iommu_dev vcodec_a_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800357 .name = "vcodec_a",
358 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700359};
360
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800361static struct msm_iommu_dev vcodec_b_iommu = {
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800362 .name = "vcodec_b",
363 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700364};
365
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800366static struct msm_iommu_dev gfx3d_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700367 .name = "gfx3d",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800368 .ncb = 3,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700369};
370
Joel King41d594e2011-10-14 13:18:20 -0700371static struct msm_iommu_dev gfx3d1_iommu = {
372 .name = "gfx3d1",
373 .ncb = 3,
374};
375
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800376static struct msm_iommu_dev gfx2d0_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700377 .name = "gfx2d0",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800378 .ncb = 2,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700379};
380
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800381static struct msm_iommu_dev gfx2d1_iommu = {
382 .name = "gfx2d1",
Stepan Moskovchenkoa43d8c12011-02-24 18:00:42 -0800383 .ncb = 2,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800384};
385
Joel King41d594e2011-10-14 13:18:20 -0700386static struct msm_iommu_dev vcap_iommu = {
387 .name = "vcap",
388 .ncb = 2,
389};
390
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800391static struct platform_device msm_device_iommu_jpegd = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700392 .name = "msm_iommu",
393 .id = 0,
394 .dev = {
395 .parent = &msm_root_iommu_dev.dev,
396 },
397 .num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
398 .resource = msm_iommu_jpegd_resources,
399};
400
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800401static struct platform_device msm_device_iommu_vpe = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700402 .name = "msm_iommu",
403 .id = 1,
404 .dev = {
405 .parent = &msm_root_iommu_dev.dev,
406 },
407 .num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
408 .resource = msm_iommu_vpe_resources,
409};
410
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800411static struct platform_device msm_device_iommu_mdp0 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700412 .name = "msm_iommu",
413 .id = 2,
414 .dev = {
415 .parent = &msm_root_iommu_dev.dev,
416 },
417 .num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
418 .resource = msm_iommu_mdp0_resources,
419};
420
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800421static struct platform_device msm_device_iommu_mdp1 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700422 .name = "msm_iommu",
423 .id = 3,
424 .dev = {
425 .parent = &msm_root_iommu_dev.dev,
426 },
427 .num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
428 .resource = msm_iommu_mdp1_resources,
429};
430
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800431static struct platform_device msm_device_iommu_rot = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700432 .name = "msm_iommu",
433 .id = 4,
434 .dev = {
435 .parent = &msm_root_iommu_dev.dev,
436 },
437 .num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
438 .resource = msm_iommu_rot_resources,
439};
440
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800441static struct platform_device msm_device_iommu_ijpeg = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700442 .name = "msm_iommu",
443 .id = 5,
444 .dev = {
445 .parent = &msm_root_iommu_dev.dev,
446 },
447 .num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),
448 .resource = msm_iommu_ijpeg_resources,
449};
450
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800451static struct platform_device msm_device_iommu_vfe = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700452 .name = "msm_iommu",
453 .id = 6,
454 .dev = {
455 .parent = &msm_root_iommu_dev.dev,
456 },
457 .num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
458 .resource = msm_iommu_vfe_resources,
459};
460
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800461static struct platform_device msm_device_iommu_vcodec_a = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700462 .name = "msm_iommu",
463 .id = 7,
464 .dev = {
465 .parent = &msm_root_iommu_dev.dev,
466 },
467 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
468 .resource = msm_iommu_vcodec_a_resources,
469};
470
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800471static struct platform_device msm_device_iommu_vcodec_b = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700472 .name = "msm_iommu",
473 .id = 8,
474 .dev = {
475 .parent = &msm_root_iommu_dev.dev,
476 },
477 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
478 .resource = msm_iommu_vcodec_b_resources,
479};
480
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800481static struct platform_device msm_device_iommu_gfx3d = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700482 .name = "msm_iommu",
483 .id = 9,
484 .dev = {
485 .parent = &msm_root_iommu_dev.dev,
486 },
487 .num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
488 .resource = msm_iommu_gfx3d_resources,
489};
490
Joel King41d594e2011-10-14 13:18:20 -0700491static struct platform_device msm_device_iommu_gfx3d1 = {
492 .name = "msm_iommu",
493 .id = 10,
494 .dev = {
495 .parent = &msm_root_iommu_dev.dev,
496 },
497 .num_resources = ARRAY_SIZE(msm_iommu_gfx3d1_resources),
498 .resource = msm_iommu_gfx3d1_resources,
499};
500
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800501static struct platform_device msm_device_iommu_gfx2d0 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700502 .name = "msm_iommu",
503 .id = 10,
504 .dev = {
505 .parent = &msm_root_iommu_dev.dev,
506 },
507 .num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
508 .resource = msm_iommu_gfx2d0_resources,
509};
510
Joel King41d594e2011-10-14 13:18:20 -0700511static struct platform_device msm_device_iommu_gfx2d1 = {
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800512 .name = "msm_iommu",
513 .id = 11,
514 .dev = {
515 .parent = &msm_root_iommu_dev.dev,
516 },
517 .num_resources = ARRAY_SIZE(msm_iommu_gfx2d1_resources),
518 .resource = msm_iommu_gfx2d1_resources,
519};
520
Joel King41d594e2011-10-14 13:18:20 -0700521static struct platform_device msm_device_iommu_vcap = {
522 .name = "msm_iommu",
523 .id = 11,
524 .dev = {
525 .parent = &msm_root_iommu_dev.dev,
526 },
527 .num_resources = ARRAY_SIZE(msm_iommu_vcap_resources),
528 .resource = msm_iommu_vcap_resources,
529};
530
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700531static struct msm_iommu_ctx_dev jpegd_src_ctx = {
532 .name = "jpegd_src",
533 .num = 0,
534 .mids = {0, -1}
535};
536
537static struct msm_iommu_ctx_dev jpegd_dst_ctx = {
538 .name = "jpegd_dst",
539 .num = 1,
540 .mids = {1, -1}
541};
542
543static struct msm_iommu_ctx_dev vpe_src_ctx = {
544 .name = "vpe_src",
545 .num = 0,
546 .mids = {0, -1}
547};
548
549static struct msm_iommu_ctx_dev vpe_dst_ctx = {
550 .name = "vpe_dst",
551 .num = 1,
552 .mids = {1, -1}
553};
554
555static struct msm_iommu_ctx_dev mdp_vg1_ctx = {
556 .name = "mdp_vg1",
557 .num = 0,
558 .mids = {0, 2, -1}
559};
560
561static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {
562 .name = "mdp_rgb1",
563 .num = 1,
564 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
565};
566
567static struct msm_iommu_ctx_dev mdp_vg2_ctx = {
568 .name = "mdp_vg2",
569 .num = 0,
570 .mids = {0, 2, -1}
571};
572
573static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {
574 .name = "mdp_rgb2",
575 .num = 1,
576 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
577};
578
579static struct msm_iommu_ctx_dev rot_src_ctx = {
580 .name = "rot_src",
581 .num = 0,
582 .mids = {0, -1}
583};
584
585static struct msm_iommu_ctx_dev rot_dst_ctx = {
586 .name = "rot_dst",
587 .num = 1,
588 .mids = {1, -1}
589};
590
591static struct msm_iommu_ctx_dev ijpeg_src_ctx = {
592 .name = "ijpeg_src",
593 .num = 0,
594 .mids = {0, -1}
595};
596
597static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {
598 .name = "ijpeg_dst",
599 .num = 1,
600 .mids = {1, -1}
601};
602
603static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {
604 .name = "vfe_imgwr",
605 .num = 0,
606 .mids = {2, 3, 4, 5, 6, 7, 8, -1}
607};
608
609static struct msm_iommu_ctx_dev vfe_misc_ctx = {
610 .name = "vfe_misc",
611 .num = 1,
612 .mids = {0, 1, 9, -1}
613};
614
615static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {
616 .name = "vcodec_a_stream",
617 .num = 0,
618 .mids = {2, 5, -1}
619};
620
621static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {
622 .name = "vcodec_a_mm1",
623 .num = 1,
624 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
625};
626
627static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {
628 .name = "vcodec_b_mm2",
629 .num = 0,
630 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
631};
632
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800633static struct msm_iommu_ctx_dev gfx3d_user_ctx = {
634 .name = "gfx3d_user",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700635 .num = 0,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800636 .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 -0700637};
638
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800639static struct msm_iommu_ctx_dev gfx3d_priv_ctx = {
640 .name = "gfx3d_priv",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700641 .num = 1,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800642 .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
643 31, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700644};
645
Joel King41d594e2011-10-14 13:18:20 -0700646static struct msm_iommu_ctx_dev gfx3d1_user_ctx = {
647 .name = "gfx3d1_user",
648 .num = 0,
649 .mids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
650};
651
652static struct msm_iommu_ctx_dev gfx3d1_priv_ctx = {
653 .name = "gfx3d1_priv",
654 .num = 1,
655 .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
656 31, -1}
657};
658
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800659static struct msm_iommu_ctx_dev gfx2d0_2d0_ctx = {
660 .name = "gfx2d0_2d0",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700661 .num = 0,
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800662 .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700663};
664
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800665static struct msm_iommu_ctx_dev gfx2d1_2d1_ctx = {
666 .name = "gfx2d1_2d1",
667 .num = 0,
668 .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
669};
670
Joel King41d594e2011-10-14 13:18:20 -0700671static struct msm_iommu_ctx_dev vcap_vc_ctx = {
672 .name = "vcap_vc",
673 .num = 0,
674 .mids = {0, -1}
675};
676
677static struct msm_iommu_ctx_dev vcap_vp_ctx = {
678 .name = "vcap_vp",
679 .num = 1,
680 .mids = {1, -1}
681};
682
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700683static struct platform_device msm_device_jpegd_src_ctx = {
684 .name = "msm_iommu_ctx",
685 .id = 0,
686 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800687 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700688 },
689};
690
691static struct platform_device msm_device_jpegd_dst_ctx = {
692 .name = "msm_iommu_ctx",
693 .id = 1,
694 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800695 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700696 },
697};
698
699static struct platform_device msm_device_vpe_src_ctx = {
700 .name = "msm_iommu_ctx",
701 .id = 2,
702 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800703 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700704 },
705};
706
707static struct platform_device msm_device_vpe_dst_ctx = {
708 .name = "msm_iommu_ctx",
709 .id = 3,
710 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800711 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700712 },
713};
714
715static struct platform_device msm_device_mdp_vg1_ctx = {
716 .name = "msm_iommu_ctx",
717 .id = 4,
718 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800719 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700720 },
721};
722
723static struct platform_device msm_device_mdp_rgb1_ctx = {
724 .name = "msm_iommu_ctx",
725 .id = 5,
726 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800727 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700728 },
729};
730
731static struct platform_device msm_device_mdp_vg2_ctx = {
732 .name = "msm_iommu_ctx",
733 .id = 6,
734 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800735 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700736 },
737};
738
739static struct platform_device msm_device_mdp_rgb2_ctx = {
740 .name = "msm_iommu_ctx",
741 .id = 7,
742 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800743 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700744 },
745};
746
747static struct platform_device msm_device_rot_src_ctx = {
748 .name = "msm_iommu_ctx",
749 .id = 8,
750 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800751 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700752 },
753};
754
755static struct platform_device msm_device_rot_dst_ctx = {
756 .name = "msm_iommu_ctx",
757 .id = 9,
758 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800759 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700760 },
761};
762
763static struct platform_device msm_device_ijpeg_src_ctx = {
764 .name = "msm_iommu_ctx",
765 .id = 10,
766 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800767 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700768 },
769};
770
771static struct platform_device msm_device_ijpeg_dst_ctx = {
772 .name = "msm_iommu_ctx",
773 .id = 11,
774 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800775 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700776 },
777};
778
779static struct platform_device msm_device_vfe_imgwr_ctx = {
780 .name = "msm_iommu_ctx",
781 .id = 12,
782 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800783 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700784 },
785};
786
787static struct platform_device msm_device_vfe_misc_ctx = {
788 .name = "msm_iommu_ctx",
789 .id = 13,
790 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800791 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700792 },
793};
794
795static struct platform_device msm_device_vcodec_a_stream_ctx = {
796 .name = "msm_iommu_ctx",
797 .id = 14,
798 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800799 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700800 },
801};
802
803static struct platform_device msm_device_vcodec_a_mm1_ctx = {
804 .name = "msm_iommu_ctx",
805 .id = 15,
806 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800807 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700808 },
809};
810
811static struct platform_device msm_device_vcodec_b_mm2_ctx = {
812 .name = "msm_iommu_ctx",
813 .id = 16,
814 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800815 .parent = &msm_device_iommu_vcodec_b.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700816 },
817};
818
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800819static struct platform_device msm_device_gfx3d_user_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700820 .name = "msm_iommu_ctx",
821 .id = 17,
822 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800823 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700824 },
825};
826
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800827static struct platform_device msm_device_gfx3d_priv_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700828 .name = "msm_iommu_ctx",
829 .id = 18,
830 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800831 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700832 },
833};
834
Joel King41d594e2011-10-14 13:18:20 -0700835static struct platform_device msm_device_gfx3d1_user_ctx = {
836 .name = "msm_iommu_ctx",
837 .id = 19,
838 .dev = {
839 .parent = &msm_device_iommu_gfx3d1.dev,
840 },
841};
842
843static struct platform_device msm_device_gfx3d1_priv_ctx = {
844 .name = "msm_iommu_ctx",
845 .id = 20,
846 .dev = {
847 .parent = &msm_device_iommu_gfx3d1.dev,
848 },
849};
850
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800851static struct platform_device msm_device_gfx2d0_2d0_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700852 .name = "msm_iommu_ctx",
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800853 .id = 19,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700854 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800855 .parent = &msm_device_iommu_gfx2d0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700856 },
857};
858
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800859static struct platform_device msm_device_gfx2d1_2d1_ctx = {
860 .name = "msm_iommu_ctx",
861 .id = 20,
862 .dev = {
863 .parent = &msm_device_iommu_gfx2d1.dev,
864 },
865};
866
Joel King41d594e2011-10-14 13:18:20 -0700867static struct platform_device msm_device_vcap_vc_ctx = {
868 .name = "msm_iommu_ctx",
869 .id = 21,
870 .dev = {
871 .parent = &msm_device_iommu_vcap.dev,
872 },
873};
874
875static struct platform_device msm_device_vcap_vp_ctx = {
876 .name = "msm_iommu_ctx",
877 .id = 22,
878 .dev = {
879 .parent = &msm_device_iommu_vcap.dev,
880 },
881};
882
883static struct platform_device *msm_iommu_common_devs[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800884 &msm_device_iommu_jpegd,
885 &msm_device_iommu_vpe,
886 &msm_device_iommu_mdp0,
887 &msm_device_iommu_mdp1,
888 &msm_device_iommu_rot,
889 &msm_device_iommu_ijpeg,
890 &msm_device_iommu_vfe,
891 &msm_device_iommu_vcodec_a,
892 &msm_device_iommu_vcodec_b,
893 &msm_device_iommu_gfx3d,
Joel King41d594e2011-10-14 13:18:20 -0700894};
895
896static struct platform_device *msm_iommu_gfx2d_devs[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800897 &msm_device_iommu_gfx2d0,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800898 &msm_device_iommu_gfx2d1,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700899};
900
Joel King41d594e2011-10-14 13:18:20 -0700901static struct platform_device *msm_iommu_8064_devs[] = {
902 &msm_device_iommu_gfx3d1,
903 &msm_device_iommu_vcap,
904};
905
906static struct msm_iommu_dev *msm_iommu_common_data[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800907 &jpegd_iommu,
908 &vpe_iommu,
909 &mdp0_iommu,
910 &mdp1_iommu,
911 &rot_iommu,
912 &ijpeg_iommu,
913 &vfe_iommu,
914 &vcodec_a_iommu,
915 &vcodec_b_iommu,
916 &gfx3d_iommu,
Joel King41d594e2011-10-14 13:18:20 -0700917};
918
919static struct msm_iommu_dev *msm_iommu_gfx2d_data[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800920 &gfx2d0_iommu,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800921 &gfx2d1_iommu,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700922};
923
Joel King41d594e2011-10-14 13:18:20 -0700924static struct msm_iommu_dev *msm_iommu_8064_data[] = {
925 &gfx3d1_iommu,
926 &vcap_iommu,
927};
928
929static struct platform_device *msm_iommu_common_ctx_devs[] = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700930 &msm_device_jpegd_src_ctx,
931 &msm_device_jpegd_dst_ctx,
932 &msm_device_vpe_src_ctx,
933 &msm_device_vpe_dst_ctx,
934 &msm_device_mdp_vg1_ctx,
935 &msm_device_mdp_rgb1_ctx,
936 &msm_device_mdp_vg2_ctx,
937 &msm_device_mdp_rgb2_ctx,
938 &msm_device_rot_src_ctx,
939 &msm_device_rot_dst_ctx,
940 &msm_device_ijpeg_src_ctx,
941 &msm_device_ijpeg_dst_ctx,
942 &msm_device_vfe_imgwr_ctx,
943 &msm_device_vfe_misc_ctx,
944 &msm_device_vcodec_a_stream_ctx,
945 &msm_device_vcodec_a_mm1_ctx,
946 &msm_device_vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800947 &msm_device_gfx3d_user_ctx,
948 &msm_device_gfx3d_priv_ctx,
Joel King41d594e2011-10-14 13:18:20 -0700949};
950
951static struct platform_device *msm_iommu_gfx2d_ctx_devs[] = {
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800952 &msm_device_gfx2d0_2d0_ctx,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800953 &msm_device_gfx2d1_2d1_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700954};
955
Joel King41d594e2011-10-14 13:18:20 -0700956static struct platform_device *msm_iommu_8064_ctx_devs[] = {
957 &msm_device_gfx3d1_user_ctx,
958 &msm_device_gfx3d1_priv_ctx,
959 &msm_device_vcap_vc_ctx,
960 &msm_device_vcap_vp_ctx,
961};
962
963static struct msm_iommu_ctx_dev *msm_iommu_common_ctx_data[] = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700964 &jpegd_src_ctx,
965 &jpegd_dst_ctx,
966 &vpe_src_ctx,
967 &vpe_dst_ctx,
968 &mdp_vg1_ctx,
969 &mdp_rgb1_ctx,
970 &mdp_vg2_ctx,
971 &mdp_rgb2_ctx,
972 &rot_src_ctx,
973 &rot_dst_ctx,
974 &ijpeg_src_ctx,
975 &ijpeg_dst_ctx,
976 &vfe_imgwr_ctx,
977 &vfe_misc_ctx,
978 &vcodec_a_stream_ctx,
979 &vcodec_a_mm1_ctx,
980 &vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800981 &gfx3d_user_ctx,
982 &gfx3d_priv_ctx,
Joel King41d594e2011-10-14 13:18:20 -0700983};
984
985static struct msm_iommu_ctx_dev *msm_iommu_gfx2d_ctx_data[] = {
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800986 &gfx2d0_2d0_ctx,
Stepan Moskovchenkoe8952e32010-11-12 19:29:52 -0800987 &gfx2d1_2d1_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700988};
989
Joel King41d594e2011-10-14 13:18:20 -0700990static struct msm_iommu_ctx_dev *msm_iommu_8064_ctx_data[] = {
991 &gfx3d1_user_ctx,
992 &gfx3d1_priv_ctx,
993 &vcap_vc_ctx,
994 &vcap_vp_ctx,
995};
996
997static int iommu_init_devs(struct platform_device *devs[],
998 struct msm_iommu_dev *data[], int size)
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700999{
1000 int ret, i;
1001
Joel King41d594e2011-10-14 13:18:20 -07001002 for (i = 0; i < size; i++) {
1003 ret = platform_device_add_data(devs[i],
1004 data[i], sizeof(struct msm_iommu_dev));
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001005 if (ret != 0) {
1006 pr_err("platform_device_add_data failed, "
1007 "i = %d\n", i);
1008 goto failure_unwind;
1009 }
1010
Joel King41d594e2011-10-14 13:18:20 -07001011 ret = platform_device_register(devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001012
1013 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -08001014 pr_err("platform_device_register iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001015 "i = %d\n", i);
1016 goto failure_unwind;
1017 }
1018 }
Joel King41d594e2011-10-14 13:18:20 -07001019 return 0;
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001020
Joel King41d594e2011-10-14 13:18:20 -07001021failure_unwind:
1022 while (--i >= 0)
1023 platform_device_unregister(devs[i]);
1024
1025 return ret;
1026}
1027
1028
1029static int iommu_init_ctx_devs(struct platform_device *ctx_devs[],
1030 struct msm_iommu_ctx_dev *ctx_data[], int size)
1031{
1032 int ret, i;
1033
1034 for (i = 0; i < size; i++) {
1035 ret = platform_device_add_data(ctx_devs[i],
1036 ctx_data[i], sizeof(struct msm_iommu_ctx_dev));
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001037 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -08001038 pr_err("platform_device_add_data iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001039 "i = %d\n", i);
Joel King41d594e2011-10-14 13:18:20 -07001040 goto failure_unwind;
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001041 }
1042
Joel King41d594e2011-10-14 13:18:20 -07001043 ret = platform_device_register(ctx_devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001044 if (ret != 0) {
1045 pr_err("platform_device_register ctx failed, "
1046 "i = %d\n", i);
Joel King41d594e2011-10-14 13:18:20 -07001047 goto failure_unwind;
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001048 }
1049 }
1050 return 0;
1051
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001052failure_unwind:
1053 while (--i >= 0)
Joel King41d594e2011-10-14 13:18:20 -07001054 platform_device_unregister(ctx_devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001055
Joel King41d594e2011-10-14 13:18:20 -07001056 return ret;
1057}
1058
1059static int __init iommu_init(void)
1060{
1061 int ret;
1062
Stepan Moskovchenko75f1e672011-10-21 19:49:44 -07001063 if (cpu_is_msm8960() &&
1064 SOCINFO_VERSION_MAJOR(socinfo_get_version()) < 2) {
1065 pr_err("IOMMU is not supported on this SoC version.\n");
1066 return -ENODEV;
1067 }
1068
Joel King41d594e2011-10-14 13:18:20 -07001069 ret = platform_device_register(&msm_root_iommu_dev);
1070 if (ret != 0) {
1071 pr_err("Failed to register root IOMMU device!\n");
1072 goto failure;
1073 }
1074
1075 /* Initialize common devs */
1076 ret = iommu_init_devs(msm_iommu_common_devs,
1077 msm_iommu_common_data,
1078 ARRAY_SIZE(msm_iommu_common_devs));
1079 if (ret != 0)
1080 goto failure2;
1081
1082 /* Initialize soc-specific devs */
1083 if (cpu_is_apq8064()) {
1084 ret = iommu_init_devs(msm_iommu_8064_devs,
1085 msm_iommu_8064_data,
1086 ARRAY_SIZE(msm_iommu_8064_devs));
1087 } else {
1088 ret = iommu_init_devs(msm_iommu_gfx2d_devs,
1089 msm_iommu_gfx2d_data,
1090 ARRAY_SIZE(msm_iommu_gfx2d_devs));
1091 }
1092 if (ret != 0)
1093 goto failure2;
1094
1095 /* Initialize common ctx_devs */
1096 ret = iommu_init_ctx_devs(msm_iommu_common_ctx_devs,
1097 msm_iommu_common_ctx_data,
1098 ARRAY_SIZE(msm_iommu_common_ctx_devs));
1099 if (ret != 0)
1100 goto failure2;
1101
1102 /* Initialize soc-specific ctx_devs */
1103 if (cpu_is_apq8064()) {
1104 ret = iommu_init_ctx_devs(msm_iommu_8064_ctx_devs,
1105 msm_iommu_8064_ctx_data,
1106 ARRAY_SIZE(msm_iommu_8064_ctx_devs));
1107 } else {
1108 ret = iommu_init_ctx_devs(msm_iommu_gfx2d_ctx_devs,
1109 msm_iommu_gfx2d_ctx_data,
1110 ARRAY_SIZE(msm_iommu_gfx2d_ctx_devs));
1111 }
1112 if (ret != 0)
1113 goto failure2;
1114
1115 return 0;
1116
1117failure2:
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001118 platform_device_unregister(&msm_root_iommu_dev);
1119failure:
1120 return ret;
1121}
1122
Joel King41d594e2011-10-14 13:18:20 -07001123static void __exit iommu_exit(void)
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001124{
1125 int i;
1126
Joel King41d594e2011-10-14 13:18:20 -07001127 /* Common ctx_devs */
1128 for (i = 0; i < ARRAY_SIZE(msm_iommu_common_ctx_devs); i++)
1129 platform_device_unregister(msm_iommu_common_ctx_devs[i]);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001130
Joel King41d594e2011-10-14 13:18:20 -07001131 /* soc-specific ctx_devs. */
1132 if (cpu_is_apq8064()) {
1133 for (i = 0; i < ARRAY_SIZE(msm_iommu_8064_ctx_devs); i++)
1134 platform_device_unregister(msm_iommu_8064_ctx_devs[i]);
1135 } else {
1136 for (i = 0; i < ARRAY_SIZE(msm_iommu_gfx2d_ctx_devs); i++)
1137 platform_device_unregister(msm_iommu_gfx2d_ctx_devs[i]);
1138 }
1139
1140 /* Common devs. */
1141 for (i = 0; i < ARRAY_SIZE(msm_iommu_common_devs); ++i)
1142 platform_device_unregister(msm_iommu_common_devs[i]);
1143
1144 /* soc-specific devs. */
1145 if (cpu_is_apq8064()) {
1146 for (i = 0; i < ARRAY_SIZE(msm_iommu_8064_devs); i++)
1147 platform_device_unregister(msm_iommu_8064_devs[i]);
1148 } else {
1149 for (i = 0; i < ARRAY_SIZE(msm_iommu_gfx2d_devs); i++)
1150 platform_device_unregister(msm_iommu_gfx2d_devs[i]);
1151 }
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001152
1153 platform_device_unregister(&msm_root_iommu_dev);
1154}
1155
Joel King41d594e2011-10-14 13:18:20 -07001156subsys_initcall(iommu_init);
1157module_exit(iommu_exit);
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001158
1159MODULE_LICENSE("GPL v2");
1160MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");