Lines Matching +full:host +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0-only
35 #define IS_MASTER_DSI_LINK(id) (msm_dsim_glb.master_dsi_link_id == id) argument
37 static inline struct msm_dsi *dsi_mgr_get_dsi(int id) in dsi_mgr_get_dsi() argument
39 return msm_dsim_glb.dsi[id]; in dsi_mgr_get_dsi()
42 static inline struct msm_dsi *dsi_mgr_get_other_dsi(int id) in dsi_mgr_get_other_dsi() argument
44 return msm_dsim_glb.dsi[(id + 1) % DSI_MAX]; in dsi_mgr_get_other_dsi()
47 static int dsi_mgr_parse_of(struct device_node *np, int id) in dsi_mgr_parse_of() argument
52 * sync-mode, and only one node specifies master in case of bonded mode. in dsi_mgr_parse_of()
54 if (!msm_dsim->is_bonded_dsi) in dsi_mgr_parse_of()
55 msm_dsim->is_bonded_dsi = of_property_read_bool(np, "qcom,dual-dsi-mode"); in dsi_mgr_parse_of()
57 if (msm_dsim->is_bonded_dsi) { in dsi_mgr_parse_of()
58 if (of_property_read_bool(np, "qcom,master-dsi")) in dsi_mgr_parse_of()
59 msm_dsim->master_dsi_link_id = id; in dsi_mgr_parse_of()
60 if (!msm_dsim->is_sync_needed) in dsi_mgr_parse_of()
61 msm_dsim->is_sync_needed = of_property_read_bool( in dsi_mgr_parse_of()
62 np, "qcom,sync-dual-dsi"); in dsi_mgr_parse_of()
68 static int dsi_mgr_setup_components(int id) in dsi_mgr_setup_components() argument
70 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_setup_components()
71 struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id); in dsi_mgr_setup_components()
77 ret = msm_dsi_host_register(msm_dsi->host); in dsi_mgr_setup_components()
81 msm_dsi_phy_set_usecase(msm_dsi->phy, MSM_DSI_PHY_STANDALONE); in dsi_mgr_setup_components()
82 msm_dsi_host_set_phy_mode(msm_dsi->host, msm_dsi->phy); in dsi_mgr_setup_components()
84 struct msm_dsi *master_link_dsi = IS_MASTER_DSI_LINK(id) ? in dsi_mgr_setup_components()
86 struct msm_dsi *slave_link_dsi = IS_MASTER_DSI_LINK(id) ? in dsi_mgr_setup_components()
88 /* Register slave host first, so that slave DSI device in dsi_mgr_setup_components()
91 * Also, do not check defer for the slave host, in dsi_mgr_setup_components()
95 ret = msm_dsi_host_register(slave_link_dsi->host); in dsi_mgr_setup_components()
98 ret = msm_dsi_host_register(master_link_dsi->host); 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 msm_dsi_host_set_phy_mode(msm_dsi->host, msm_dsi->phy); in dsi_mgr_setup_components()
108 msm_dsi_host_set_phy_mode(other_dsi->host, other_dsi->phy); in dsi_mgr_setup_components()
120 msm_dsi_host_get_phy_clk_req(msm_dsi->host, &clk_req, is_bonded_dsi); in enable_phy()
122 return msm_dsi_phy_enable(msm_dsi->phy, &clk_req, shared_timings); in enable_phy()
126 dsi_mgr_phy_enable(int id, in dsi_mgr_phy_enable() argument
129 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_phy_enable()
140 if (!mdsi->phy_enabled && !sdsi->phy_enabled) { in dsi_mgr_phy_enable()
141 msm_dsi_host_reset_phy(mdsi->host); in dsi_mgr_phy_enable()
142 msm_dsi_host_reset_phy(sdsi->host); in dsi_mgr_phy_enable()
151 msm_dsi_phy_disable(mdsi->phy); in dsi_mgr_phy_enable()
156 msm_dsi_host_reset_phy(msm_dsi->host); in dsi_mgr_phy_enable()
157 ret = enable_phy(msm_dsi, &shared_timings[id]); in dsi_mgr_phy_enable()
162 msm_dsi->phy_enabled = true; in dsi_mgr_phy_enable()
167 static void dsi_mgr_phy_disable(int id) in dsi_mgr_phy_disable() argument
169 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_phy_disable()
177 msm_dsi->phy_enabled = false; in dsi_mgr_phy_disable()
179 if (!mdsi->phy_enabled && !sdsi->phy_enabled) { in dsi_mgr_phy_disable()
180 msm_dsi_phy_disable(sdsi->phy); in dsi_mgr_phy_disable()
181 msm_dsi_phy_disable(mdsi->phy); in dsi_mgr_phy_disable()
184 msm_dsi_phy_disable(msm_dsi->phy); in dsi_mgr_phy_disable()
190 int id; member
198 return dsi_bridge->id; in dsi_mgr_bridge_get_id()
203 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_power_on() local
204 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_power_on()
206 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_power_on() local
211 DBG("id=%d", id); in dsi_mgr_bridge_power_on()
213 ret = dsi_mgr_phy_enable(id, phy_shared_timings); in dsi_mgr_bridge_power_on()
217 ret = msm_dsi_host_power_on(host, &phy_shared_timings[id], is_bonded_dsi, msm_dsi->phy); in dsi_mgr_bridge_power_on()
219 pr_err("%s: power on host %d failed, %d\n", __func__, id, ret); in dsi_mgr_bridge_power_on()
224 ret = msm_dsi_host_power_on(msm_dsi1->host, in dsi_mgr_bridge_power_on()
225 &phy_shared_timings[DSI_1], is_bonded_dsi, msm_dsi1->phy); in dsi_mgr_bridge_power_on()
237 msm_dsi_host_enable_irq(host); in dsi_mgr_bridge_power_on()
239 msm_dsi_host_enable_irq(msm_dsi1->host); in dsi_mgr_bridge_power_on()
244 msm_dsi_host_power_off(host); in dsi_mgr_bridge_power_on()
246 dsi_mgr_phy_disable(id); in dsi_mgr_bridge_power_on()
253 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_power_off() local
254 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_power_off()
256 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_power_off() local
259 msm_dsi_host_disable_irq(host); in dsi_mgr_bridge_power_off()
261 msm_dsi_host_disable_irq(msm_dsi1->host); in dsi_mgr_bridge_power_off()
262 msm_dsi_host_power_off(msm_dsi1->host); in dsi_mgr_bridge_power_off()
264 msm_dsi_host_power_off(host); in dsi_mgr_bridge_power_off()
265 dsi_mgr_phy_disable(id); in dsi_mgr_bridge_power_off()
270 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_pre_enable() local
271 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_pre_enable()
273 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_pre_enable() local
277 DBG("id=%d", id); in dsi_mgr_bridge_pre_enable()
279 /* Do nothing with the host if it is slave-DSI in case of bonded DSI */ in dsi_mgr_bridge_pre_enable()
280 if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) in dsi_mgr_bridge_pre_enable()
285 dev_err(&msm_dsi->pdev->dev, "Power on failed: %d\n", ret); in dsi_mgr_bridge_pre_enable()
289 ret = msm_dsi_host_enable(host); in dsi_mgr_bridge_pre_enable()
291 pr_err("%s: enable host %d failed, %d\n", __func__, id, ret); in dsi_mgr_bridge_pre_enable()
296 ret = msm_dsi_host_enable(msm_dsi1->host); in dsi_mgr_bridge_pre_enable()
306 msm_dsi_host_disable(host); in dsi_mgr_bridge_pre_enable()
318 msm_dsi_host_test_pattern_en(m_dsi->host); in msm_dsi_manager_tpg_enable()
320 msm_dsi_host_test_pattern_en(s_dsi->host); in msm_dsi_manager_tpg_enable()
326 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_post_disable() local
327 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_post_disable()
329 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_post_disable() local
333 DBG("id=%d", id); in dsi_mgr_bridge_post_disable()
336 * Do nothing with the host if it is slave-DSI in case of bonded DSI. in dsi_mgr_bridge_post_disable()
340 if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) in dsi_mgr_bridge_post_disable()
343 ret = msm_dsi_host_disable(host); in dsi_mgr_bridge_post_disable()
345 pr_err("%s: host %d disable failed, %d\n", __func__, id, ret); in dsi_mgr_bridge_post_disable()
348 ret = msm_dsi_host_disable(msm_dsi1->host); in dsi_mgr_bridge_post_disable()
353 msm_dsi_host_disable_irq(host); in dsi_mgr_bridge_post_disable()
355 msm_dsi_host_disable_irq(msm_dsi1->host); in dsi_mgr_bridge_post_disable()
358 msm_dsi_phy_pll_save_state(msm_dsi->phy); in dsi_mgr_bridge_post_disable()
360 ret = msm_dsi_host_power_off(host); in dsi_mgr_bridge_post_disable()
362 pr_err("%s: host %d power off failed,%d\n", __func__, id, ret); in dsi_mgr_bridge_post_disable()
365 ret = msm_dsi_host_power_off(msm_dsi1->host); in dsi_mgr_bridge_post_disable()
372 dsi_mgr_phy_disable(id); in dsi_mgr_bridge_post_disable()
379 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_mode_set() local
380 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_mode_set()
381 struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id); in dsi_mgr_bridge_mode_set()
382 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_mode_set() local
387 if (is_bonded_dsi && !IS_MASTER_DSI_LINK(id)) in dsi_mgr_bridge_mode_set()
390 msm_dsi_host_set_display_mode(host, adjusted_mode); in dsi_mgr_bridge_mode_set()
392 msm_dsi_host_set_display_mode(other_dsi->host, adjusted_mode); in dsi_mgr_bridge_mode_set()
399 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_mode_valid() local
400 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_mode_valid()
401 struct mipi_dsi_host *host = msm_dsi->host; in dsi_mgr_bridge_mode_valid() local
402 struct platform_device *pdev = msm_dsi->pdev; in dsi_mgr_bridge_mode_valid()
406 byte_clk_rate = dsi_byte_clk_get_rate(host, IS_BONDED_DSI(), mode); in dsi_mgr_bridge_mode_valid()
408 opp = dev_pm_opp_find_freq_ceil(&pdev->dev, &byte_clk_rate); in dsi_mgr_bridge_mode_valid()
411 } else if (PTR_ERR(opp) == -ERANGE) { in dsi_mgr_bridge_mode_valid()
415 * -ERANGE in such case. in dsi_mgr_bridge_mode_valid()
417 if (dev_pm_opp_get_opp_count(&pdev->dev) != 0) in dsi_mgr_bridge_mode_valid()
423 return msm_dsi_host_check_dsc(host, mode); in dsi_mgr_bridge_mode_valid()
429 int id = dsi_mgr_bridge_get_id(bridge); in dsi_mgr_bridge_attach() local
430 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in dsi_mgr_bridge_attach()
432 return drm_bridge_attach(bridge->encoder, msm_dsi->next_bridge, in dsi_mgr_bridge_attach()
448 struct drm_device *dev = msm_dsi->dev; in msm_dsi_manager_connector_init()
454 dsi_bridge = devm_kzalloc(msm_dsi->dev->dev, in msm_dsi_manager_connector_init()
457 return -ENOMEM; in msm_dsi_manager_connector_init()
459 dsi_bridge->id = msm_dsi->id; in msm_dsi_manager_connector_init()
461 bridge = &dsi_bridge->base; in msm_dsi_manager_connector_init()
462 bridge->funcs = &dsi_mgr_bridge_funcs; in msm_dsi_manager_connector_init()
464 ret = devm_drm_bridge_add(msm_dsi->dev->dev, bridge); in msm_dsi_manager_connector_init()
485 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg) in msm_dsi_manager_cmd_xfer() argument
487 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in msm_dsi_manager_cmd_xfer()
489 struct mipi_dsi_host *host = msm_dsi->host; in msm_dsi_manager_cmd_xfer() local
490 bool is_read = (msg->rx_buf && msg->rx_len); in msm_dsi_manager_cmd_xfer()
494 if (!msg->tx_buf || !msg->tx_len) in msm_dsi_manager_cmd_xfer()
498 * both DSI links. Host issues the command trigger to both links in msm_dsi_manager_cmd_xfer()
502 if (need_sync && (id == DSI_0)) in msm_dsi_manager_cmd_xfer()
503 return is_read ? msg->rx_len : msg->tx_len; in msm_dsi_manager_cmd_xfer()
506 ret = msm_dsi_host_xfer_prepare(msm_dsi0->host, msg); in msm_dsi_manager_cmd_xfer()
508 pr_err("%s: failed to prepare non-trigger host, %d\n", in msm_dsi_manager_cmd_xfer()
513 ret = msm_dsi_host_xfer_prepare(host, msg); in msm_dsi_manager_cmd_xfer()
515 pr_err("%s: failed to prepare host, %d\n", __func__, ret); in msm_dsi_manager_cmd_xfer()
519 ret = is_read ? msm_dsi_host_cmd_rx(host, msg) : in msm_dsi_manager_cmd_xfer()
520 msm_dsi_host_cmd_tx(host, msg); in msm_dsi_manager_cmd_xfer()
522 msm_dsi_host_xfer_restore(host, msg); in msm_dsi_manager_cmd_xfer()
526 msm_dsi_host_xfer_restore(msm_dsi0->host, msg); in msm_dsi_manager_cmd_xfer()
531 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len) in msm_dsi_manager_cmd_xfer_trigger() argument
533 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); in msm_dsi_manager_cmd_xfer_trigger()
535 struct mipi_dsi_host *host = msm_dsi->host; in msm_dsi_manager_cmd_xfer_trigger() local
537 if (IS_SYNC_NEEDED() && (id == DSI_0)) in msm_dsi_manager_cmd_xfer_trigger()
541 msm_dsi_host_cmd_xfer_commit(msm_dsi0->host, dma_base, len); in msm_dsi_manager_cmd_xfer_trigger()
543 msm_dsi_host_cmd_xfer_commit(host, dma_base, len); in msm_dsi_manager_cmd_xfer_trigger()
551 int id = msm_dsi->id; in msm_dsi_manager_register() local
554 if (id >= DSI_MAX) { in msm_dsi_manager_register()
555 pr_err("%s: invalid id %d\n", __func__, id); in msm_dsi_manager_register()
556 return -EINVAL; in msm_dsi_manager_register()
559 if (msm_dsim->dsi[id]) { in msm_dsi_manager_register()
560 pr_err("%s: dsi%d already registered\n", __func__, id); in msm_dsi_manager_register()
561 return -EBUSY; in msm_dsi_manager_register()
564 msm_dsim->dsi[id] = msm_dsi; in msm_dsi_manager_register()
566 ret = dsi_mgr_parse_of(msm_dsi->pdev->dev.of_node, id); in msm_dsi_manager_register()
572 ret = dsi_mgr_setup_components(id); in msm_dsi_manager_register()
574 pr_err("%s: failed to register mipi dsi host for DSI %d: %d\n", in msm_dsi_manager_register()
575 __func__, id, ret); in msm_dsi_manager_register()
582 msm_dsim->dsi[id] = NULL; in msm_dsi_manager_register()
590 if (msm_dsi->host) in msm_dsi_manager_unregister()
591 msm_dsi_host_unregister(msm_dsi->host); in msm_dsi_manager_unregister()
593 if (msm_dsi->id >= 0) in msm_dsi_manager_unregister()
594 msm_dsim->dsi[msm_dsi->id] = NULL; in msm_dsi_manager_unregister()
604 return IS_MASTER_DSI_LINK(msm_dsi->id); in msm_dsi_is_master_dsi()
609 return msm_dsi->te_source; in msm_dsi_get_te_source()