devices-iommu.c 19 KB

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