Lines Matching refs:msm_host
38 static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc);
197 static inline u32 dsi_read(struct msm_dsi_host *msm_host, u32 reg) in dsi_read() argument
199 return msm_readl(msm_host->ctrl_base + reg); in dsi_read()
201 static inline void dsi_write(struct msm_dsi_host *msm_host, u32 reg, u32 data) in dsi_write() argument
203 msm_writel(data, msm_host->ctrl_base + reg); in dsi_write()
207 struct msm_dsi_host *msm_host) in dsi_get_config() argument
210 struct device *dev = &msm_host->pdev->dev; in dsi_get_config()
215 ahb_clk = msm_clk_get(msm_host->pdev, "iface"); in dsi_get_config()
229 ret = dsi_get_version(msm_host->ctrl_base, &major, &minor); in dsi_get_config()
252 int dsi_clk_init_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_v2() argument
254 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_v2()
257 msm_host->src_clk = msm_clk_get(pdev, "src"); in dsi_clk_init_v2()
259 if (IS_ERR(msm_host->src_clk)) { in dsi_clk_init_v2()
260 ret = PTR_ERR(msm_host->src_clk); in dsi_clk_init_v2()
263 msm_host->src_clk = NULL; in dsi_clk_init_v2()
270 int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_6g_v2() argument
272 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_6g_v2()
275 msm_host->byte_intf_clk = msm_clk_get(pdev, "byte_intf"); in dsi_clk_init_6g_v2()
276 if (IS_ERR(msm_host->byte_intf_clk)) { in dsi_clk_init_6g_v2()
277 ret = PTR_ERR(msm_host->byte_intf_clk); in dsi_clk_init_6g_v2()
285 static int dsi_clk_init(struct msm_dsi_host *msm_host) in dsi_clk_init() argument
287 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init()
288 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_clk_init()
294 msm_host->bus_clks[i].id = cfg->bus_clk_names[i]; in dsi_clk_init()
295 msm_host->num_bus_clks = cfg->num_bus_clks; in dsi_clk_init()
297 ret = devm_clk_bulk_get(&pdev->dev, msm_host->num_bus_clks, msm_host->bus_clks); in dsi_clk_init()
304 msm_host->byte_clk = msm_clk_get(pdev, "byte"); in dsi_clk_init()
305 if (IS_ERR(msm_host->byte_clk)) { in dsi_clk_init()
306 ret = PTR_ERR(msm_host->byte_clk); in dsi_clk_init()
309 msm_host->byte_clk = NULL; in dsi_clk_init()
313 msm_host->pixel_clk = msm_clk_get(pdev, "pixel"); in dsi_clk_init()
314 if (IS_ERR(msm_host->pixel_clk)) { in dsi_clk_init()
315 ret = PTR_ERR(msm_host->pixel_clk); in dsi_clk_init()
318 msm_host->pixel_clk = NULL; in dsi_clk_init()
322 msm_host->esc_clk = msm_clk_get(pdev, "core"); in dsi_clk_init()
323 if (IS_ERR(msm_host->esc_clk)) { in dsi_clk_init()
324 ret = PTR_ERR(msm_host->esc_clk); in dsi_clk_init()
327 msm_host->esc_clk = NULL; in dsi_clk_init()
332 ret = cfg_hnd->ops->clk_init_ver(msm_host); in dsi_clk_init()
342 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_suspend() local
344 if (!msm_host->cfg_hnd) in msm_dsi_runtime_suspend()
347 clk_bulk_disable_unprepare(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_suspend()
357 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_resume() local
359 if (!msm_host->cfg_hnd) in msm_dsi_runtime_resume()
362 return clk_bulk_prepare_enable(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_resume()
365 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_6g() argument
370 msm_host->mode->clock, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
372 ret = dev_pm_opp_set_rate(&msm_host->pdev->dev, in dsi_link_clk_set_rate_6g()
373 msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
379 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_6g()
385 if (msm_host->byte_intf_clk) { in dsi_link_clk_set_rate_6g()
386 ret = clk_set_rate(msm_host->byte_intf_clk, msm_host->byte_intf_clk_rate); in dsi_link_clk_set_rate_6g()
398 int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_6g() argument
402 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_6g()
408 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_6g()
414 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
420 ret = clk_prepare_enable(msm_host->byte_intf_clk); in dsi_link_clk_enable_6g()
430 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
432 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_6g()
434 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_6g()
439 int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_v2() argument
444 msm_host->mode->clock, msm_host->byte_clk_rate, in dsi_link_clk_set_rate_v2()
445 msm_host->esc_clk_rate, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
447 ret = clk_set_rate(msm_host->byte_clk, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_v2()
453 ret = clk_set_rate(msm_host->esc_clk, msm_host->esc_clk_rate); in dsi_link_clk_set_rate_v2()
459 ret = clk_set_rate(msm_host->src_clk, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
465 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_v2()
474 int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_v2() argument
478 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_v2()
484 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_v2()
490 ret = clk_prepare_enable(msm_host->src_clk); in dsi_link_clk_enable_v2()
496 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_v2()
505 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_enable_v2()
507 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_v2()
509 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_v2()
514 void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_6g() argument
517 dev_pm_opp_set_rate(&msm_host->pdev->dev, 0); in dsi_link_clk_disable_6g()
518 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_6g()
519 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_6g()
520 clk_disable_unprepare(msm_host->byte_intf_clk); in dsi_link_clk_disable_6g()
521 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_6g()
524 void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_v2() argument
526 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_v2()
527 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_disable_v2()
528 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_v2()
529 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_v2()
568 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_byte_clk_get_rate() local
569 u8 lanes = msm_host->lanes; in dsi_byte_clk_get_rate()
570 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_byte_clk_get_rate()
571 unsigned long pclk_rate = dsi_get_pclk_rate(mode, msm_host->dsc, is_bonded_dsi); in dsi_byte_clk_get_rate()
580 if (msm_host->cphy_mode) in dsi_byte_clk_get_rate()
588 static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_pclk() argument
590 msm_host->pixel_clk_rate = dsi_get_pclk_rate(msm_host->mode, msm_host->dsc, is_bonded_dsi); in dsi_calc_pclk()
591 msm_host->byte_clk_rate = dsi_byte_clk_get_rate(&msm_host->base, is_bonded_dsi, in dsi_calc_pclk()
592 msm_host->mode); in dsi_calc_pclk()
594 DBG("pclk=%lu, bclk=%lu", msm_host->pixel_clk_rate, in dsi_calc_pclk()
595 msm_host->byte_clk_rate); in dsi_calc_pclk()
599 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_6g() argument
601 if (!msm_host->mode) { in dsi_calc_clk_rate_6g()
606 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_6g()
607 msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); in dsi_calc_clk_rate_6g()
611 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_v2() argument
613 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_clk_rate_v2()
617 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_v2()
619 msm_host->src_clk_rate = mult_frac(msm_host->pixel_clk_rate, bpp, 8); in dsi_calc_clk_rate_v2()
630 byte_mhz = msm_host->byte_clk_rate / 1000000; in dsi_calc_clk_rate_v2()
648 msm_host->esc_clk_rate = msm_host->byte_clk_rate / esc_div; in dsi_calc_clk_rate_v2()
650 DBG("esc=%lu, src=%lu", msm_host->esc_clk_rate, in dsi_calc_clk_rate_v2()
651 msm_host->src_clk_rate); in dsi_calc_clk_rate_v2()
656 static void dsi_intr_ctrl(struct msm_dsi_host *msm_host, u32 mask, int enable) in dsi_intr_ctrl() argument
661 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
662 intr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_intr_ctrl()
671 dsi_write(msm_host, REG_DSI_INTR_CTRL, intr); in dsi_intr_ctrl()
672 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
709 static void dsi_ctrl_disable(struct msm_dsi_host *msm_host) in dsi_ctrl_disable() argument
711 dsi_write(msm_host, REG_DSI_CTRL, 0); in dsi_ctrl_disable()
714 static void dsi_ctrl_enable(struct msm_dsi_host *msm_host, in dsi_ctrl_enable() argument
717 u32 flags = msm_host->mode_flags; in dsi_ctrl_enable()
718 enum mipi_dsi_pixel_format mipi_fmt = msm_host->format; in dsi_ctrl_enable()
719 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_ctrl_enable()
738 data |= DSI_VID_CFG0_VIRT_CHANNEL(msm_host->channel); in dsi_ctrl_enable()
739 dsi_write(msm_host, REG_DSI_VID_CFG0, data); in dsi_ctrl_enable()
743 dsi_write(msm_host, REG_DSI_VID_CFG1, 0); in dsi_ctrl_enable()
748 dsi_write(msm_host, REG_DSI_CMD_CFG0, data); in dsi_ctrl_enable()
755 dsi_write(msm_host, REG_DSI_CMD_CFG1, data); in dsi_ctrl_enable()
757 if (msm_host->cfg_hnd->major == MSM_DSI_VER_MAJOR_6G && in dsi_ctrl_enable()
758 msm_host->cfg_hnd->minor >= MSM_DSI_6G_VER_MINOR_V1_3) { in dsi_ctrl_enable()
759 data = dsi_read(msm_host, REG_DSI_CMD_MODE_MDP_CTRL2); in dsi_ctrl_enable()
761 dsi_write(msm_host, REG_DSI_CMD_MODE_MDP_CTRL2, data); in dsi_ctrl_enable()
765 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, in dsi_ctrl_enable()
774 data |= DSI_TRIG_CTRL_STREAM(msm_host->channel); in dsi_ctrl_enable()
778 dsi_write(msm_host, REG_DSI_TRIG_CTRL, data); in dsi_ctrl_enable()
782 dsi_write(msm_host, REG_DSI_CLKOUT_TIMING_CTRL, data); in dsi_ctrl_enable()
787 dsi_write(msm_host, REG_DSI_T_CLK_PRE_EXTEND, in dsi_ctrl_enable()
793 dsi_write(msm_host, REG_DSI_EOT_PACKET_CTRL, data); in dsi_ctrl_enable()
796 dsi_write(msm_host, REG_DSI_ERR_INT_MASK0, 0x13ff3fe0); in dsi_ctrl_enable()
798 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_ctrl_enable()
800 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_ctrl_enable()
804 DBG("lane number=%d", msm_host->lanes); in dsi_ctrl_enable()
805 data |= ((DSI_CTRL_LANE0 << msm_host->lanes) - DSI_CTRL_LANE0); in dsi_ctrl_enable()
807 dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL, in dsi_ctrl_enable()
808 DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(msm_host->dlane_swap)); in dsi_ctrl_enable()
811 lane_ctrl = dsi_read(msm_host, REG_DSI_LANE_CTRL); in dsi_ctrl_enable()
816 dsi_write(msm_host, REG_DSI_LANE_CTRL, in dsi_ctrl_enable()
822 dsi_write(msm_host, REG_DSI_CTRL, data); in dsi_ctrl_enable()
824 if (msm_host->cphy_mode) in dsi_ctrl_enable()
825 dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0)); in dsi_ctrl_enable()
828 static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mode, u32 hdisplay) in dsi_update_dsc_timing() argument
830 struct drm_dsc_config *dsc = msm_host->dsc; in dsi_update_dsc_timing()
867 reg_ctrl = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL); in dsi_update_dsc_timing()
868 reg_ctrl2 = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2); in dsi_update_dsc_timing()
876 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl); in dsi_update_dsc_timing()
877 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2); in dsi_update_dsc_timing()
879 dsi_write(msm_host, REG_DSI_VIDEO_COMPRESSION_MODE_CTRL, reg); in dsi_update_dsc_timing()
883 static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_timing_setup() argument
885 struct drm_display_mode *mode = msm_host->mode; in dsi_timing_setup()
916 if (msm_host->dsc) { in dsi_timing_setup()
917 struct drm_dsc_config *dsc = msm_host->dsc; in dsi_timing_setup()
933 ret = dsi_populate_dsc_params(msm_host, dsc); in dsi_timing_setup()
941 hdisplay = DIV_ROUND_UP(msm_dsc_get_bytes_per_line(msm_host->dsc), 3); in dsi_timing_setup()
946 if (msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) { in dsi_timing_setup()
947 if (msm_host->dsc) in dsi_timing_setup()
948 dsi_update_dsc_timing(msm_host, false, mode->hdisplay); in dsi_timing_setup()
950 dsi_write(msm_host, REG_DSI_ACTIVE_H, in dsi_timing_setup()
953 dsi_write(msm_host, REG_DSI_ACTIVE_V, in dsi_timing_setup()
956 dsi_write(msm_host, REG_DSI_TOTAL, in dsi_timing_setup()
960 dsi_write(msm_host, REG_DSI_ACTIVE_HSYNC, in dsi_timing_setup()
963 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_HPOS, 0); in dsi_timing_setup()
964 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_VPOS, in dsi_timing_setup()
968 if (msm_host->dsc) in dsi_timing_setup()
969 dsi_update_dsc_timing(msm_host, true, mode->hdisplay); in dsi_timing_setup()
972 if (!msm_host->dsc) in dsi_timing_setup()
973 wc = hdisplay * dsi_get_bpp(msm_host->format) / 8 + 1; in dsi_timing_setup()
982 wc = msm_host->dsc->slice_chunk_size + 1; in dsi_timing_setup()
984 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_CTRL, in dsi_timing_setup()
987 msm_host->channel) | in dsi_timing_setup()
991 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_TOTAL, in dsi_timing_setup()
997 static void dsi_sw_reset(struct msm_dsi_host *msm_host) in dsi_sw_reset() argument
1001 ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_sw_reset()
1004 dsi_write(msm_host, REG_DSI_CTRL, ctrl & ~DSI_CTRL_ENABLE); in dsi_sw_reset()
1012 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset()
1016 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset()
1018 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset()
1022 dsi_write(msm_host, REG_DSI_CTRL, ctrl); in dsi_sw_reset()
1027 static void dsi_op_mode_config(struct msm_dsi_host *msm_host, in dsi_op_mode_config() argument
1032 dsi_ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_op_mode_config()
1037 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE | in dsi_op_mode_config()
1044 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE, 1); in dsi_op_mode_config()
1049 dsi_write(msm_host, REG_DSI_CTRL, dsi_ctrl); in dsi_op_mode_config()
1052 static void dsi_set_tx_power_mode(int mode, struct msm_dsi_host *msm_host) in dsi_set_tx_power_mode() argument
1056 data = dsi_read(msm_host, REG_DSI_CMD_DMA_CTRL); in dsi_set_tx_power_mode()
1063 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, data); in dsi_set_tx_power_mode()
1066 static void dsi_wait4video_done(struct msm_dsi_host *msm_host) in dsi_wait4video_done() argument
1069 struct device *dev = &msm_host->pdev->dev; in dsi_wait4video_done()
1071 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 1); in dsi_wait4video_done()
1073 reinit_completion(&msm_host->video_comp); in dsi_wait4video_done()
1075 ret = wait_for_completion_timeout(&msm_host->video_comp, in dsi_wait4video_done()
1081 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0); in dsi_wait4video_done()
1084 static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host) in dsi_wait4video_eng_busy() argument
1088 if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO)) in dsi_wait4video_eng_busy()
1091 data = dsi_read(msm_host, REG_DSI_STATUS0); in dsi_wait4video_eng_busy()
1101 if (msm_host->power_on && msm_host->enabled) { in dsi_wait4video_eng_busy()
1102 dsi_wait4video_done(msm_host); in dsi_wait4video_eng_busy()
1108 int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_6g() argument
1110 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_6g()
1115 msm_host->aspace = msm_gem_address_space_get(priv->kms->aspace); in dsi_tx_buf_alloc_6g()
1118 msm_host->aspace, in dsi_tx_buf_alloc_6g()
1119 &msm_host->tx_gem_obj, &iova); in dsi_tx_buf_alloc_6g()
1122 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_alloc_6g()
1126 msm_gem_object_set_name(msm_host->tx_gem_obj, "tx_gem"); in dsi_tx_buf_alloc_6g()
1128 msm_host->tx_size = msm_host->tx_gem_obj->size; in dsi_tx_buf_alloc_6g()
1133 int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_v2() argument
1135 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_v2()
1137 msm_host->tx_buf = dma_alloc_coherent(dev->dev, size, in dsi_tx_buf_alloc_v2()
1138 &msm_host->tx_buf_paddr, GFP_KERNEL); in dsi_tx_buf_alloc_v2()
1139 if (!msm_host->tx_buf) in dsi_tx_buf_alloc_v2()
1142 msm_host->tx_size = size; in dsi_tx_buf_alloc_v2()
1149 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_tx_buf_free() local
1150 struct drm_device *dev = msm_host->dev; in msm_dsi_tx_buf_free()
1161 if (msm_host->tx_gem_obj) { in msm_dsi_tx_buf_free()
1162 msm_gem_kernel_put(msm_host->tx_gem_obj, msm_host->aspace); in msm_dsi_tx_buf_free()
1163 msm_gem_address_space_put(msm_host->aspace); in msm_dsi_tx_buf_free()
1164 msm_host->tx_gem_obj = NULL; in msm_dsi_tx_buf_free()
1165 msm_host->aspace = NULL; in msm_dsi_tx_buf_free()
1168 if (msm_host->tx_buf) in msm_dsi_tx_buf_free()
1169 dma_free_coherent(dev->dev, msm_host->tx_size, msm_host->tx_buf, in msm_dsi_tx_buf_free()
1170 msm_host->tx_buf_paddr); in msm_dsi_tx_buf_free()
1173 void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_6g() argument
1175 return msm_gem_get_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_get_6g()
1178 void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_v2() argument
1180 return msm_host->tx_buf; in dsi_tx_buf_get_v2()
1183 void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_put_6g() argument
1185 msm_gem_put_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_put_6g()
1191 static int dsi_cmd_dma_add(struct msm_dsi_host *msm_host, in dsi_cmd_dma_add() argument
1194 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_add()
1207 if (len > msm_host->tx_size) { in dsi_cmd_dma_add()
1212 data = cfg_hnd->ops->tx_buf_get(msm_host); in dsi_cmd_dma_add()
1238 cfg_hnd->ops->tx_buf_put(msm_host); in dsi_cmd_dma_add()
1285 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_6g() argument
1287 struct drm_device *dev = msm_host->dev; in dsi_dma_base_get_6g()
1293 return msm_gem_get_and_pin_iova(msm_host->tx_gem_obj, in dsi_dma_base_get_6g()
1297 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_v2() argument
1302 *dma_base = msm_host->tx_buf_paddr; in dsi_dma_base_get_v2()
1306 static int dsi_cmd_dma_tx(struct msm_dsi_host *msm_host, int len) in dsi_cmd_dma_tx() argument
1308 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_tx()
1313 ret = cfg_hnd->ops->dma_base_get(msm_host, &dma_base); in dsi_cmd_dma_tx()
1319 reinit_completion(&msm_host->dma_comp); in dsi_cmd_dma_tx()
1321 dsi_wait4video_eng_busy(msm_host); in dsi_cmd_dma_tx()
1324 msm_host->id, dma_base, len); in dsi_cmd_dma_tx()
1326 ret = wait_for_completion_timeout(&msm_host->dma_comp, in dsi_cmd_dma_tx()
1339 static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host, in dsi_cmd_dma_rx() argument
1347 int buf_offset = buf - msm_host->rx_buf; in dsi_cmd_dma_rx()
1377 data = dsi_read(msm_host, REG_DSI_RDBK_DATA(i)); in dsi_cmd_dma_rx()
1388 static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, in dsi_cmds2buf_tx() argument
1392 int bllp_len = msm_host->mode->hdisplay * in dsi_cmds2buf_tx()
1393 dsi_get_bpp(msm_host->format) / 8; in dsi_cmds2buf_tx()
1395 len = dsi_cmd_dma_add(msm_host, msg); in dsi_cmds2buf_tx()
1411 if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && (len > bllp_len)) { in dsi_cmds2buf_tx()
1417 ret = dsi_cmd_dma_tx(msm_host, len); in dsi_cmds2buf_tx()
1433 struct msm_dsi_host *msm_host = in dsi_err_worker() local
1435 u32 status = msm_host->err_work_state; in dsi_err_worker()
1439 dsi_sw_reset(msm_host); in dsi_err_worker()
1442 msm_host->err_work_state = 0; in dsi_err_worker()
1445 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_err_worker()
1448 static void dsi_ack_err_status(struct msm_dsi_host *msm_host) in dsi_ack_err_status() argument
1452 status = dsi_read(msm_host, REG_DSI_ACK_ERR_STATUS); in dsi_ack_err_status()
1455 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, status); in dsi_ack_err_status()
1457 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, 0); in dsi_ack_err_status()
1458 msm_host->err_work_state |= DSI_ERR_STATE_ACK; in dsi_ack_err_status()
1462 static void dsi_timeout_status(struct msm_dsi_host *msm_host) in dsi_timeout_status() argument
1466 status = dsi_read(msm_host, REG_DSI_TIMEOUT_STATUS); in dsi_timeout_status()
1469 dsi_write(msm_host, REG_DSI_TIMEOUT_STATUS, status); in dsi_timeout_status()
1470 msm_host->err_work_state |= DSI_ERR_STATE_TIMEOUT; in dsi_timeout_status()
1474 static void dsi_dln0_phy_err(struct msm_dsi_host *msm_host) in dsi_dln0_phy_err() argument
1478 status = dsi_read(msm_host, REG_DSI_DLN0_PHY_ERR); in dsi_dln0_phy_err()
1485 dsi_write(msm_host, REG_DSI_DLN0_PHY_ERR, status); in dsi_dln0_phy_err()
1486 msm_host->err_work_state |= DSI_ERR_STATE_DLN0_PHY; in dsi_dln0_phy_err()
1490 static void dsi_fifo_status(struct msm_dsi_host *msm_host) in dsi_fifo_status() argument
1494 status = dsi_read(msm_host, REG_DSI_FIFO_STATUS); in dsi_fifo_status()
1498 dsi_write(msm_host, REG_DSI_FIFO_STATUS, status); in dsi_fifo_status()
1499 msm_host->err_work_state |= DSI_ERR_STATE_FIFO; in dsi_fifo_status()
1501 msm_host->err_work_state |= in dsi_fifo_status()
1506 static void dsi_status(struct msm_dsi_host *msm_host) in dsi_status() argument
1510 status = dsi_read(msm_host, REG_DSI_STATUS0); in dsi_status()
1513 dsi_write(msm_host, REG_DSI_STATUS0, status); in dsi_status()
1514 msm_host->err_work_state |= in dsi_status()
1519 static void dsi_clk_status(struct msm_dsi_host *msm_host) in dsi_clk_status() argument
1523 status = dsi_read(msm_host, REG_DSI_CLK_STATUS); in dsi_clk_status()
1526 dsi_write(msm_host, REG_DSI_CLK_STATUS, status); in dsi_clk_status()
1527 msm_host->err_work_state |= DSI_ERR_STATE_PLL_UNLOCKED; in dsi_clk_status()
1531 static void dsi_error(struct msm_dsi_host *msm_host) in dsi_error() argument
1534 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 0); in dsi_error()
1536 dsi_clk_status(msm_host); in dsi_error()
1537 dsi_fifo_status(msm_host); in dsi_error()
1538 dsi_ack_err_status(msm_host); in dsi_error()
1539 dsi_timeout_status(msm_host); in dsi_error()
1540 dsi_status(msm_host); in dsi_error()
1541 dsi_dln0_phy_err(msm_host); in dsi_error()
1543 queue_work(msm_host->workqueue, &msm_host->err_work); in dsi_error()
1548 struct msm_dsi_host *msm_host = ptr; in dsi_host_irq() local
1552 if (!msm_host->ctrl_base) in dsi_host_irq()
1555 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_host_irq()
1556 isr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_host_irq()
1557 dsi_write(msm_host, REG_DSI_INTR_CTRL, isr); in dsi_host_irq()
1558 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_host_irq()
1560 DBG("isr=0x%x, id=%d", isr, msm_host->id); in dsi_host_irq()
1563 dsi_error(msm_host); in dsi_host_irq()
1566 complete(&msm_host->video_comp); in dsi_host_irq()
1569 complete(&msm_host->dma_comp); in dsi_host_irq()
1574 static int dsi_host_init_panel_gpios(struct msm_dsi_host *msm_host, in dsi_host_init_panel_gpios() argument
1577 msm_host->disp_en_gpio = devm_gpiod_get_optional(panel_device, in dsi_host_init_panel_gpios()
1580 if (IS_ERR(msm_host->disp_en_gpio)) { in dsi_host_init_panel_gpios()
1582 PTR_ERR(msm_host->disp_en_gpio)); in dsi_host_init_panel_gpios()
1583 return PTR_ERR(msm_host->disp_en_gpio); in dsi_host_init_panel_gpios()
1586 msm_host->te_gpio = devm_gpiod_get_optional(panel_device, "disp-te", in dsi_host_init_panel_gpios()
1588 if (IS_ERR(msm_host->te_gpio)) { in dsi_host_init_panel_gpios()
1589 DBG("cannot get disp-te-gpios %ld", PTR_ERR(msm_host->te_gpio)); in dsi_host_init_panel_gpios()
1590 return PTR_ERR(msm_host->te_gpio); in dsi_host_init_panel_gpios()
1599 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_attach() local
1602 if (dsi->lanes > msm_host->num_data_lanes) in dsi_host_attach()
1605 msm_host->channel = dsi->channel; in dsi_host_attach()
1606 msm_host->lanes = dsi->lanes; in dsi_host_attach()
1607 msm_host->format = dsi->format; in dsi_host_attach()
1608 msm_host->mode_flags = dsi->mode_flags; in dsi_host_attach()
1610 msm_host->dsc = dsi->dsc; in dsi_host_attach()
1613 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); in dsi_host_attach()
1617 ret = dsi_dev_attach(msm_host->pdev); in dsi_host_attach()
1621 DBG("id=%d", msm_host->id); in dsi_host_attach()
1629 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_detach() local
1631 dsi_dev_detach(msm_host->pdev); in dsi_host_detach()
1633 DBG("id=%d", msm_host->id); in dsi_host_detach()
1641 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_transfer() local
1644 if (!msg || !msm_host->power_on) in dsi_host_transfer()
1647 mutex_lock(&msm_host->cmd_mutex); in dsi_host_transfer()
1648 ret = msm_dsi_manager_cmd_xfer(msm_host->id, msg); in dsi_host_transfer()
1649 mutex_unlock(&msm_host->cmd_mutex); in dsi_host_transfer()
1677 static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host, in dsi_host_parse_lane_data() argument
1680 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_lane_data()
1690 msm_host->num_data_lanes = 4; in dsi_host_parse_lane_data()
1700 msm_host->num_data_lanes = num_lanes; in dsi_host_parse_lane_data()
1734 msm_host->dlane_swap = i; in dsi_host_parse_lane_data()
1742 static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc) in dsi_populate_dsc_params() argument
1747 DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n"); in dsi_populate_dsc_params()
1752 DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n"); in dsi_populate_dsc_params()
1766 DRM_DEV_ERROR(&msm_host->pdev->dev, "could not find DSC RC parameters\n"); in dsi_populate_dsc_params()
1776 static int dsi_host_parse_dt(struct msm_dsi_host *msm_host) in dsi_host_parse_dt() argument
1778 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_dt()
1795 ret = dsi_host_parse_lane_data(msm_host, endpoint); in dsi_host_parse_dt()
1804 msm_host->sfpb = syscon_regmap_lookup_by_phandle(np, in dsi_host_parse_dt()
1806 if (IS_ERR(msm_host->sfpb)) { in dsi_host_parse_dt()
1809 ret = PTR_ERR(msm_host->sfpb); in dsi_host_parse_dt()
1819 static int dsi_host_get_id(struct msm_dsi_host *msm_host) in dsi_host_get_id() argument
1821 struct platform_device *pdev = msm_host->pdev; in dsi_host_get_id()
1822 const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg; in dsi_host_get_id()
1840 struct msm_dsi_host *msm_host = NULL; in msm_dsi_host_init() local
1845 msm_host = devm_kzalloc(&pdev->dev, sizeof(*msm_host), GFP_KERNEL); in msm_dsi_host_init()
1846 if (!msm_host) { in msm_dsi_host_init()
1850 msm_host->pdev = pdev; in msm_dsi_host_init()
1851 msm_dsi->host = &msm_host->base; in msm_dsi_host_init()
1853 ret = dsi_host_parse_dt(msm_host); in msm_dsi_host_init()
1859 msm_host->ctrl_base = msm_ioremap_size(pdev, "dsi_ctrl", &msm_host->ctrl_size); in msm_dsi_host_init()
1860 if (IS_ERR(msm_host->ctrl_base)) { in msm_dsi_host_init()
1862 return PTR_ERR(msm_host->ctrl_base); in msm_dsi_host_init()
1867 msm_host->cfg_hnd = dsi_get_config(msm_host); in msm_dsi_host_init()
1868 if (!msm_host->cfg_hnd) { in msm_dsi_host_init()
1872 cfg = msm_host->cfg_hnd->cfg; in msm_dsi_host_init()
1874 msm_host->id = dsi_host_get_id(msm_host); in msm_dsi_host_init()
1875 if (msm_host->id < 0) { in msm_dsi_host_init()
1877 return msm_host->id; in msm_dsi_host_init()
1881 msm_host->ctrl_base += cfg->io_offset; in msm_dsi_host_init()
1885 &msm_host->supplies); in msm_dsi_host_init()
1889 ret = dsi_clk_init(msm_host); in msm_dsi_host_init()
1895 msm_host->rx_buf = devm_kzalloc(&pdev->dev, SZ_4K, GFP_KERNEL); in msm_dsi_host_init()
1896 if (!msm_host->rx_buf) { in msm_dsi_host_init()
1911 msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in msm_dsi_host_init()
1912 if (!msm_host->irq) { in msm_dsi_host_init()
1918 ret = devm_request_irq(&pdev->dev, msm_host->irq, dsi_host_irq, in msm_dsi_host_init()
1920 "dsi_isr", msm_host); in msm_dsi_host_init()
1923 msm_host->irq, ret); in msm_dsi_host_init()
1927 init_completion(&msm_host->dma_comp); in msm_dsi_host_init()
1928 init_completion(&msm_host->video_comp); in msm_dsi_host_init()
1929 mutex_init(&msm_host->dev_mutex); in msm_dsi_host_init()
1930 mutex_init(&msm_host->cmd_mutex); in msm_dsi_host_init()
1931 spin_lock_init(&msm_host->intr_lock); in msm_dsi_host_init()
1934 msm_host->workqueue = alloc_ordered_workqueue("dsi_drm_work", 0); in msm_dsi_host_init()
1935 if (!msm_host->workqueue) in msm_dsi_host_init()
1938 INIT_WORK(&msm_host->err_work, dsi_err_worker); in msm_dsi_host_init()
1940 msm_dsi->id = msm_host->id; in msm_dsi_host_init()
1942 DBG("Dsi Host %d initialized", msm_host->id); in msm_dsi_host_init()
1948 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_destroy() local
1951 if (msm_host->workqueue) { in msm_dsi_host_destroy()
1952 destroy_workqueue(msm_host->workqueue); in msm_dsi_host_destroy()
1953 msm_host->workqueue = NULL; in msm_dsi_host_destroy()
1956 mutex_destroy(&msm_host->cmd_mutex); in msm_dsi_host_destroy()
1957 mutex_destroy(&msm_host->dev_mutex); in msm_dsi_host_destroy()
1959 pm_runtime_disable(&msm_host->pdev->dev); in msm_dsi_host_destroy()
1965 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_modeset_init() local
1966 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_modeset_init()
1969 msm_host->dev = dev; in msm_dsi_host_modeset_init()
1971 ret = cfg_hnd->ops->tx_buf_alloc(msm_host, SZ_4K); in msm_dsi_host_modeset_init()
1982 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_register() local
1986 if (!msm_host->registered) { in msm_dsi_host_register()
1987 host->dev = &msm_host->pdev->dev; in msm_dsi_host_register()
1993 msm_host->registered = true; in msm_dsi_host_register()
2001 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_unregister() local
2003 if (msm_host->registered) { in msm_dsi_host_unregister()
2007 msm_host->registered = false; in msm_dsi_host_unregister()
2014 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_prepare() local
2015 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_prepare()
2027 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_xfer_prepare()
2028 cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_xfer_prepare()
2029 cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_xfer_prepare()
2034 dsi_set_tx_power_mode(0, msm_host); in msm_dsi_host_xfer_prepare()
2036 msm_host->dma_cmd_ctrl_restore = dsi_read(msm_host, REG_DSI_CTRL); in msm_dsi_host_xfer_prepare()
2037 dsi_write(msm_host, REG_DSI_CTRL, in msm_dsi_host_xfer_prepare()
2038 msm_host->dma_cmd_ctrl_restore | in msm_dsi_host_xfer_prepare()
2041 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 1); in msm_dsi_host_xfer_prepare()
2049 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_restore() local
2050 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_restore()
2052 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 0); in msm_dsi_host_xfer_restore()
2053 dsi_write(msm_host, REG_DSI_CTRL, msm_host->dma_cmd_ctrl_restore); in msm_dsi_host_xfer_restore()
2056 dsi_set_tx_power_mode(1, msm_host); in msm_dsi_host_xfer_restore()
2060 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_xfer_restore()
2061 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_xfer_restore()
2067 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_tx() local
2069 return dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_tx()
2075 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_rx() local
2076 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_cmd_rx()
2097 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2111 ret = dsi_cmds2buf_tx(msm_host, &max_pkt_size_msg); in msm_dsi_host_cmd_rx()
2121 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, in msm_dsi_host_cmd_rx()
2124 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, 0); in msm_dsi_host_cmd_rx()
2128 ret = dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_rx()
2144 dlen = dsi_cmd_dma_rx(msm_host, buf, rx_byte, pkt_size); in msm_dsi_host_cmd_rx()
2180 buf = msm_host->rx_buf + (10 - rlen); in msm_dsi_host_cmd_rx()
2182 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2213 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_xfer_commit() local
2215 dsi_write(msm_host, REG_DSI_DMA_BASE, dma_base); in msm_dsi_host_cmd_xfer_commit()
2216 dsi_write(msm_host, REG_DSI_DMA_LEN, len); in msm_dsi_host_cmd_xfer_commit()
2217 dsi_write(msm_host, REG_DSI_TRIG_DMA, 1); in msm_dsi_host_cmd_xfer_commit()
2226 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_phy_mode() local
2228 msm_host->cphy_mode = src_phy->cphy_mode; in msm_dsi_host_set_phy_mode()
2233 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_reset_phy() local
2236 dsi_write(msm_host, REG_DSI_PHY_RESET, DSI_PHY_RESET_RESET); in msm_dsi_host_reset_phy()
2240 dsi_write(msm_host, REG_DSI_PHY_RESET, 0); in msm_dsi_host_reset_phy()
2248 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_phy_clk_req() local
2249 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_get_phy_clk_req()
2252 ret = cfg_hnd->ops->calc_clk_rate(msm_host, is_bonded_dsi); in msm_dsi_host_get_phy_clk_req()
2262 if (msm_host->cphy_mode) in msm_dsi_host_get_phy_clk_req()
2263 clk_req->bitclk_rate = msm_host->byte_clk_rate * 7; in msm_dsi_host_get_phy_clk_req()
2265 clk_req->bitclk_rate = msm_host->byte_clk_rate * 8; in msm_dsi_host_get_phy_clk_req()
2266 clk_req->escclk_rate = msm_host->esc_clk_rate; in msm_dsi_host_get_phy_clk_req()
2271 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable_irq() local
2273 enable_irq(msm_host->irq); in msm_dsi_host_enable_irq()
2278 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable_irq() local
2280 disable_irq(msm_host->irq); in msm_dsi_host_disable_irq()
2285 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable() local
2287 dsi_op_mode_config(msm_host, in msm_dsi_host_enable()
2288 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), true); in msm_dsi_host_enable()
2299 msm_host->enabled = true; in msm_dsi_host_enable()
2305 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable() local
2307 msm_host->enabled = false; in msm_dsi_host_disable()
2308 dsi_op_mode_config(msm_host, in msm_dsi_host_disable()
2309 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), false); in msm_dsi_host_disable()
2315 dsi_sw_reset(msm_host); in msm_dsi_host_disable()
2320 static void msm_dsi_sfpb_config(struct msm_dsi_host *msm_host, bool enable) in msm_dsi_sfpb_config() argument
2324 if (!msm_host->sfpb) in msm_dsi_sfpb_config()
2329 regmap_update_bits(msm_host->sfpb, REG_SFPB_GPREG, in msm_dsi_sfpb_config()
2338 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_on() local
2339 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_on()
2342 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2343 if (msm_host->power_on) { in msm_dsi_host_power_on()
2348 msm_host->byte_intf_clk_rate = msm_host->byte_clk_rate; in msm_dsi_host_power_on()
2350 msm_host->byte_intf_clk_rate /= 2; in msm_dsi_host_power_on()
2352 msm_dsi_sfpb_config(msm_host, true); in msm_dsi_host_power_on()
2354 ret = regulator_bulk_enable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_on()
2355 msm_host->supplies); in msm_dsi_host_power_on()
2362 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2363 ret = cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_power_on()
2365 ret = cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_power_on()
2372 ret = pinctrl_pm_select_default_state(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2379 dsi_timing_setup(msm_host, is_bonded_dsi); in msm_dsi_host_power_on()
2380 dsi_sw_reset(msm_host); in msm_dsi_host_power_on()
2381 dsi_ctrl_enable(msm_host, phy_shared_timings, phy); in msm_dsi_host_power_on()
2383 if (msm_host->disp_en_gpio) in msm_dsi_host_power_on()
2384 gpiod_set_value(msm_host->disp_en_gpio, 1); in msm_dsi_host_power_on()
2386 msm_host->power_on = true; in msm_dsi_host_power_on()
2387 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2392 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_on()
2393 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2395 regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_on()
2396 msm_host->supplies); in msm_dsi_host_power_on()
2398 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2404 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_off() local
2405 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_off()
2407 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2408 if (!msm_host->power_on) { in msm_dsi_host_power_off()
2413 dsi_ctrl_disable(msm_host); in msm_dsi_host_power_off()
2415 if (msm_host->disp_en_gpio) in msm_dsi_host_power_off()
2416 gpiod_set_value(msm_host->disp_en_gpio, 0); in msm_dsi_host_power_off()
2418 pinctrl_pm_select_sleep_state(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2420 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_off()
2421 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2423 regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_off()
2424 msm_host->supplies); in msm_dsi_host_power_off()
2426 msm_dsi_sfpb_config(msm_host, false); in msm_dsi_host_power_off()
2430 msm_host->power_on = false; in msm_dsi_host_power_off()
2433 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2440 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_display_mode() local
2442 if (msm_host->mode) { in msm_dsi_host_set_display_mode()
2443 drm_mode_destroy(msm_host->dev, msm_host->mode); in msm_dsi_host_set_display_mode()
2444 msm_host->mode = NULL; in msm_dsi_host_set_display_mode()
2447 msm_host->mode = drm_mode_duplicate(msm_host->dev, mode); in msm_dsi_host_set_display_mode()
2448 if (!msm_host->mode) { in msm_dsi_host_set_display_mode()
2459 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_check_dsc() local
2460 struct drm_dsc_config *dsc = msm_host->dsc; in msm_dsi_host_check_dsc()
2464 if (!msm_host->dsc) in msm_dsi_host_check_dsc()
2489 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_snapshot() local
2491 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2493 msm_disp_snapshot_add_block(disp_state, msm_host->ctrl_size, in msm_dsi_host_snapshot()
2494 msm_host->ctrl_base, "dsi%d_ctrl", msm_host->id); in msm_dsi_host_snapshot()
2496 pm_runtime_put_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2499 static void msm_dsi_host_video_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_video_test_pattern_setup() argument
2503 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_video_test_pattern_setup()
2505 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_VIDEO_INIT_VAL, 0xff); in msm_dsi_host_video_test_pattern_setup()
2507 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL, in msm_dsi_host_video_test_pattern_setup()
2510 dsi_write(msm_host, REG_DSI_TPG_VIDEO_CONFIG, in msm_dsi_host_video_test_pattern_setup()
2515 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_video_test_pattern_setup()
2520 static void msm_dsi_host_cmd_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_cmd_test_pattern_setup() argument
2524 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_cmd_test_pattern_setup()
2527 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_MDP_INIT_VAL0, 0xff); in msm_dsi_host_cmd_test_pattern_setup()
2531 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_cmd_test_pattern_setup()
2533 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL2, in msm_dsi_host_cmd_test_pattern_setup()
2541 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_test_pattern_en() local
2542 bool is_video_mode = !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO); in msm_dsi_host_test_pattern_en()
2546 msm_dsi_host_video_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2548 msm_dsi_host_cmd_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2550 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_test_pattern_en()
2552 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, (reg | DSI_TEST_PATTERN_GEN_CTRL_EN)); in msm_dsi_host_test_pattern_en()
2556 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER, in msm_dsi_host_test_pattern_en()
2562 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_dsc_config() local
2564 return msm_host->dsc; in msm_dsi_host_get_dsc_config()