Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015, The Linux Foundation. All rights reserved. */ #include "drm/drm_bridge_connector.h" #include "msm_kms.h" #include "dsi.h" #define DSI_CLOCK_MASTER DSI_0 #define DSI_CLOCK_SLAVE DSI_1 #define DSI_LEFT DSI_0 #define DSI_RIGHT DSI_1 /* According to the current drm framework sequence, take the encoder of * DSI_1 as master encoder */ #define DSI_ENCODER_MASTER DSI_1 #define DSI_ENCODER_SLAVE DSI_0 struct msm_dsi_manager { struct msm_dsi *dsi[DSI_MAX]; bool is_bonded_dsi; bool is_sync_needed; int master_dsi_link_id; }; static struct msm_dsi_manager msm_dsim_glb; #define IS_BONDED_DSI() (msm_dsim_glb.is_bonded_dsi) #define IS_SYNC_NEEDED() (msm_dsim_glb.is_sync_needed) #define IS_MASTER_DSI_LINK(id) (msm_dsim_glb.master_dsi_link_id == id) #ifdef CONFIG_OF static bool dsi_mgr_power_on_early(struct drm_bridge *bridge) { struct drm_bridge *next_bridge = drm_bridge_get_next_bridge(bridge); /* * If the next bridge in the chain is the Parade ps8640 bridge chip * then don't power on early since it seems to violate the expectations * of the firmware that the bridge chip is running. * * NOTE: this is expected to be a temporary special case. It's expected * that we'll eventually have a framework that allows the next level * bridge to indicate whether it needs us to power on before it or * after it. When that framework is in place then we'll use it and * remove this special case. */ return !(next_bridge && next_bridge->of_node && of_device_is_compatible(next_bridge->of_node, "parade,ps8640")); } #else static inline bool dsi_mgr_power_on_early(struct drm_bridge *bridge) { return true; } #endif static inline struct msm_dsi *dsi_mgr_get_dsi(int id) { return msm_dsim_glb.dsi[id]; } static inline struct msm_dsi *dsi_mgr_get_other_dsi(int id) { return msm_dsim_glb.dsi[(id + 1) % DSI_MAX]; } static int dsi_mgr_parse_of(struct device_node *np, int id) { struct msm_dsi_manager *msm_dsim = &msm_dsim_glb; /* We assume 2 dsi nodes have the same information of bonded dsi and * sync-mode, and only one node specifies master in case of bonded mode. */ if (!msm_dsim->is_bonded_dsi) msm_dsim->is_bonded_dsi = of_property_read_bool(np, "qcom,dual-dsi-mode"); if (msm_dsim->is_bonded_dsi) { if (of_property_read_bool(np, "qcom,master-dsi")) msm_dsim->master_dsi_link_id = id; if (!msm_dsim->is_sync_needed) msm_dsim->is_sync_needed = of_property_read_bool( np, "qcom,sync-dual-dsi"); } return 0; } static int dsi_mgr_setup_components(int id) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id); struct msm_dsi *clk_master_dsi = dsi_mgr_get_dsi(DSI_CLOCK_MASTER); struct msm_dsi *clk_slave_dsi = dsi_mgr_get_dsi(DSI_CLOCK_SLAVE); int ret; if (!IS_BONDED_DSI()) { ret = msm_dsi_host_register(msm_dsi->host); if (ret) return ret; msm_dsi_phy_set_usecase(msm_dsi->phy, MSM_DSI_PHY_STANDALONE); msm_dsi_host_set_phy_mode(msm_dsi->host, msm_dsi->phy); } else if (other_dsi) { struct msm_dsi *master_link_dsi = IS_MASTER_DSI_LINK(id) ? msm_dsi : other_dsi; struct msm_dsi *slave_link_dsi = IS_MASTER_DSI_LINK(id) ? other_dsi : msm_dsi; /* Register slave host first, so that slave DSI device * has a chance to probe, and do not block the master * DSI device's probe. * Also, do not check defer for the slave host, * because only master DSI device adds the panel to global * panel list. The panel's device is the master DSI device. */ ret = msm_dsi_host_register(slave_link_dsi->host); if (ret) return ret; ret = msm_dsi_host_register(master_link_dsi->host); if (ret) return ret; /* PLL0 is to drive both 2 DSI link clocks in bonded DSI mode. */ msm_dsi_phy_set_usecase(clk_master_dsi->phy, MSM_DSI_PHY_MASTER); msm_dsi_phy_set_usecase(clk_slave_dsi->phy, MSM_DSI_PHY_SLAVE); msm_dsi_host_set_phy_mode(msm_dsi->host, msm_dsi->phy); msm_dsi_host_set_phy_mode(other_dsi->host, other_dsi->phy); } return 0; } static int enable_phy(struct msm_dsi *msm_dsi, struct msm_dsi_phy_shared_timings *shared_timings) { struct msm_dsi_phy_clk_request clk_req; bool is_bonded_dsi = IS_BONDED_DSI(); msm_dsi_host_get_phy_clk_req(msm_dsi->host, &clk_req, is_bonded_dsi); return msm_dsi_phy_enable(msm_dsi->phy, &clk_req, shared_timings); } static int dsi_mgr_phy_enable(int id, struct msm_dsi_phy_shared_timings shared_timings[DSI_MAX]) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *mdsi = dsi_mgr_get_dsi(DSI_CLOCK_MASTER); struct msm_dsi *sdsi = dsi_mgr_get_dsi(DSI_CLOCK_SLAVE); int ret; /* In case of bonded DSI, some registers in PHY1 have been programmed * during PLL0 clock's set_rate. The PHY1 reset called by host1 here * will silently reset those PHY1 registers. Therefore we need to reset * and enable both PHYs before any PLL clock operation. */ if (IS_BONDED_DSI() && mdsi && sdsi) { if (!mdsi->phy_enabled && !sdsi->phy_enabled) { msm_dsi_host_reset_phy(mdsi->host); msm_dsi_host_reset_phy(sdsi->host); ret = enable_phy(mdsi, &shared_timings[DSI_CLOCK_MASTER]); if (ret) return ret; ret = enable_phy(sdsi, &shared_timings[DSI_CLOCK_SLAVE]); if (ret) { msm_dsi_phy_disable(mdsi->phy); return ret; } } } else { msm_dsi_host_reset_phy(msm_dsi->host); ret = enable_phy(msm_dsi, &shared_timings[id]); if (ret) return ret; } msm_dsi->phy_enabled = true; return 0; } static void dsi_mgr_phy_disable(int id) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *mdsi = dsi_mgr_get_dsi(DSI_CLOCK_MASTER); struct msm_dsi *sdsi = dsi_mgr_get_dsi(DSI_CLOCK_SLAVE); /* disable DSI phy * In bonded dsi configuration, the phy should be disabled for the * first controller only when the second controller is disabled. */ msm_dsi->phy_enabled = false; if (IS_BONDED_DSI() && mdsi && sdsi) { if (!mdsi->phy_enabled && !sdsi->phy_enabled) { msm_dsi_phy_disable(sdsi->phy); msm_dsi_phy_disable(mdsi->phy); } } else { msm_dsi_phy_disable(msm_dsi->phy); } } struct dsi_bridge { struct drm_bridge base; int id; }; #define to_dsi_bridge(x) container_of(x, struct dsi_bridge, base) static int dsi_mgr_bridge_get_id(struct drm_bridge *bridge) { struct dsi_bridge *dsi_bridge = to_dsi_bridge(bridge); return dsi_bridge->id; } static void msm_dsi_manager_set_split_display(u8 id) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id); struct msm_drm_private *priv = msm_dsi->dev->dev_private; struct msm_kms *kms = priv->kms; struct msm_dsi *master_dsi, *slave_dsi; if (IS_BONDED_DSI() && !IS_MASTER_DSI_LINK(id)) { master_dsi = other_dsi; slave_dsi = msm_dsi; } else { master_dsi = msm_dsi; slave_dsi = other_dsi; } if (!msm_dsi->external_bridge || !IS_BONDED_DSI()) return; /* * Set split display info to kms once bonded DSI panel is connected to * both hosts. */ if (other_dsi && other_dsi->external_bridge && kms->funcs->set_split_display) { kms->funcs->set_split_display(kms, master_dsi->encoder, slave_dsi->encoder, msm_dsi_is_cmd_mode(msm_dsi)); } } static void dsi_mgr_bridge_power_on(struct drm_bridge *bridge) { int id = dsi_mgr_bridge_get_id(bridge); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi1 = dsi_mgr_get_dsi(DSI_1); struct mipi_dsi_host *host = msm_dsi->host; struct msm_dsi_phy_shared_timings phy_shared_timings[DSI_MAX]; bool is_bonded_dsi = IS_BONDED_DSI(); int ret; DBG("id=%d", id); if (!msm_dsi_device_connected(msm_dsi)) return; /* Do nothing with the host if it is slave-DSI in case of bonded DSI */ if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) return; ret = dsi_mgr_phy_enable(id, phy_shared_timings); if (ret) goto phy_en_fail; ret = msm_dsi_host_power_on(host, &phy_shared_timings[id], is_bonded_dsi, msm_dsi->phy); if (ret) { pr_err("%s: power on host %d failed, %d\n", __func__, id, ret); goto host_on_fail; } if (is_bonded_dsi && msm_dsi1) { ret = msm_dsi_host_power_on(msm_dsi1->host, &phy_shared_timings[DSI_1], is_bonded_dsi, msm_dsi1->phy); if (ret) { pr_err("%s: power on host1 failed, %d\n", __func__, ret); goto host1_on_fail; } } /* * Enable before preparing the panel, disable after unpreparing, so * that the panel can communicate over the DSI link. */ msm_dsi_host_enable_irq(host); if (is_bonded_dsi && msm_dsi1) msm_dsi_host_enable_irq(msm_dsi1->host); return; host1_on_fail: msm_dsi_host_power_off(host); host_on_fail: dsi_mgr_phy_disable(id); phy_en_fail: return; } static void dsi_mgr_bridge_pre_enable(struct drm_bridge *bridge) { int id = dsi_mgr_bridge_get_id(bridge); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi1 = dsi_mgr_get_dsi(DSI_1); struct mipi_dsi_host *host = msm_dsi->host; bool is_bonded_dsi = IS_BONDED_DSI(); int ret; DBG("id=%d", id); if (!msm_dsi_device_connected(msm_dsi)) return; /* Do nothing with the host if it is slave-DSI in case of bonded DSI */ if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) return; if (!dsi_mgr_power_on_early(bridge)) dsi_mgr_bridge_power_on(bridge); ret = msm_dsi_host_enable(host); if (ret) { pr_err("%s: enable host %d failed, %d\n", __func__, id, ret); goto host_en_fail; } if (is_bonded_dsi && msm_dsi1) { ret = msm_dsi_host_enable(msm_dsi1->host); if (ret) { pr_err("%s: enable host1 failed, %d\n", __func__, ret); goto host1_en_fail; } } return; host1_en_fail: msm_dsi_host_disable(host); host_en_fail: return; } void msm_dsi_manager_tpg_enable(void) { struct msm_dsi *m_dsi = dsi_mgr_get_dsi(DSI_0); struct msm_dsi *s_dsi = dsi_mgr_get_dsi(DSI_1); /* if dual dsi, trigger tpg on master first then slave */ if (m_dsi) { msm_dsi_host_test_pattern_en(m_dsi->host); if (IS_BONDED_DSI() && s_dsi) msm_dsi_host_test_pattern_en(s_dsi->host); } } static void dsi_mgr_bridge_post_disable(struct drm_bridge *bridge) { int id = dsi_mgr_bridge_get_id(bridge); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi1 = dsi_mgr_get_dsi(DSI_1); struct mipi_dsi_host *host = msm_dsi->host; bool is_bonded_dsi = IS_BONDED_DSI(); int ret; DBG("id=%d", id); if (!msm_dsi_device_connected(msm_dsi)) return; /* * Do nothing with the host if it is slave-DSI in case of bonded DSI. * It is safe to call dsi_mgr_phy_disable() here because a single PHY * won't be diabled until both PHYs request disable. */ if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) goto disable_phy; ret = msm_dsi_host_disable(host); if (ret) pr_err("%s: host %d disable failed, %d\n", __func__, id, ret); if (is_bonded_dsi && msm_dsi1) { ret = msm_dsi_host_disable(msm_dsi1->host); if (ret) pr_err("%s: host1 disable failed, %d\n", __func__, ret); } msm_dsi_host_disable_irq(host); if (is_bonded_dsi && msm_dsi1) msm_dsi_host_disable_irq(msm_dsi1->host); /* Save PHY status if it is a clock source */ msm_dsi_phy_pll_save_state(msm_dsi->phy); ret = msm_dsi_host_power_off(host); if (ret) pr_err("%s: host %d power off failed,%d\n", __func__, id, ret); if (is_bonded_dsi && msm_dsi1) { ret = msm_dsi_host_power_off(msm_dsi1->host); if (ret) pr_err("%s: host1 power off failed, %d\n", __func__, ret); } disable_phy: dsi_mgr_phy_disable(id); } static void dsi_mgr_bridge_mode_set(struct drm_bridge *bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode) { int id = dsi_mgr_bridge_get_id(bridge); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id); struct mipi_dsi_host *host = msm_dsi->host; bool is_bonded_dsi = IS_BONDED_DSI(); DBG("set mode: " DRM_MODE_FMT, DRM_MODE_ARG(mode)); if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) return; msm_dsi_host_set_display_mode(host, adjusted_mode); if (is_bonded_dsi && other_dsi) msm_dsi_host_set_display_mode(other_dsi->host, adjusted_mode); if (dsi_mgr_power_on_early(bridge)) dsi_mgr_bridge_power_on(bridge); } static enum drm_mode_status dsi_mgr_bridge_mode_valid(struct drm_bridge *bridge, const struct drm_display_info *info, const struct drm_display_mode *mode) { int id = dsi_mgr_bridge_get_id(bridge); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct mipi_dsi_host *host = msm_dsi->host; struct platform_device *pdev = msm_dsi->pdev; struct dev_pm_opp *opp; unsigned long byte_clk_rate; byte_clk_rate = dsi_byte_clk_get_rate(host, IS_BONDED_DSI(), mode); opp = dev_pm_opp_find_freq_ceil(&pdev->dev, &byte_clk_rate); if (!IS_ERR(opp)) { dev_pm_opp_put(opp); } else if (PTR_ERR(opp) == -ERANGE) { /* * An empty table is created by devm_pm_opp_set_clkname() even * if there is none. Thus find_freq_ceil will still return * -ERANGE in such case. */ if (dev_pm_opp_get_opp_count(&pdev->dev) != 0) return MODE_CLOCK_RANGE; } else { return MODE_ERROR; } return msm_dsi_host_check_dsc(host, mode); } static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = { .pre_enable = dsi_mgr_bridge_pre_enable, .post_disable = dsi_mgr_bridge_post_disable, .mode_set = dsi_mgr_bridge_mode_set, .mode_valid = dsi_mgr_bridge_mode_valid, }; /* initialize bridge */ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct drm_bridge *bridge = NULL; struct dsi_bridge *dsi_bridge; struct drm_encoder *encoder; int ret; dsi_bridge = devm_kzalloc(msm_dsi->dev->dev, sizeof(*dsi_bridge), GFP_KERNEL); if (!dsi_bridge) { ret = -ENOMEM; goto fail; } dsi_bridge->id = id; encoder = msm_dsi->encoder; bridge = &dsi_bridge->base; bridge->funcs = &dsi_mgr_bridge_funcs; drm_bridge_add(bridge); ret = drm_bridge_attach(encoder, bridge, NULL, 0); if (ret) goto fail; return bridge; fail: if (bridge) msm_dsi_manager_bridge_destroy(bridge); return ERR_PTR(ret); } int msm_dsi_manager_ext_bridge_init(u8 id) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct drm_device *dev = msm_dsi->dev; struct drm_encoder *encoder; struct drm_bridge *int_bridge, *ext_bridge; int ret; int_bridge = msm_dsi->bridge; ext_bridge = devm_drm_of_get_bridge(&msm_dsi->pdev->dev, msm_dsi->pdev->dev.of_node, 1, 0); if (IS_ERR(ext_bridge)) return PTR_ERR(ext_bridge); msm_dsi->external_bridge = ext_bridge; encoder = msm_dsi->encoder; /* * Try first to create the bridge without it creating its own * connector.. currently some bridges support this, and others * do not (and some support both modes) */ ret = drm_bridge_attach(encoder, ext_bridge, int_bridge, DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret == -EINVAL) { /* * link the internal dsi bridge to the external bridge, * connector is created by the next bridge. */ ret = drm_bridge_attach(encoder, ext_bridge, int_bridge, 0); if (ret < 0) return ret; } else { struct drm_connector *connector; /* We are in charge of the connector, create one now. */ connector = drm_bridge_connector_init(dev, encoder); if (IS_ERR(connector)) { DRM_ERROR("Unable to create bridge connector\n"); return PTR_ERR(connector); } ret = drm_connector_attach_encoder(connector, encoder); if (ret < 0) return ret; } /* The pipeline is ready, ping encoders if necessary */ msm_dsi_manager_set_split_display(id); return 0; } void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge) { drm_bridge_remove(bridge); } int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi0 = dsi_mgr_get_dsi(DSI_0); struct mipi_dsi_host *host = msm_dsi->host; bool is_read = (msg->rx_buf && msg->rx_len); bool need_sync = (IS_SYNC_NEEDED() && !is_read); int ret; if (!msg->tx_buf || !msg->tx_len) return 0; /* In bonded master case, panel requires the same commands sent to * both DSI links. Host issues the command trigger to both links * when DSI_1 calls the cmd transfer function, no matter it happens * before or after DSI_0 cmd transfer. */ if (need_sync && (id == DSI_0)) return is_read ? msg->rx_len : msg->tx_len; if (need_sync && msm_dsi0) { ret = msm_dsi_host_xfer_prepare(msm_dsi0->host, msg); if (ret) { pr_err("%s: failed to prepare non-trigger host, %d\n", __func__, ret); return ret; } } ret = msm_dsi_host_xfer_prepare(host, msg); if (ret) { pr_err("%s: failed to prepare host, %d\n", __func__, ret); goto restore_host0; } ret = is_read ? msm_dsi_host_cmd_rx(host, msg) : msm_dsi_host_cmd_tx(host, msg); msm_dsi_host_xfer_restore(host, msg); restore_host0: if (need_sync && msm_dsi0) msm_dsi_host_xfer_restore(msm_dsi0->host, msg); return ret; } bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi0 = dsi_mgr_get_dsi(DSI_0); struct mipi_dsi_host *host = msm_dsi->host; if (IS_SYNC_NEEDED() && (id == DSI_0)) return false; if (IS_SYNC_NEEDED() && msm_dsi0) msm_dsi_host_cmd_xfer_commit(msm_dsi0->host, dma_base, len); msm_dsi_host_cmd_xfer_commit(host, dma_base, len); return true; } int msm_dsi_manager_register(struct msm_dsi *msm_dsi) { struct msm_dsi_manager *msm_dsim = &msm_dsim_glb; int id = msm_dsi->id; int ret; if (id >= DSI_MAX) { pr_err("%s: invalid id %d\n", __func__, id); return -EINVAL; } if (msm_dsim->dsi[id]) { pr_err("%s: dsi%d already registered\n", __func__, id); return -EBUSY; } msm_dsim->dsi[id] = msm_dsi; ret = dsi_mgr_parse_of(msm_dsi->pdev->dev.of_node, id); if (ret) { pr_err("%s: failed to parse OF DSI info\n", __func__); goto fail; } ret = dsi_mgr_setup_components(id); if (ret) { pr_err("%s: failed to register mipi dsi host for DSI %d: %d\n", __func__, id, ret); goto fail; } return 0; fail: msm_dsim->dsi[id] = NULL; return ret; } void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi) { struct msm_dsi_manager *msm_dsim = &msm_dsim_glb; if (msm_dsi->host) msm_dsi_host_unregister(msm_dsi->host); if (msm_dsi->id >= 0) msm_dsim->dsi[msm_dsi->id] = NULL; } bool msm_dsi_is_bonded_dsi(struct msm_dsi *msm_dsi) { return IS_BONDED_DSI(); } bool msm_dsi_is_master_dsi(struct msm_dsi *msm_dsi) { return IS_MASTER_DSI_LINK(msm_dsi->id); } |