Lines Matching refs:msm_host

37 static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc);
198 static inline u32 dsi_read(struct msm_dsi_host *msm_host, u32 reg) in dsi_read() argument
200 return msm_readl(msm_host->ctrl_base + reg); in dsi_read()
202 static inline void dsi_write(struct msm_dsi_host *msm_host, u32 reg, u32 data) in dsi_write() argument
204 msm_writel(data, msm_host->ctrl_base + reg); in dsi_write()
208 struct msm_dsi_host *msm_host) in dsi_get_config() argument
211 struct device *dev = &msm_host->pdev->dev; in dsi_get_config()
220 ahb_clk = msm_clk_get(msm_host->pdev, "iface"); in dsi_get_config()
234 ret = dsi_get_version(msm_host->ctrl_base, &major, &minor); in dsi_get_config()
257 int dsi_clk_init_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_v2() argument
259 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_v2()
262 msm_host->src_clk = msm_clk_get(pdev, "src"); in dsi_clk_init_v2()
264 if (IS_ERR(msm_host->src_clk)) { in dsi_clk_init_v2()
265 ret = PTR_ERR(msm_host->src_clk); in dsi_clk_init_v2()
268 msm_host->src_clk = NULL; in dsi_clk_init_v2()
272 msm_host->esc_clk_src = clk_get_parent(msm_host->esc_clk); in dsi_clk_init_v2()
273 if (!msm_host->esc_clk_src) { in dsi_clk_init_v2()
280 msm_host->dsi_clk_src = clk_get_parent(msm_host->src_clk); in dsi_clk_init_v2()
281 if (!msm_host->dsi_clk_src) { in dsi_clk_init_v2()
290 int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_6g_v2() argument
292 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_6g_v2()
295 msm_host->byte_intf_clk = msm_clk_get(pdev, "byte_intf"); in dsi_clk_init_6g_v2()
296 if (IS_ERR(msm_host->byte_intf_clk)) { in dsi_clk_init_6g_v2()
297 ret = PTR_ERR(msm_host->byte_intf_clk); in dsi_clk_init_6g_v2()
305 static int dsi_clk_init(struct msm_dsi_host *msm_host) in dsi_clk_init() argument
307 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init()
308 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_clk_init()
314 msm_host->bus_clks[i].id = cfg->bus_clk_names[i]; in dsi_clk_init()
315 msm_host->num_bus_clks = cfg->num_bus_clks; in dsi_clk_init()
317 ret = devm_clk_bulk_get(&pdev->dev, msm_host->num_bus_clks, msm_host->bus_clks); in dsi_clk_init()
324 msm_host->byte_clk = msm_clk_get(pdev, "byte"); in dsi_clk_init()
325 if (IS_ERR(msm_host->byte_clk)) { in dsi_clk_init()
326 ret = PTR_ERR(msm_host->byte_clk); in dsi_clk_init()
329 msm_host->byte_clk = NULL; in dsi_clk_init()
333 msm_host->pixel_clk = msm_clk_get(pdev, "pixel"); in dsi_clk_init()
334 if (IS_ERR(msm_host->pixel_clk)) { in dsi_clk_init()
335 ret = PTR_ERR(msm_host->pixel_clk); in dsi_clk_init()
338 msm_host->pixel_clk = NULL; in dsi_clk_init()
342 msm_host->esc_clk = msm_clk_get(pdev, "core"); in dsi_clk_init()
343 if (IS_ERR(msm_host->esc_clk)) { in dsi_clk_init()
344 ret = PTR_ERR(msm_host->esc_clk); in dsi_clk_init()
347 msm_host->esc_clk = NULL; in dsi_clk_init()
351 msm_host->byte_clk_src = clk_get_parent(msm_host->byte_clk); in dsi_clk_init()
352 if (IS_ERR(msm_host->byte_clk_src)) { in dsi_clk_init()
353 ret = PTR_ERR(msm_host->byte_clk_src); in dsi_clk_init()
358 msm_host->pixel_clk_src = clk_get_parent(msm_host->pixel_clk); in dsi_clk_init()
359 if (IS_ERR(msm_host->pixel_clk_src)) { in dsi_clk_init()
360 ret = PTR_ERR(msm_host->pixel_clk_src); in dsi_clk_init()
366 ret = cfg_hnd->ops->clk_init_ver(msm_host); in dsi_clk_init()
376 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_suspend() local
378 if (!msm_host->cfg_hnd) in msm_dsi_runtime_suspend()
381 clk_bulk_disable_unprepare(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_suspend()
391 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_resume() local
393 if (!msm_host->cfg_hnd) in msm_dsi_runtime_resume()
396 return clk_bulk_prepare_enable(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_resume()
399 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_6g() argument
405 msm_host->mode->clock, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
407 ret = dev_pm_opp_set_rate(&msm_host->pdev->dev, in dsi_link_clk_set_rate_6g()
408 msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
414 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_6g()
420 if (msm_host->byte_intf_clk) { in dsi_link_clk_set_rate_6g()
422 if (msm_host->cphy_mode) in dsi_link_clk_set_rate_6g()
423 byte_intf_rate = msm_host->byte_clk_rate; in dsi_link_clk_set_rate_6g()
425 byte_intf_rate = msm_host->byte_clk_rate / 2; in dsi_link_clk_set_rate_6g()
427 ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_rate); in dsi_link_clk_set_rate_6g()
439 int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_6g() argument
443 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_6g()
449 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_6g()
455 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
461 ret = clk_prepare_enable(msm_host->byte_intf_clk); in dsi_link_clk_enable_6g()
471 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
473 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_6g()
475 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_6g()
480 int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_v2() argument
485 msm_host->mode->clock, msm_host->byte_clk_rate, in dsi_link_clk_set_rate_v2()
486 msm_host->esc_clk_rate, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
488 ret = clk_set_rate(msm_host->byte_clk, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_v2()
494 ret = clk_set_rate(msm_host->esc_clk, msm_host->esc_clk_rate); in dsi_link_clk_set_rate_v2()
500 ret = clk_set_rate(msm_host->src_clk, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
506 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_v2()
515 int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_v2() argument
519 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_v2()
525 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_v2()
531 ret = clk_prepare_enable(msm_host->src_clk); in dsi_link_clk_enable_v2()
537 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_v2()
546 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_enable_v2()
548 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_v2()
550 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_v2()
555 void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_6g() argument
558 dev_pm_opp_set_rate(&msm_host->pdev->dev, 0); in dsi_link_clk_disable_6g()
559 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_6g()
560 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_6g()
561 clk_disable_unprepare(msm_host->byte_intf_clk); in dsi_link_clk_disable_6g()
562 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_6g()
565 void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_v2() argument
567 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_v2()
568 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_disable_v2()
569 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_v2()
570 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_v2()
573 static unsigned long dsi_get_pclk_rate(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_get_pclk_rate() argument
575 struct drm_display_mode *mode = msm_host->mode; in dsi_get_pclk_rate()
592 static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_pclk() argument
594 u8 lanes = msm_host->lanes; in dsi_calc_pclk()
595 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_pclk()
596 unsigned long pclk_rate = dsi_get_pclk_rate(msm_host, is_bonded_dsi); in dsi_calc_pclk()
605 if (msm_host->cphy_mode) in dsi_calc_pclk()
610 msm_host->pixel_clk_rate = pclk_rate; in dsi_calc_pclk()
611 msm_host->byte_clk_rate = pclk_bpp; in dsi_calc_pclk()
613 DBG("pclk=%lu, bclk=%lu", msm_host->pixel_clk_rate, in dsi_calc_pclk()
614 msm_host->byte_clk_rate); in dsi_calc_pclk()
618 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_6g() argument
620 if (!msm_host->mode) { in dsi_calc_clk_rate_6g()
625 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_6g()
626 msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); in dsi_calc_clk_rate_6g()
630 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_v2() argument
632 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_clk_rate_v2()
637 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_v2()
639 pclk_bpp = (u64)dsi_get_pclk_rate(msm_host, is_bonded_dsi) * bpp; in dsi_calc_clk_rate_v2()
641 msm_host->src_clk_rate = pclk_bpp; in dsi_calc_clk_rate_v2()
652 byte_mhz = msm_host->byte_clk_rate / 1000000; in dsi_calc_clk_rate_v2()
670 msm_host->esc_clk_rate = msm_host->byte_clk_rate / esc_div; in dsi_calc_clk_rate_v2()
672 DBG("esc=%lu, src=%lu", msm_host->esc_clk_rate, in dsi_calc_clk_rate_v2()
673 msm_host->src_clk_rate); in dsi_calc_clk_rate_v2()
678 static void dsi_intr_ctrl(struct msm_dsi_host *msm_host, u32 mask, int enable) in dsi_intr_ctrl() argument
683 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
684 intr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_intr_ctrl()
693 dsi_write(msm_host, REG_DSI_INTR_CTRL, intr); in dsi_intr_ctrl()
694 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
731 static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable, in dsi_ctrl_config() argument
734 u32 flags = msm_host->mode_flags; in dsi_ctrl_config()
735 enum mipi_dsi_pixel_format mipi_fmt = msm_host->format; in dsi_ctrl_config()
736 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_ctrl_config()
740 dsi_write(msm_host, REG_DSI_CTRL, 0); in dsi_ctrl_config()
760 data |= DSI_VID_CFG0_VIRT_CHANNEL(msm_host->channel); in dsi_ctrl_config()
761 dsi_write(msm_host, REG_DSI_VID_CFG0, data); in dsi_ctrl_config()
765 dsi_write(msm_host, REG_DSI_VID_CFG1, 0); in dsi_ctrl_config()
770 dsi_write(msm_host, REG_DSI_CMD_CFG0, data); in dsi_ctrl_config()
777 dsi_write(msm_host, REG_DSI_CMD_CFG1, data); in dsi_ctrl_config()
780 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, in dsi_ctrl_config()
789 data |= DSI_TRIG_CTRL_STREAM(msm_host->channel); in dsi_ctrl_config()
793 dsi_write(msm_host, REG_DSI_TRIG_CTRL, data); in dsi_ctrl_config()
797 dsi_write(msm_host, REG_DSI_CLKOUT_TIMING_CTRL, data); in dsi_ctrl_config()
802 dsi_write(msm_host, REG_DSI_T_CLK_PRE_EXTEND, in dsi_ctrl_config()
808 dsi_write(msm_host, REG_DSI_EOT_PACKET_CTRL, data); in dsi_ctrl_config()
811 dsi_write(msm_host, REG_DSI_ERR_INT_MASK0, 0x13ff3fe0); in dsi_ctrl_config()
813 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_ctrl_config()
815 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_ctrl_config()
819 DBG("lane number=%d", msm_host->lanes); in dsi_ctrl_config()
820 data |= ((DSI_CTRL_LANE0 << msm_host->lanes) - DSI_CTRL_LANE0); in dsi_ctrl_config()
822 dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL, in dsi_ctrl_config()
823 DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(msm_host->dlane_swap)); in dsi_ctrl_config()
826 lane_ctrl = dsi_read(msm_host, REG_DSI_LANE_CTRL); in dsi_ctrl_config()
831 dsi_write(msm_host, REG_DSI_LANE_CTRL, in dsi_ctrl_config()
837 dsi_write(msm_host, REG_DSI_CTRL, data); in dsi_ctrl_config()
839 if (msm_host->cphy_mode) in dsi_ctrl_config()
840 dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0)); in dsi_ctrl_config()
843 static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mode, u32 hdisplay) in dsi_update_dsc_timing() argument
845 struct drm_dsc_config *dsc = msm_host->dsc; in dsi_update_dsc_timing()
882 reg_ctrl = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL); in dsi_update_dsc_timing()
883 reg_ctrl2 = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2); in dsi_update_dsc_timing()
891 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl); in dsi_update_dsc_timing()
892 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2); in dsi_update_dsc_timing()
894 dsi_write(msm_host, REG_DSI_VIDEO_COMPRESSION_MODE_CTRL, reg); in dsi_update_dsc_timing()
898 static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_timing_setup() argument
900 struct drm_display_mode *mode = msm_host->mode; in dsi_timing_setup()
931 if (msm_host->dsc) { in dsi_timing_setup()
932 struct drm_dsc_config *dsc = msm_host->dsc; in dsi_timing_setup()
948 ret = dsi_populate_dsc_params(msm_host, dsc); in dsi_timing_setup()
961 if (msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) { in dsi_timing_setup()
962 if (msm_host->dsc) in dsi_timing_setup()
963 dsi_update_dsc_timing(msm_host, false, mode->hdisplay); in dsi_timing_setup()
965 dsi_write(msm_host, REG_DSI_ACTIVE_H, in dsi_timing_setup()
968 dsi_write(msm_host, REG_DSI_ACTIVE_V, in dsi_timing_setup()
971 dsi_write(msm_host, REG_DSI_TOTAL, in dsi_timing_setup()
975 dsi_write(msm_host, REG_DSI_ACTIVE_HSYNC, in dsi_timing_setup()
978 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_HPOS, 0); in dsi_timing_setup()
979 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_VPOS, in dsi_timing_setup()
983 if (msm_host->dsc) in dsi_timing_setup()
984 dsi_update_dsc_timing(msm_host, true, mode->hdisplay); in dsi_timing_setup()
987 if (!msm_host->dsc) in dsi_timing_setup()
988 wc = hdisplay * dsi_get_bpp(msm_host->format) / 8 + 1; in dsi_timing_setup()
992 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_CTRL, in dsi_timing_setup()
995 msm_host->channel) | in dsi_timing_setup()
999 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_TOTAL, in dsi_timing_setup()
1005 static void dsi_sw_reset(struct msm_dsi_host *msm_host) in dsi_sw_reset() argument
1009 ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_sw_reset()
1012 dsi_write(msm_host, REG_DSI_CTRL, ctrl & ~DSI_CTRL_ENABLE); in dsi_sw_reset()
1020 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset()
1024 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset()
1026 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset()
1030 dsi_write(msm_host, REG_DSI_CTRL, ctrl); in dsi_sw_reset()
1035 static void dsi_op_mode_config(struct msm_dsi_host *msm_host, in dsi_op_mode_config() argument
1040 dsi_ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_op_mode_config()
1045 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE | in dsi_op_mode_config()
1052 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE, 1); in dsi_op_mode_config()
1057 dsi_write(msm_host, REG_DSI_CTRL, dsi_ctrl); in dsi_op_mode_config()
1060 static void dsi_set_tx_power_mode(int mode, struct msm_dsi_host *msm_host) in dsi_set_tx_power_mode() argument
1064 data = dsi_read(msm_host, REG_DSI_CMD_DMA_CTRL); in dsi_set_tx_power_mode()
1071 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, data); in dsi_set_tx_power_mode()
1074 static void dsi_wait4video_done(struct msm_dsi_host *msm_host) in dsi_wait4video_done() argument
1077 struct device *dev = &msm_host->pdev->dev; in dsi_wait4video_done()
1079 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 1); in dsi_wait4video_done()
1081 reinit_completion(&msm_host->video_comp); in dsi_wait4video_done()
1083 ret = wait_for_completion_timeout(&msm_host->video_comp, in dsi_wait4video_done()
1089 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0); in dsi_wait4video_done()
1092 static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host) in dsi_wait4video_eng_busy() argument
1094 if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO)) in dsi_wait4video_eng_busy()
1097 if (msm_host->power_on && msm_host->enabled) { in dsi_wait4video_eng_busy()
1098 dsi_wait4video_done(msm_host); in dsi_wait4video_eng_busy()
1104 int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_6g() argument
1106 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_6g()
1113 &msm_host->tx_gem_obj, &iova); in dsi_tx_buf_alloc_6g()
1116 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_alloc_6g()
1120 msm_gem_object_set_name(msm_host->tx_gem_obj, "tx_gem"); in dsi_tx_buf_alloc_6g()
1122 msm_host->tx_size = msm_host->tx_gem_obj->size; in dsi_tx_buf_alloc_6g()
1127 int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_v2() argument
1129 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_v2()
1131 msm_host->tx_buf = dma_alloc_coherent(dev->dev, size, in dsi_tx_buf_alloc_v2()
1132 &msm_host->tx_buf_paddr, GFP_KERNEL); in dsi_tx_buf_alloc_v2()
1133 if (!msm_host->tx_buf) in dsi_tx_buf_alloc_v2()
1136 msm_host->tx_size = size; in dsi_tx_buf_alloc_v2()
1141 static void dsi_tx_buf_free(struct msm_dsi_host *msm_host) in dsi_tx_buf_free() argument
1143 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_free()
1156 if (msm_host->tx_gem_obj) { in dsi_tx_buf_free()
1157 msm_gem_unpin_iova(msm_host->tx_gem_obj, priv->kms->aspace); in dsi_tx_buf_free()
1158 drm_gem_object_put(msm_host->tx_gem_obj); in dsi_tx_buf_free()
1159 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_free()
1162 if (msm_host->tx_buf) in dsi_tx_buf_free()
1163 dma_free_coherent(dev->dev, msm_host->tx_size, msm_host->tx_buf, in dsi_tx_buf_free()
1164 msm_host->tx_buf_paddr); in dsi_tx_buf_free()
1167 void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_6g() argument
1169 return msm_gem_get_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_get_6g()
1172 void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_v2() argument
1174 return msm_host->tx_buf; in dsi_tx_buf_get_v2()
1177 void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_put_6g() argument
1179 msm_gem_put_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_put_6g()
1185 static int dsi_cmd_dma_add(struct msm_dsi_host *msm_host, in dsi_cmd_dma_add() argument
1188 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_add()
1201 if (len > msm_host->tx_size) { in dsi_cmd_dma_add()
1206 data = cfg_hnd->ops->tx_buf_get(msm_host); in dsi_cmd_dma_add()
1232 cfg_hnd->ops->tx_buf_put(msm_host); in dsi_cmd_dma_add()
1279 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_6g() argument
1281 struct drm_device *dev = msm_host->dev; in dsi_dma_base_get_6g()
1287 return msm_gem_get_and_pin_iova(msm_host->tx_gem_obj, in dsi_dma_base_get_6g()
1291 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_v2() argument
1296 *dma_base = msm_host->tx_buf_paddr; in dsi_dma_base_get_v2()
1300 static int dsi_cmd_dma_tx(struct msm_dsi_host *msm_host, int len) in dsi_cmd_dma_tx() argument
1302 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_tx()
1307 ret = cfg_hnd->ops->dma_base_get(msm_host, &dma_base); in dsi_cmd_dma_tx()
1313 reinit_completion(&msm_host->dma_comp); in dsi_cmd_dma_tx()
1315 dsi_wait4video_eng_busy(msm_host); in dsi_cmd_dma_tx()
1318 msm_host->id, dma_base, len); in dsi_cmd_dma_tx()
1320 ret = wait_for_completion_timeout(&msm_host->dma_comp, in dsi_cmd_dma_tx()
1333 static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host, in dsi_cmd_dma_rx() argument
1341 int buf_offset = buf - msm_host->rx_buf; in dsi_cmd_dma_rx()
1371 data = dsi_read(msm_host, REG_DSI_RDBK_DATA(i)); in dsi_cmd_dma_rx()
1382 static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, in dsi_cmds2buf_tx() argument
1386 int bllp_len = msm_host->mode->hdisplay * in dsi_cmds2buf_tx()
1387 dsi_get_bpp(msm_host->format) / 8; in dsi_cmds2buf_tx()
1389 len = dsi_cmd_dma_add(msm_host, msg); in dsi_cmds2buf_tx()
1405 if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && (len > bllp_len)) { in dsi_cmds2buf_tx()
1411 ret = dsi_cmd_dma_tx(msm_host, len); in dsi_cmds2buf_tx()
1427 struct msm_dsi_host *msm_host = in dsi_err_worker() local
1429 u32 status = msm_host->err_work_state; in dsi_err_worker()
1433 dsi_sw_reset(msm_host); in dsi_err_worker()
1436 msm_host->err_work_state = 0; in dsi_err_worker()
1439 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_err_worker()
1442 static void dsi_ack_err_status(struct msm_dsi_host *msm_host) in dsi_ack_err_status() argument
1446 status = dsi_read(msm_host, REG_DSI_ACK_ERR_STATUS); in dsi_ack_err_status()
1449 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, status); in dsi_ack_err_status()
1451 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, 0); in dsi_ack_err_status()
1452 msm_host->err_work_state |= DSI_ERR_STATE_ACK; in dsi_ack_err_status()
1456 static void dsi_timeout_status(struct msm_dsi_host *msm_host) in dsi_timeout_status() argument
1460 status = dsi_read(msm_host, REG_DSI_TIMEOUT_STATUS); in dsi_timeout_status()
1463 dsi_write(msm_host, REG_DSI_TIMEOUT_STATUS, status); in dsi_timeout_status()
1464 msm_host->err_work_state |= DSI_ERR_STATE_TIMEOUT; in dsi_timeout_status()
1468 static void dsi_dln0_phy_err(struct msm_dsi_host *msm_host) in dsi_dln0_phy_err() argument
1472 status = dsi_read(msm_host, REG_DSI_DLN0_PHY_ERR); in dsi_dln0_phy_err()
1479 dsi_write(msm_host, REG_DSI_DLN0_PHY_ERR, status); in dsi_dln0_phy_err()
1480 msm_host->err_work_state |= DSI_ERR_STATE_DLN0_PHY; in dsi_dln0_phy_err()
1484 static void dsi_fifo_status(struct msm_dsi_host *msm_host) in dsi_fifo_status() argument
1488 status = dsi_read(msm_host, REG_DSI_FIFO_STATUS); in dsi_fifo_status()
1492 dsi_write(msm_host, REG_DSI_FIFO_STATUS, status); in dsi_fifo_status()
1493 msm_host->err_work_state |= DSI_ERR_STATE_FIFO; in dsi_fifo_status()
1495 msm_host->err_work_state |= in dsi_fifo_status()
1500 static void dsi_status(struct msm_dsi_host *msm_host) in dsi_status() argument
1504 status = dsi_read(msm_host, REG_DSI_STATUS0); in dsi_status()
1507 dsi_write(msm_host, REG_DSI_STATUS0, status); in dsi_status()
1508 msm_host->err_work_state |= in dsi_status()
1513 static void dsi_clk_status(struct msm_dsi_host *msm_host) in dsi_clk_status() argument
1517 status = dsi_read(msm_host, REG_DSI_CLK_STATUS); in dsi_clk_status()
1520 dsi_write(msm_host, REG_DSI_CLK_STATUS, status); in dsi_clk_status()
1521 msm_host->err_work_state |= DSI_ERR_STATE_PLL_UNLOCKED; in dsi_clk_status()
1525 static void dsi_error(struct msm_dsi_host *msm_host) in dsi_error() argument
1528 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 0); in dsi_error()
1530 dsi_clk_status(msm_host); in dsi_error()
1531 dsi_fifo_status(msm_host); in dsi_error()
1532 dsi_ack_err_status(msm_host); in dsi_error()
1533 dsi_timeout_status(msm_host); in dsi_error()
1534 dsi_status(msm_host); in dsi_error()
1535 dsi_dln0_phy_err(msm_host); in dsi_error()
1537 queue_work(msm_host->workqueue, &msm_host->err_work); in dsi_error()
1542 struct msm_dsi_host *msm_host = ptr; in dsi_host_irq() local
1546 if (!msm_host->ctrl_base) in dsi_host_irq()
1549 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_host_irq()
1550 isr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_host_irq()
1551 dsi_write(msm_host, REG_DSI_INTR_CTRL, isr); in dsi_host_irq()
1552 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_host_irq()
1554 DBG("isr=0x%x, id=%d", isr, msm_host->id); in dsi_host_irq()
1557 dsi_error(msm_host); in dsi_host_irq()
1560 complete(&msm_host->video_comp); in dsi_host_irq()
1563 complete(&msm_host->dma_comp); in dsi_host_irq()
1568 static int dsi_host_init_panel_gpios(struct msm_dsi_host *msm_host, in dsi_host_init_panel_gpios() argument
1571 msm_host->disp_en_gpio = devm_gpiod_get_optional(panel_device, in dsi_host_init_panel_gpios()
1574 if (IS_ERR(msm_host->disp_en_gpio)) { in dsi_host_init_panel_gpios()
1576 PTR_ERR(msm_host->disp_en_gpio)); in dsi_host_init_panel_gpios()
1577 return PTR_ERR(msm_host->disp_en_gpio); in dsi_host_init_panel_gpios()
1580 msm_host->te_gpio = devm_gpiod_get_optional(panel_device, "disp-te", in dsi_host_init_panel_gpios()
1582 if (IS_ERR(msm_host->te_gpio)) { in dsi_host_init_panel_gpios()
1583 DBG("cannot get disp-te-gpios %ld", PTR_ERR(msm_host->te_gpio)); in dsi_host_init_panel_gpios()
1584 return PTR_ERR(msm_host->te_gpio); in dsi_host_init_panel_gpios()
1593 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_attach() local
1596 if (dsi->lanes > msm_host->num_data_lanes) in dsi_host_attach()
1599 msm_host->channel = dsi->channel; in dsi_host_attach()
1600 msm_host->lanes = dsi->lanes; in dsi_host_attach()
1601 msm_host->format = dsi->format; in dsi_host_attach()
1602 msm_host->mode_flags = dsi->mode_flags; in dsi_host_attach()
1604 msm_host->dsc = dsi->dsc; in dsi_host_attach()
1607 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); in dsi_host_attach()
1611 ret = dsi_dev_attach(msm_host->pdev); in dsi_host_attach()
1615 DBG("id=%d", msm_host->id); in dsi_host_attach()
1623 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_detach() local
1625 dsi_dev_detach(msm_host->pdev); in dsi_host_detach()
1627 DBG("id=%d", msm_host->id); in dsi_host_detach()
1635 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_transfer() local
1638 if (!msg || !msm_host->power_on) in dsi_host_transfer()
1641 mutex_lock(&msm_host->cmd_mutex); in dsi_host_transfer()
1642 ret = msm_dsi_manager_cmd_xfer(msm_host->id, msg); in dsi_host_transfer()
1643 mutex_unlock(&msm_host->cmd_mutex); in dsi_host_transfer()
1671 static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host, in dsi_host_parse_lane_data() argument
1674 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_lane_data()
1684 msm_host->num_data_lanes = 4; in dsi_host_parse_lane_data()
1694 msm_host->num_data_lanes = num_lanes; in dsi_host_parse_lane_data()
1728 msm_host->dlane_swap = i; in dsi_host_parse_lane_data()
1754 static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc) in dsi_populate_dsc_params() argument
1760 DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n"); in dsi_populate_dsc_params()
1765 DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n"); in dsi_populate_dsc_params()
1815 static int dsi_host_parse_dt(struct msm_dsi_host *msm_host) in dsi_host_parse_dt() argument
1817 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_dt()
1834 ret = dsi_host_parse_lane_data(msm_host, endpoint); in dsi_host_parse_dt()
1843 msm_host->sfpb = syscon_regmap_lookup_by_phandle(np, in dsi_host_parse_dt()
1845 if (IS_ERR(msm_host->sfpb)) { in dsi_host_parse_dt()
1848 ret = PTR_ERR(msm_host->sfpb); in dsi_host_parse_dt()
1858 static int dsi_host_get_id(struct msm_dsi_host *msm_host) in dsi_host_get_id() argument
1860 struct platform_device *pdev = msm_host->pdev; in dsi_host_get_id()
1861 const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg; in dsi_host_get_id()
1879 struct msm_dsi_host *msm_host = NULL; in msm_dsi_host_init() local
1884 msm_host = devm_kzalloc(&pdev->dev, sizeof(*msm_host), GFP_KERNEL); in msm_dsi_host_init()
1885 if (!msm_host) { in msm_dsi_host_init()
1890 msm_host->pdev = pdev; in msm_dsi_host_init()
1891 msm_dsi->host = &msm_host->base; in msm_dsi_host_init()
1893 ret = dsi_host_parse_dt(msm_host); in msm_dsi_host_init()
1899 msm_host->ctrl_base = msm_ioremap_size(pdev, "dsi_ctrl", &msm_host->ctrl_size); in msm_dsi_host_init()
1900 if (IS_ERR(msm_host->ctrl_base)) { in msm_dsi_host_init()
1902 ret = PTR_ERR(msm_host->ctrl_base); in msm_dsi_host_init()
1908 msm_host->cfg_hnd = dsi_get_config(msm_host); in msm_dsi_host_init()
1909 if (!msm_host->cfg_hnd) { in msm_dsi_host_init()
1914 cfg = msm_host->cfg_hnd->cfg; in msm_dsi_host_init()
1916 msm_host->id = dsi_host_get_id(msm_host); in msm_dsi_host_init()
1917 if (msm_host->id < 0) { in msm_dsi_host_init()
1918 ret = msm_host->id; in msm_dsi_host_init()
1924 msm_host->ctrl_base += cfg->io_offset; in msm_dsi_host_init()
1928 &msm_host->supplies); in msm_dsi_host_init()
1932 ret = dsi_clk_init(msm_host); in msm_dsi_host_init()
1938 msm_host->rx_buf = devm_kzalloc(&pdev->dev, SZ_4K, GFP_KERNEL); in msm_dsi_host_init()
1939 if (!msm_host->rx_buf) { in msm_dsi_host_init()
1955 msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in msm_dsi_host_init()
1956 if (msm_host->irq < 0) { in msm_dsi_host_init()
1957 ret = msm_host->irq; in msm_dsi_host_init()
1963 ret = devm_request_irq(&pdev->dev, msm_host->irq, dsi_host_irq, in msm_dsi_host_init()
1965 "dsi_isr", msm_host); in msm_dsi_host_init()
1968 msm_host->irq, ret); in msm_dsi_host_init()
1972 init_completion(&msm_host->dma_comp); in msm_dsi_host_init()
1973 init_completion(&msm_host->video_comp); in msm_dsi_host_init()
1974 mutex_init(&msm_host->dev_mutex); in msm_dsi_host_init()
1975 mutex_init(&msm_host->cmd_mutex); in msm_dsi_host_init()
1976 spin_lock_init(&msm_host->intr_lock); in msm_dsi_host_init()
1979 msm_host->workqueue = alloc_ordered_workqueue("dsi_drm_work", 0); in msm_dsi_host_init()
1980 INIT_WORK(&msm_host->err_work, dsi_err_worker); in msm_dsi_host_init()
1982 msm_dsi->id = msm_host->id; in msm_dsi_host_init()
1984 DBG("Dsi Host %d initialized", msm_host->id); in msm_dsi_host_init()
1993 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_destroy() local
1996 dsi_tx_buf_free(msm_host); in msm_dsi_host_destroy()
1997 if (msm_host->workqueue) { in msm_dsi_host_destroy()
1998 destroy_workqueue(msm_host->workqueue); in msm_dsi_host_destroy()
1999 msm_host->workqueue = NULL; in msm_dsi_host_destroy()
2002 mutex_destroy(&msm_host->cmd_mutex); in msm_dsi_host_destroy()
2003 mutex_destroy(&msm_host->dev_mutex); in msm_dsi_host_destroy()
2005 pm_runtime_disable(&msm_host->pdev->dev); in msm_dsi_host_destroy()
2011 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_modeset_init() local
2012 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_modeset_init()
2015 msm_host->dev = dev; in msm_dsi_host_modeset_init()
2017 ret = cfg_hnd->ops->tx_buf_alloc(msm_host, SZ_4K); in msm_dsi_host_modeset_init()
2028 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_register() local
2032 if (!msm_host->registered) { in msm_dsi_host_register()
2033 host->dev = &msm_host->pdev->dev; in msm_dsi_host_register()
2039 msm_host->registered = true; in msm_dsi_host_register()
2047 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_unregister() local
2049 if (msm_host->registered) { in msm_dsi_host_unregister()
2053 msm_host->registered = false; in msm_dsi_host_unregister()
2060 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_prepare() local
2061 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_prepare()
2073 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_xfer_prepare()
2074 cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_xfer_prepare()
2075 cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_xfer_prepare()
2080 dsi_set_tx_power_mode(0, msm_host); in msm_dsi_host_xfer_prepare()
2082 msm_host->dma_cmd_ctrl_restore = dsi_read(msm_host, REG_DSI_CTRL); in msm_dsi_host_xfer_prepare()
2083 dsi_write(msm_host, REG_DSI_CTRL, in msm_dsi_host_xfer_prepare()
2084 msm_host->dma_cmd_ctrl_restore | in msm_dsi_host_xfer_prepare()
2087 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 1); in msm_dsi_host_xfer_prepare()
2095 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_restore() local
2096 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_restore()
2098 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 0); in msm_dsi_host_xfer_restore()
2099 dsi_write(msm_host, REG_DSI_CTRL, msm_host->dma_cmd_ctrl_restore); in msm_dsi_host_xfer_restore()
2102 dsi_set_tx_power_mode(1, msm_host); in msm_dsi_host_xfer_restore()
2106 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_xfer_restore()
2107 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_xfer_restore()
2113 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_tx() local
2115 return dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_tx()
2121 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_rx() local
2122 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_cmd_rx()
2143 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2157 ret = dsi_cmds2buf_tx(msm_host, &max_pkt_size_msg); in msm_dsi_host_cmd_rx()
2167 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, in msm_dsi_host_cmd_rx()
2170 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, 0); in msm_dsi_host_cmd_rx()
2174 ret = dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_rx()
2190 dlen = dsi_cmd_dma_rx(msm_host, buf, rx_byte, pkt_size); in msm_dsi_host_cmd_rx()
2226 buf = msm_host->rx_buf + (10 - rlen); in msm_dsi_host_cmd_rx()
2228 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2259 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_xfer_commit() local
2261 dsi_write(msm_host, REG_DSI_DMA_BASE, dma_base); in msm_dsi_host_cmd_xfer_commit()
2262 dsi_write(msm_host, REG_DSI_DMA_LEN, len); in msm_dsi_host_cmd_xfer_commit()
2263 dsi_write(msm_host, REG_DSI_TRIG_DMA, 1); in msm_dsi_host_cmd_xfer_commit()
2272 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_phy_mode() local
2274 msm_host->cphy_mode = src_phy->cphy_mode; in msm_dsi_host_set_phy_mode()
2279 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_reset_phy() local
2282 dsi_write(msm_host, REG_DSI_PHY_RESET, DSI_PHY_RESET_RESET); in msm_dsi_host_reset_phy()
2286 dsi_write(msm_host, REG_DSI_PHY_RESET, 0); in msm_dsi_host_reset_phy()
2294 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_phy_clk_req() local
2295 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_get_phy_clk_req()
2298 ret = cfg_hnd->ops->calc_clk_rate(msm_host, is_bonded_dsi); in msm_dsi_host_get_phy_clk_req()
2308 if (msm_host->cphy_mode) in msm_dsi_host_get_phy_clk_req()
2309 clk_req->bitclk_rate = msm_host->byte_clk_rate * 7; in msm_dsi_host_get_phy_clk_req()
2311 clk_req->bitclk_rate = msm_host->byte_clk_rate * 8; in msm_dsi_host_get_phy_clk_req()
2312 clk_req->escclk_rate = msm_host->esc_clk_rate; in msm_dsi_host_get_phy_clk_req()
2317 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable_irq() local
2319 enable_irq(msm_host->irq); in msm_dsi_host_enable_irq()
2324 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable_irq() local
2326 disable_irq(msm_host->irq); in msm_dsi_host_disable_irq()
2331 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable() local
2333 dsi_op_mode_config(msm_host, in msm_dsi_host_enable()
2334 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), true); in msm_dsi_host_enable()
2345 msm_host->enabled = true; in msm_dsi_host_enable()
2351 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable() local
2353 msm_host->enabled = false; in msm_dsi_host_disable()
2354 dsi_op_mode_config(msm_host, in msm_dsi_host_disable()
2355 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), false); in msm_dsi_host_disable()
2361 dsi_sw_reset(msm_host); in msm_dsi_host_disable()
2366 static void msm_dsi_sfpb_config(struct msm_dsi_host *msm_host, bool enable) in msm_dsi_sfpb_config() argument
2370 if (!msm_host->sfpb) in msm_dsi_sfpb_config()
2375 regmap_update_bits(msm_host->sfpb, REG_SFPB_GPREG, in msm_dsi_sfpb_config()
2384 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_on() local
2385 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_on()
2388 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2389 if (msm_host->power_on) { in msm_dsi_host_power_on()
2394 msm_dsi_sfpb_config(msm_host, true); in msm_dsi_host_power_on()
2396 ret = regulator_bulk_enable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_on()
2397 msm_host->supplies); in msm_dsi_host_power_on()
2404 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2405 ret = cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_power_on()
2407 ret = cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_power_on()
2414 ret = pinctrl_pm_select_default_state(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2421 dsi_timing_setup(msm_host, is_bonded_dsi); in msm_dsi_host_power_on()
2422 dsi_sw_reset(msm_host); in msm_dsi_host_power_on()
2423 dsi_ctrl_config(msm_host, true, phy_shared_timings, phy); in msm_dsi_host_power_on()
2425 if (msm_host->disp_en_gpio) in msm_dsi_host_power_on()
2426 gpiod_set_value(msm_host->disp_en_gpio, 1); in msm_dsi_host_power_on()
2428 msm_host->power_on = true; in msm_dsi_host_power_on()
2429 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2434 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_on()
2435 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2437 regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_on()
2438 msm_host->supplies); in msm_dsi_host_power_on()
2440 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2446 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_off() local
2447 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_off()
2449 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2450 if (!msm_host->power_on) { in msm_dsi_host_power_off()
2455 dsi_ctrl_config(msm_host, false, NULL, NULL); in msm_dsi_host_power_off()
2457 if (msm_host->disp_en_gpio) in msm_dsi_host_power_off()
2458 gpiod_set_value(msm_host->disp_en_gpio, 0); in msm_dsi_host_power_off()
2460 pinctrl_pm_select_sleep_state(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2462 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_off()
2463 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2465 regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_off()
2466 msm_host->supplies); in msm_dsi_host_power_off()
2468 msm_dsi_sfpb_config(msm_host, false); in msm_dsi_host_power_off()
2472 msm_host->power_on = false; in msm_dsi_host_power_off()
2475 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2482 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_display_mode() local
2484 if (msm_host->mode) { in msm_dsi_host_set_display_mode()
2485 drm_mode_destroy(msm_host->dev, msm_host->mode); in msm_dsi_host_set_display_mode()
2486 msm_host->mode = NULL; in msm_dsi_host_set_display_mode()
2489 msm_host->mode = drm_mode_duplicate(msm_host->dev, mode); in msm_dsi_host_set_display_mode()
2490 if (!msm_host->mode) { in msm_dsi_host_set_display_mode()
2501 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_check_dsc() local
2502 struct drm_dsc_config *dsc = msm_host->dsc; in msm_dsi_host_check_dsc()
2506 if (!msm_host->dsc) in msm_dsi_host_check_dsc()
2531 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_snapshot() local
2533 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2535 msm_disp_snapshot_add_block(disp_state, msm_host->ctrl_size, in msm_dsi_host_snapshot()
2536 msm_host->ctrl_base, "dsi%d_ctrl", msm_host->id); in msm_dsi_host_snapshot()
2538 pm_runtime_put_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2541 static void msm_dsi_host_video_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_video_test_pattern_setup() argument
2545 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_video_test_pattern_setup()
2547 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_VIDEO_INIT_VAL, 0xff); in msm_dsi_host_video_test_pattern_setup()
2549 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL, in msm_dsi_host_video_test_pattern_setup()
2552 dsi_write(msm_host, REG_DSI_TPG_VIDEO_CONFIG, in msm_dsi_host_video_test_pattern_setup()
2557 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_video_test_pattern_setup()
2562 static void msm_dsi_host_cmd_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_cmd_test_pattern_setup() argument
2566 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_cmd_test_pattern_setup()
2569 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_MDP_INIT_VAL0, 0xff); in msm_dsi_host_cmd_test_pattern_setup()
2573 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_cmd_test_pattern_setup()
2575 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL2, in msm_dsi_host_cmd_test_pattern_setup()
2583 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_test_pattern_en() local
2584 bool is_video_mode = !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO); in msm_dsi_host_test_pattern_en()
2588 msm_dsi_host_video_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2590 msm_dsi_host_cmd_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2592 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_test_pattern_en()
2594 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, (reg | DSI_TEST_PATTERN_GEN_CTRL_EN)); in msm_dsi_host_test_pattern_en()
2598 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER, in msm_dsi_host_test_pattern_en()
2604 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_dsc_config() local
2606 return msm_host->dsc; in msm_dsi_host_get_dsc_config()