devices-msm8x60-iommu.c 19 KB

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