mdp5_cfg.c 10 KB

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