devices-iommu.c 19 KB

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