mdp5_cfg.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 msm8x74_config = {
  22. .name = "msm8x74",
  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. },
  45. .pipe_rgb = {
  46. .count = 3,
  47. .base = { 0x01e00, 0x02200, 0x02600 },
  48. },
  49. .pipe_dma = {
  50. .count = 2,
  51. .base = { 0x02a00, 0x02e00 },
  52. },
  53. .lm = {
  54. .count = 5,
  55. .base = { 0x03200, 0x03600, 0x03a00, 0x03e00, 0x04200 },
  56. .nb_stages = 5,
  57. },
  58. .dspp = {
  59. .count = 3,
  60. .base = { 0x04600, 0x04a00, 0x04e00 },
  61. },
  62. .ad = {
  63. .count = 2,
  64. .base = { 0x13100, 0x13300 }, /* NOTE: no ad in v1.0 */
  65. },
  66. .pp = {
  67. .count = 3,
  68. .base = { 0x12d00, 0x12e00, 0x12f00 },
  69. },
  70. .intf = {
  71. .base = { 0x12500, 0x12700, 0x12900, 0x12b00 },
  72. .connect = {
  73. [0] = INTF_eDP,
  74. [1] = INTF_DSI,
  75. [2] = INTF_DSI,
  76. [3] = INTF_HDMI,
  77. },
  78. },
  79. .max_clk = 200000000,
  80. };
  81. const struct mdp5_cfg_hw apq8084_config = {
  82. .name = "apq8084",
  83. .mdp = {
  84. .count = 1,
  85. .base = { 0x00100 },
  86. },
  87. .smp = {
  88. .mmb_count = 44,
  89. .mmb_size = 8192,
  90. .clients = {
  91. [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
  92. [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
  93. [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
  94. [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
  95. [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
  96. },
  97. .reserved_state[0] = GENMASK(7, 0), /* first 8 MMBs */
  98. .reserved = {
  99. /* Two SMP blocks are statically tied to RGB pipes: */
  100. [16] = 2, [17] = 2, [18] = 2, [22] = 2,
  101. },
  102. },
  103. .ctl = {
  104. .count = 5,
  105. .base = { 0x00600, 0x00700, 0x00800, 0x00900, 0x00a00 },
  106. .flush_hw_mask = 0x003fffff,
  107. },
  108. .pipe_vig = {
  109. .count = 4,
  110. .base = { 0x01200, 0x01600, 0x01a00, 0x01e00 },
  111. },
  112. .pipe_rgb = {
  113. .count = 4,
  114. .base = { 0x02200, 0x02600, 0x02a00, 0x02e00 },
  115. },
  116. .pipe_dma = {
  117. .count = 2,
  118. .base = { 0x03200, 0x03600 },
  119. },
  120. .lm = {
  121. .count = 6,
  122. .base = { 0x03a00, 0x03e00, 0x04200, 0x04600, 0x04a00, 0x04e00 },
  123. .nb_stages = 5,
  124. },
  125. .dspp = {
  126. .count = 4,
  127. .base = { 0x05200, 0x05600, 0x05a00, 0x05e00 },
  128. },
  129. .ad = {
  130. .count = 3,
  131. .base = { 0x13500, 0x13700, 0x13900 },
  132. },
  133. .pp = {
  134. .count = 4,
  135. .base = { 0x12f00, 0x13000, 0x13100, 0x13200 },
  136. },
  137. .intf = {
  138. .base = { 0x12500, 0x12700, 0x12900, 0x12b00, 0x12d00 },
  139. .connect = {
  140. [0] = INTF_eDP,
  141. [1] = INTF_DSI,
  142. [2] = INTF_DSI,
  143. [3] = INTF_HDMI,
  144. },
  145. },
  146. .max_clk = 320000000,
  147. };
  148. const struct mdp5_cfg_hw msm8x16_config = {
  149. .name = "msm8x16",
  150. .mdp = {
  151. .count = 1,
  152. .base = { 0x01000 },
  153. },
  154. .smp = {
  155. .mmb_count = 8,
  156. .mmb_size = 8192,
  157. .clients = {
  158. [SSPP_VIG0] = 1, [SSPP_DMA0] = 4,
  159. [SSPP_RGB0] = 7, [SSPP_RGB1] = 8,
  160. },
  161. },
  162. .ctl = {
  163. .count = 5,
  164. .base = { 0x02000, 0x02200, 0x02400, 0x02600, 0x02800 },
  165. .flush_hw_mask = 0x4003ffff,
  166. },
  167. .pipe_vig = {
  168. .count = 1,
  169. .base = { 0x05000 },
  170. },
  171. .pipe_rgb = {
  172. .count = 2,
  173. .base = { 0x15000, 0x17000 },
  174. },
  175. .pipe_dma = {
  176. .count = 1,
  177. .base = { 0x25000 },
  178. },
  179. .lm = {
  180. .count = 2, /* LM0 and LM3 */
  181. .base = { 0x45000, 0x48000 },
  182. .nb_stages = 5,
  183. },
  184. .dspp = {
  185. .count = 1,
  186. .base = { 0x55000 },
  187. },
  188. .intf = {
  189. .base = { 0x00000, 0x6b800 },
  190. .connect = {
  191. [0] = INTF_DISABLED,
  192. [1] = INTF_DSI,
  193. },
  194. },
  195. .max_clk = 320000000,
  196. };
  197. static const struct mdp5_cfg_handler cfg_handlers[] = {
  198. { .revision = 0, .config = { .hw = &msm8x74_config } },
  199. { .revision = 2, .config = { .hw = &msm8x74_config } },
  200. { .revision = 3, .config = { .hw = &apq8084_config } },
  201. { .revision = 6, .config = { .hw = &msm8x16_config } },
  202. };
  203. static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev);
  204. const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(struct mdp5_cfg_handler *cfg_handler)
  205. {
  206. return cfg_handler->config.hw;
  207. }
  208. struct mdp5_cfg *mdp5_cfg_get_config(struct mdp5_cfg_handler *cfg_handler)
  209. {
  210. return &cfg_handler->config;
  211. }
  212. int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler *cfg_handler)
  213. {
  214. return cfg_handler->revision;
  215. }
  216. void mdp5_cfg_destroy(struct mdp5_cfg_handler *cfg_handler)
  217. {
  218. kfree(cfg_handler);
  219. }
  220. struct mdp5_cfg_handler *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
  221. uint32_t major, uint32_t minor)
  222. {
  223. struct drm_device *dev = mdp5_kms->dev;
  224. struct platform_device *pdev = dev->platformdev;
  225. struct mdp5_cfg_handler *cfg_handler;
  226. struct mdp5_cfg_platform *pconfig;
  227. int i, ret = 0;
  228. cfg_handler = kzalloc(sizeof(*cfg_handler), GFP_KERNEL);
  229. if (unlikely(!cfg_handler)) {
  230. ret = -ENOMEM;
  231. goto fail;
  232. }
  233. if (major != 1) {
  234. dev_err(dev->dev, "unexpected MDP major version: v%d.%d\n",
  235. major, minor);
  236. ret = -ENXIO;
  237. goto fail;
  238. }
  239. /* only after mdp5_cfg global pointer's init can we access the hw */
  240. for (i = 0; i < ARRAY_SIZE(cfg_handlers); i++) {
  241. if (cfg_handlers[i].revision != minor)
  242. continue;
  243. mdp5_cfg = cfg_handlers[i].config.hw;
  244. break;
  245. }
  246. if (unlikely(!mdp5_cfg)) {
  247. dev_err(dev->dev, "unexpected MDP minor revision: v%d.%d\n",
  248. major, minor);
  249. ret = -ENXIO;
  250. goto fail;
  251. }
  252. cfg_handler->revision = minor;
  253. cfg_handler->config.hw = mdp5_cfg;
  254. pconfig = mdp5_get_config(pdev);
  255. memcpy(&cfg_handler->config.platform, pconfig, sizeof(*pconfig));
  256. DBG("MDP5: %s hw config selected", mdp5_cfg->name);
  257. return cfg_handler;
  258. fail:
  259. if (cfg_handler)
  260. mdp5_cfg_destroy(cfg_handler);
  261. return NULL;
  262. }
  263. static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
  264. {
  265. static struct mdp5_cfg_platform config = {};
  266. #ifdef CONFIG_OF
  267. /* TODO */
  268. #endif
  269. config.iommu = iommu_domain_alloc(&platform_bus_type);
  270. return &config;
  271. }