mdp4_kms.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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, ncrtcs = state->dev->mode_config.num_crtc;
  85. mdp4_enable(mdp4_kms);
  86. /* see 119ecb7fd */
  87. for (i = 0; i < ncrtcs; i++) {
  88. struct drm_crtc *crtc = state->crtcs[i];
  89. if (!crtc)
  90. continue;
  91. drm_crtc_vblank_get(crtc);
  92. }
  93. }
  94. static void mdp4_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
  95. {
  96. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  97. int i, ncrtcs = state->dev->mode_config.num_crtc;
  98. /* see 119ecb7fd */
  99. for (i = 0; i < ncrtcs; i++) {
  100. struct drm_crtc *crtc = state->crtcs[i];
  101. if (!crtc)
  102. continue;
  103. drm_crtc_vblank_put(crtc);
  104. }
  105. mdp4_disable(mdp4_kms);
  106. }
  107. static void mdp4_wait_for_crtc_commit_done(struct msm_kms *kms,
  108. struct drm_crtc *crtc)
  109. {
  110. mdp4_crtc_wait_for_commit_done(crtc);
  111. }
  112. static long mdp4_round_pixclk(struct msm_kms *kms, unsigned long rate,
  113. struct drm_encoder *encoder)
  114. {
  115. /* if we had >1 encoder, we'd need something more clever: */
  116. switch (encoder->encoder_type) {
  117. case DRM_MODE_ENCODER_TMDS:
  118. return mdp4_dtv_round_pixclk(encoder, rate);
  119. case DRM_MODE_ENCODER_LVDS:
  120. case DRM_MODE_ENCODER_DSI:
  121. default:
  122. return rate;
  123. }
  124. }
  125. static const char * const iommu_ports[] = {
  126. "mdp_port0_cb0", "mdp_port1_cb0",
  127. };
  128. static void mdp4_destroy(struct msm_kms *kms)
  129. {
  130. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  131. struct msm_mmu *mmu = mdp4_kms->mmu;
  132. if (mmu) {
  133. mmu->funcs->detach(mmu, iommu_ports, ARRAY_SIZE(iommu_ports));
  134. mmu->funcs->destroy(mmu);
  135. }
  136. if (mdp4_kms->blank_cursor_iova)
  137. msm_gem_put_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id);
  138. if (mdp4_kms->blank_cursor_bo)
  139. drm_gem_object_unreference_unlocked(mdp4_kms->blank_cursor_bo);
  140. kfree(mdp4_kms);
  141. }
  142. static const struct mdp_kms_funcs kms_funcs = {
  143. .base = {
  144. .hw_init = mdp4_hw_init,
  145. .irq_preinstall = mdp4_irq_preinstall,
  146. .irq_postinstall = mdp4_irq_postinstall,
  147. .irq_uninstall = mdp4_irq_uninstall,
  148. .irq = mdp4_irq,
  149. .enable_vblank = mdp4_enable_vblank,
  150. .disable_vblank = mdp4_disable_vblank,
  151. .prepare_commit = mdp4_prepare_commit,
  152. .complete_commit = mdp4_complete_commit,
  153. .wait_for_crtc_commit_done = mdp4_wait_for_crtc_commit_done,
  154. .get_format = mdp_get_format,
  155. .round_pixclk = mdp4_round_pixclk,
  156. .destroy = mdp4_destroy,
  157. },
  158. .set_irqmask = mdp4_set_irqmask,
  159. };
  160. int mdp4_disable(struct mdp4_kms *mdp4_kms)
  161. {
  162. DBG("");
  163. clk_disable_unprepare(mdp4_kms->clk);
  164. if (mdp4_kms->pclk)
  165. clk_disable_unprepare(mdp4_kms->pclk);
  166. clk_disable_unprepare(mdp4_kms->lut_clk);
  167. if (mdp4_kms->axi_clk)
  168. clk_disable_unprepare(mdp4_kms->axi_clk);
  169. return 0;
  170. }
  171. int mdp4_enable(struct mdp4_kms *mdp4_kms)
  172. {
  173. DBG("");
  174. clk_prepare_enable(mdp4_kms->clk);
  175. if (mdp4_kms->pclk)
  176. clk_prepare_enable(mdp4_kms->pclk);
  177. clk_prepare_enable(mdp4_kms->lut_clk);
  178. if (mdp4_kms->axi_clk)
  179. clk_prepare_enable(mdp4_kms->axi_clk);
  180. return 0;
  181. }
  182. static struct device_node *mdp4_detect_lcdc_panel(struct drm_device *dev)
  183. {
  184. struct device_node *endpoint, *panel_node;
  185. struct device_node *np = dev->dev->of_node;
  186. endpoint = of_graph_get_next_endpoint(np, NULL);
  187. if (!endpoint) {
  188. DBG("no endpoint in MDP4 to fetch LVDS panel\n");
  189. return NULL;
  190. }
  191. /* don't proceed if we have an endpoint but no panel_node tied to it */
  192. panel_node = of_graph_get_remote_port_parent(endpoint);
  193. if (!panel_node) {
  194. dev_err(dev->dev, "no valid panel node\n");
  195. of_node_put(endpoint);
  196. return ERR_PTR(-ENODEV);
  197. }
  198. of_node_put(endpoint);
  199. return panel_node;
  200. }
  201. static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
  202. int intf_type)
  203. {
  204. struct drm_device *dev = mdp4_kms->dev;
  205. struct msm_drm_private *priv = dev->dev_private;
  206. struct drm_encoder *encoder;
  207. struct drm_connector *connector;
  208. struct device_node *panel_node;
  209. struct drm_encoder *dsi_encs[MSM_DSI_ENCODER_NUM];
  210. int i, dsi_id;
  211. int ret;
  212. switch (intf_type) {
  213. case DRM_MODE_ENCODER_LVDS:
  214. /*
  215. * bail out early if:
  216. * - there is no panel node (no need to initialize lcdc
  217. * encoder and lvds connector), or
  218. * - panel node is a bad pointer
  219. */
  220. panel_node = mdp4_detect_lcdc_panel(dev);
  221. if (IS_ERR_OR_NULL(panel_node))
  222. return PTR_ERR(panel_node);
  223. encoder = mdp4_lcdc_encoder_init(dev, panel_node);
  224. if (IS_ERR(encoder)) {
  225. dev_err(dev->dev, "failed to construct LCDC encoder\n");
  226. return PTR_ERR(encoder);
  227. }
  228. /* LCDC can be hooked to DMA_P (TODO: Add DMA_S later?) */
  229. encoder->possible_crtcs = 1 << DMA_P;
  230. connector = mdp4_lvds_connector_init(dev, panel_node, encoder);
  231. if (IS_ERR(connector)) {
  232. dev_err(dev->dev, "failed to initialize LVDS connector\n");
  233. return PTR_ERR(connector);
  234. }
  235. priv->encoders[priv->num_encoders++] = encoder;
  236. priv->connectors[priv->num_connectors++] = connector;
  237. break;
  238. case DRM_MODE_ENCODER_TMDS:
  239. encoder = mdp4_dtv_encoder_init(dev);
  240. if (IS_ERR(encoder)) {
  241. dev_err(dev->dev, "failed to construct DTV encoder\n");
  242. return PTR_ERR(encoder);
  243. }
  244. /* DTV can be hooked to DMA_E: */
  245. encoder->possible_crtcs = 1 << 1;
  246. if (priv->hdmi) {
  247. /* Construct bridge/connector for HDMI: */
  248. ret = msm_hdmi_modeset_init(priv->hdmi, dev, encoder);
  249. if (ret) {
  250. dev_err(dev->dev, "failed to initialize HDMI: %d\n", ret);
  251. return ret;
  252. }
  253. }
  254. priv->encoders[priv->num_encoders++] = encoder;
  255. break;
  256. case DRM_MODE_ENCODER_DSI:
  257. /* only DSI1 supported for now */
  258. dsi_id = 0;
  259. if (!priv->dsi[dsi_id])
  260. break;
  261. for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) {
  262. dsi_encs[i] = mdp4_dsi_encoder_init(dev);
  263. if (IS_ERR(dsi_encs[i])) {
  264. ret = PTR_ERR(dsi_encs[i]);
  265. dev_err(dev->dev,
  266. "failed to construct DSI encoder: %d\n",
  267. ret);
  268. return ret;
  269. }
  270. /* TODO: Add DMA_S later? */
  271. dsi_encs[i]->possible_crtcs = 1 << DMA_P;
  272. priv->encoders[priv->num_encoders++] = dsi_encs[i];
  273. }
  274. ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, dsi_encs);
  275. if (ret) {
  276. dev_err(dev->dev, "failed to initialize DSI: %d\n",
  277. ret);
  278. return ret;
  279. }
  280. break;
  281. default:
  282. dev_err(dev->dev, "Invalid or unsupported interface\n");
  283. return -EINVAL;
  284. }
  285. return 0;
  286. }
  287. static int modeset_init(struct mdp4_kms *mdp4_kms)
  288. {
  289. struct drm_device *dev = mdp4_kms->dev;
  290. struct msm_drm_private *priv = dev->dev_private;
  291. struct drm_plane *plane;
  292. struct drm_crtc *crtc;
  293. int i, ret;
  294. static const enum mdp4_pipe rgb_planes[] = {
  295. RGB1, RGB2,
  296. };
  297. static const enum mdp4_pipe vg_planes[] = {
  298. VG1, VG2,
  299. };
  300. static const enum mdp4_dma mdp4_crtcs[] = {
  301. DMA_P, DMA_E,
  302. };
  303. static const char * const mdp4_crtc_names[] = {
  304. "DMA_P", "DMA_E",
  305. };
  306. static const int mdp4_intfs[] = {
  307. DRM_MODE_ENCODER_LVDS,
  308. DRM_MODE_ENCODER_DSI,
  309. DRM_MODE_ENCODER_TMDS,
  310. };
  311. /* construct non-private planes: */
  312. for (i = 0; i < ARRAY_SIZE(vg_planes); i++) {
  313. plane = mdp4_plane_init(dev, vg_planes[i], false);
  314. if (IS_ERR(plane)) {
  315. dev_err(dev->dev,
  316. "failed to construct plane for VG%d\n", i + 1);
  317. ret = PTR_ERR(plane);
  318. goto fail;
  319. }
  320. priv->planes[priv->num_planes++] = plane;
  321. }
  322. for (i = 0; i < ARRAY_SIZE(mdp4_crtcs); i++) {
  323. plane = mdp4_plane_init(dev, rgb_planes[i], true);
  324. if (IS_ERR(plane)) {
  325. dev_err(dev->dev,
  326. "failed to construct plane for RGB%d\n", i + 1);
  327. ret = PTR_ERR(plane);
  328. goto fail;
  329. }
  330. crtc = mdp4_crtc_init(dev, plane, priv->num_crtcs, i,
  331. mdp4_crtcs[i]);
  332. if (IS_ERR(crtc)) {
  333. dev_err(dev->dev, "failed to construct crtc for %s\n",
  334. mdp4_crtc_names[i]);
  335. ret = PTR_ERR(crtc);
  336. goto fail;
  337. }
  338. priv->crtcs[priv->num_crtcs++] = crtc;
  339. }
  340. /*
  341. * we currently set up two relatively fixed paths:
  342. *
  343. * LCDC/LVDS path: RGB1 -> DMA_P -> LCDC -> LVDS
  344. * or
  345. * DSI path: RGB1 -> DMA_P -> DSI1 -> DSI Panel
  346. *
  347. * DTV/HDMI path: RGB2 -> DMA_E -> DTV -> HDMI
  348. */
  349. for (i = 0; i < ARRAY_SIZE(mdp4_intfs); i++) {
  350. ret = mdp4_modeset_init_intf(mdp4_kms, mdp4_intfs[i]);
  351. if (ret) {
  352. dev_err(dev->dev, "failed to initialize intf: %d, %d\n",
  353. i, ret);
  354. goto fail;
  355. }
  356. }
  357. return 0;
  358. fail:
  359. return ret;
  360. }
  361. struct msm_kms *mdp4_kms_init(struct drm_device *dev)
  362. {
  363. struct platform_device *pdev = dev->platformdev;
  364. struct mdp4_platform_config *config = mdp4_get_config(pdev);
  365. struct mdp4_kms *mdp4_kms;
  366. struct msm_kms *kms = NULL;
  367. struct msm_mmu *mmu;
  368. int ret;
  369. mdp4_kms = kzalloc(sizeof(*mdp4_kms), GFP_KERNEL);
  370. if (!mdp4_kms) {
  371. dev_err(dev->dev, "failed to allocate kms\n");
  372. ret = -ENOMEM;
  373. goto fail;
  374. }
  375. mdp_kms_init(&mdp4_kms->base, &kms_funcs);
  376. kms = &mdp4_kms->base.base;
  377. mdp4_kms->dev = dev;
  378. mdp4_kms->mmio = msm_ioremap(pdev, NULL, "MDP4");
  379. if (IS_ERR(mdp4_kms->mmio)) {
  380. ret = PTR_ERR(mdp4_kms->mmio);
  381. goto fail;
  382. }
  383. /* NOTE: driver for this regulator still missing upstream.. use
  384. * _get_exclusive() and ignore the error if it does not exist
  385. * (and hope that the bootloader left it on for us)
  386. */
  387. mdp4_kms->vdd = devm_regulator_get_exclusive(&pdev->dev, "vdd");
  388. if (IS_ERR(mdp4_kms->vdd))
  389. mdp4_kms->vdd = NULL;
  390. if (mdp4_kms->vdd) {
  391. ret = regulator_enable(mdp4_kms->vdd);
  392. if (ret) {
  393. dev_err(dev->dev, "failed to enable regulator vdd: %d\n", ret);
  394. goto fail;
  395. }
  396. }
  397. mdp4_kms->clk = devm_clk_get(&pdev->dev, "core_clk");
  398. if (IS_ERR(mdp4_kms->clk)) {
  399. dev_err(dev->dev, "failed to get core_clk\n");
  400. ret = PTR_ERR(mdp4_kms->clk);
  401. goto fail;
  402. }
  403. mdp4_kms->pclk = devm_clk_get(&pdev->dev, "iface_clk");
  404. if (IS_ERR(mdp4_kms->pclk))
  405. mdp4_kms->pclk = NULL;
  406. // XXX if (rev >= MDP_REV_42) { ???
  407. mdp4_kms->lut_clk = devm_clk_get(&pdev->dev, "lut_clk");
  408. if (IS_ERR(mdp4_kms->lut_clk)) {
  409. dev_err(dev->dev, "failed to get lut_clk\n");
  410. ret = PTR_ERR(mdp4_kms->lut_clk);
  411. goto fail;
  412. }
  413. mdp4_kms->axi_clk = devm_clk_get(&pdev->dev, "mdp_axi_clk");
  414. if (IS_ERR(mdp4_kms->axi_clk)) {
  415. dev_err(dev->dev, "failed to get axi_clk\n");
  416. ret = PTR_ERR(mdp4_kms->axi_clk);
  417. goto fail;
  418. }
  419. clk_set_rate(mdp4_kms->clk, config->max_clk);
  420. clk_set_rate(mdp4_kms->lut_clk, config->max_clk);
  421. /* make sure things are off before attaching iommu (bootloader could
  422. * have left things on, in which case we'll start getting faults if
  423. * we don't disable):
  424. */
  425. mdp4_enable(mdp4_kms);
  426. mdp4_write(mdp4_kms, REG_MDP4_DTV_ENABLE, 0);
  427. mdp4_write(mdp4_kms, REG_MDP4_LCDC_ENABLE, 0);
  428. mdp4_write(mdp4_kms, REG_MDP4_DSI_ENABLE, 0);
  429. mdp4_disable(mdp4_kms);
  430. mdelay(16);
  431. if (config->iommu) {
  432. mmu = msm_iommu_new(&pdev->dev, config->iommu);
  433. if (IS_ERR(mmu)) {
  434. ret = PTR_ERR(mmu);
  435. goto fail;
  436. }
  437. ret = mmu->funcs->attach(mmu, iommu_ports,
  438. ARRAY_SIZE(iommu_ports));
  439. if (ret)
  440. goto fail;
  441. mdp4_kms->mmu = mmu;
  442. } else {
  443. dev_info(dev->dev, "no iommu, fallback to phys "
  444. "contig buffers for scanout\n");
  445. mmu = NULL;
  446. }
  447. mdp4_kms->id = msm_register_mmu(dev, mmu);
  448. if (mdp4_kms->id < 0) {
  449. ret = mdp4_kms->id;
  450. dev_err(dev->dev, "failed to register mdp4 iommu: %d\n", ret);
  451. goto fail;
  452. }
  453. ret = modeset_init(mdp4_kms);
  454. if (ret) {
  455. dev_err(dev->dev, "modeset_init failed: %d\n", ret);
  456. goto fail;
  457. }
  458. mutex_lock(&dev->struct_mutex);
  459. mdp4_kms->blank_cursor_bo = msm_gem_new(dev, SZ_16K, MSM_BO_WC);
  460. mutex_unlock(&dev->struct_mutex);
  461. if (IS_ERR(mdp4_kms->blank_cursor_bo)) {
  462. ret = PTR_ERR(mdp4_kms->blank_cursor_bo);
  463. dev_err(dev->dev, "could not allocate blank-cursor bo: %d\n", ret);
  464. mdp4_kms->blank_cursor_bo = NULL;
  465. goto fail;
  466. }
  467. ret = msm_gem_get_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id,
  468. &mdp4_kms->blank_cursor_iova);
  469. if (ret) {
  470. dev_err(dev->dev, "could not pin blank-cursor bo: %d\n", ret);
  471. goto fail;
  472. }
  473. dev->mode_config.min_width = 0;
  474. dev->mode_config.min_height = 0;
  475. dev->mode_config.max_width = 2048;
  476. dev->mode_config.max_height = 2048;
  477. return kms;
  478. fail:
  479. if (kms)
  480. mdp4_destroy(kms);
  481. return ERR_PTR(ret);
  482. }
  483. static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev)
  484. {
  485. static struct mdp4_platform_config config = {};
  486. /* TODO: Chips that aren't apq8064 have a 200 Mhz max_clk */
  487. config.max_clk = 266667000;
  488. config.iommu = iommu_domain_alloc(&platform_bus_type);
  489. return &config;
  490. }