devices-msm8x60-iommu.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. /* 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. #include <linux/kernel.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/bootmem.h>
  20. #include <mach/msm_iomap-8x60.h>
  21. #include <mach/irqs-8x60.h>
  22. #include <mach/iommu.h>
  23. static struct resource msm_iommu_jpegd_resources[] = {
  24. {
  25. .start = MSM_IOMMU_JPEGD_PHYS,
  26. .end = MSM_IOMMU_JPEGD_PHYS + MSM_IOMMU_JPEGD_SIZE - 1,
  27. .name = "physbase",
  28. .flags = IORESOURCE_MEM,
  29. },
  30. {
  31. .name = "nonsecure_irq",
  32. .start = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
  33. .end = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
  34. .flags = IORESOURCE_IRQ,
  35. },
  36. {
  37. .name = "secure_irq",
  38. .start = SMMU_JPEGD_CB_SC_SECURE_IRQ,
  39. .end = SMMU_JPEGD_CB_SC_SECURE_IRQ,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static struct resource msm_iommu_vpe_resources[] = {
  44. {
  45. .start = MSM_IOMMU_VPE_PHYS,
  46. .end = MSM_IOMMU_VPE_PHYS + MSM_IOMMU_VPE_SIZE - 1,
  47. .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. static struct resource msm_iommu_mdp0_resources[] = {
  64. {
  65. .start = MSM_IOMMU_MDP0_PHYS,
  66. .end = MSM_IOMMU_MDP0_PHYS + MSM_IOMMU_MDP0_SIZE - 1,
  67. .name = "physbase",
  68. .flags = IORESOURCE_MEM,
  69. },
  70. {
  71. .name = "nonsecure_irq",
  72. .start = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
  73. .end = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
  74. .flags = IORESOURCE_IRQ,
  75. },
  76. {
  77. .name = "secure_irq",
  78. .start = SMMU_MDP0_CB_SC_SECURE_IRQ,
  79. .end = SMMU_MDP0_CB_SC_SECURE_IRQ,
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. };
  83. static struct resource msm_iommu_mdp1_resources[] = {
  84. {
  85. .start = MSM_IOMMU_MDP1_PHYS,
  86. .end = MSM_IOMMU_MDP1_PHYS + MSM_IOMMU_MDP1_SIZE - 1,
  87. .name = "physbase",
  88. .flags = IORESOURCE_MEM,
  89. },
  90. {
  91. .name = "nonsecure_irq",
  92. .start = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
  93. .end = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
  94. .flags = IORESOURCE_IRQ,
  95. },
  96. {
  97. .name = "secure_irq",
  98. .start = SMMU_MDP1_CB_SC_SECURE_IRQ,
  99. .end = SMMU_MDP1_CB_SC_SECURE_IRQ,
  100. .flags = IORESOURCE_IRQ,
  101. },
  102. };
  103. static struct resource msm_iommu_rot_resources[] = {
  104. {
  105. .start = MSM_IOMMU_ROT_PHYS,
  106. .end = MSM_IOMMU_ROT_PHYS + MSM_IOMMU_ROT_SIZE - 1,
  107. .name = "physbase",
  108. .flags = IORESOURCE_MEM,
  109. },
  110. {
  111. .name = "nonsecure_irq",
  112. .start = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
  113. .end = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. {
  117. .name = "secure_irq",
  118. .start = SMMU_ROT_CB_SC_SECURE_IRQ,
  119. .end = SMMU_ROT_CB_SC_SECURE_IRQ,
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct resource msm_iommu_ijpeg_resources[] = {
  124. {
  125. .start = MSM_IOMMU_IJPEG_PHYS,
  126. .end = MSM_IOMMU_IJPEG_PHYS + MSM_IOMMU_IJPEG_SIZE - 1,
  127. .name = "physbase",
  128. .flags = IORESOURCE_MEM,
  129. },
  130. {
  131. .name = "nonsecure_irq",
  132. .start = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
  133. .end = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
  134. .flags = IORESOURCE_IRQ,
  135. },
  136. {
  137. .name = "secure_irq",
  138. .start = SMMU_IJPEG_CB_SC_SECURE_IRQ,
  139. .end = SMMU_IJPEG_CB_SC_SECURE_IRQ,
  140. .flags = IORESOURCE_IRQ,
  141. },
  142. };
  143. static struct resource msm_iommu_vfe_resources[] = {
  144. {
  145. .start = MSM_IOMMU_VFE_PHYS,
  146. .end = MSM_IOMMU_VFE_PHYS + MSM_IOMMU_VFE_SIZE - 1,
  147. .name = "physbase",
  148. .flags = IORESOURCE_MEM,
  149. },
  150. {
  151. .name = "nonsecure_irq",
  152. .start = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
  153. .end = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. {
  157. .name = "secure_irq",
  158. .start = SMMU_VFE_CB_SC_SECURE_IRQ,
  159. .end = SMMU_VFE_CB_SC_SECURE_IRQ,
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct resource msm_iommu_vcodec_a_resources[] = {
  164. {
  165. .start = MSM_IOMMU_VCODEC_A_PHYS,
  166. .end = MSM_IOMMU_VCODEC_A_PHYS + MSM_IOMMU_VCODEC_A_SIZE - 1,
  167. .name = "physbase",
  168. .flags = IORESOURCE_MEM,
  169. },
  170. {
  171. .name = "nonsecure_irq",
  172. .start = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
  173. .end = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
  174. .flags = IORESOURCE_IRQ,
  175. },
  176. {
  177. .name = "secure_irq",
  178. .start = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
  179. .end = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
  180. .flags = IORESOURCE_IRQ,
  181. },
  182. };
  183. static struct resource msm_iommu_vcodec_b_resources[] = {
  184. {
  185. .start = MSM_IOMMU_VCODEC_B_PHYS,
  186. .end = MSM_IOMMU_VCODEC_B_PHYS + MSM_IOMMU_VCODEC_B_SIZE - 1,
  187. .name = "physbase",
  188. .flags = IORESOURCE_MEM,
  189. },
  190. {
  191. .name = "nonsecure_irq",
  192. .start = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
  193. .end = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. {
  197. .name = "secure_irq",
  198. .start = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
  199. .end = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
  200. .flags = IORESOURCE_IRQ,
  201. },
  202. };
  203. static struct resource msm_iommu_gfx3d_resources[] = {
  204. {
  205. .start = MSM_IOMMU_GFX3D_PHYS,
  206. .end = MSM_IOMMU_GFX3D_PHYS + MSM_IOMMU_GFX3D_SIZE - 1,
  207. .name = "physbase",
  208. .flags = IORESOURCE_MEM,
  209. },
  210. {
  211. .name = "nonsecure_irq",
  212. .start = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
  213. .end = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
  214. .flags = IORESOURCE_IRQ,
  215. },
  216. {
  217. .name = "secure_irq",
  218. .start = SMMU_GFX3D_CB_SC_SECURE_IRQ,
  219. .end = SMMU_GFX3D_CB_SC_SECURE_IRQ,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. };
  223. static struct resource msm_iommu_gfx2d0_resources[] = {
  224. {
  225. .start = MSM_IOMMU_GFX2D0_PHYS,
  226. .end = MSM_IOMMU_GFX2D0_PHYS + MSM_IOMMU_GFX2D0_SIZE - 1,
  227. .name = "physbase",
  228. .flags = IORESOURCE_MEM,
  229. },
  230. {
  231. .name = "nonsecure_irq",
  232. .start = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
  233. .end = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
  234. .flags = IORESOURCE_IRQ,
  235. },
  236. {
  237. .name = "secure_irq",
  238. .start = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
  239. .end = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
  240. .flags = IORESOURCE_IRQ,
  241. },
  242. };
  243. static struct platform_device msm_root_iommu_dev = {
  244. .name = "msm_iommu",
  245. .id = -1,
  246. };
  247. static struct msm_iommu_dev jpegd_iommu = {
  248. .name = "jpegd",
  249. .clk_rate = -1
  250. };
  251. static struct msm_iommu_dev vpe_iommu = {
  252. .name = "vpe"
  253. };
  254. static struct msm_iommu_dev mdp0_iommu = {
  255. .name = "mdp0"
  256. };
  257. static struct msm_iommu_dev mdp1_iommu = {
  258. .name = "mdp1"
  259. };
  260. static struct msm_iommu_dev rot_iommu = {
  261. .name = "rot"
  262. };
  263. static struct msm_iommu_dev ijpeg_iommu = {
  264. .name = "ijpeg"
  265. };
  266. static struct msm_iommu_dev vfe_iommu = {
  267. .name = "vfe",
  268. .clk_rate = -1
  269. };
  270. static struct msm_iommu_dev vcodec_a_iommu = {
  271. .name = "vcodec_a"
  272. };
  273. static struct msm_iommu_dev vcodec_b_iommu = {
  274. .name = "vcodec_b"
  275. };
  276. static struct msm_iommu_dev gfx3d_iommu = {
  277. .name = "gfx3d",
  278. .clk_rate = 27000000
  279. };
  280. static struct msm_iommu_dev gfx2d0_iommu = {
  281. .name = "gfx2d0",
  282. .clk_rate = 27000000
  283. };
  284. static struct platform_device msm_device_iommu_jpegd = {
  285. .name = "msm_iommu",
  286. .id = 0,
  287. .dev = {
  288. .parent = &msm_root_iommu_dev.dev,
  289. },
  290. .num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
  291. .resource = msm_iommu_jpegd_resources,
  292. };
  293. static struct platform_device msm_device_iommu_vpe = {
  294. .name = "msm_iommu",
  295. .id = 1,
  296. .dev = {
  297. .parent = &msm_root_iommu_dev.dev,
  298. },
  299. .num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
  300. .resource = msm_iommu_vpe_resources,
  301. };
  302. static struct platform_device msm_device_iommu_mdp0 = {
  303. .name = "msm_iommu",
  304. .id = 2,
  305. .dev = {
  306. .parent = &msm_root_iommu_dev.dev,
  307. },
  308. .num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
  309. .resource = msm_iommu_mdp0_resources,
  310. };
  311. static struct platform_device msm_device_iommu_mdp1 = {
  312. .name = "msm_iommu",
  313. .id = 3,
  314. .dev = {
  315. .parent = &msm_root_iommu_dev.dev,
  316. },
  317. .num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
  318. .resource = msm_iommu_mdp1_resources,
  319. };
  320. static struct platform_device msm_device_iommu_rot = {
  321. .name = "msm_iommu",
  322. .id = 4,
  323. .dev = {
  324. .parent = &msm_root_iommu_dev.dev,
  325. },
  326. .num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
  327. .resource = msm_iommu_rot_resources,
  328. };
  329. static struct platform_device msm_device_iommu_ijpeg = {
  330. .name = "msm_iommu",
  331. .id = 5,
  332. .dev = {
  333. .parent = &msm_root_iommu_dev.dev,
  334. },
  335. .num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),
  336. .resource = msm_iommu_ijpeg_resources,
  337. };
  338. static struct platform_device msm_device_iommu_vfe = {
  339. .name = "msm_iommu",
  340. .id = 6,
  341. .dev = {
  342. .parent = &msm_root_iommu_dev.dev,
  343. },
  344. .num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
  345. .resource = msm_iommu_vfe_resources,
  346. };
  347. static struct platform_device msm_device_iommu_vcodec_a = {
  348. .name = "msm_iommu",
  349. .id = 7,
  350. .dev = {
  351. .parent = &msm_root_iommu_dev.dev,
  352. },
  353. .num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
  354. .resource = msm_iommu_vcodec_a_resources,
  355. };
  356. static struct platform_device msm_device_iommu_vcodec_b = {
  357. .name = "msm_iommu",
  358. .id = 8,
  359. .dev = {
  360. .parent = &msm_root_iommu_dev.dev,
  361. },
  362. .num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
  363. .resource = msm_iommu_vcodec_b_resources,
  364. };
  365. static struct platform_device msm_device_iommu_gfx3d = {
  366. .name = "msm_iommu",
  367. .id = 9,
  368. .dev = {
  369. .parent = &msm_root_iommu_dev.dev,
  370. },
  371. .num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
  372. .resource = msm_iommu_gfx3d_resources,
  373. };
  374. static struct platform_device msm_device_iommu_gfx2d0 = {
  375. .name = "msm_iommu",
  376. .id = 10,
  377. .dev = {
  378. .parent = &msm_root_iommu_dev.dev,
  379. },
  380. .num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
  381. .resource = msm_iommu_gfx2d0_resources,
  382. };
  383. static struct msm_iommu_ctx_dev jpegd_src_ctx = {
  384. .name = "jpegd_src",
  385. .num = 0,
  386. .mids = {0, -1}
  387. };
  388. static struct msm_iommu_ctx_dev jpegd_dst_ctx = {
  389. .name = "jpegd_dst",
  390. .num = 1,
  391. .mids = {1, -1}
  392. };
  393. static struct msm_iommu_ctx_dev vpe_src_ctx = {
  394. .name = "vpe_src",
  395. .num = 0,
  396. .mids = {0, -1}
  397. };
  398. static struct msm_iommu_ctx_dev vpe_dst_ctx = {
  399. .name = "vpe_dst",
  400. .num = 1,
  401. .mids = {1, -1}
  402. };
  403. static struct msm_iommu_ctx_dev mdp_vg1_ctx = {
  404. .name = "mdp_vg1",
  405. .num = 0,
  406. .mids = {0, 2, -1}
  407. };
  408. static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {
  409. .name = "mdp_rgb1",
  410. .num = 1,
  411. .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
  412. };
  413. static struct msm_iommu_ctx_dev mdp_vg2_ctx = {
  414. .name = "mdp_vg2",
  415. .num = 0,
  416. .mids = {0, 2, -1}
  417. };
  418. static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {
  419. .name = "mdp_rgb2",
  420. .num = 1,
  421. .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
  422. };
  423. static struct msm_iommu_ctx_dev rot_src_ctx = {
  424. .name = "rot_src",
  425. .num = 0,
  426. .mids = {0, -1}
  427. };
  428. static struct msm_iommu_ctx_dev rot_dst_ctx = {
  429. .name = "rot_dst",
  430. .num = 1,
  431. .mids = {1, -1}
  432. };
  433. static struct msm_iommu_ctx_dev ijpeg_src_ctx = {
  434. .name = "ijpeg_src",
  435. .num = 0,
  436. .mids = {0, -1}
  437. };
  438. static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {
  439. .name = "ijpeg_dst",
  440. .num = 1,
  441. .mids = {1, -1}
  442. };
  443. static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {
  444. .name = "vfe_imgwr",
  445. .num = 0,
  446. .mids = {2, 3, 4, 5, 6, 7, 8, -1}
  447. };
  448. static struct msm_iommu_ctx_dev vfe_misc_ctx = {
  449. .name = "vfe_misc",
  450. .num = 1,
  451. .mids = {0, 1, 9, -1}
  452. };
  453. static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {
  454. .name = "vcodec_a_stream",
  455. .num = 0,
  456. .mids = {2, 5, -1}
  457. };
  458. static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {
  459. .name = "vcodec_a_mm1",
  460. .num = 1,
  461. .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
  462. };
  463. static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {
  464. .name = "vcodec_b_mm2",
  465. .num = 0,
  466. .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
  467. };
  468. static struct msm_iommu_ctx_dev gfx3d_user_ctx = {
  469. .name = "gfx3d_user",
  470. .num = 0,
  471. .mids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
  472. };
  473. static struct msm_iommu_ctx_dev gfx3d_priv_ctx = {
  474. .name = "gfx3d_priv",
  475. .num = 1,
  476. .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
  477. 31, -1}
  478. };
  479. static struct msm_iommu_ctx_dev gfx2d0_pixv1_ctx = {
  480. .name = "gfx2d0_pixv1_smmu",
  481. .num = 0,
  482. .mids = {0, 3, 4, -1}
  483. };
  484. static struct msm_iommu_ctx_dev gfx2d0_texv3_ctx = {
  485. .name = "gfx2d0_texv3_smmu",
  486. .num = 1,
  487. .mids = {1, 6, 7, -1}
  488. };
  489. static struct platform_device msm_device_jpegd_src_ctx = {
  490. .name = "msm_iommu_ctx",
  491. .id = 0,
  492. .dev = {
  493. .parent = &msm_device_iommu_jpegd.dev,
  494. },
  495. };
  496. static struct platform_device msm_device_jpegd_dst_ctx = {
  497. .name = "msm_iommu_ctx",
  498. .id = 1,
  499. .dev = {
  500. .parent = &msm_device_iommu_jpegd.dev,
  501. },
  502. };
  503. static struct platform_device msm_device_vpe_src_ctx = {
  504. .name = "msm_iommu_ctx",
  505. .id = 2,
  506. .dev = {
  507. .parent = &msm_device_iommu_vpe.dev,
  508. },
  509. };
  510. static struct platform_device msm_device_vpe_dst_ctx = {
  511. .name = "msm_iommu_ctx",
  512. .id = 3,
  513. .dev = {
  514. .parent = &msm_device_iommu_vpe.dev,
  515. },
  516. };
  517. static struct platform_device msm_device_mdp_vg1_ctx = {
  518. .name = "msm_iommu_ctx",
  519. .id = 4,
  520. .dev = {
  521. .parent = &msm_device_iommu_mdp0.dev,
  522. },
  523. };
  524. static struct platform_device msm_device_mdp_rgb1_ctx = {
  525. .name = "msm_iommu_ctx",
  526. .id = 5,
  527. .dev = {
  528. .parent = &msm_device_iommu_mdp0.dev,
  529. },
  530. };
  531. static struct platform_device msm_device_mdp_vg2_ctx = {
  532. .name = "msm_iommu_ctx",
  533. .id = 6,
  534. .dev = {
  535. .parent = &msm_device_iommu_mdp1.dev,
  536. },
  537. };
  538. static struct platform_device msm_device_mdp_rgb2_ctx = {
  539. .name = "msm_iommu_ctx",
  540. .id = 7,
  541. .dev = {
  542. .parent = &msm_device_iommu_mdp1.dev,
  543. },
  544. };
  545. static struct platform_device msm_device_rot_src_ctx = {
  546. .name = "msm_iommu_ctx",
  547. .id = 8,
  548. .dev = {
  549. .parent = &msm_device_iommu_rot.dev,
  550. },
  551. };
  552. static struct platform_device msm_device_rot_dst_ctx = {
  553. .name = "msm_iommu_ctx",
  554. .id = 9,
  555. .dev = {
  556. .parent = &msm_device_iommu_rot.dev,
  557. },
  558. };
  559. static struct platform_device msm_device_ijpeg_src_ctx = {
  560. .name = "msm_iommu_ctx",
  561. .id = 10,
  562. .dev = {
  563. .parent = &msm_device_iommu_ijpeg.dev,
  564. },
  565. };
  566. static struct platform_device msm_device_ijpeg_dst_ctx = {
  567. .name = "msm_iommu_ctx",
  568. .id = 11,
  569. .dev = {
  570. .parent = &msm_device_iommu_ijpeg.dev,
  571. },
  572. };
  573. static struct platform_device msm_device_vfe_imgwr_ctx = {
  574. .name = "msm_iommu_ctx",
  575. .id = 12,
  576. .dev = {
  577. .parent = &msm_device_iommu_vfe.dev,
  578. },
  579. };
  580. static struct platform_device msm_device_vfe_misc_ctx = {
  581. .name = "msm_iommu_ctx",
  582. .id = 13,
  583. .dev = {
  584. .parent = &msm_device_iommu_vfe.dev,
  585. },
  586. };
  587. static struct platform_device msm_device_vcodec_a_stream_ctx = {
  588. .name = "msm_iommu_ctx",
  589. .id = 14,
  590. .dev = {
  591. .parent = &msm_device_iommu_vcodec_a.dev,
  592. },
  593. };
  594. static struct platform_device msm_device_vcodec_a_mm1_ctx = {
  595. .name = "msm_iommu_ctx",
  596. .id = 15,
  597. .dev = {
  598. .parent = &msm_device_iommu_vcodec_a.dev,
  599. },
  600. };
  601. static struct platform_device msm_device_vcodec_b_mm2_ctx = {
  602. .name = "msm_iommu_ctx",
  603. .id = 16,
  604. .dev = {
  605. .parent = &msm_device_iommu_vcodec_b.dev,
  606. },
  607. };
  608. static struct platform_device msm_device_gfx3d_user_ctx = {
  609. .name = "msm_iommu_ctx",
  610. .id = 17,
  611. .dev = {
  612. .parent = &msm_device_iommu_gfx3d.dev,
  613. },
  614. };
  615. static struct platform_device msm_device_gfx3d_priv_ctx = {
  616. .name = "msm_iommu_ctx",
  617. .id = 18,
  618. .dev = {
  619. .parent = &msm_device_iommu_gfx3d.dev,
  620. },
  621. };
  622. static struct platform_device msm_device_gfx2d0_pixv1_ctx = {
  623. .name = "msm_iommu_ctx",
  624. .id = 19,
  625. .dev = {
  626. .parent = &msm_device_iommu_gfx2d0.dev,
  627. },
  628. };
  629. static struct platform_device msm_device_gfx2d0_texv3_ctx = {
  630. .name = "msm_iommu_ctx",
  631. .id = 20,
  632. .dev = {
  633. .parent = &msm_device_iommu_gfx2d0.dev,
  634. },
  635. };
  636. static struct platform_device *msm_iommu_devs[] = {
  637. &msm_device_iommu_jpegd,
  638. &msm_device_iommu_vpe,
  639. &msm_device_iommu_mdp0,
  640. &msm_device_iommu_mdp1,
  641. &msm_device_iommu_rot,
  642. &msm_device_iommu_ijpeg,
  643. &msm_device_iommu_vfe,
  644. &msm_device_iommu_vcodec_a,
  645. &msm_device_iommu_vcodec_b,
  646. &msm_device_iommu_gfx3d,
  647. &msm_device_iommu_gfx2d0,
  648. };
  649. static struct msm_iommu_dev *msm_iommu_data[] = {
  650. &jpegd_iommu,
  651. &vpe_iommu,
  652. &mdp0_iommu,
  653. &mdp1_iommu,
  654. &rot_iommu,
  655. &ijpeg_iommu,
  656. &vfe_iommu,
  657. &vcodec_a_iommu,
  658. &vcodec_b_iommu,
  659. &gfx3d_iommu,
  660. &gfx2d0_iommu,
  661. };
  662. static struct platform_device *msm_iommu_ctx_devs[] = {
  663. &msm_device_jpegd_src_ctx,
  664. &msm_device_jpegd_dst_ctx,
  665. &msm_device_vpe_src_ctx,
  666. &msm_device_vpe_dst_ctx,
  667. &msm_device_mdp_vg1_ctx,
  668. &msm_device_mdp_rgb1_ctx,
  669. &msm_device_mdp_vg2_ctx,
  670. &msm_device_mdp_rgb2_ctx,
  671. &msm_device_rot_src_ctx,
  672. &msm_device_rot_dst_ctx,
  673. &msm_device_ijpeg_src_ctx,
  674. &msm_device_ijpeg_dst_ctx,
  675. &msm_device_vfe_imgwr_ctx,
  676. &msm_device_vfe_misc_ctx,
  677. &msm_device_vcodec_a_stream_ctx,
  678. &msm_device_vcodec_a_mm1_ctx,
  679. &msm_device_vcodec_b_mm2_ctx,
  680. &msm_device_gfx3d_user_ctx,
  681. &msm_device_gfx3d_priv_ctx,
  682. &msm_device_gfx2d0_pixv1_ctx,
  683. &msm_device_gfx2d0_texv3_ctx,
  684. };
  685. static struct msm_iommu_ctx_dev *msm_iommu_ctx_data[] = {
  686. &jpegd_src_ctx,
  687. &jpegd_dst_ctx,
  688. &vpe_src_ctx,
  689. &vpe_dst_ctx,
  690. &mdp_vg1_ctx,
  691. &mdp_rgb1_ctx,
  692. &mdp_vg2_ctx,
  693. &mdp_rgb2_ctx,
  694. &rot_src_ctx,
  695. &rot_dst_ctx,
  696. &ijpeg_src_ctx,
  697. &ijpeg_dst_ctx,
  698. &vfe_imgwr_ctx,
  699. &vfe_misc_ctx,
  700. &vcodec_a_stream_ctx,
  701. &vcodec_a_mm1_ctx,
  702. &vcodec_b_mm2_ctx,
  703. &gfx3d_user_ctx,
  704. &gfx3d_priv_ctx,
  705. &gfx2d0_pixv1_ctx,
  706. &gfx2d0_texv3_ctx,
  707. };
  708. static int msm8x60_iommu_init(void)
  709. {
  710. int ret, i;
  711. ret = platform_device_register(&msm_root_iommu_dev);
  712. if (ret != 0) {
  713. pr_err("Failed to register root IOMMU device!\n");
  714. goto failure;
  715. }
  716. for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); i++) {
  717. ret = platform_device_add_data(msm_iommu_devs[i],
  718. msm_iommu_data[i],
  719. sizeof(struct msm_iommu_dev));
  720. if (ret != 0) {
  721. pr_err("platform_device_add_data failed, "
  722. "i = %d\n", i);
  723. goto failure_unwind;
  724. }
  725. ret = platform_device_register(msm_iommu_devs[i]);
  726. if (ret != 0) {
  727. pr_err("platform_device_register iommu failed, "
  728. "i = %d\n", i);
  729. goto failure_unwind;
  730. }
  731. }
  732. for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++) {
  733. ret = platform_device_add_data(msm_iommu_ctx_devs[i],
  734. msm_iommu_ctx_data[i],
  735. sizeof(*msm_iommu_ctx_devs[i]));
  736. if (ret != 0) {
  737. pr_err("platform_device_add_data iommu failed, "
  738. "i = %d\n", i);
  739. goto failure_unwind2;
  740. }
  741. ret = platform_device_register(msm_iommu_ctx_devs[i]);
  742. if (ret != 0) {
  743. pr_err("platform_device_register ctx failed, "
  744. "i = %d\n", i);
  745. goto failure_unwind2;
  746. }
  747. }
  748. return 0;
  749. failure_unwind2:
  750. while (--i >= 0)
  751. platform_device_unregister(msm_iommu_ctx_devs[i]);
  752. failure_unwind:
  753. while (--i >= 0)
  754. platform_device_unregister(msm_iommu_devs[i]);
  755. platform_device_unregister(&msm_root_iommu_dev);
  756. failure:
  757. return ret;
  758. }
  759. static void msm8x60_iommu_exit(void)
  760. {
  761. int i;
  762. for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++)
  763. platform_device_unregister(msm_iommu_ctx_devs[i]);
  764. for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); ++i)
  765. platform_device_unregister(msm_iommu_devs[i]);
  766. platform_device_unregister(&msm_root_iommu_dev);
  767. }
  768. subsys_initcall(msm8x60_iommu_init);
  769. module_exit(msm8x60_iommu_exit);
  770. MODULE_LICENSE("GPL v2");
  771. MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");