devices-msm8x60-iommu.c 20 KB

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