mdp5_cfg.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include "mdp5_kms.h"
  14. #include "mdp5_cfg.h"
  15. struct mdp5_cfg_handler {
  16. int revision;
  17. struct mdp5_cfg config;
  18. };
  19. /* mdp5_cfg must be exposed (used in mdp5.xml.h) */
  20. const struct mdp5_cfg_hw *mdp5_cfg = NULL;
  21. const struct mdp5_cfg_hw msm8x74v1_config = {
  22. .name = "msm8x74v1",
  23. .mdp = {
  24. .count = 1,
  25. .caps = MDP_CAP_SMP |
  26. 0,
  27. },
  28. .smp = {
  29. .mmb_count = 22,
  30. .mmb_size = 4096,
  31. .clients = {
  32. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4, [SSPP_VIG2] = 7,
  33. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  34. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17, [SSPP_RGB2] = 18,
  35. },
  36. },
  37. .ctl = {
  38. .count = 5,
  39. .base = { 0x00500, 0x00600, 0x00700, 0x00800, 0x00900 },
  40. .flush_hw_mask = 0x0003ffff,
  41. },
  42. .pipe_vig = {
  43. .count = 3,
  44. .base = { 0x01100, 0x01500, 0x01900 },
  45. .caps = MDP_PIPE_CAP_HFLIP |
  46. MDP_PIPE_CAP_VFLIP |
  47. MDP_PIPE_CAP_SCALE |
  48. MDP_PIPE_CAP_CSC |
  49. 0,
  50. },
  51. .pipe_rgb = {
  52. .count = 3,
  53. .base = { 0x01d00, 0x02100, 0x02500 },
  54. .caps = MDP_PIPE_CAP_HFLIP |
  55. MDP_PIPE_CAP_VFLIP |
  56. MDP_PIPE_CAP_SCALE |
  57. 0,
  58. },
  59. .pipe_dma = {
  60. .count = 2,
  61. .base = { 0x02900, 0x02d00 },
  62. .caps = MDP_PIPE_CAP_HFLIP |
  63. MDP_PIPE_CAP_VFLIP |
  64. 0,
  65. },
  66. .lm = {
  67. .count = 5,
  68. .base = { 0x03100, 0x03500, 0x03900, 0x03d00, 0x04100 },
  69. .instances = {
  70. { .id = 0, .pp = 0, .dspp = 0,
  71. .caps = MDP_LM_CAP_DISPLAY, },
  72. { .id = 1, .pp = 1, .dspp = 1,
  73. .caps = MDP_LM_CAP_DISPLAY, },
  74. { .id = 2, .pp = 2, .dspp = 2,
  75. .caps = MDP_LM_CAP_DISPLAY, },
  76. { .id = 3, .pp = -1, .dspp = -1,
  77. .caps = MDP_LM_CAP_WB },
  78. { .id = 4, .pp = -1, .dspp = -1,
  79. .caps = MDP_LM_CAP_WB },
  80. },
  81. .nb_stages = 5,
  82. .max_width = 2048,
  83. .max_height = 0xFFFF,
  84. },
  85. .dspp = {
  86. .count = 3,
  87. .base = { 0x04500, 0x04900, 0x04d00 },
  88. },
  89. .pp = {
  90. .count = 3,
  91. .base = { 0x21a00, 0x21b00, 0x21c00 },
  92. },
  93. .intf = {
  94. .base = { 0x21000, 0x21200, 0x21400, 0x21600 },
  95. .connect = {
  96. [0] = INTF_eDP,
  97. [1] = INTF_DSI,
  98. [2] = INTF_DSI,
  99. [3] = INTF_HDMI,
  100. },
  101. },
  102. .max_clk = 200000000,
  103. };
  104. const struct mdp5_cfg_hw msm8x74v2_config = {
  105. .name = "msm8x74",
  106. .mdp = {
  107. .count = 1,
  108. .caps = MDP_CAP_SMP |
  109. 0,
  110. },
  111. .smp = {
  112. .mmb_count = 22,
  113. .mmb_size = 4096,
  114. .clients = {
  115. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4, [SSPP_VIG2] = 7,
  116. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  117. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17, [SSPP_RGB2] = 18,
  118. },
  119. },
  120. .ctl = {
  121. .count = 5,
  122. .base = { 0x00500, 0x00600, 0x00700, 0x00800, 0x00900 },
  123. .flush_hw_mask = 0x0003ffff,
  124. },
  125. .pipe_vig = {
  126. .count = 3,
  127. .base = { 0x01100, 0x01500, 0x01900 },
  128. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  129. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  130. MDP_PIPE_CAP_DECIMATION,
  131. },
  132. .pipe_rgb = {
  133. .count = 3,
  134. .base = { 0x01d00, 0x02100, 0x02500 },
  135. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  136. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  137. },
  138. .pipe_dma = {
  139. .count = 2,
  140. .base = { 0x02900, 0x02d00 },
  141. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  142. },
  143. .lm = {
  144. .count = 5,
  145. .base = { 0x03100, 0x03500, 0x03900, 0x03d00, 0x04100 },
  146. .instances = {
  147. { .id = 0, .pp = 0, .dspp = 0,
  148. .caps = MDP_LM_CAP_DISPLAY, },
  149. { .id = 1, .pp = 1, .dspp = 1,
  150. .caps = MDP_LM_CAP_DISPLAY, },
  151. { .id = 2, .pp = 2, .dspp = 2,
  152. .caps = MDP_LM_CAP_DISPLAY, },
  153. { .id = 3, .pp = -1, .dspp = -1,
  154. .caps = MDP_LM_CAP_WB, },
  155. { .id = 4, .pp = -1, .dspp = -1,
  156. .caps = MDP_LM_CAP_WB, },
  157. },
  158. .nb_stages = 5,
  159. .max_width = 2048,
  160. .max_height = 0xFFFF,
  161. },
  162. .dspp = {
  163. .count = 3,
  164. .base = { 0x04500, 0x04900, 0x04d00 },
  165. },
  166. .ad = {
  167. .count = 2,
  168. .base = { 0x13000, 0x13200 },
  169. },
  170. .pp = {
  171. .count = 3,
  172. .base = { 0x12c00, 0x12d00, 0x12e00 },
  173. },
  174. .intf = {
  175. .base = { 0x12400, 0x12600, 0x12800, 0x12a00 },
  176. .connect = {
  177. [0] = INTF_eDP,
  178. [1] = INTF_DSI,
  179. [2] = INTF_DSI,
  180. [3] = INTF_HDMI,
  181. },
  182. },
  183. .max_clk = 200000000,
  184. };
  185. const struct mdp5_cfg_hw apq8084_config = {
  186. .name = "apq8084",
  187. .mdp = {
  188. .count = 1,
  189. .caps = MDP_CAP_SMP |
  190. MDP_CAP_SRC_SPLIT |
  191. 0,
  192. },
  193. .smp = {
  194. .mmb_count = 44,
  195. .mmb_size = 8192,
  196. .clients = {
  197. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
  198. [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
  199. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  200. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
  201. [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
  202. },
  203. .reserved_state[0] = GENMASK(7, 0), /* first 8 MMBs */
  204. .reserved = {
  205. /* Two SMP blocks are statically tied to RGB pipes: */
  206. [16] = 2, [17] = 2, [18] = 2, [22] = 2,
  207. },
  208. },
  209. .ctl = {
  210. .count = 5,
  211. .base = { 0x00500, 0x00600, 0x00700, 0x00800, 0x00900 },
  212. .flush_hw_mask = 0x003fffff,
  213. },
  214. .pipe_vig = {
  215. .count = 4,
  216. .base = { 0x01100, 0x01500, 0x01900, 0x01d00 },
  217. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  218. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  219. MDP_PIPE_CAP_DECIMATION,
  220. },
  221. .pipe_rgb = {
  222. .count = 4,
  223. .base = { 0x02100, 0x02500, 0x02900, 0x02d00 },
  224. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  225. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  226. },
  227. .pipe_dma = {
  228. .count = 2,
  229. .base = { 0x03100, 0x03500 },
  230. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  231. },
  232. .lm = {
  233. .count = 6,
  234. .base = { 0x03900, 0x03d00, 0x04100, 0x04500, 0x04900, 0x04d00 },
  235. .instances = {
  236. { .id = 0, .pp = 0, .dspp = 0,
  237. .caps = MDP_LM_CAP_DISPLAY |
  238. MDP_LM_CAP_PAIR, },
  239. { .id = 1, .pp = 1, .dspp = 1,
  240. .caps = MDP_LM_CAP_DISPLAY, },
  241. { .id = 2, .pp = 2, .dspp = 2,
  242. .caps = MDP_LM_CAP_DISPLAY |
  243. MDP_LM_CAP_PAIR, },
  244. { .id = 3, .pp = -1, .dspp = -1,
  245. .caps = MDP_LM_CAP_WB, },
  246. { .id = 4, .pp = -1, .dspp = -1,
  247. .caps = MDP_LM_CAP_WB, },
  248. { .id = 5, .pp = 3, .dspp = 3,
  249. .caps = MDP_LM_CAP_DISPLAY, },
  250. },
  251. .nb_stages = 5,
  252. .max_width = 2048,
  253. .max_height = 0xFFFF,
  254. },
  255. .dspp = {
  256. .count = 4,
  257. .base = { 0x05100, 0x05500, 0x05900, 0x05d00 },
  258. },
  259. .ad = {
  260. .count = 3,
  261. .base = { 0x13400, 0x13600, 0x13800 },
  262. },
  263. .pp = {
  264. .count = 4,
  265. .base = { 0x12e00, 0x12f00, 0x13000, 0x13100 },
  266. },
  267. .intf = {
  268. .base = { 0x12400, 0x12600, 0x12800, 0x12a00, 0x12c00 },
  269. .connect = {
  270. [0] = INTF_eDP,
  271. [1] = INTF_DSI,
  272. [2] = INTF_DSI,
  273. [3] = INTF_HDMI,
  274. },
  275. },
  276. .max_clk = 320000000,
  277. };
  278. const struct mdp5_cfg_hw msm8x16_config = {
  279. .name = "msm8x16",
  280. .mdp = {
  281. .count = 1,
  282. .base = { 0x0 },
  283. .caps = MDP_CAP_SMP |
  284. 0,
  285. },
  286. .smp = {
  287. .mmb_count = 8,
  288. .mmb_size = 8192,
  289. .clients = {
  290. [SSPP_VIG0] = 1, [SSPP_DMA0] = 4,
  291. [SSPP_RGB0] = 7, [SSPP_RGB1] = 8,
  292. },
  293. },
  294. .ctl = {
  295. .count = 5,
  296. .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
  297. .flush_hw_mask = 0x4003ffff,
  298. },
  299. .pipe_vig = {
  300. .count = 1,
  301. .base = { 0x04000 },
  302. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  303. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  304. MDP_PIPE_CAP_DECIMATION,
  305. },
  306. .pipe_rgb = {
  307. .count = 2,
  308. .base = { 0x14000, 0x16000 },
  309. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  310. MDP_PIPE_CAP_DECIMATION,
  311. },
  312. .pipe_dma = {
  313. .count = 1,
  314. .base = { 0x24000 },
  315. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  316. },
  317. .lm = {
  318. .count = 2, /* LM0 and LM3 */
  319. .base = { 0x44000, 0x47000 },
  320. .instances = {
  321. { .id = 0, .pp = 0, .dspp = 0,
  322. .caps = MDP_LM_CAP_DISPLAY, },
  323. { .id = 3, .pp = -1, .dspp = -1,
  324. .caps = MDP_LM_CAP_WB },
  325. },
  326. .nb_stages = 8,
  327. .max_width = 2048,
  328. .max_height = 0xFFFF,
  329. },
  330. .dspp = {
  331. .count = 1,
  332. .base = { 0x54000 },
  333. },
  334. .intf = {
  335. .base = { 0x00000, 0x6a800 },
  336. .connect = {
  337. [0] = INTF_DISABLED,
  338. [1] = INTF_DSI,
  339. },
  340. },
  341. .max_clk = 320000000,
  342. };
  343. const struct mdp5_cfg_hw msm8x94_config = {
  344. .name = "msm8x94",
  345. .mdp = {
  346. .count = 1,
  347. .caps = MDP_CAP_SMP |
  348. MDP_CAP_SRC_SPLIT |
  349. 0,
  350. },
  351. .smp = {
  352. .mmb_count = 44,
  353. .mmb_size = 8192,
  354. .clients = {
  355. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
  356. [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
  357. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  358. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
  359. [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
  360. },
  361. .reserved_state[0] = GENMASK(23, 0), /* first 24 MMBs */
  362. .reserved = {
  363. [1] = 1, [4] = 1, [7] = 1, [19] = 1,
  364. [16] = 5, [17] = 5, [18] = 5, [22] = 5,
  365. },
  366. },
  367. .ctl = {
  368. .count = 5,
  369. .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
  370. .flush_hw_mask = 0xf0ffffff,
  371. },
  372. .pipe_vig = {
  373. .count = 4,
  374. .base = { 0x04000, 0x06000, 0x08000, 0x0a000 },
  375. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  376. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  377. MDP_PIPE_CAP_DECIMATION,
  378. },
  379. .pipe_rgb = {
  380. .count = 4,
  381. .base = { 0x14000, 0x16000, 0x18000, 0x1a000 },
  382. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  383. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  384. },
  385. .pipe_dma = {
  386. .count = 2,
  387. .base = { 0x24000, 0x26000 },
  388. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  389. },
  390. .lm = {
  391. .count = 6,
  392. .base = { 0x44000, 0x45000, 0x46000, 0x47000, 0x48000, 0x49000 },
  393. .instances = {
  394. { .id = 0, .pp = 0, .dspp = 0,
  395. .caps = MDP_LM_CAP_DISPLAY |
  396. MDP_LM_CAP_PAIR, },
  397. { .id = 1, .pp = 1, .dspp = 1,
  398. .caps = MDP_LM_CAP_DISPLAY, },
  399. { .id = 2, .pp = 2, .dspp = 2,
  400. .caps = MDP_LM_CAP_DISPLAY |
  401. MDP_LM_CAP_PAIR, },
  402. { .id = 3, .pp = -1, .dspp = -1,
  403. .caps = MDP_LM_CAP_WB, },
  404. { .id = 4, .pp = -1, .dspp = -1,
  405. .caps = MDP_LM_CAP_WB, },
  406. { .id = 5, .pp = 3, .dspp = 3,
  407. .caps = MDP_LM_CAP_DISPLAY, },
  408. },
  409. .nb_stages = 8,
  410. .max_width = 2048,
  411. .max_height = 0xFFFF,
  412. },
  413. .dspp = {
  414. .count = 4,
  415. .base = { 0x54000, 0x56000, 0x58000, 0x5a000 },
  416. },
  417. .ad = {
  418. .count = 3,
  419. .base = { 0x78000, 0x78800, 0x79000 },
  420. },
  421. .pp = {
  422. .count = 4,
  423. .base = { 0x70000, 0x70800, 0x71000, 0x71800 },
  424. },
  425. .intf = {
  426. .base = { 0x6a000, 0x6a800, 0x6b000, 0x6b800, 0x6c000 },
  427. .connect = {
  428. [0] = INTF_DISABLED,
  429. [1] = INTF_DSI,
  430. [2] = INTF_DSI,
  431. [3] = INTF_HDMI,
  432. },
  433. },
  434. .max_clk = 400000000,
  435. };
  436. const struct mdp5_cfg_hw msm8x96_config = {
  437. .name = "msm8x96",
  438. .mdp = {
  439. .count = 1,
  440. .caps = MDP_CAP_DSC |
  441. MDP_CAP_CDM |
  442. MDP_CAP_SRC_SPLIT |
  443. 0,
  444. },
  445. .ctl = {
  446. .count = 5,
  447. .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
  448. .flush_hw_mask = 0xf4ffffff,
  449. },
  450. .pipe_vig = {
  451. .count = 4,
  452. .base = { 0x04000, 0x06000, 0x08000, 0x0a000 },
  453. .caps = MDP_PIPE_CAP_HFLIP |
  454. MDP_PIPE_CAP_VFLIP |
  455. MDP_PIPE_CAP_SCALE |
  456. MDP_PIPE_CAP_CSC |
  457. MDP_PIPE_CAP_DECIMATION |
  458. MDP_PIPE_CAP_SW_PIX_EXT |
  459. 0,
  460. },
  461. .pipe_rgb = {
  462. .count = 4,
  463. .base = { 0x14000, 0x16000, 0x18000, 0x1a000 },
  464. .caps = MDP_PIPE_CAP_HFLIP |
  465. MDP_PIPE_CAP_VFLIP |
  466. MDP_PIPE_CAP_SCALE |
  467. MDP_PIPE_CAP_DECIMATION |
  468. MDP_PIPE_CAP_SW_PIX_EXT |
  469. 0,
  470. },
  471. .pipe_dma = {
  472. .count = 2,
  473. .base = { 0x24000, 0x26000 },
  474. .caps = MDP_PIPE_CAP_HFLIP |
  475. MDP_PIPE_CAP_VFLIP |
  476. MDP_PIPE_CAP_SW_PIX_EXT |
  477. 0,
  478. },
  479. .pipe_cursor = {
  480. .count = 2,
  481. .base = { 0x34000, 0x36000 },
  482. .caps = MDP_PIPE_CAP_HFLIP |
  483. MDP_PIPE_CAP_VFLIP |
  484. MDP_PIPE_CAP_SW_PIX_EXT |
  485. MDP_PIPE_CAP_CURSOR |
  486. 0,
  487. },
  488. .lm = {
  489. .count = 6,
  490. .base = { 0x44000, 0x45000, 0x46000, 0x47000, 0x48000, 0x49000 },
  491. .instances = {
  492. { .id = 0, .pp = 0, .dspp = 0,
  493. .caps = MDP_LM_CAP_DISPLAY |
  494. MDP_LM_CAP_PAIR, },
  495. { .id = 1, .pp = 1, .dspp = 1,
  496. .caps = MDP_LM_CAP_DISPLAY, },
  497. { .id = 2, .pp = 2, .dspp = -1,
  498. .caps = MDP_LM_CAP_DISPLAY |
  499. MDP_LM_CAP_PAIR, },
  500. { .id = 3, .pp = -1, .dspp = -1,
  501. .caps = MDP_LM_CAP_WB, },
  502. { .id = 4, .pp = -1, .dspp = -1,
  503. .caps = MDP_LM_CAP_WB, },
  504. { .id = 5, .pp = 3, .dspp = -1,
  505. .caps = MDP_LM_CAP_DISPLAY, },
  506. },
  507. .nb_stages = 8,
  508. .max_width = 2560,
  509. .max_height = 0xFFFF,
  510. },
  511. .dspp = {
  512. .count = 2,
  513. .base = { 0x54000, 0x56000 },
  514. },
  515. .ad = {
  516. .count = 3,
  517. .base = { 0x78000, 0x78800, 0x79000 },
  518. },
  519. .pp = {
  520. .count = 4,
  521. .base = { 0x70000, 0x70800, 0x71000, 0x71800 },
  522. },
  523. .cdm = {
  524. .count = 1,
  525. .base = { 0x79200 },
  526. },
  527. .dsc = {
  528. .count = 2,
  529. .base = { 0x80000, 0x80400 },
  530. },
  531. .intf = {
  532. .base = { 0x6a000, 0x6a800, 0x6b000, 0x6b800, 0x6c000 },
  533. .connect = {
  534. [0] = INTF_DISABLED,
  535. [1] = INTF_DSI,
  536. [2] = INTF_DSI,
  537. [3] = INTF_HDMI,
  538. },
  539. },
  540. .max_clk = 412500000,
  541. };
  542. static const struct mdp5_cfg_handler cfg_handlers[] = {
  543. { .revision = 0, .config = { .hw = &msm8x74v1_config } },
  544. { .revision = 2, .config = { .hw = &msm8x74v2_config } },
  545. { .revision = 3, .config = { .hw = &apq8084_config } },
  546. { .revision = 6, .config = { .hw = &msm8x16_config } },
  547. { .revision = 9, .config = { .hw = &msm8x94_config } },
  548. { .revision = 7, .config = { .hw = &msm8x96_config } },
  549. };
  550. static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev);
  551. const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(struct mdp5_cfg_handler *cfg_handler)
  552. {
  553. return cfg_handler->config.hw;
  554. }
  555. struct mdp5_cfg *mdp5_cfg_get_config(struct mdp5_cfg_handler *cfg_handler)
  556. {
  557. return &cfg_handler->config;
  558. }
  559. int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler *cfg_handler)
  560. {
  561. return cfg_handler->revision;
  562. }
  563. void mdp5_cfg_destroy(struct mdp5_cfg_handler *cfg_handler)
  564. {
  565. kfree(cfg_handler);
  566. }
  567. struct mdp5_cfg_handler *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
  568. uint32_t major, uint32_t minor)
  569. {
  570. struct drm_device *dev = mdp5_kms->dev;
  571. struct platform_device *pdev = to_platform_device(dev->dev);
  572. struct mdp5_cfg_handler *cfg_handler;
  573. struct mdp5_cfg_platform *pconfig;
  574. int i, ret = 0;
  575. cfg_handler = kzalloc(sizeof(*cfg_handler), GFP_KERNEL);
  576. if (unlikely(!cfg_handler)) {
  577. ret = -ENOMEM;
  578. goto fail;
  579. }
  580. if (major != 1) {
  581. dev_err(dev->dev, "unexpected MDP major version: v%d.%d\n",
  582. major, minor);
  583. ret = -ENXIO;
  584. goto fail;
  585. }
  586. /* only after mdp5_cfg global pointer's init can we access the hw */
  587. for (i = 0; i < ARRAY_SIZE(cfg_handlers); i++) {
  588. if (cfg_handlers[i].revision != minor)
  589. continue;
  590. mdp5_cfg = cfg_handlers[i].config.hw;
  591. break;
  592. }
  593. if (unlikely(!mdp5_cfg)) {
  594. dev_err(dev->dev, "unexpected MDP minor revision: v%d.%d\n",
  595. major, minor);
  596. ret = -ENXIO;
  597. goto fail;
  598. }
  599. cfg_handler->revision = minor;
  600. cfg_handler->config.hw = mdp5_cfg;
  601. pconfig = mdp5_get_config(pdev);
  602. memcpy(&cfg_handler->config.platform, pconfig, sizeof(*pconfig));
  603. DBG("MDP5: %s hw config selected", mdp5_cfg->name);
  604. return cfg_handler;
  605. fail:
  606. if (cfg_handler)
  607. mdp5_cfg_destroy(cfg_handler);
  608. return NULL;
  609. }
  610. static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
  611. {
  612. static struct mdp5_cfg_platform config = {};
  613. config.iommu = iommu_domain_alloc(&platform_bus_type);
  614. if (config.iommu) {
  615. config.iommu->geometry.aperture_start = 0x1000;
  616. config.iommu->geometry.aperture_end = 0xffffffff;
  617. }
  618. return &config;
  619. }