mdp4_kms.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "msm_drv.h"
  18. #include "msm_mmu.h"
  19. #include "mdp4_kms.h"
  20. static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev);
  21. static int mdp4_hw_init(struct msm_kms *kms)
  22. {
  23. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  24. struct drm_device *dev = mdp4_kms->dev;
  25. uint32_t version, major, minor, dmap_cfg, vg_cfg;
  26. unsigned long clk;
  27. int ret = 0;
  28. pm_runtime_get_sync(dev->dev);
  29. mdp4_enable(mdp4_kms);
  30. version = mdp4_read(mdp4_kms, REG_MDP4_VERSION);
  31. mdp4_disable(mdp4_kms);
  32. major = FIELD(version, MDP4_VERSION_MAJOR);
  33. minor = FIELD(version, MDP4_VERSION_MINOR);
  34. DBG("found MDP4 version v%d.%d", major, minor);
  35. if (major != 4) {
  36. dev_err(dev->dev, "unexpected MDP version: v%d.%d\n",
  37. major, minor);
  38. ret = -ENXIO;
  39. goto out;
  40. }
  41. mdp4_kms->rev = minor;
  42. if (mdp4_kms->rev > 1) {
  43. mdp4_write(mdp4_kms, REG_MDP4_CS_CONTROLLER0, 0x0707ffff);
  44. mdp4_write(mdp4_kms, REG_MDP4_CS_CONTROLLER1, 0x03073f3f);
  45. }
  46. mdp4_write(mdp4_kms, REG_MDP4_PORTMAP_MODE, 0x3);
  47. /* max read pending cmd config, 3 pending requests: */
  48. mdp4_write(mdp4_kms, REG_MDP4_READ_CNFG, 0x02222);
  49. clk = clk_get_rate(mdp4_kms->clk);
  50. if ((mdp4_kms->rev >= 1) || (clk >= 90000000)) {
  51. dmap_cfg = 0x47; /* 16 bytes-burst x 8 req */
  52. vg_cfg = 0x47; /* 16 bytes-burs x 8 req */
  53. } else {
  54. dmap_cfg = 0x27; /* 8 bytes-burst x 8 req */
  55. vg_cfg = 0x43; /* 16 bytes-burst x 4 req */
  56. }
  57. DBG("fetch config: dmap=%02x, vg=%02x", dmap_cfg, vg_cfg);
  58. mdp4_write(mdp4_kms, REG_MDP4_DMA_FETCH_CONFIG(DMA_P), dmap_cfg);
  59. mdp4_write(mdp4_kms, REG_MDP4_DMA_FETCH_CONFIG(DMA_E), dmap_cfg);
  60. mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(VG1), vg_cfg);
  61. mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(VG2), vg_cfg);
  62. mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(RGB1), vg_cfg);
  63. mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(RGB2), vg_cfg);
  64. if (mdp4_kms->rev >= 2)
  65. mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG_UPDATE_METHOD, 1);
  66. mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG, 0);
  67. /* disable CSC matrix / YUV by default: */
  68. mdp4_write(mdp4_kms, REG_MDP4_PIPE_OP_MODE(VG1), 0);
  69. mdp4_write(mdp4_kms, REG_MDP4_PIPE_OP_MODE(VG2), 0);
  70. mdp4_write(mdp4_kms, REG_MDP4_DMA_P_OP_MODE, 0);
  71. mdp4_write(mdp4_kms, REG_MDP4_DMA_S_OP_MODE, 0);
  72. mdp4_write(mdp4_kms, REG_MDP4_OVLP_CSC_CONFIG(1), 0);
  73. mdp4_write(mdp4_kms, REG_MDP4_OVLP_CSC_CONFIG(2), 0);
  74. if (mdp4_kms->rev > 1)
  75. mdp4_write(mdp4_kms, REG_MDP4_RESET_STATUS, 1);
  76. dev->mode_config.allow_fb_modifiers = true;
  77. out:
  78. pm_runtime_put_sync(dev->dev);
  79. return ret;
  80. }
  81. static void mdp4_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *state)
  82. {
  83. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  84. int i;
  85. struct drm_crtc *crtc;
  86. struct drm_crtc_state *crtc_state;
  87. mdp4_enable(mdp4_kms);
  88. /* see 119ecb7fd */
  89. for_each_crtc_in_state(state, crtc, crtc_state, i)
  90. drm_crtc_vblank_get(crtc);
  91. }
  92. static void mdp4_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
  93. {
  94. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  95. int i;
  96. struct drm_crtc *crtc;
  97. struct drm_crtc_state *crtc_state;
  98. /* see 119ecb7fd */
  99. for_each_crtc_in_state(state, crtc, crtc_state, i)
  100. drm_crtc_vblank_put(crtc);
  101. mdp4_disable(mdp4_kms);
  102. }
  103. static void mdp4_wait_for_crtc_commit_done(struct msm_kms *kms,
  104. struct drm_crtc *crtc)
  105. {
  106. mdp4_crtc_wait_for_commit_done(crtc);
  107. }
  108. static long mdp4_round_pixclk(struct msm_kms *kms, unsigned long rate,
  109. struct drm_encoder *encoder)
  110. {
  111. /* if we had >1 encoder, we'd need something more clever: */
  112. switch (encoder->encoder_type) {
  113. case DRM_MODE_ENCODER_TMDS:
  114. return mdp4_dtv_round_pixclk(encoder, rate);
  115. case DRM_MODE_ENCODER_LVDS:
  116. case DRM_MODE_ENCODER_DSI:
  117. default:
  118. return rate;
  119. }
  120. }
  121. static const char * const iommu_ports[] = {
  122. "mdp_port0_cb0", "mdp_port1_cb0",
  123. };
  124. static void mdp4_destroy(struct msm_kms *kms)
  125. {
  126. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  127. struct device *dev = mdp4_kms->dev->dev;
  128. struct msm_mmu *mmu = mdp4_kms->mmu;
  129. if (mmu) {
  130. mmu->funcs->detach(mmu, iommu_ports, ARRAY_SIZE(iommu_ports));
  131. mmu->funcs->destroy(mmu);
  132. }
  133. if (mdp4_kms->blank_cursor_iova)
  134. msm_gem_put_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id);
  135. drm_gem_object_unreference_unlocked(mdp4_kms->blank_cursor_bo);
  136. if (mdp4_kms->rpm_enabled)
  137. pm_runtime_disable(dev);
  138. kfree(mdp4_kms);
  139. }
  140. static const struct mdp_kms_funcs kms_funcs = {
  141. .base = {
  142. .hw_init = mdp4_hw_init,
  143. .irq_preinstall = mdp4_irq_preinstall,
  144. .irq_postinstall = mdp4_irq_postinstall,
  145. .irq_uninstall = mdp4_irq_uninstall,
  146. .irq = mdp4_irq,
  147. .enable_vblank = mdp4_enable_vblank,
  148. .disable_vblank = mdp4_disable_vblank,
  149. .prepare_commit = mdp4_prepare_commit,
  150. .complete_commit = mdp4_complete_commit,
  151. .wait_for_crtc_commit_done = mdp4_wait_for_crtc_commit_done,
  152. .get_format = mdp_get_format,
  153. .round_pixclk = mdp4_round_pixclk,
  154. .destroy = mdp4_destroy,
  155. },
  156. .set_irqmask = mdp4_set_irqmask,
  157. };
  158. int mdp4_disable(struct mdp4_kms *mdp4_kms)
  159. {
  160. DBG("");
  161. clk_disable_unprepare(mdp4_kms->clk);
  162. if (mdp4_kms->pclk)
  163. clk_disable_unprepare(mdp4_kms->pclk);
  164. clk_disable_unprepare(mdp4_kms->lut_clk);
  165. if (mdp4_kms->axi_clk)
  166. clk_disable_unprepare(mdp4_kms->axi_clk);
  167. return 0;
  168. }
  169. int mdp4_enable(struct mdp4_kms *mdp4_kms)
  170. {
  171. DBG("");
  172. clk_prepare_enable(mdp4_kms->clk);
  173. if (mdp4_kms->pclk)
  174. clk_prepare_enable(mdp4_kms->pclk);
  175. clk_prepare_enable(mdp4_kms->lut_clk);
  176. if (mdp4_kms->axi_clk)
  177. clk_prepare_enable(mdp4_kms->axi_clk);
  178. return 0;
  179. }
  180. static struct device_node *mdp4_detect_lcdc_panel(struct drm_device *dev)
  181. {
  182. struct device_node *endpoint, *panel_node;
  183. struct device_node *np = dev->dev->of_node;
  184. endpoint = of_graph_get_next_endpoint(np, NULL);
  185. if (!endpoint) {
  186. DBG("no endpoint in MDP4 to fetch LVDS panel\n");
  187. return NULL;
  188. }
  189. /* don't proceed if we have an endpoint but no panel_node tied to it */
  190. panel_node = of_graph_get_remote_port_parent(endpoint);
  191. if (!panel_node) {
  192. dev_err(dev->dev, "no valid panel node\n");
  193. of_node_put(endpoint);
  194. return ERR_PTR(-ENODEV);
  195. }
  196. of_node_put(endpoint);
  197. return panel_node;
  198. }
  199. static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
  200. int intf_type)
  201. {
  202. struct drm_device *dev = mdp4_kms->dev;
  203. struct msm_drm_private *priv = dev->dev_private;
  204. struct drm_encoder *encoder;
  205. struct drm_connector *connector;
  206. struct device_node *panel_node;
  207. struct drm_encoder *dsi_encs[MSM_DSI_ENCODER_NUM];
  208. int i, dsi_id;
  209. int ret;
  210. switch (intf_type) {
  211. case DRM_MODE_ENCODER_LVDS:
  212. /*
  213. * bail out early if:
  214. * - there is no panel node (no need to initialize lcdc
  215. * encoder and lvds connector), or
  216. * - panel node is a bad pointer
  217. */
  218. panel_node = mdp4_detect_lcdc_panel(dev);
  219. if (IS_ERR_OR_NULL(panel_node))
  220. return PTR_ERR(panel_node);
  221. encoder = mdp4_lcdc_encoder_init(dev, panel_node);
  222. if (IS_ERR(encoder)) {
  223. dev_err(dev->dev, "failed to construct LCDC encoder\n");
  224. return PTR_ERR(encoder);
  225. }
  226. /* LCDC can be hooked to DMA_P (TODO: Add DMA_S later?) */
  227. encoder->possible_crtcs = 1 << DMA_P;
  228. connector = mdp4_lvds_connector_init(dev, panel_node, encoder);
  229. if (IS_ERR(connector)) {
  230. dev_err(dev->dev, "failed to initialize LVDS connector\n");
  231. return PTR_ERR(connector);
  232. }
  233. priv->encoders[priv->num_encoders++] = encoder;
  234. priv->connectors[priv->num_connectors++] = connector;
  235. break;
  236. case DRM_MODE_ENCODER_TMDS:
  237. encoder = mdp4_dtv_encoder_init(dev);
  238. if (IS_ERR(encoder)) {
  239. dev_err(dev->dev, "failed to construct DTV encoder\n");
  240. return PTR_ERR(encoder);
  241. }
  242. /* DTV can be hooked to DMA_E: */
  243. encoder->possible_crtcs = 1 << 1;
  244. if (priv->hdmi) {
  245. /* Construct bridge/connector for HDMI: */
  246. ret = msm_hdmi_modeset_init(priv->hdmi, dev, encoder);
  247. if (ret) {
  248. dev_err(dev->dev, "failed to initialize HDMI: %d\n", ret);
  249. return ret;
  250. }
  251. }
  252. priv->encoders[priv->num_encoders++] = encoder;
  253. break;
  254. case DRM_MODE_ENCODER_DSI:
  255. /* only DSI1 supported for now */
  256. dsi_id = 0;
  257. if (!priv->dsi[dsi_id])
  258. break;
  259. for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) {
  260. dsi_encs[i] = mdp4_dsi_encoder_init(dev);
  261. if (IS_ERR(dsi_encs[i])) {
  262. ret = PTR_ERR(dsi_encs[i]);
  263. dev_err(dev->dev,
  264. "failed to construct DSI encoder: %d\n",
  265. ret);
  266. return ret;
  267. }
  268. /* TODO: Add DMA_S later? */
  269. dsi_encs[i]->possible_crtcs = 1 << DMA_P;
  270. priv->encoders[priv->num_encoders++] = dsi_encs[i];
  271. }
  272. ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, dsi_encs);
  273. if (ret) {
  274. dev_err(dev->dev, "failed to initialize DSI: %d\n",
  275. ret);
  276. return ret;
  277. }
  278. break;
  279. default:
  280. dev_err(dev->dev, "Invalid or unsupported interface\n");
  281. return -EINVAL;
  282. }
  283. return 0;
  284. }
  285. static int modeset_init(struct mdp4_kms *mdp4_kms)
  286. {
  287. struct drm_device *dev = mdp4_kms->dev;
  288. struct msm_drm_private *priv = dev->dev_private;
  289. struct drm_plane *plane;
  290. struct drm_crtc *crtc;
  291. int i, ret;
  292. static const enum mdp4_pipe rgb_planes[] = {
  293. RGB1, RGB2,
  294. };
  295. static const enum mdp4_pipe vg_planes[] = {
  296. VG1, VG2,
  297. };
  298. static const enum mdp4_dma mdp4_crtcs[] = {
  299. DMA_P, DMA_E,
  300. };
  301. static const char * const mdp4_crtc_names[] = {
  302. "DMA_P", "DMA_E",
  303. };
  304. static const int mdp4_intfs[] = {
  305. DRM_MODE_ENCODER_LVDS,
  306. DRM_MODE_ENCODER_DSI,
  307. DRM_MODE_ENCODER_TMDS,
  308. };
  309. /* construct non-private planes: */
  310. for (i = 0; i < ARRAY_SIZE(vg_planes); i++) {
  311. plane = mdp4_plane_init(dev, vg_planes[i], false);
  312. if (IS_ERR(plane)) {
  313. dev_err(dev->dev,
  314. "failed to construct plane for VG%d\n", i + 1);
  315. ret = PTR_ERR(plane);
  316. goto fail;
  317. }
  318. priv->planes[priv->num_planes++] = plane;
  319. }
  320. for (i = 0; i < ARRAY_SIZE(mdp4_crtcs); i++) {
  321. plane = mdp4_plane_init(dev, rgb_planes[i], true);
  322. if (IS_ERR(plane)) {
  323. dev_err(dev->dev,
  324. "failed to construct plane for RGB%d\n", i + 1);
  325. ret = PTR_ERR(plane);
  326. goto fail;
  327. }
  328. crtc = mdp4_crtc_init(dev, plane, priv->num_crtcs, i,
  329. mdp4_crtcs[i]);
  330. if (IS_ERR(crtc)) {
  331. dev_err(dev->dev, "failed to construct crtc for %s\n",
  332. mdp4_crtc_names[i]);
  333. ret = PTR_ERR(crtc);
  334. goto fail;
  335. }
  336. priv->crtcs[priv->num_crtcs++] = crtc;
  337. }
  338. /*
  339. * we currently set up two relatively fixed paths:
  340. *
  341. * LCDC/LVDS path: RGB1 -> DMA_P -> LCDC -> LVDS
  342. * or
  343. * DSI path: RGB1 -> DMA_P -> DSI1 -> DSI Panel
  344. *
  345. * DTV/HDMI path: RGB2 -> DMA_E -> DTV -> HDMI
  346. */
  347. for (i = 0; i < ARRAY_SIZE(mdp4_intfs); i++) {
  348. ret = mdp4_modeset_init_intf(mdp4_kms, mdp4_intfs[i]);
  349. if (ret) {
  350. dev_err(dev->dev, "failed to initialize intf: %d, %d\n",
  351. i, ret);
  352. goto fail;
  353. }
  354. }
  355. return 0;
  356. fail:
  357. return ret;
  358. }
  359. struct msm_kms *mdp4_kms_init(struct drm_device *dev)
  360. {
  361. struct platform_device *pdev = dev->platformdev;
  362. struct mdp4_platform_config *config = mdp4_get_config(pdev);
  363. struct mdp4_kms *mdp4_kms;
  364. struct msm_kms *kms = NULL;
  365. struct msm_mmu *mmu;
  366. int irq, ret;
  367. mdp4_kms = kzalloc(sizeof(*mdp4_kms), GFP_KERNEL);
  368. if (!mdp4_kms) {
  369. dev_err(dev->dev, "failed to allocate kms\n");
  370. ret = -ENOMEM;
  371. goto fail;
  372. }
  373. mdp_kms_init(&mdp4_kms->base, &kms_funcs);
  374. kms = &mdp4_kms->base.base;
  375. mdp4_kms->dev = dev;
  376. mdp4_kms->mmio = msm_ioremap(pdev, NULL, "MDP4");
  377. if (IS_ERR(mdp4_kms->mmio)) {
  378. ret = PTR_ERR(mdp4_kms->mmio);
  379. goto fail;
  380. }
  381. irq = platform_get_irq(pdev, 0);
  382. if (irq < 0) {
  383. ret = irq;
  384. dev_err(dev->dev, "failed to get irq: %d\n", ret);
  385. goto fail;
  386. }
  387. kms->irq = irq;
  388. /* NOTE: driver for this regulator still missing upstream.. use
  389. * _get_exclusive() and ignore the error if it does not exist
  390. * (and hope that the bootloader left it on for us)
  391. */
  392. mdp4_kms->vdd = devm_regulator_get_exclusive(&pdev->dev, "vdd");
  393. if (IS_ERR(mdp4_kms->vdd))
  394. mdp4_kms->vdd = NULL;
  395. if (mdp4_kms->vdd) {
  396. ret = regulator_enable(mdp4_kms->vdd);
  397. if (ret) {
  398. dev_err(dev->dev, "failed to enable regulator vdd: %d\n", ret);
  399. goto fail;
  400. }
  401. }
  402. mdp4_kms->clk = devm_clk_get(&pdev->dev, "core_clk");
  403. if (IS_ERR(mdp4_kms->clk)) {
  404. dev_err(dev->dev, "failed to get core_clk\n");
  405. ret = PTR_ERR(mdp4_kms->clk);
  406. goto fail;
  407. }
  408. mdp4_kms->pclk = devm_clk_get(&pdev->dev, "iface_clk");
  409. if (IS_ERR(mdp4_kms->pclk))
  410. mdp4_kms->pclk = NULL;
  411. // XXX if (rev >= MDP_REV_42) { ???
  412. mdp4_kms->lut_clk = devm_clk_get(&pdev->dev, "lut_clk");
  413. if (IS_ERR(mdp4_kms->lut_clk)) {
  414. dev_err(dev->dev, "failed to get lut_clk\n");
  415. ret = PTR_ERR(mdp4_kms->lut_clk);
  416. goto fail;
  417. }
  418. mdp4_kms->axi_clk = devm_clk_get(&pdev->dev, "bus_clk");
  419. if (IS_ERR(mdp4_kms->axi_clk)) {
  420. dev_err(dev->dev, "failed to get axi_clk\n");
  421. ret = PTR_ERR(mdp4_kms->axi_clk);
  422. goto fail;
  423. }
  424. clk_set_rate(mdp4_kms->clk, config->max_clk);
  425. clk_set_rate(mdp4_kms->lut_clk, config->max_clk);
  426. pm_runtime_enable(dev->dev);
  427. mdp4_kms->rpm_enabled = true;
  428. /* make sure things are off before attaching iommu (bootloader could
  429. * have left things on, in which case we'll start getting faults if
  430. * we don't disable):
  431. */
  432. mdp4_enable(mdp4_kms);
  433. mdp4_write(mdp4_kms, REG_MDP4_DTV_ENABLE, 0);
  434. mdp4_write(mdp4_kms, REG_MDP4_LCDC_ENABLE, 0);
  435. mdp4_write(mdp4_kms, REG_MDP4_DSI_ENABLE, 0);
  436. mdp4_disable(mdp4_kms);
  437. mdelay(16);
  438. if (config->iommu) {
  439. mmu = msm_iommu_new(&pdev->dev, config->iommu);
  440. if (IS_ERR(mmu)) {
  441. ret = PTR_ERR(mmu);
  442. goto fail;
  443. }
  444. ret = mmu->funcs->attach(mmu, iommu_ports,
  445. ARRAY_SIZE(iommu_ports));
  446. if (ret)
  447. goto fail;
  448. mdp4_kms->mmu = mmu;
  449. } else {
  450. dev_info(dev->dev, "no iommu, fallback to phys "
  451. "contig buffers for scanout\n");
  452. mmu = NULL;
  453. }
  454. mdp4_kms->id = msm_register_mmu(dev, mmu);
  455. if (mdp4_kms->id < 0) {
  456. ret = mdp4_kms->id;
  457. dev_err(dev->dev, "failed to register mdp4 iommu: %d\n", ret);
  458. goto fail;
  459. }
  460. ret = modeset_init(mdp4_kms);
  461. if (ret) {
  462. dev_err(dev->dev, "modeset_init failed: %d\n", ret);
  463. goto fail;
  464. }
  465. mutex_lock(&dev->struct_mutex);
  466. mdp4_kms->blank_cursor_bo = msm_gem_new(dev, SZ_16K, MSM_BO_WC);
  467. mutex_unlock(&dev->struct_mutex);
  468. if (IS_ERR(mdp4_kms->blank_cursor_bo)) {
  469. ret = PTR_ERR(mdp4_kms->blank_cursor_bo);
  470. dev_err(dev->dev, "could not allocate blank-cursor bo: %d\n", ret);
  471. mdp4_kms->blank_cursor_bo = NULL;
  472. goto fail;
  473. }
  474. ret = msm_gem_get_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id,
  475. &mdp4_kms->blank_cursor_iova);
  476. if (ret) {
  477. dev_err(dev->dev, "could not pin blank-cursor bo: %d\n", ret);
  478. goto fail;
  479. }
  480. dev->mode_config.min_width = 0;
  481. dev->mode_config.min_height = 0;
  482. dev->mode_config.max_width = 2048;
  483. dev->mode_config.max_height = 2048;
  484. return kms;
  485. fail:
  486. if (kms)
  487. mdp4_destroy(kms);
  488. return ERR_PTR(ret);
  489. }
  490. static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev)
  491. {
  492. static struct mdp4_platform_config config = {};
  493. /* TODO: Chips that aren't apq8064 have a 200 Mhz max_clk */
  494. config.max_clk = 266667000;
  495. config.iommu = iommu_domain_alloc(&platform_bus_type);
  496. return &config;
  497. }