blob: 22d0c7cb71f6402ba5ab26916f34958e16a68491 [file] [log] [blame]
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -07001/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
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.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#include <linux/kernel.h>
19#include <linux/platform_device.h>
20#include <linux/bootmem.h>
21
22#include <mach/msm_iomap-8x60.h>
23#include <mach/irqs-8x60.h>
24#include <mach/iommu.h>
25
26static struct resource msm_iommu_jpegd_resources[] = {
27 {
28 .start = MSM_IOMMU_JPEGD_PHYS,
29 .end = MSM_IOMMU_JPEGD_PHYS + MSM_IOMMU_JPEGD_SIZE - 1,
30 .name = "physbase",
31 .flags = IORESOURCE_MEM,
32 },
33 {
34 .name = "nonsecure_irq",
35 .start = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
36 .end = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
37 .flags = IORESOURCE_IRQ,
38 },
39 {
40 .name = "secure_irq",
41 .start = SMMU_JPEGD_CB_SC_SECURE_IRQ,
42 .end = SMMU_JPEGD_CB_SC_SECURE_IRQ,
43 .flags = IORESOURCE_IRQ,
44 },
45};
46
47static struct resource msm_iommu_vpe_resources[] = {
48 {
49 .start = MSM_IOMMU_VPE_PHYS,
50 .end = MSM_IOMMU_VPE_PHYS + MSM_IOMMU_VPE_SIZE - 1,
51 .name = "physbase",
52 .flags = IORESOURCE_MEM,
53 },
54 {
55 .name = "nonsecure_irq",
56 .start = SMMU_VPE_CB_SC_NON_SECURE_IRQ,
57 .end = SMMU_VPE_CB_SC_NON_SECURE_IRQ,
58 .flags = IORESOURCE_IRQ,
59 },
60 {
61 .name = "secure_irq",
62 .start = SMMU_VPE_CB_SC_SECURE_IRQ,
63 .end = SMMU_VPE_CB_SC_SECURE_IRQ,
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
68static struct resource msm_iommu_mdp0_resources[] = {
69 {
70 .start = MSM_IOMMU_MDP0_PHYS,
71 .end = MSM_IOMMU_MDP0_PHYS + MSM_IOMMU_MDP0_SIZE - 1,
72 .name = "physbase",
73 .flags = IORESOURCE_MEM,
74 },
75 {
76 .name = "nonsecure_irq",
77 .start = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
78 .end = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
79 .flags = IORESOURCE_IRQ,
80 },
81 {
82 .name = "secure_irq",
83 .start = SMMU_MDP0_CB_SC_SECURE_IRQ,
84 .end = SMMU_MDP0_CB_SC_SECURE_IRQ,
85 .flags = IORESOURCE_IRQ,
86 },
87};
88
89static struct resource msm_iommu_mdp1_resources[] = {
90 {
91 .start = MSM_IOMMU_MDP1_PHYS,
92 .end = MSM_IOMMU_MDP1_PHYS + MSM_IOMMU_MDP1_SIZE - 1,
93 .name = "physbase",
94 .flags = IORESOURCE_MEM,
95 },
96 {
97 .name = "nonsecure_irq",
98 .start = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
99 .end = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
100 .flags = IORESOURCE_IRQ,
101 },
102 {
103 .name = "secure_irq",
104 .start = SMMU_MDP1_CB_SC_SECURE_IRQ,
105 .end = SMMU_MDP1_CB_SC_SECURE_IRQ,
106 .flags = IORESOURCE_IRQ,
107 },
108};
109
110static struct resource msm_iommu_rot_resources[] = {
111 {
112 .start = MSM_IOMMU_ROT_PHYS,
113 .end = MSM_IOMMU_ROT_PHYS + MSM_IOMMU_ROT_SIZE - 1,
114 .name = "physbase",
115 .flags = IORESOURCE_MEM,
116 },
117 {
118 .name = "nonsecure_irq",
119 .start = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
120 .end = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
121 .flags = IORESOURCE_IRQ,
122 },
123 {
124 .name = "secure_irq",
125 .start = SMMU_ROT_CB_SC_SECURE_IRQ,
126 .end = SMMU_ROT_CB_SC_SECURE_IRQ,
127 .flags = IORESOURCE_IRQ,
128 },
129};
130
131static struct resource msm_iommu_ijpeg_resources[] = {
132 {
133 .start = MSM_IOMMU_IJPEG_PHYS,
134 .end = MSM_IOMMU_IJPEG_PHYS + MSM_IOMMU_IJPEG_SIZE - 1,
135 .name = "physbase",
136 .flags = IORESOURCE_MEM,
137 },
138 {
139 .name = "nonsecure_irq",
140 .start = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
141 .end = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
142 .flags = IORESOURCE_IRQ,
143 },
144 {
145 .name = "secure_irq",
146 .start = SMMU_IJPEG_CB_SC_SECURE_IRQ,
147 .end = SMMU_IJPEG_CB_SC_SECURE_IRQ,
148 .flags = IORESOURCE_IRQ,
149 },
150};
151
152static struct resource msm_iommu_vfe_resources[] = {
153 {
154 .start = MSM_IOMMU_VFE_PHYS,
155 .end = MSM_IOMMU_VFE_PHYS + MSM_IOMMU_VFE_SIZE - 1,
156 .name = "physbase",
157 .flags = IORESOURCE_MEM,
158 },
159 {
160 .name = "nonsecure_irq",
161 .start = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
162 .end = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
163 .flags = IORESOURCE_IRQ,
164 },
165 {
166 .name = "secure_irq",
167 .start = SMMU_VFE_CB_SC_SECURE_IRQ,
168 .end = SMMU_VFE_CB_SC_SECURE_IRQ,
169 .flags = IORESOURCE_IRQ,
170 },
171};
172
173static struct resource msm_iommu_vcodec_a_resources[] = {
174 {
175 .start = MSM_IOMMU_VCODEC_A_PHYS,
176 .end = MSM_IOMMU_VCODEC_A_PHYS + MSM_IOMMU_VCODEC_A_SIZE - 1,
177 .name = "physbase",
178 .flags = IORESOURCE_MEM,
179 },
180 {
181 .name = "nonsecure_irq",
182 .start = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
183 .end = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
184 .flags = IORESOURCE_IRQ,
185 },
186 {
187 .name = "secure_irq",
188 .start = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
189 .end = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
190 .flags = IORESOURCE_IRQ,
191 },
192};
193
194static struct resource msm_iommu_vcodec_b_resources[] = {
195 {
196 .start = MSM_IOMMU_VCODEC_B_PHYS,
197 .end = MSM_IOMMU_VCODEC_B_PHYS + MSM_IOMMU_VCODEC_B_SIZE - 1,
198 .name = "physbase",
199 .flags = IORESOURCE_MEM,
200 },
201 {
202 .name = "nonsecure_irq",
203 .start = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
204 .end = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
205 .flags = IORESOURCE_IRQ,
206 },
207 {
208 .name = "secure_irq",
209 .start = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
210 .end = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
211 .flags = IORESOURCE_IRQ,
212 },
213};
214
215static struct resource msm_iommu_gfx3d_resources[] = {
216 {
217 .start = MSM_IOMMU_GFX3D_PHYS,
218 .end = MSM_IOMMU_GFX3D_PHYS + MSM_IOMMU_GFX3D_SIZE - 1,
219 .name = "physbase",
220 .flags = IORESOURCE_MEM,
221 },
222 {
223 .name = "nonsecure_irq",
224 .start = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
225 .end = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
226 .flags = IORESOURCE_IRQ,
227 },
228 {
229 .name = "secure_irq",
230 .start = SMMU_GFX3D_CB_SC_SECURE_IRQ,
231 .end = SMMU_GFX3D_CB_SC_SECURE_IRQ,
232 .flags = IORESOURCE_IRQ,
233 },
234};
235
236static struct resource msm_iommu_gfx2d0_resources[] = {
237 {
238 .start = MSM_IOMMU_GFX2D0_PHYS,
239 .end = MSM_IOMMU_GFX2D0_PHYS + MSM_IOMMU_GFX2D0_SIZE - 1,
240 .name = "physbase",
241 .flags = IORESOURCE_MEM,
242 },
243 {
244 .name = "nonsecure_irq",
245 .start = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
246 .end = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
247 .flags = IORESOURCE_IRQ,
248 },
249 {
250 .name = "secure_irq",
251 .start = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
252 .end = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
253 .flags = IORESOURCE_IRQ,
254 },
255};
256
257static struct platform_device msm_root_iommu_dev = {
258 .name = "msm_iommu",
259 .id = -1,
260};
261
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800262static struct msm_iommu_dev jpegd_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700263 .name = "jpegd",
264 .clk_rate = -1
265};
266
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800267static struct msm_iommu_dev vpe_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700268 .name = "vpe"
269};
270
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800271static struct msm_iommu_dev mdp0_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700272 .name = "mdp0"
273};
274
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800275static struct msm_iommu_dev mdp1_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700276 .name = "mdp1"
277};
278
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800279static struct msm_iommu_dev rot_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700280 .name = "rot"
281};
282
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800283static struct msm_iommu_dev ijpeg_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700284 .name = "ijpeg"
285};
286
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800287static struct msm_iommu_dev vfe_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700288 .name = "vfe",
289 .clk_rate = -1
290};
291
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800292static struct msm_iommu_dev vcodec_a_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700293 .name = "vcodec_a"
294};
295
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800296static struct msm_iommu_dev vcodec_b_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700297 .name = "vcodec_b"
298};
299
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800300static struct msm_iommu_dev gfx3d_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700301 .name = "gfx3d",
302 .clk_rate = 27000000
303};
304
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800305static struct msm_iommu_dev gfx2d0_iommu = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700306 .name = "gfx2d0",
307 .clk_rate = 27000000
308};
309
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800310static struct platform_device msm_device_iommu_jpegd = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700311 .name = "msm_iommu",
312 .id = 0,
313 .dev = {
314 .parent = &msm_root_iommu_dev.dev,
315 },
316 .num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
317 .resource = msm_iommu_jpegd_resources,
318};
319
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800320static struct platform_device msm_device_iommu_vpe = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700321 .name = "msm_iommu",
322 .id = 1,
323 .dev = {
324 .parent = &msm_root_iommu_dev.dev,
325 },
326 .num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
327 .resource = msm_iommu_vpe_resources,
328};
329
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800330static struct platform_device msm_device_iommu_mdp0 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700331 .name = "msm_iommu",
332 .id = 2,
333 .dev = {
334 .parent = &msm_root_iommu_dev.dev,
335 },
336 .num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
337 .resource = msm_iommu_mdp0_resources,
338};
339
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800340static struct platform_device msm_device_iommu_mdp1 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700341 .name = "msm_iommu",
342 .id = 3,
343 .dev = {
344 .parent = &msm_root_iommu_dev.dev,
345 },
346 .num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
347 .resource = msm_iommu_mdp1_resources,
348};
349
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800350static struct platform_device msm_device_iommu_rot = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700351 .name = "msm_iommu",
352 .id = 4,
353 .dev = {
354 .parent = &msm_root_iommu_dev.dev,
355 },
356 .num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
357 .resource = msm_iommu_rot_resources,
358};
359
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800360static struct platform_device msm_device_iommu_ijpeg = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700361 .name = "msm_iommu",
362 .id = 5,
363 .dev = {
364 .parent = &msm_root_iommu_dev.dev,
365 },
366 .num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),
367 .resource = msm_iommu_ijpeg_resources,
368};
369
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800370static struct platform_device msm_device_iommu_vfe = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700371 .name = "msm_iommu",
372 .id = 6,
373 .dev = {
374 .parent = &msm_root_iommu_dev.dev,
375 },
376 .num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
377 .resource = msm_iommu_vfe_resources,
378};
379
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800380static struct platform_device msm_device_iommu_vcodec_a = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700381 .name = "msm_iommu",
382 .id = 7,
383 .dev = {
384 .parent = &msm_root_iommu_dev.dev,
385 },
386 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
387 .resource = msm_iommu_vcodec_a_resources,
388};
389
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800390static struct platform_device msm_device_iommu_vcodec_b = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700391 .name = "msm_iommu",
392 .id = 8,
393 .dev = {
394 .parent = &msm_root_iommu_dev.dev,
395 },
396 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
397 .resource = msm_iommu_vcodec_b_resources,
398};
399
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800400static struct platform_device msm_device_iommu_gfx3d = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700401 .name = "msm_iommu",
402 .id = 9,
403 .dev = {
404 .parent = &msm_root_iommu_dev.dev,
405 },
406 .num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
407 .resource = msm_iommu_gfx3d_resources,
408};
409
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800410static struct platform_device msm_device_iommu_gfx2d0 = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700411 .name = "msm_iommu",
412 .id = 10,
413 .dev = {
414 .parent = &msm_root_iommu_dev.dev,
415 },
416 .num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
417 .resource = msm_iommu_gfx2d0_resources,
418};
419
420static struct msm_iommu_ctx_dev jpegd_src_ctx = {
421 .name = "jpegd_src",
422 .num = 0,
423 .mids = {0, -1}
424};
425
426static struct msm_iommu_ctx_dev jpegd_dst_ctx = {
427 .name = "jpegd_dst",
428 .num = 1,
429 .mids = {1, -1}
430};
431
432static struct msm_iommu_ctx_dev vpe_src_ctx = {
433 .name = "vpe_src",
434 .num = 0,
435 .mids = {0, -1}
436};
437
438static struct msm_iommu_ctx_dev vpe_dst_ctx = {
439 .name = "vpe_dst",
440 .num = 1,
441 .mids = {1, -1}
442};
443
444static struct msm_iommu_ctx_dev mdp_vg1_ctx = {
445 .name = "mdp_vg1",
446 .num = 0,
447 .mids = {0, 2, -1}
448};
449
450static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {
451 .name = "mdp_rgb1",
452 .num = 1,
453 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
454};
455
456static struct msm_iommu_ctx_dev mdp_vg2_ctx = {
457 .name = "mdp_vg2",
458 .num = 0,
459 .mids = {0, 2, -1}
460};
461
462static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {
463 .name = "mdp_rgb2",
464 .num = 1,
465 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
466};
467
468static struct msm_iommu_ctx_dev rot_src_ctx = {
469 .name = "rot_src",
470 .num = 0,
471 .mids = {0, -1}
472};
473
474static struct msm_iommu_ctx_dev rot_dst_ctx = {
475 .name = "rot_dst",
476 .num = 1,
477 .mids = {1, -1}
478};
479
480static struct msm_iommu_ctx_dev ijpeg_src_ctx = {
481 .name = "ijpeg_src",
482 .num = 0,
483 .mids = {0, -1}
484};
485
486static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {
487 .name = "ijpeg_dst",
488 .num = 1,
489 .mids = {1, -1}
490};
491
492static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {
493 .name = "vfe_imgwr",
494 .num = 0,
495 .mids = {2, 3, 4, 5, 6, 7, 8, -1}
496};
497
498static struct msm_iommu_ctx_dev vfe_misc_ctx = {
499 .name = "vfe_misc",
500 .num = 1,
501 .mids = {0, 1, 9, -1}
502};
503
504static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {
505 .name = "vcodec_a_stream",
506 .num = 0,
507 .mids = {2, 5, -1}
508};
509
510static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {
511 .name = "vcodec_a_mm1",
512 .num = 1,
513 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
514};
515
516static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {
517 .name = "vcodec_b_mm2",
518 .num = 0,
519 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
520};
521
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800522static struct msm_iommu_ctx_dev gfx3d_user_ctx = {
523 .name = "gfx3d_user",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700524 .num = 0,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800525 .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 -0700526};
527
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800528static struct msm_iommu_ctx_dev gfx3d_priv_ctx = {
529 .name = "gfx3d_priv",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700530 .num = 1,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800531 .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
532 31, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700533};
534
535static struct msm_iommu_ctx_dev gfx2d0_pixv1_ctx = {
536 .name = "gfx2d0_pixv1_smmu",
537 .num = 0,
538 .mids = {0, 3, 4, -1}
539};
540
541static struct msm_iommu_ctx_dev gfx2d0_texv3_ctx = {
542 .name = "gfx2d0_texv3_smmu",
543 .num = 1,
544 .mids = {1, 6, 7, -1}
545};
546
547static struct platform_device msm_device_jpegd_src_ctx = {
548 .name = "msm_iommu_ctx",
549 .id = 0,
550 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800551 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700552 },
553};
554
555static struct platform_device msm_device_jpegd_dst_ctx = {
556 .name = "msm_iommu_ctx",
557 .id = 1,
558 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800559 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700560 },
561};
562
563static struct platform_device msm_device_vpe_src_ctx = {
564 .name = "msm_iommu_ctx",
565 .id = 2,
566 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800567 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700568 },
569};
570
571static struct platform_device msm_device_vpe_dst_ctx = {
572 .name = "msm_iommu_ctx",
573 .id = 3,
574 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800575 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700576 },
577};
578
579static struct platform_device msm_device_mdp_vg1_ctx = {
580 .name = "msm_iommu_ctx",
581 .id = 4,
582 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800583 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700584 },
585};
586
587static struct platform_device msm_device_mdp_rgb1_ctx = {
588 .name = "msm_iommu_ctx",
589 .id = 5,
590 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800591 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700592 },
593};
594
595static struct platform_device msm_device_mdp_vg2_ctx = {
596 .name = "msm_iommu_ctx",
597 .id = 6,
598 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800599 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700600 },
601};
602
603static struct platform_device msm_device_mdp_rgb2_ctx = {
604 .name = "msm_iommu_ctx",
605 .id = 7,
606 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800607 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700608 },
609};
610
611static struct platform_device msm_device_rot_src_ctx = {
612 .name = "msm_iommu_ctx",
613 .id = 8,
614 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800615 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700616 },
617};
618
619static struct platform_device msm_device_rot_dst_ctx = {
620 .name = "msm_iommu_ctx",
621 .id = 9,
622 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800623 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700624 },
625};
626
627static struct platform_device msm_device_ijpeg_src_ctx = {
628 .name = "msm_iommu_ctx",
629 .id = 10,
630 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800631 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700632 },
633};
634
635static struct platform_device msm_device_ijpeg_dst_ctx = {
636 .name = "msm_iommu_ctx",
637 .id = 11,
638 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800639 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700640 },
641};
642
643static struct platform_device msm_device_vfe_imgwr_ctx = {
644 .name = "msm_iommu_ctx",
645 .id = 12,
646 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800647 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700648 },
649};
650
651static struct platform_device msm_device_vfe_misc_ctx = {
652 .name = "msm_iommu_ctx",
653 .id = 13,
654 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800655 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700656 },
657};
658
659static struct platform_device msm_device_vcodec_a_stream_ctx = {
660 .name = "msm_iommu_ctx",
661 .id = 14,
662 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800663 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700664 },
665};
666
667static struct platform_device msm_device_vcodec_a_mm1_ctx = {
668 .name = "msm_iommu_ctx",
669 .id = 15,
670 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800671 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700672 },
673};
674
675static struct platform_device msm_device_vcodec_b_mm2_ctx = {
676 .name = "msm_iommu_ctx",
677 .id = 16,
678 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800679 .parent = &msm_device_iommu_vcodec_b.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700680 },
681};
682
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800683static struct platform_device msm_device_gfx3d_user_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700684 .name = "msm_iommu_ctx",
685 .id = 17,
686 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800687 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700688 },
689};
690
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800691static struct platform_device msm_device_gfx3d_priv_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700692 .name = "msm_iommu_ctx",
693 .id = 18,
694 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800695 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700696 },
697};
698
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700699static struct platform_device msm_device_gfx2d0_pixv1_ctx = {
700 .name = "msm_iommu_ctx",
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800701 .id = 19,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700702 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800703 .parent = &msm_device_iommu_gfx2d0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700704 },
705};
706
707static struct platform_device msm_device_gfx2d0_texv3_ctx = {
708 .name = "msm_iommu_ctx",
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800709 .id = 20,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700710 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800711 .parent = &msm_device_iommu_gfx2d0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700712 },
713};
714
715static struct platform_device *msm_iommu_devs[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800716 &msm_device_iommu_jpegd,
717 &msm_device_iommu_vpe,
718 &msm_device_iommu_mdp0,
719 &msm_device_iommu_mdp1,
720 &msm_device_iommu_rot,
721 &msm_device_iommu_ijpeg,
722 &msm_device_iommu_vfe,
723 &msm_device_iommu_vcodec_a,
724 &msm_device_iommu_vcodec_b,
725 &msm_device_iommu_gfx3d,
726 &msm_device_iommu_gfx2d0,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700727};
728
729static struct msm_iommu_dev *msm_iommu_data[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800730 &jpegd_iommu,
731 &vpe_iommu,
732 &mdp0_iommu,
733 &mdp1_iommu,
734 &rot_iommu,
735 &ijpeg_iommu,
736 &vfe_iommu,
737 &vcodec_a_iommu,
738 &vcodec_b_iommu,
739 &gfx3d_iommu,
740 &gfx2d0_iommu,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700741};
742
743static struct platform_device *msm_iommu_ctx_devs[] = {
744 &msm_device_jpegd_src_ctx,
745 &msm_device_jpegd_dst_ctx,
746 &msm_device_vpe_src_ctx,
747 &msm_device_vpe_dst_ctx,
748 &msm_device_mdp_vg1_ctx,
749 &msm_device_mdp_rgb1_ctx,
750 &msm_device_mdp_vg2_ctx,
751 &msm_device_mdp_rgb2_ctx,
752 &msm_device_rot_src_ctx,
753 &msm_device_rot_dst_ctx,
754 &msm_device_ijpeg_src_ctx,
755 &msm_device_ijpeg_dst_ctx,
756 &msm_device_vfe_imgwr_ctx,
757 &msm_device_vfe_misc_ctx,
758 &msm_device_vcodec_a_stream_ctx,
759 &msm_device_vcodec_a_mm1_ctx,
760 &msm_device_vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800761 &msm_device_gfx3d_user_ctx,
762 &msm_device_gfx3d_priv_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700763 &msm_device_gfx2d0_pixv1_ctx,
764 &msm_device_gfx2d0_texv3_ctx,
765};
766
767static struct msm_iommu_ctx_dev *msm_iommu_ctx_data[] = {
768 &jpegd_src_ctx,
769 &jpegd_dst_ctx,
770 &vpe_src_ctx,
771 &vpe_dst_ctx,
772 &mdp_vg1_ctx,
773 &mdp_rgb1_ctx,
774 &mdp_vg2_ctx,
775 &mdp_rgb2_ctx,
776 &rot_src_ctx,
777 &rot_dst_ctx,
778 &ijpeg_src_ctx,
779 &ijpeg_dst_ctx,
780 &vfe_imgwr_ctx,
781 &vfe_misc_ctx,
782 &vcodec_a_stream_ctx,
783 &vcodec_a_mm1_ctx,
784 &vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800785 &gfx3d_user_ctx,
786 &gfx3d_priv_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700787 &gfx2d0_pixv1_ctx,
788 &gfx2d0_texv3_ctx,
789};
790
791static int msm8x60_iommu_init(void)
792{
793 int ret, i;
794
795 ret = platform_device_register(&msm_root_iommu_dev);
796 if (ret != 0) {
797 pr_err("Failed to register root IOMMU device!\n");
798 goto failure;
799 }
800
801 for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); i++) {
802 ret = platform_device_add_data(msm_iommu_devs[i],
803 msm_iommu_data[i],
804 sizeof(struct msm_iommu_dev));
805 if (ret != 0) {
806 pr_err("platform_device_add_data failed, "
807 "i = %d\n", i);
808 goto failure_unwind;
809 }
810
811 ret = platform_device_register(msm_iommu_devs[i]);
812
813 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800814 pr_err("platform_device_register iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700815 "i = %d\n", i);
816 goto failure_unwind;
817 }
818 }
819
820 for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++) {
821 ret = platform_device_add_data(msm_iommu_ctx_devs[i],
822 msm_iommu_ctx_data[i],
823 sizeof(*msm_iommu_ctx_devs[i]));
824 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800825 pr_err("platform_device_add_data iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700826 "i = %d\n", i);
827 goto failure_unwind2;
828 }
829
830 ret = platform_device_register(msm_iommu_ctx_devs[i]);
831 if (ret != 0) {
832 pr_err("platform_device_register ctx failed, "
833 "i = %d\n", i);
834 goto failure_unwind2;
835 }
836 }
837 return 0;
838
839failure_unwind2:
840 while (--i >= 0)
841 platform_device_unregister(msm_iommu_ctx_devs[i]);
842failure_unwind:
843 while (--i >= 0)
844 platform_device_unregister(msm_iommu_devs[i]);
845
846 platform_device_unregister(&msm_root_iommu_dev);
847failure:
848 return ret;
849}
850
851static void msm8x60_iommu_exit(void)
852{
853 int i;
854
855 for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++)
856 platform_device_unregister(msm_iommu_ctx_devs[i]);
857
858 for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); ++i)
859 platform_device_unregister(msm_iommu_devs[i]);
860
861 platform_device_unregister(&msm_root_iommu_dev);
862}
863
864subsys_initcall(msm8x60_iommu_init);
865module_exit(msm8x60_iommu_exit);
866
867MODULE_LICENSE("GPL v2");
868MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");