mdp5_cfg.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  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. .base = { 0x00100 },
  26. .caps = MDP_CAP_SMP |
  27. 0,
  28. },
  29. .smp = {
  30. .mmb_count = 22,
  31. .mmb_size = 4096,
  32. .clients = {
  33. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4, [SSPP_VIG2] = 7,
  34. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  35. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17, [SSPP_RGB2] = 18,
  36. },
  37. },
  38. .ctl = {
  39. .count = 5,
  40. .base = { 0x00600, 0x00700, 0x00800, 0x00900, 0x00a00 },
  41. .flush_hw_mask = 0x0003ffff,
  42. },
  43. .pipe_vig = {
  44. .count = 3,
  45. .base = { 0x01200, 0x01600, 0x01a00 },
  46. .caps = MDP_PIPE_CAP_HFLIP |
  47. MDP_PIPE_CAP_VFLIP |
  48. MDP_PIPE_CAP_SCALE |
  49. MDP_PIPE_CAP_CSC |
  50. 0,
  51. },
  52. .pipe_rgb = {
  53. .count = 3,
  54. .base = { 0x01e00, 0x02200, 0x02600 },
  55. .caps = MDP_PIPE_CAP_HFLIP |
  56. MDP_PIPE_CAP_VFLIP |
  57. MDP_PIPE_CAP_SCALE |
  58. 0,
  59. },
  60. .pipe_dma = {
  61. .count = 2,
  62. .base = { 0x02a00, 0x02e00 },
  63. .caps = MDP_PIPE_CAP_HFLIP |
  64. MDP_PIPE_CAP_VFLIP |
  65. 0,
  66. },
  67. .lm = {
  68. .count = 5,
  69. .base = { 0x03200, 0x03600, 0x03a00, 0x03e00, 0x04200 },
  70. .nb_stages = 5,
  71. },
  72. .dspp = {
  73. .count = 3,
  74. .base = { 0x04600, 0x04a00, 0x04e00 },
  75. },
  76. .pp = {
  77. .count = 3,
  78. .base = { 0x21b00, 0x21c00, 0x21d00 },
  79. },
  80. .intf = {
  81. .base = { 0x21100, 0x21300, 0x21500, 0x21700 },
  82. .connect = {
  83. [0] = INTF_eDP,
  84. [1] = INTF_DSI,
  85. [2] = INTF_DSI,
  86. [3] = INTF_HDMI,
  87. },
  88. },
  89. .max_clk = 200000000,
  90. };
  91. const struct mdp5_cfg_hw msm8x74v2_config = {
  92. .name = "msm8x74",
  93. .mdp = {
  94. .count = 1,
  95. .base = { 0x00100 },
  96. .caps = MDP_CAP_SMP |
  97. 0,
  98. },
  99. .smp = {
  100. .mmb_count = 22,
  101. .mmb_size = 4096,
  102. .clients = {
  103. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4, [SSPP_VIG2] = 7,
  104. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  105. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17, [SSPP_RGB2] = 18,
  106. },
  107. },
  108. .ctl = {
  109. .count = 5,
  110. .base = { 0x00600, 0x00700, 0x00800, 0x00900, 0x00a00 },
  111. .flush_hw_mask = 0x0003ffff,
  112. },
  113. .pipe_vig = {
  114. .count = 3,
  115. .base = { 0x01200, 0x01600, 0x01a00 },
  116. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  117. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  118. MDP_PIPE_CAP_DECIMATION,
  119. },
  120. .pipe_rgb = {
  121. .count = 3,
  122. .base = { 0x01e00, 0x02200, 0x02600 },
  123. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  124. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  125. },
  126. .pipe_dma = {
  127. .count = 2,
  128. .base = { 0x02a00, 0x02e00 },
  129. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  130. },
  131. .lm = {
  132. .count = 5,
  133. .base = { 0x03200, 0x03600, 0x03a00, 0x03e00, 0x04200 },
  134. .nb_stages = 5,
  135. .max_width = 2048,
  136. .max_height = 0xFFFF,
  137. },
  138. .dspp = {
  139. .count = 3,
  140. .base = { 0x04600, 0x04a00, 0x04e00 },
  141. },
  142. .ad = {
  143. .count = 2,
  144. .base = { 0x13100, 0x13300 },
  145. },
  146. .pp = {
  147. .count = 3,
  148. .base = { 0x12d00, 0x12e00, 0x12f00 },
  149. },
  150. .intf = {
  151. .base = { 0x12500, 0x12700, 0x12900, 0x12b00 },
  152. .connect = {
  153. [0] = INTF_eDP,
  154. [1] = INTF_DSI,
  155. [2] = INTF_DSI,
  156. [3] = INTF_HDMI,
  157. },
  158. },
  159. .max_clk = 200000000,
  160. };
  161. const struct mdp5_cfg_hw apq8084_config = {
  162. .name = "apq8084",
  163. .mdp = {
  164. .count = 1,
  165. .base = { 0x00100 },
  166. .caps = MDP_CAP_SMP |
  167. 0,
  168. },
  169. .smp = {
  170. .mmb_count = 44,
  171. .mmb_size = 8192,
  172. .clients = {
  173. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
  174. [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
  175. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  176. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
  177. [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
  178. },
  179. .reserved_state[0] = GENMASK(7, 0), /* first 8 MMBs */
  180. .reserved = {
  181. /* Two SMP blocks are statically tied to RGB pipes: */
  182. [16] = 2, [17] = 2, [18] = 2, [22] = 2,
  183. },
  184. },
  185. .ctl = {
  186. .count = 5,
  187. .base = { 0x00600, 0x00700, 0x00800, 0x00900, 0x00a00 },
  188. .flush_hw_mask = 0x003fffff,
  189. },
  190. .pipe_vig = {
  191. .count = 4,
  192. .base = { 0x01200, 0x01600, 0x01a00, 0x01e00 },
  193. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  194. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  195. MDP_PIPE_CAP_DECIMATION,
  196. },
  197. .pipe_rgb = {
  198. .count = 4,
  199. .base = { 0x02200, 0x02600, 0x02a00, 0x02e00 },
  200. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  201. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  202. },
  203. .pipe_dma = {
  204. .count = 2,
  205. .base = { 0x03200, 0x03600 },
  206. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  207. },
  208. .lm = {
  209. .count = 6,
  210. .base = { 0x03a00, 0x03e00, 0x04200, 0x04600, 0x04a00, 0x04e00 },
  211. .nb_stages = 5,
  212. .max_width = 2048,
  213. .max_height = 0xFFFF,
  214. },
  215. .dspp = {
  216. .count = 4,
  217. .base = { 0x05200, 0x05600, 0x05a00, 0x05e00 },
  218. },
  219. .ad = {
  220. .count = 3,
  221. .base = { 0x13500, 0x13700, 0x13900 },
  222. },
  223. .pp = {
  224. .count = 4,
  225. .base = { 0x12f00, 0x13000, 0x13100, 0x13200 },
  226. },
  227. .intf = {
  228. .base = { 0x12500, 0x12700, 0x12900, 0x12b00, 0x12d00 },
  229. .connect = {
  230. [0] = INTF_eDP,
  231. [1] = INTF_DSI,
  232. [2] = INTF_DSI,
  233. [3] = INTF_HDMI,
  234. },
  235. },
  236. .max_clk = 320000000,
  237. };
  238. const struct mdp5_cfg_hw msm8x16_config = {
  239. .name = "msm8x16",
  240. .mdp = {
  241. .count = 1,
  242. .base = { 0x01000 },
  243. .caps = MDP_CAP_SMP |
  244. 0,
  245. },
  246. .smp = {
  247. .mmb_count = 8,
  248. .mmb_size = 8192,
  249. .clients = {
  250. [SSPP_VIG0] = 1, [SSPP_DMA0] = 4,
  251. [SSPP_RGB0] = 7, [SSPP_RGB1] = 8,
  252. },
  253. },
  254. .ctl = {
  255. .count = 5,
  256. .base = { 0x02000, 0x02200, 0x02400, 0x02600, 0x02800 },
  257. .flush_hw_mask = 0x4003ffff,
  258. },
  259. .pipe_vig = {
  260. .count = 1,
  261. .base = { 0x05000 },
  262. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  263. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  264. MDP_PIPE_CAP_DECIMATION,
  265. },
  266. .pipe_rgb = {
  267. .count = 2,
  268. .base = { 0x15000, 0x17000 },
  269. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  270. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  271. },
  272. .pipe_dma = {
  273. .count = 1,
  274. .base = { 0x25000 },
  275. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  276. },
  277. .lm = {
  278. .count = 2, /* LM0 and LM3 */
  279. .base = { 0x45000, 0x48000 },
  280. .nb_stages = 5,
  281. .max_width = 2048,
  282. .max_height = 0xFFFF,
  283. },
  284. .dspp = {
  285. .count = 1,
  286. .base = { 0x55000 },
  287. },
  288. .intf = {
  289. .base = { 0x00000, 0x6b800 },
  290. .connect = {
  291. [0] = INTF_DISABLED,
  292. [1] = INTF_DSI,
  293. },
  294. },
  295. .max_clk = 320000000,
  296. };
  297. const struct mdp5_cfg_hw msm8x94_config = {
  298. .name = "msm8x94",
  299. .mdp = {
  300. .count = 1,
  301. .base = { 0x01000 },
  302. .caps = MDP_CAP_SMP |
  303. 0,
  304. },
  305. .smp = {
  306. .mmb_count = 44,
  307. .mmb_size = 8192,
  308. .clients = {
  309. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
  310. [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
  311. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  312. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
  313. [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
  314. },
  315. .reserved_state[0] = GENMASK(23, 0), /* first 24 MMBs */
  316. .reserved = {
  317. [1] = 1, [4] = 1, [7] = 1, [19] = 1,
  318. [16] = 5, [17] = 5, [18] = 5, [22] = 5,
  319. },
  320. },
  321. .ctl = {
  322. .count = 5,
  323. .base = { 0x02000, 0x02200, 0x02400, 0x02600, 0x02800 },
  324. .flush_hw_mask = 0xf0ffffff,
  325. },
  326. .pipe_vig = {
  327. .count = 4,
  328. .base = { 0x05000, 0x07000, 0x09000, 0x0b000 },
  329. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  330. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
  331. MDP_PIPE_CAP_DECIMATION,
  332. },
  333. .pipe_rgb = {
  334. .count = 4,
  335. .base = { 0x15000, 0x17000, 0x19000, 0x1b000 },
  336. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
  337. MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
  338. },
  339. .pipe_dma = {
  340. .count = 2,
  341. .base = { 0x25000, 0x27000 },
  342. .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
  343. },
  344. .lm = {
  345. .count = 6,
  346. .base = { 0x45000, 0x46000, 0x47000, 0x48000, 0x49000, 0x4a000 },
  347. .nb_stages = 8,
  348. .max_width = 2048,
  349. .max_height = 0xFFFF,
  350. },
  351. .dspp = {
  352. .count = 4,
  353. .base = { 0x55000, 0x57000, 0x59000, 0x5b000 },
  354. },
  355. .ad = {
  356. .count = 3,
  357. .base = { 0x79000, 0x79800, 0x7a000 },
  358. },
  359. .pp = {
  360. .count = 4,
  361. .base = { 0x71000, 0x71800, 0x72000, 0x72800 },
  362. },
  363. .intf = {
  364. .base = { 0x6b000, 0x6b800, 0x6c000, 0x6c800, 0x6d000 },
  365. .connect = {
  366. [0] = INTF_DISABLED,
  367. [1] = INTF_DSI,
  368. [2] = INTF_DSI,
  369. [3] = INTF_HDMI,
  370. },
  371. },
  372. .max_clk = 400000000,
  373. };
  374. const struct mdp5_cfg_hw msm8x96_config = {
  375. .name = "msm8x96",
  376. .mdp = {
  377. .count = 1,
  378. .base = { 0x01000 },
  379. .caps = MDP_CAP_DSC |
  380. MDP_CAP_CDM |
  381. 0,
  382. },
  383. .ctl = {
  384. .count = 5,
  385. .base = { 0x02000, 0x02200, 0x02400, 0x02600, 0x02800 },
  386. .flush_hw_mask = 0xf4ffffff,
  387. },
  388. .pipe_vig = {
  389. .count = 4,
  390. .base = { 0x05000, 0x07000, 0x09000, 0x0b000 },
  391. .caps = MDP_PIPE_CAP_HFLIP |
  392. MDP_PIPE_CAP_VFLIP |
  393. MDP_PIPE_CAP_SCALE |
  394. MDP_PIPE_CAP_CSC |
  395. MDP_PIPE_CAP_DECIMATION |
  396. MDP_PIPE_CAP_SW_PIX_EXT |
  397. 0,
  398. },
  399. .pipe_rgb = {
  400. .count = 4,
  401. .base = { 0x15000, 0x17000, 0x19000, 0x1b000 },
  402. .caps = MDP_PIPE_CAP_HFLIP |
  403. MDP_PIPE_CAP_VFLIP |
  404. MDP_PIPE_CAP_SCALE |
  405. MDP_PIPE_CAP_DECIMATION |
  406. MDP_PIPE_CAP_SW_PIX_EXT |
  407. 0,
  408. },
  409. .pipe_dma = {
  410. .count = 2,
  411. .base = { 0x25000, 0x27000 },
  412. .caps = MDP_PIPE_CAP_HFLIP |
  413. MDP_PIPE_CAP_VFLIP |
  414. MDP_PIPE_CAP_SW_PIX_EXT |
  415. 0,
  416. },
  417. .lm = {
  418. .count = 6,
  419. .base = { 0x45000, 0x46000, 0x47000, 0x48000, 0x49000, 0x4a000 },
  420. .nb_stages = 8,
  421. .max_width = 2560,
  422. .max_height = 0xFFFF,
  423. },
  424. .dspp = {
  425. .count = 2,
  426. .base = { 0x55000, 0x57000 },
  427. },
  428. .ad = {
  429. .count = 3,
  430. .base = { 0x79000, 0x79800, 0x7a000 },
  431. },
  432. .pp = {
  433. .count = 4,
  434. .base = { 0x71000, 0x71800, 0x72000, 0x72800 },
  435. },
  436. .cdm = {
  437. .count = 1,
  438. .base = { 0x7a200 },
  439. },
  440. .dsc = {
  441. .count = 2,
  442. .base = { 0x81000, 0x81400 },
  443. },
  444. .intf = {
  445. .base = { 0x6b000, 0x6b800, 0x6c000, 0x6c800, 0x6d000 },
  446. .connect = {
  447. [0] = INTF_DISABLED,
  448. [1] = INTF_DSI,
  449. [2] = INTF_DSI,
  450. [3] = INTF_HDMI,
  451. },
  452. },
  453. .max_clk = 412500000,
  454. };
  455. static const struct mdp5_cfg_handler cfg_handlers[] = {
  456. { .revision = 0, .config = { .hw = &msm8x74v1_config } },
  457. { .revision = 2, .config = { .hw = &msm8x74v2_config } },
  458. { .revision = 3, .config = { .hw = &apq8084_config } },
  459. { .revision = 6, .config = { .hw = &msm8x16_config } },
  460. { .revision = 9, .config = { .hw = &msm8x94_config } },
  461. { .revision = 7, .config = { .hw = &msm8x96_config } },
  462. };
  463. static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev);
  464. const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(struct mdp5_cfg_handler *cfg_handler)
  465. {
  466. return cfg_handler->config.hw;
  467. }
  468. struct mdp5_cfg *mdp5_cfg_get_config(struct mdp5_cfg_handler *cfg_handler)
  469. {
  470. return &cfg_handler->config;
  471. }
  472. int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler *cfg_handler)
  473. {
  474. return cfg_handler->revision;
  475. }
  476. void mdp5_cfg_destroy(struct mdp5_cfg_handler *cfg_handler)
  477. {
  478. kfree(cfg_handler);
  479. }
  480. struct mdp5_cfg_handler *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
  481. uint32_t major, uint32_t minor)
  482. {
  483. struct drm_device *dev = mdp5_kms->dev;
  484. struct platform_device *pdev = dev->platformdev;
  485. struct mdp5_cfg_handler *cfg_handler;
  486. struct mdp5_cfg_platform *pconfig;
  487. int i, ret = 0;
  488. cfg_handler = kzalloc(sizeof(*cfg_handler), GFP_KERNEL);
  489. if (unlikely(!cfg_handler)) {
  490. ret = -ENOMEM;
  491. goto fail;
  492. }
  493. if (major != 1) {
  494. dev_err(dev->dev, "unexpected MDP major version: v%d.%d\n",
  495. major, minor);
  496. ret = -ENXIO;
  497. goto fail;
  498. }
  499. /* only after mdp5_cfg global pointer's init can we access the hw */
  500. for (i = 0; i < ARRAY_SIZE(cfg_handlers); i++) {
  501. if (cfg_handlers[i].revision != minor)
  502. continue;
  503. mdp5_cfg = cfg_handlers[i].config.hw;
  504. break;
  505. }
  506. if (unlikely(!mdp5_cfg)) {
  507. dev_err(dev->dev, "unexpected MDP minor revision: v%d.%d\n",
  508. major, minor);
  509. ret = -ENXIO;
  510. goto fail;
  511. }
  512. cfg_handler->revision = minor;
  513. cfg_handler->config.hw = mdp5_cfg;
  514. pconfig = mdp5_get_config(pdev);
  515. memcpy(&cfg_handler->config.platform, pconfig, sizeof(*pconfig));
  516. DBG("MDP5: %s hw config selected", mdp5_cfg->name);
  517. return cfg_handler;
  518. fail:
  519. if (cfg_handler)
  520. mdp5_cfg_destroy(cfg_handler);
  521. return NULL;
  522. }
  523. static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
  524. {
  525. static struct mdp5_cfg_platform config = {};
  526. #ifdef CONFIG_OF
  527. /* TODO */
  528. #endif
  529. config.iommu = iommu_domain_alloc(&platform_bus_type);
  530. return &config;
  531. }