blob: 8cccb26805421bf4f1aee7229bbf7dd7fd34021a [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
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800535static struct msm_iommu_ctx_dev gfx2d0_2d0_ctx = {
536 .name = "gfx2d0_2d0",
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700537 .num = 0,
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800538 .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700539};
540
541static struct platform_device msm_device_jpegd_src_ctx = {
542 .name = "msm_iommu_ctx",
543 .id = 0,
544 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800545 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700546 },
547};
548
549static struct platform_device msm_device_jpegd_dst_ctx = {
550 .name = "msm_iommu_ctx",
551 .id = 1,
552 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800553 .parent = &msm_device_iommu_jpegd.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700554 },
555};
556
557static struct platform_device msm_device_vpe_src_ctx = {
558 .name = "msm_iommu_ctx",
559 .id = 2,
560 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800561 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700562 },
563};
564
565static struct platform_device msm_device_vpe_dst_ctx = {
566 .name = "msm_iommu_ctx",
567 .id = 3,
568 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800569 .parent = &msm_device_iommu_vpe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700570 },
571};
572
573static struct platform_device msm_device_mdp_vg1_ctx = {
574 .name = "msm_iommu_ctx",
575 .id = 4,
576 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800577 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700578 },
579};
580
581static struct platform_device msm_device_mdp_rgb1_ctx = {
582 .name = "msm_iommu_ctx",
583 .id = 5,
584 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800585 .parent = &msm_device_iommu_mdp0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700586 },
587};
588
589static struct platform_device msm_device_mdp_vg2_ctx = {
590 .name = "msm_iommu_ctx",
591 .id = 6,
592 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800593 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700594 },
595};
596
597static struct platform_device msm_device_mdp_rgb2_ctx = {
598 .name = "msm_iommu_ctx",
599 .id = 7,
600 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800601 .parent = &msm_device_iommu_mdp1.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700602 },
603};
604
605static struct platform_device msm_device_rot_src_ctx = {
606 .name = "msm_iommu_ctx",
607 .id = 8,
608 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800609 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700610 },
611};
612
613static struct platform_device msm_device_rot_dst_ctx = {
614 .name = "msm_iommu_ctx",
615 .id = 9,
616 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800617 .parent = &msm_device_iommu_rot.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700618 },
619};
620
621static struct platform_device msm_device_ijpeg_src_ctx = {
622 .name = "msm_iommu_ctx",
623 .id = 10,
624 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800625 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700626 },
627};
628
629static struct platform_device msm_device_ijpeg_dst_ctx = {
630 .name = "msm_iommu_ctx",
631 .id = 11,
632 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800633 .parent = &msm_device_iommu_ijpeg.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700634 },
635};
636
637static struct platform_device msm_device_vfe_imgwr_ctx = {
638 .name = "msm_iommu_ctx",
639 .id = 12,
640 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800641 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700642 },
643};
644
645static struct platform_device msm_device_vfe_misc_ctx = {
646 .name = "msm_iommu_ctx",
647 .id = 13,
648 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800649 .parent = &msm_device_iommu_vfe.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700650 },
651};
652
653static struct platform_device msm_device_vcodec_a_stream_ctx = {
654 .name = "msm_iommu_ctx",
655 .id = 14,
656 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800657 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700658 },
659};
660
661static struct platform_device msm_device_vcodec_a_mm1_ctx = {
662 .name = "msm_iommu_ctx",
663 .id = 15,
664 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800665 .parent = &msm_device_iommu_vcodec_a.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700666 },
667};
668
669static struct platform_device msm_device_vcodec_b_mm2_ctx = {
670 .name = "msm_iommu_ctx",
671 .id = 16,
672 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800673 .parent = &msm_device_iommu_vcodec_b.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700674 },
675};
676
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800677static struct platform_device msm_device_gfx3d_user_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700678 .name = "msm_iommu_ctx",
679 .id = 17,
680 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800681 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700682 },
683};
684
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800685static struct platform_device msm_device_gfx3d_priv_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700686 .name = "msm_iommu_ctx",
687 .id = 18,
688 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800689 .parent = &msm_device_iommu_gfx3d.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700690 },
691};
692
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800693static struct platform_device msm_device_gfx2d0_2d0_ctx = {
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700694 .name = "msm_iommu_ctx",
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800695 .id = 19,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700696 .dev = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800697 .parent = &msm_device_iommu_gfx2d0.dev,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700698 },
699};
700
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700701static struct platform_device *msm_iommu_devs[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800702 &msm_device_iommu_jpegd,
703 &msm_device_iommu_vpe,
704 &msm_device_iommu_mdp0,
705 &msm_device_iommu_mdp1,
706 &msm_device_iommu_rot,
707 &msm_device_iommu_ijpeg,
708 &msm_device_iommu_vfe,
709 &msm_device_iommu_vcodec_a,
710 &msm_device_iommu_vcodec_b,
711 &msm_device_iommu_gfx3d,
712 &msm_device_iommu_gfx2d0,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700713};
714
715static struct msm_iommu_dev *msm_iommu_data[] = {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800716 &jpegd_iommu,
717 &vpe_iommu,
718 &mdp0_iommu,
719 &mdp1_iommu,
720 &rot_iommu,
721 &ijpeg_iommu,
722 &vfe_iommu,
723 &vcodec_a_iommu,
724 &vcodec_b_iommu,
725 &gfx3d_iommu,
726 &gfx2d0_iommu,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700727};
728
729static struct platform_device *msm_iommu_ctx_devs[] = {
730 &msm_device_jpegd_src_ctx,
731 &msm_device_jpegd_dst_ctx,
732 &msm_device_vpe_src_ctx,
733 &msm_device_vpe_dst_ctx,
734 &msm_device_mdp_vg1_ctx,
735 &msm_device_mdp_rgb1_ctx,
736 &msm_device_mdp_vg2_ctx,
737 &msm_device_mdp_rgb2_ctx,
738 &msm_device_rot_src_ctx,
739 &msm_device_rot_dst_ctx,
740 &msm_device_ijpeg_src_ctx,
741 &msm_device_ijpeg_dst_ctx,
742 &msm_device_vfe_imgwr_ctx,
743 &msm_device_vfe_misc_ctx,
744 &msm_device_vcodec_a_stream_ctx,
745 &msm_device_vcodec_a_mm1_ctx,
746 &msm_device_vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800747 &msm_device_gfx3d_user_ctx,
748 &msm_device_gfx3d_priv_ctx,
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800749 &msm_device_gfx2d0_2d0_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700750};
751
752static struct msm_iommu_ctx_dev *msm_iommu_ctx_data[] = {
753 &jpegd_src_ctx,
754 &jpegd_dst_ctx,
755 &vpe_src_ctx,
756 &vpe_dst_ctx,
757 &mdp_vg1_ctx,
758 &mdp_rgb1_ctx,
759 &mdp_vg2_ctx,
760 &mdp_rgb2_ctx,
761 &rot_src_ctx,
762 &rot_dst_ctx,
763 &ijpeg_src_ctx,
764 &ijpeg_dst_ctx,
765 &vfe_imgwr_ctx,
766 &vfe_misc_ctx,
767 &vcodec_a_stream_ctx,
768 &vcodec_a_mm1_ctx,
769 &vcodec_b_mm2_ctx,
Stepan Moskovchenkoa5fcd5f2010-11-12 19:29:50 -0800770 &gfx3d_user_ctx,
771 &gfx3d_priv_ctx,
Stepan Moskovchenkoff25ff82010-11-12 19:29:51 -0800772 &gfx2d0_2d0_ctx,
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700773};
774
775static int msm8x60_iommu_init(void)
776{
777 int ret, i;
778
779 ret = platform_device_register(&msm_root_iommu_dev);
780 if (ret != 0) {
781 pr_err("Failed to register root IOMMU device!\n");
782 goto failure;
783 }
784
785 for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); i++) {
786 ret = platform_device_add_data(msm_iommu_devs[i],
787 msm_iommu_data[i],
788 sizeof(struct msm_iommu_dev));
789 if (ret != 0) {
790 pr_err("platform_device_add_data failed, "
791 "i = %d\n", i);
792 goto failure_unwind;
793 }
794
795 ret = platform_device_register(msm_iommu_devs[i]);
796
797 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800798 pr_err("platform_device_register iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700799 "i = %d\n", i);
800 goto failure_unwind;
801 }
802 }
803
804 for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++) {
805 ret = platform_device_add_data(msm_iommu_ctx_devs[i],
806 msm_iommu_ctx_data[i],
807 sizeof(*msm_iommu_ctx_devs[i]));
808 if (ret != 0) {
Stepan Moskovchenko12943322010-11-12 19:29:49 -0800809 pr_err("platform_device_add_data iommu failed, "
Stepan Moskovchenkod9c82792010-08-24 19:51:15 -0700810 "i = %d\n", i);
811 goto failure_unwind2;
812 }
813
814 ret = platform_device_register(msm_iommu_ctx_devs[i]);
815 if (ret != 0) {
816 pr_err("platform_device_register ctx failed, "
817 "i = %d\n", i);
818 goto failure_unwind2;
819 }
820 }
821 return 0;
822
823failure_unwind2:
824 while (--i >= 0)
825 platform_device_unregister(msm_iommu_ctx_devs[i]);
826failure_unwind:
827 while (--i >= 0)
828 platform_device_unregister(msm_iommu_devs[i]);
829
830 platform_device_unregister(&msm_root_iommu_dev);
831failure:
832 return ret;
833}
834
835static void msm8x60_iommu_exit(void)
836{
837 int i;
838
839 for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++)
840 platform_device_unregister(msm_iommu_ctx_devs[i]);
841
842 for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); ++i)
843 platform_device_unregister(msm_iommu_devs[i]);
844
845 platform_device_unregister(&msm_root_iommu_dev);
846}
847
848subsys_initcall(msm8x60_iommu_init);
849module_exit(msm8x60_iommu_exit);
850
851MODULE_LICENSE("GPL v2");
852MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");