devices-iommu.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  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 <linux/module.h>
  21. #include <mach/irqs.h>
  22. #include <mach/iommu.h>
  23. static struct resource msm_iommu_jpegd_resources[] = {
  24. {
  25. .start = 0x07300000,
  26. .end = 0x07300000 + SZ_1M - 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 = 0x07400000,
  46. .end = 0x07400000 + SZ_1M - 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 = 0x07500000,
  66. .end = 0x07500000 + SZ_1M - 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 = 0x07600000,
  86. .end = 0x07600000 + SZ_1M - 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 = 0x07700000,
  106. .end = 0x07700000 + SZ_1M - 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 = 0x07800000,
  126. .end = 0x07800000 + SZ_1M - 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 = 0x07900000,
  146. .end = 0x07900000 + SZ_1M - 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 = 0x07A00000,
  166. .end = 0x07A00000 + SZ_1M - 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 = 0x07B00000,
  186. .end = 0x07B00000 + SZ_1M - 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 = 0x07C00000,
  206. .end = 0x07C00000 + SZ_1M - 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 = 0x07D00000,
  226. .end = 0x07D00000 + SZ_1M - 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 resource msm_iommu_gfx2d1_resources[] = {
  244. {
  245. .start = 0x07E00000,
  246. .end = 0x07E00000 + SZ_1M - 1,
  247. .name = "physbase",
  248. .flags = IORESOURCE_MEM,
  249. },
  250. {
  251. .name = "nonsecure_irq",
  252. .start = SMMU_GFX2D1_CB_SC_NON_SECURE_IRQ,
  253. .end = SMMU_GFX2D1_CB_SC_NON_SECURE_IRQ,
  254. .flags = IORESOURCE_IRQ,
  255. },
  256. {
  257. .name = "secure_irq",
  258. .start = SMMU_GFX2D1_CB_SC_SECURE_IRQ,
  259. .end = SMMU_GFX2D1_CB_SC_SECURE_IRQ,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. };
  263. static struct platform_device msm_root_iommu_dev = {
  264. .name = "msm_iommu",
  265. .id = -1,
  266. };
  267. static struct msm_iommu_dev jpegd_iommu = {
  268. .name = "jpegd",
  269. .ncb = 2,
  270. };
  271. static struct msm_iommu_dev vpe_iommu = {
  272. .name = "vpe",
  273. .ncb = 2,
  274. };
  275. static struct msm_iommu_dev mdp0_iommu = {
  276. .name = "mdp0",
  277. .ncb = 2,
  278. };
  279. static struct msm_iommu_dev mdp1_iommu = {
  280. .name = "mdp1",
  281. .ncb = 2,
  282. };
  283. static struct msm_iommu_dev rot_iommu = {
  284. .name = "rot",
  285. .ncb = 2,
  286. };
  287. static struct msm_iommu_dev ijpeg_iommu = {
  288. .name = "ijpeg",
  289. .ncb = 2,
  290. };
  291. static struct msm_iommu_dev vfe_iommu = {
  292. .name = "vfe",
  293. .ncb = 2,
  294. };
  295. static struct msm_iommu_dev vcodec_a_iommu = {
  296. .name = "vcodec_a",
  297. .ncb = 2,
  298. };
  299. static struct msm_iommu_dev vcodec_b_iommu = {
  300. .name = "vcodec_b",
  301. .ncb = 2,
  302. };
  303. static struct msm_iommu_dev gfx3d_iommu = {
  304. .name = "gfx3d",
  305. .ncb = 3,
  306. };
  307. static struct msm_iommu_dev gfx2d0_iommu = {
  308. .name = "gfx2d0",
  309. .ncb = 2,
  310. };
  311. static struct msm_iommu_dev gfx2d1_iommu = {
  312. .name = "gfx2d1",
  313. .ncb = 2,
  314. };
  315. static struct platform_device msm_device_iommu_jpegd = {
  316. .name = "msm_iommu",
  317. .id = 0,
  318. .dev = {
  319. .parent = &msm_root_iommu_dev.dev,
  320. },
  321. .num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
  322. .resource = msm_iommu_jpegd_resources,
  323. };
  324. static struct platform_device msm_device_iommu_vpe = {
  325. .name = "msm_iommu",
  326. .id = 1,
  327. .dev = {
  328. .parent = &msm_root_iommu_dev.dev,
  329. },
  330. .num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
  331. .resource = msm_iommu_vpe_resources,
  332. };
  333. static struct platform_device msm_device_iommu_mdp0 = {
  334. .name = "msm_iommu",
  335. .id = 2,
  336. .dev = {
  337. .parent = &msm_root_iommu_dev.dev,
  338. },
  339. .num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
  340. .resource = msm_iommu_mdp0_resources,
  341. };
  342. static struct platform_device msm_device_iommu_mdp1 = {
  343. .name = "msm_iommu",
  344. .id = 3,
  345. .dev = {
  346. .parent = &msm_root_iommu_dev.dev,
  347. },
  348. .num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
  349. .resource = msm_iommu_mdp1_resources,
  350. };
  351. static struct platform_device msm_device_iommu_rot = {
  352. .name = "msm_iommu",
  353. .id = 4,
  354. .dev = {
  355. .parent = &msm_root_iommu_dev.dev,
  356. },
  357. .num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
  358. .resource = msm_iommu_rot_resources,
  359. };
  360. static struct platform_device msm_device_iommu_ijpeg = {
  361. .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. static struct platform_device msm_device_iommu_vfe = {
  370. .name = "msm_iommu",
  371. .id = 6,
  372. .dev = {
  373. .parent = &msm_root_iommu_dev.dev,
  374. },
  375. .num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
  376. .resource = msm_iommu_vfe_resources,
  377. };
  378. static struct platform_device msm_device_iommu_vcodec_a = {
  379. .name = "msm_iommu",
  380. .id = 7,
  381. .dev = {
  382. .parent = &msm_root_iommu_dev.dev,
  383. },
  384. .num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
  385. .resource = msm_iommu_vcodec_a_resources,
  386. };
  387. static struct platform_device msm_device_iommu_vcodec_b = {
  388. .name = "msm_iommu",
  389. .id = 8,
  390. .dev = {
  391. .parent = &msm_root_iommu_dev.dev,
  392. },
  393. .num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
  394. .resource = msm_iommu_vcodec_b_resources,
  395. };
  396. static struct platform_device msm_device_iommu_gfx3d = {
  397. .name = "msm_iommu",
  398. .id = 9,
  399. .dev = {
  400. .parent = &msm_root_iommu_dev.dev,
  401. },
  402. .num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
  403. .resource = msm_iommu_gfx3d_resources,
  404. };
  405. static struct platform_device msm_device_iommu_gfx2d0 = {
  406. .name = "msm_iommu",
  407. .id = 10,
  408. .dev = {
  409. .parent = &msm_root_iommu_dev.dev,
  410. },
  411. .num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
  412. .resource = msm_iommu_gfx2d0_resources,
  413. };
  414. struct platform_device msm_device_iommu_gfx2d1 = {
  415. .name = "msm_iommu",
  416. .id = 11,
  417. .dev = {
  418. .parent = &msm_root_iommu_dev.dev,
  419. },
  420. .num_resources = ARRAY_SIZE(msm_iommu_gfx2d1_resources),
  421. .resource = msm_iommu_gfx2d1_resources,
  422. };
  423. static struct msm_iommu_ctx_dev jpegd_src_ctx = {
  424. .name = "jpegd_src",
  425. .num = 0,
  426. .mids = {0, -1}
  427. };
  428. static struct msm_iommu_ctx_dev jpegd_dst_ctx = {
  429. .name = "jpegd_dst",
  430. .num = 1,
  431. .mids = {1, -1}
  432. };
  433. static struct msm_iommu_ctx_dev vpe_src_ctx = {
  434. .name = "vpe_src",
  435. .num = 0,
  436. .mids = {0, -1}
  437. };
  438. static struct msm_iommu_ctx_dev vpe_dst_ctx = {
  439. .name = "vpe_dst",
  440. .num = 1,
  441. .mids = {1, -1}
  442. };
  443. static struct msm_iommu_ctx_dev mdp_vg1_ctx = {
  444. .name = "mdp_vg1",
  445. .num = 0,
  446. .mids = {0, 2, -1}
  447. };
  448. static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {
  449. .name = "mdp_rgb1",
  450. .num = 1,
  451. .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
  452. };
  453. static struct msm_iommu_ctx_dev mdp_vg2_ctx = {
  454. .name = "mdp_vg2",
  455. .num = 0,
  456. .mids = {0, 2, -1}
  457. };
  458. static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {
  459. .name = "mdp_rgb2",
  460. .num = 1,
  461. .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
  462. };
  463. static struct msm_iommu_ctx_dev rot_src_ctx = {
  464. .name = "rot_src",
  465. .num = 0,
  466. .mids = {0, -1}
  467. };
  468. static struct msm_iommu_ctx_dev rot_dst_ctx = {
  469. .name = "rot_dst",
  470. .num = 1,
  471. .mids = {1, -1}
  472. };
  473. static struct msm_iommu_ctx_dev ijpeg_src_ctx = {
  474. .name = "ijpeg_src",
  475. .num = 0,
  476. .mids = {0, -1}
  477. };
  478. static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {
  479. .name = "ijpeg_dst",
  480. .num = 1,
  481. .mids = {1, -1}
  482. };
  483. static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {
  484. .name = "vfe_imgwr",
  485. .num = 0,
  486. .mids = {2, 3, 4, 5, 6, 7, 8, -1}
  487. };
  488. static struct msm_iommu_ctx_dev vfe_misc_ctx = {
  489. .name = "vfe_misc",
  490. .num = 1,
  491. .mids = {0, 1, 9, -1}
  492. };
  493. static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {
  494. .name = "vcodec_a_stream",
  495. .num = 0,
  496. .mids = {2, 5, -1}
  497. };
  498. static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {
  499. .name = "vcodec_a_mm1",
  500. .num = 1,
  501. .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
  502. };
  503. static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {
  504. .name = "vcodec_b_mm2",
  505. .num = 0,
  506. .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
  507. };
  508. static struct msm_iommu_ctx_dev gfx3d_user_ctx = {
  509. .name = "gfx3d_user",
  510. .num = 0,
  511. .mids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
  512. };
  513. static struct msm_iommu_ctx_dev gfx3d_priv_ctx = {
  514. .name = "gfx3d_priv",
  515. .num = 1,
  516. .mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
  517. 31, -1}
  518. };
  519. static struct msm_iommu_ctx_dev gfx2d0_2d0_ctx = {
  520. .name = "gfx2d0_2d0",
  521. .num = 0,
  522. .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
  523. };
  524. static struct msm_iommu_ctx_dev gfx2d1_2d1_ctx = {
  525. .name = "gfx2d1_2d1",
  526. .num = 0,
  527. .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
  528. };
  529. static struct platform_device msm_device_jpegd_src_ctx = {
  530. .name = "msm_iommu_ctx",
  531. .id = 0,
  532. .dev = {
  533. .parent = &msm_device_iommu_jpegd.dev,
  534. },
  535. };
  536. static struct platform_device msm_device_jpegd_dst_ctx = {
  537. .name = "msm_iommu_ctx",
  538. .id = 1,
  539. .dev = {
  540. .parent = &msm_device_iommu_jpegd.dev,
  541. },
  542. };
  543. static struct platform_device msm_device_vpe_src_ctx = {
  544. .name = "msm_iommu_ctx",
  545. .id = 2,
  546. .dev = {
  547. .parent = &msm_device_iommu_vpe.dev,
  548. },
  549. };
  550. static struct platform_device msm_device_vpe_dst_ctx = {
  551. .name = "msm_iommu_ctx",
  552. .id = 3,
  553. .dev = {
  554. .parent = &msm_device_iommu_vpe.dev,
  555. },
  556. };
  557. static struct platform_device msm_device_mdp_vg1_ctx = {
  558. .name = "msm_iommu_ctx",
  559. .id = 4,
  560. .dev = {
  561. .parent = &msm_device_iommu_mdp0.dev,
  562. },
  563. };
  564. static struct platform_device msm_device_mdp_rgb1_ctx = {
  565. .name = "msm_iommu_ctx",
  566. .id = 5,
  567. .dev = {
  568. .parent = &msm_device_iommu_mdp0.dev,
  569. },
  570. };
  571. static struct platform_device msm_device_mdp_vg2_ctx = {
  572. .name = "msm_iommu_ctx",
  573. .id = 6,
  574. .dev = {
  575. .parent = &msm_device_iommu_mdp1.dev,
  576. },
  577. };
  578. static struct platform_device msm_device_mdp_rgb2_ctx = {
  579. .name = "msm_iommu_ctx",
  580. .id = 7,
  581. .dev = {
  582. .parent = &msm_device_iommu_mdp1.dev,
  583. },
  584. };
  585. static struct platform_device msm_device_rot_src_ctx = {
  586. .name = "msm_iommu_ctx",
  587. .id = 8,
  588. .dev = {
  589. .parent = &msm_device_iommu_rot.dev,
  590. },
  591. };
  592. static struct platform_device msm_device_rot_dst_ctx = {
  593. .name = "msm_iommu_ctx",
  594. .id = 9,
  595. .dev = {
  596. .parent = &msm_device_iommu_rot.dev,
  597. },
  598. };
  599. static struct platform_device msm_device_ijpeg_src_ctx = {
  600. .name = "msm_iommu_ctx",
  601. .id = 10,
  602. .dev = {
  603. .parent = &msm_device_iommu_ijpeg.dev,
  604. },
  605. };
  606. static struct platform_device msm_device_ijpeg_dst_ctx = {
  607. .name = "msm_iommu_ctx",
  608. .id = 11,
  609. .dev = {
  610. .parent = &msm_device_iommu_ijpeg.dev,
  611. },
  612. };
  613. static struct platform_device msm_device_vfe_imgwr_ctx = {
  614. .name = "msm_iommu_ctx",
  615. .id = 12,
  616. .dev = {
  617. .parent = &msm_device_iommu_vfe.dev,
  618. },
  619. };
  620. static struct platform_device msm_device_vfe_misc_ctx = {
  621. .name = "msm_iommu_ctx",
  622. .id = 13,
  623. .dev = {
  624. .parent = &msm_device_iommu_vfe.dev,
  625. },
  626. };
  627. static struct platform_device msm_device_vcodec_a_stream_ctx = {
  628. .name = "msm_iommu_ctx",
  629. .id = 14,
  630. .dev = {
  631. .parent = &msm_device_iommu_vcodec_a.dev,
  632. },
  633. };
  634. static struct platform_device msm_device_vcodec_a_mm1_ctx = {
  635. .name = "msm_iommu_ctx",
  636. .id = 15,
  637. .dev = {
  638. .parent = &msm_device_iommu_vcodec_a.dev,
  639. },
  640. };
  641. static struct platform_device msm_device_vcodec_b_mm2_ctx = {
  642. .name = "msm_iommu_ctx",
  643. .id = 16,
  644. .dev = {
  645. .parent = &msm_device_iommu_vcodec_b.dev,
  646. },
  647. };
  648. static struct platform_device msm_device_gfx3d_user_ctx = {
  649. .name = "msm_iommu_ctx",
  650. .id = 17,
  651. .dev = {
  652. .parent = &msm_device_iommu_gfx3d.dev,
  653. },
  654. };
  655. static struct platform_device msm_device_gfx3d_priv_ctx = {
  656. .name = "msm_iommu_ctx",
  657. .id = 18,
  658. .dev = {
  659. .parent = &msm_device_iommu_gfx3d.dev,
  660. },
  661. };
  662. static struct platform_device msm_device_gfx2d0_2d0_ctx = {
  663. .name = "msm_iommu_ctx",
  664. .id = 19,
  665. .dev = {
  666. .parent = &msm_device_iommu_gfx2d0.dev,
  667. },
  668. };
  669. static struct platform_device msm_device_gfx2d1_2d1_ctx = {
  670. .name = "msm_iommu_ctx",
  671. .id = 20,
  672. .dev = {
  673. .parent = &msm_device_iommu_gfx2d1.dev,
  674. },
  675. };
  676. static struct platform_device *msm_iommu_devs[] = {
  677. &msm_device_iommu_jpegd,
  678. &msm_device_iommu_vpe,
  679. &msm_device_iommu_mdp0,
  680. &msm_device_iommu_mdp1,
  681. &msm_device_iommu_rot,
  682. &msm_device_iommu_ijpeg,
  683. &msm_device_iommu_vfe,
  684. &msm_device_iommu_vcodec_a,
  685. &msm_device_iommu_vcodec_b,
  686. &msm_device_iommu_gfx3d,
  687. &msm_device_iommu_gfx2d0,
  688. &msm_device_iommu_gfx2d1,
  689. };
  690. static struct msm_iommu_dev *msm_iommu_data[] = {
  691. &jpegd_iommu,
  692. &vpe_iommu,
  693. &mdp0_iommu,
  694. &mdp1_iommu,
  695. &rot_iommu,
  696. &ijpeg_iommu,
  697. &vfe_iommu,
  698. &vcodec_a_iommu,
  699. &vcodec_b_iommu,
  700. &gfx3d_iommu,
  701. &gfx2d0_iommu,
  702. &gfx2d1_iommu,
  703. };
  704. static struct platform_device *msm_iommu_ctx_devs[] = {
  705. &msm_device_jpegd_src_ctx,
  706. &msm_device_jpegd_dst_ctx,
  707. &msm_device_vpe_src_ctx,
  708. &msm_device_vpe_dst_ctx,
  709. &msm_device_mdp_vg1_ctx,
  710. &msm_device_mdp_rgb1_ctx,
  711. &msm_device_mdp_vg2_ctx,
  712. &msm_device_mdp_rgb2_ctx,
  713. &msm_device_rot_src_ctx,
  714. &msm_device_rot_dst_ctx,
  715. &msm_device_ijpeg_src_ctx,
  716. &msm_device_ijpeg_dst_ctx,
  717. &msm_device_vfe_imgwr_ctx,
  718. &msm_device_vfe_misc_ctx,
  719. &msm_device_vcodec_a_stream_ctx,
  720. &msm_device_vcodec_a_mm1_ctx,
  721. &msm_device_vcodec_b_mm2_ctx,
  722. &msm_device_gfx3d_user_ctx,
  723. &msm_device_gfx3d_priv_ctx,
  724. &msm_device_gfx2d0_2d0_ctx,
  725. &msm_device_gfx2d1_2d1_ctx,
  726. };
  727. static struct msm_iommu_ctx_dev *msm_iommu_ctx_data[] = {
  728. &jpegd_src_ctx,
  729. &jpegd_dst_ctx,
  730. &vpe_src_ctx,
  731. &vpe_dst_ctx,
  732. &mdp_vg1_ctx,
  733. &mdp_rgb1_ctx,
  734. &mdp_vg2_ctx,
  735. &mdp_rgb2_ctx,
  736. &rot_src_ctx,
  737. &rot_dst_ctx,
  738. &ijpeg_src_ctx,
  739. &ijpeg_dst_ctx,
  740. &vfe_imgwr_ctx,
  741. &vfe_misc_ctx,
  742. &vcodec_a_stream_ctx,
  743. &vcodec_a_mm1_ctx,
  744. &vcodec_b_mm2_ctx,
  745. &gfx3d_user_ctx,
  746. &gfx3d_priv_ctx,
  747. &gfx2d0_2d0_ctx,
  748. &gfx2d1_2d1_ctx,
  749. };
  750. static int __init msm8x60_iommu_init(void)
  751. {
  752. int ret, i;
  753. ret = platform_device_register(&msm_root_iommu_dev);
  754. if (ret != 0) {
  755. pr_err("Failed to register root IOMMU device!\n");
  756. goto failure;
  757. }
  758. for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); i++) {
  759. ret = platform_device_add_data(msm_iommu_devs[i],
  760. msm_iommu_data[i],
  761. sizeof(struct msm_iommu_dev));
  762. if (ret != 0) {
  763. pr_err("platform_device_add_data failed, "
  764. "i = %d\n", i);
  765. goto failure_unwind;
  766. }
  767. ret = platform_device_register(msm_iommu_devs[i]);
  768. if (ret != 0) {
  769. pr_err("platform_device_register iommu failed, "
  770. "i = %d\n", i);
  771. goto failure_unwind;
  772. }
  773. }
  774. for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++) {
  775. ret = platform_device_add_data(msm_iommu_ctx_devs[i],
  776. msm_iommu_ctx_data[i],
  777. sizeof(*msm_iommu_ctx_devs[i]));
  778. if (ret != 0) {
  779. pr_err("platform_device_add_data iommu failed, "
  780. "i = %d\n", i);
  781. goto failure_unwind2;
  782. }
  783. ret = platform_device_register(msm_iommu_ctx_devs[i]);
  784. if (ret != 0) {
  785. pr_err("platform_device_register ctx failed, "
  786. "i = %d\n", i);
  787. goto failure_unwind2;
  788. }
  789. }
  790. return 0;
  791. failure_unwind2:
  792. while (--i >= 0)
  793. platform_device_unregister(msm_iommu_ctx_devs[i]);
  794. failure_unwind:
  795. while (--i >= 0)
  796. platform_device_unregister(msm_iommu_devs[i]);
  797. platform_device_unregister(&msm_root_iommu_dev);
  798. failure:
  799. return ret;
  800. }
  801. static void __exit msm8x60_iommu_exit(void)
  802. {
  803. int i;
  804. for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++)
  805. platform_device_unregister(msm_iommu_ctx_devs[i]);
  806. for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); ++i)
  807. platform_device_unregister(msm_iommu_devs[i]);
  808. platform_device_unregister(&msm_root_iommu_dev);
  809. }
  810. subsys_initcall(msm8x60_iommu_init);
  811. module_exit(msm8x60_iommu_exit);
  812. MODULE_LICENSE("GPL v2");
  813. MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");