Lines Matching +full:dsi +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include "dsi.h"
22 struct msm_dsi *dsi[DSI_MAX]; member
37 return msm_dsim_glb.dsi[id]; in dsi_mgr_get_dsi()
42 return msm_dsim_glb.dsi[(id + 1) % DSI_MAX]; in dsi_mgr_get_other_dsi()
49 /* We assume 2 dsi nodes have the same information of bonded dsi and in dsi_mgr_parse_of()
50 * sync-mode, and only one node specifies master in case of bonded mode. in dsi_mgr_parse_of()
52 if (!msm_dsim->is_bonded_dsi) in dsi_mgr_parse_of()
53 msm_dsim->is_bonded_dsi = of_property_read_bool(np, "qcom,dual-dsi-mode"); in dsi_mgr_parse_of()
55 if (msm_dsim->is_bonded_dsi) { in dsi_mgr_parse_of()
56 if (of_property_read_bool(np, "qcom,master-dsi")) in dsi_mgr_parse_of()
57 msm_dsim->master_dsi_link_id = id; in dsi_mgr_parse_of()
58 if (!msm_dsim->is_sync_needed) in dsi_mgr_parse_of()
59 msm_dsim->is_sync_needed = of_property_read_bool( in dsi_mgr_parse_of()
60 np, "qcom,sync-dual-dsi"); in dsi_mgr_parse_of()
75 ret = msm_dsi_host_register(msm_dsi->host, true); in dsi_mgr_setup_components()
79 msm_dsi_phy_set_usecase(msm_dsi->phy, MSM_DSI_PHY_STANDALONE); in dsi_mgr_setup_components()
80 ret = msm_dsi_host_set_src_pll(msm_dsi->host, msm_dsi->phy); in dsi_mgr_setup_components()
88 /* Register slave host first, so that slave DSI device in dsi_mgr_setup_components()
90 * DSI device's probe. in dsi_mgr_setup_components()
92 * because only master DSI device adds the panel to global in dsi_mgr_setup_components()
93 * panel list. The panel's device is the master DSI device. in dsi_mgr_setup_components()
95 ret = msm_dsi_host_register(slave_link_dsi->host, false); in dsi_mgr_setup_components()
98 ret = msm_dsi_host_register(master_link_dsi->host, true); in dsi_mgr_setup_components()
102 /* PLL0 is to drive both 2 DSI link clocks in bonded DSI mode. */ in dsi_mgr_setup_components()
103 msm_dsi_phy_set_usecase(clk_master_dsi->phy, in dsi_mgr_setup_components()
105 msm_dsi_phy_set_usecase(clk_slave_dsi->phy, in dsi_mgr_setup_components()
107 ret = msm_dsi_host_set_src_pll(msm_dsi->host, clk_master_dsi->phy); in dsi_mgr_setup_components()
110 ret = msm_dsi_host_set_src_pll(other_dsi->host, clk_master_dsi->phy); in dsi_mgr_setup_components()
123 msm_dsi_host_get_phy_clk_req(msm_dsi->host, &clk_req, is_bonded_dsi); in enable_phy()
125 ret = msm_dsi_phy_enable(msm_dsi->phy, &clk_req, shared_timings); in enable_phy()
139 /* In case of bonded DSI, some registers in PHY1 have been programmed in dsi_mgr_phy_enable()
145 if (!mdsi->phy_enabled && !sdsi->phy_enabled) { in dsi_mgr_phy_enable()
146 msm_dsi_host_reset_phy(mdsi->host); in dsi_mgr_phy_enable()
147 msm_dsi_host_reset_phy(sdsi->host); in dsi_mgr_phy_enable()
156 msm_dsi_phy_disable(mdsi->phy); in dsi_mgr_phy_enable()
161 msm_dsi_host_reset_phy(msm_dsi->host); in dsi_mgr_phy_enable()
167 msm_dsi->phy_enabled = true; in dsi_mgr_phy_enable()
178 /* disable DSI phy in dsi_mgr_phy_disable()
179 * In bonded dsi configuration, the phy should be disabled for the in dsi_mgr_phy_disable()
182 msm_dsi->phy_enabled = false; in dsi_mgr_phy_disable()
184 if (!mdsi->phy_enabled && !sdsi->phy_enabled) { in dsi_mgr_phy_disable()
185 msm_dsi_phy_disable(sdsi->phy); in dsi_mgr_phy_disable()
186 msm_dsi_phy_disable(mdsi->phy); in dsi_mgr_phy_disable()
189 msm_dsi_phy_disable(msm_dsi->phy); in dsi_mgr_phy_disable()
209 return dsi_connector->id; in dsi_mgr_connector_get_id()
215 return dsi_bridge->id; in dsi_mgr_bridge_get_id()
220 struct msm_drm_private *priv = conn->dev->dev_private; in msm_dsi_manager_panel_init()
221 struct msm_kms *kms = priv->kms; in msm_dsi_manager_panel_init()
236 * There is only 1 panel in the global panel list for bonded DSI mode. in msm_dsi_manager_panel_init()
237 * Therefore slave dsi should get the drm_panel instance from master in msm_dsi_manager_panel_init()
238 * dsi. in msm_dsi_manager_panel_init()
240 panel = msm_dsi_host_get_panel(master_dsi->host); in msm_dsi_manager_panel_init()
242 DRM_ERROR("Could not find panel for %u (%ld)\n", msm_dsi->id, in msm_dsi_manager_panel_init()
250 drm_object_attach_property(&conn->base, in msm_dsi_manager_panel_init()
251 conn->dev->mode_config.tile_property, 0); in msm_dsi_manager_panel_init()
254 * Set split display info to kms once bonded DSI panel is connected to in msm_dsi_manager_panel_init()
257 if (other_dsi && other_dsi->panel && kms->funcs->set_split_display) { in msm_dsi_manager_panel_init()
258 kms->funcs->set_split_display(kms, master_dsi->encoder, in msm_dsi_manager_panel_init()
259 slave_dsi->encoder, in msm_dsi_manager_panel_init()
264 msm_dsi->panel = panel; in msm_dsi_manager_panel_init()
274 return msm_dsi->panel ? connector_status_connected : in dsi_mgr_connector_detect()
293 struct drm_panel *panel = msm_dsi->panel; in dsi_mgr_connector_get_modes()
300 * In bonded DSI mode, we have one connector that can be in dsi_mgr_connector_get_modes()
316 struct msm_drm_private *priv = connector->dev->dev_private; in dsi_mgr_connector_mode_valid()
317 struct msm_kms *kms = priv->kms; in dsi_mgr_connector_mode_valid()
321 requested = 1000 * mode->clock; in dsi_mgr_connector_mode_valid()
322 actual = kms->funcs->round_pixclk(kms, requested, encoder); in dsi_mgr_connector_mode_valid()
346 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_pre_enable()
347 struct drm_panel *panel = msm_dsi->panel; in dsi_mgr_bridge_pre_enable()
356 /* Do nothing with the host if it is slave-DSI in case of bonded DSI */ in dsi_mgr_bridge_pre_enable()
364 ret = msm_dsi_host_power_on(host, &phy_shared_timings[id], is_bonded_dsi, msm_dsi->phy); in dsi_mgr_bridge_pre_enable()
371 ret = msm_dsi_host_power_on(msm_dsi1->host, in dsi_mgr_bridge_pre_enable()
372 &phy_shared_timings[DSI_1], is_bonded_dsi, msm_dsi1->phy); in dsi_mgr_bridge_pre_enable()
399 ret = msm_dsi_host_enable(msm_dsi1->host); in dsi_mgr_bridge_pre_enable()
415 msm_dsi_host_power_off(msm_dsi1->host); in dsi_mgr_bridge_pre_enable()
429 /* if dual dsi, trigger tpg on master first then slave */ in msm_dsi_manager_tpg_enable()
431 msm_dsi_host_test_pattern_en(m_dsi->host); in msm_dsi_manager_tpg_enable()
433 msm_dsi_host_test_pattern_en(s_dsi->host); in msm_dsi_manager_tpg_enable()
441 struct drm_panel *panel = msm_dsi->panel; in dsi_mgr_bridge_enable()
449 /* Do nothing with the host if it is slave-DSI in case of bonded DSI */ in dsi_mgr_bridge_enable()
466 struct drm_panel *panel = msm_dsi->panel; in dsi_mgr_bridge_disable()
474 /* Do nothing with the host if it is slave-DSI in case of bonded DSI */ in dsi_mgr_bridge_disable()
491 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_post_disable()
492 struct drm_panel *panel = msm_dsi->panel; in dsi_mgr_bridge_post_disable()
502 * Do nothing with the host if it is slave-DSI in case of bonded DSI. in dsi_mgr_bridge_post_disable()
503 * It is safe to call dsi_mgr_phy_disable() here because a single PHY in dsi_mgr_bridge_post_disable()
514 ret = msm_dsi_host_disable(msm_dsi1->host); in dsi_mgr_bridge_post_disable()
526 /* Save PHY status if it is a clock source */ in dsi_mgr_bridge_post_disable()
527 msm_dsi_phy_pll_save_state(msm_dsi->phy); in dsi_mgr_bridge_post_disable()
534 ret = msm_dsi_host_power_off(msm_dsi1->host); in dsi_mgr_bridge_post_disable()
551 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_mode_set()
561 msm_dsi_host_set_display_mode(other_dsi->host, adjusted_mode); in dsi_mgr_bridge_mode_set()
597 return ERR_PTR(-ENOMEM); in msm_dsi_manager_connector_init()
599 dsi_connector->id = id; in msm_dsi_manager_connector_init()
601 connector = &dsi_connector->base; in msm_dsi_manager_connector_init()
603 ret = drm_connector_init(msm_dsi->dev, connector, in msm_dsi_manager_connector_init()
613 connector->polled = DRM_CONNECTOR_POLL_HPD; in msm_dsi_manager_connector_init()
616 connector->interlace_allowed = 0; in msm_dsi_manager_connector_init()
617 connector->doublescan_allowed = 0; in msm_dsi_manager_connector_init()
619 drm_connector_attach_encoder(connector, msm_dsi->encoder); in msm_dsi_manager_connector_init()
623 DRM_DEV_ERROR(msm_dsi->dev->dev, "init panel failed %d\n", ret); in msm_dsi_manager_connector_init()
630 connector->funcs->destroy(msm_dsi->connector); in msm_dsi_manager_connector_init()
639 * For bonded DSI, we only have one drm panel. For this in msm_dsi_manager_validate_current_config()
642 * slave-DSI for bonded DSI configuration. in msm_dsi_manager_validate_current_config()
645 DBG("Skip bridge registration for slave DSI->id: %d\n", id); in msm_dsi_manager_validate_current_config()
660 dsi_bridge = devm_kzalloc(msm_dsi->dev->dev, in msm_dsi_manager_bridge_init()
663 ret = -ENOMEM; in msm_dsi_manager_bridge_init()
667 dsi_bridge->id = id; in msm_dsi_manager_bridge_init()
669 encoder = msm_dsi->encoder; in msm_dsi_manager_bridge_init()
671 bridge = &dsi_bridge->base; in msm_dsi_manager_bridge_init()
672 bridge->funcs = &dsi_mgr_bridge_funcs; in msm_dsi_manager_bridge_init()
690 struct drm_device *dev = msm_dsi->dev; in msm_dsi_manager_ext_bridge_init()
696 int_bridge = msm_dsi->bridge; in msm_dsi_manager_ext_bridge_init()
697 ext_bridge = msm_dsi->external_bridge = in msm_dsi_manager_ext_bridge_init()
698 msm_dsi_host_get_bridge(msm_dsi->host); in msm_dsi_manager_ext_bridge_init()
700 encoder = msm_dsi->encoder; in msm_dsi_manager_ext_bridge_init()
702 /* link the internal dsi bridge to the external bridge */ in msm_dsi_manager_ext_bridge_init()
708 * priv->connector[] list, mainly for msm_fbdev_init() in msm_dsi_manager_ext_bridge_init()
710 connector_list = &dev->mode_config.connector_list; in msm_dsi_manager_ext_bridge_init()
717 return ERR_PTR(-ENODEV); in msm_dsi_manager_ext_bridge_init()
728 struct mipi_dsi_host *host = msm_dsi->host; in msm_dsi_manager_cmd_xfer()
729 bool is_read = (msg->rx_buf && msg->rx_len); in msm_dsi_manager_cmd_xfer()
733 if (!msg->tx_buf || !msg->tx_len) in msm_dsi_manager_cmd_xfer()
737 * both DSI links. Host issues the command trigger to both links in msm_dsi_manager_cmd_xfer()
742 return is_read ? msg->rx_len : msg->tx_len; in msm_dsi_manager_cmd_xfer()
745 ret = msm_dsi_host_xfer_prepare(msm_dsi0->host, msg); in msm_dsi_manager_cmd_xfer()
747 pr_err("%s: failed to prepare non-trigger host, %d\n", in msm_dsi_manager_cmd_xfer()
765 msm_dsi_host_xfer_restore(msm_dsi0->host, msg); in msm_dsi_manager_cmd_xfer()
774 struct mipi_dsi_host *host = msm_dsi->host; in msm_dsi_manager_cmd_xfer_trigger()
780 msm_dsi_host_cmd_xfer_commit(msm_dsi0->host, dma_base, len); in msm_dsi_manager_cmd_xfer_trigger()
790 int id = msm_dsi->id; in msm_dsi_manager_register()
795 return -EINVAL; in msm_dsi_manager_register()
798 if (msm_dsim->dsi[id]) { in msm_dsi_manager_register()
799 pr_err("%s: dsi%d already registered\n", __func__, id); in msm_dsi_manager_register()
800 return -EBUSY; in msm_dsi_manager_register()
803 msm_dsim->dsi[id] = msm_dsi; in msm_dsi_manager_register()
805 ret = dsi_mgr_parse_of(msm_dsi->pdev->dev.of_node, id); in msm_dsi_manager_register()
807 pr_err("%s: failed to parse OF DSI info\n", __func__); in msm_dsi_manager_register()
813 pr_err("%s: failed to register mipi dsi host for DSI %d: %d\n", in msm_dsi_manager_register()
821 msm_dsim->dsi[id] = NULL; in msm_dsi_manager_register()
829 if (msm_dsi->host) in msm_dsi_manager_unregister()
830 msm_dsi_host_unregister(msm_dsi->host); in msm_dsi_manager_unregister()
832 if (msm_dsi->id >= 0) in msm_dsi_manager_unregister()
833 msm_dsim->dsi[msm_dsi->id] = NULL; in msm_dsi_manager_unregister()
843 return IS_MASTER_DSI_LINK(msm_dsi->id); in msm_dsi_is_master_dsi()