Lines Matching refs:msm_host
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()
219 ahb_clk = msm_clk_get(msm_host->pdev, "iface"); in dsi_get_config()
233 ret = dsi_get_version(msm_host->ctrl_base, &major, &minor); in dsi_get_config()
256 int dsi_clk_init_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_v2() argument
258 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_v2()
261 msm_host->src_clk = msm_clk_get(pdev, "src"); in dsi_clk_init_v2()
263 if (IS_ERR(msm_host->src_clk)) { in dsi_clk_init_v2()
264 ret = PTR_ERR(msm_host->src_clk); in dsi_clk_init_v2()
267 msm_host->src_clk = NULL; in dsi_clk_init_v2()
271 msm_host->esc_clk_src = clk_get_parent(msm_host->esc_clk); in dsi_clk_init_v2()
272 if (!msm_host->esc_clk_src) { in dsi_clk_init_v2()
279 msm_host->dsi_clk_src = clk_get_parent(msm_host->src_clk); in dsi_clk_init_v2()
280 if (!msm_host->dsi_clk_src) { in dsi_clk_init_v2()
289 int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_6g_v2() argument
291 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_6g_v2()
294 msm_host->byte_intf_clk = msm_clk_get(pdev, "byte_intf"); in dsi_clk_init_6g_v2()
295 if (IS_ERR(msm_host->byte_intf_clk)) { in dsi_clk_init_6g_v2()
296 ret = PTR_ERR(msm_host->byte_intf_clk); in dsi_clk_init_6g_v2()
304 static int dsi_clk_init(struct msm_dsi_host *msm_host) in dsi_clk_init() argument
306 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init()
307 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_clk_init()
313 msm_host->bus_clks[i].id = cfg->bus_clk_names[i]; in dsi_clk_init()
314 msm_host->num_bus_clks = cfg->num_bus_clks; in dsi_clk_init()
316 ret = devm_clk_bulk_get(&pdev->dev, msm_host->num_bus_clks, msm_host->bus_clks); in dsi_clk_init()
323 msm_host->byte_clk = msm_clk_get(pdev, "byte"); in dsi_clk_init()
324 if (IS_ERR(msm_host->byte_clk)) { in dsi_clk_init()
325 ret = PTR_ERR(msm_host->byte_clk); in dsi_clk_init()
328 msm_host->byte_clk = NULL; in dsi_clk_init()
332 msm_host->pixel_clk = msm_clk_get(pdev, "pixel"); in dsi_clk_init()
333 if (IS_ERR(msm_host->pixel_clk)) { in dsi_clk_init()
334 ret = PTR_ERR(msm_host->pixel_clk); in dsi_clk_init()
337 msm_host->pixel_clk = NULL; in dsi_clk_init()
341 msm_host->esc_clk = msm_clk_get(pdev, "core"); in dsi_clk_init()
342 if (IS_ERR(msm_host->esc_clk)) { in dsi_clk_init()
343 ret = PTR_ERR(msm_host->esc_clk); in dsi_clk_init()
346 msm_host->esc_clk = NULL; in dsi_clk_init()
350 msm_host->byte_clk_src = clk_get_parent(msm_host->byte_clk); in dsi_clk_init()
351 if (IS_ERR(msm_host->byte_clk_src)) { in dsi_clk_init()
352 ret = PTR_ERR(msm_host->byte_clk_src); in dsi_clk_init()
357 msm_host->pixel_clk_src = clk_get_parent(msm_host->pixel_clk); in dsi_clk_init()
358 if (IS_ERR(msm_host->pixel_clk_src)) { in dsi_clk_init()
359 ret = PTR_ERR(msm_host->pixel_clk_src); in dsi_clk_init()
365 ret = cfg_hnd->ops->clk_init_ver(msm_host); in dsi_clk_init()
375 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_suspend() local
377 if (!msm_host->cfg_hnd) in msm_dsi_runtime_suspend()
380 clk_bulk_disable_unprepare(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_suspend()
390 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_resume() local
392 if (!msm_host->cfg_hnd) in msm_dsi_runtime_resume()
395 return clk_bulk_prepare_enable(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_resume()
398 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_6g() argument
404 msm_host->mode->clock, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
406 ret = dev_pm_opp_set_rate(&msm_host->pdev->dev, in dsi_link_clk_set_rate_6g()
407 msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
413 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_6g()
419 if (msm_host->byte_intf_clk) { in dsi_link_clk_set_rate_6g()
421 if (msm_host->cphy_mode) in dsi_link_clk_set_rate_6g()
422 byte_intf_rate = msm_host->byte_clk_rate; in dsi_link_clk_set_rate_6g()
424 byte_intf_rate = msm_host->byte_clk_rate / 2; in dsi_link_clk_set_rate_6g()
426 ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_rate); in dsi_link_clk_set_rate_6g()
438 int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_6g() argument
442 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_6g()
448 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_6g()
454 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
460 ret = clk_prepare_enable(msm_host->byte_intf_clk); in dsi_link_clk_enable_6g()
470 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
472 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_6g()
474 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_6g()
479 int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_v2() argument
484 msm_host->mode->clock, msm_host->byte_clk_rate, in dsi_link_clk_set_rate_v2()
485 msm_host->esc_clk_rate, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
487 ret = clk_set_rate(msm_host->byte_clk, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_v2()
493 ret = clk_set_rate(msm_host->esc_clk, msm_host->esc_clk_rate); in dsi_link_clk_set_rate_v2()
499 ret = clk_set_rate(msm_host->src_clk, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
505 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_v2()
514 int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_v2() argument
518 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_v2()
524 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_v2()
530 ret = clk_prepare_enable(msm_host->src_clk); in dsi_link_clk_enable_v2()
536 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_v2()
545 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_enable_v2()
547 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_v2()
549 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_v2()
554 void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_6g() argument
557 dev_pm_opp_set_rate(&msm_host->pdev->dev, 0); in dsi_link_clk_disable_6g()
558 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_6g()
559 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_6g()
560 clk_disable_unprepare(msm_host->byte_intf_clk); in dsi_link_clk_disable_6g()
561 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_6g()
564 void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_v2() argument
566 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_v2()
567 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_disable_v2()
568 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_v2()
569 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_v2()
572 static unsigned long dsi_get_pclk_rate(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_get_pclk_rate() argument
574 struct drm_display_mode *mode = msm_host->mode; in dsi_get_pclk_rate()
591 static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_pclk() argument
593 u8 lanes = msm_host->lanes; in dsi_calc_pclk()
594 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_pclk()
595 unsigned long pclk_rate = dsi_get_pclk_rate(msm_host, is_bonded_dsi); in dsi_calc_pclk()
604 if (msm_host->cphy_mode) in dsi_calc_pclk()
609 msm_host->pixel_clk_rate = pclk_rate; in dsi_calc_pclk()
610 msm_host->byte_clk_rate = pclk_bpp; in dsi_calc_pclk()
612 DBG("pclk=%lu, bclk=%lu", msm_host->pixel_clk_rate, in dsi_calc_pclk()
613 msm_host->byte_clk_rate); in dsi_calc_pclk()
617 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_6g() argument
619 if (!msm_host->mode) { in dsi_calc_clk_rate_6g()
624 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_6g()
625 msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); in dsi_calc_clk_rate_6g()
629 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_v2() argument
631 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_clk_rate_v2()
636 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_v2()
638 pclk_bpp = (u64)dsi_get_pclk_rate(msm_host, is_bonded_dsi) * bpp; in dsi_calc_clk_rate_v2()
640 msm_host->src_clk_rate = pclk_bpp; in dsi_calc_clk_rate_v2()
651 byte_mhz = msm_host->byte_clk_rate / 1000000; in dsi_calc_clk_rate_v2()
669 msm_host->esc_clk_rate = msm_host->byte_clk_rate / esc_div; in dsi_calc_clk_rate_v2()
671 DBG("esc=%lu, src=%lu", msm_host->esc_clk_rate, in dsi_calc_clk_rate_v2()
672 msm_host->src_clk_rate); in dsi_calc_clk_rate_v2()
677 static void dsi_intr_ctrl(struct msm_dsi_host *msm_host, u32 mask, int enable) in dsi_intr_ctrl() argument
682 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
683 intr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_intr_ctrl()
692 dsi_write(msm_host, REG_DSI_INTR_CTRL, intr); in dsi_intr_ctrl()
693 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
730 static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable, in dsi_ctrl_config() argument
733 u32 flags = msm_host->mode_flags; in dsi_ctrl_config()
734 enum mipi_dsi_pixel_format mipi_fmt = msm_host->format; in dsi_ctrl_config()
735 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_ctrl_config()
739 dsi_write(msm_host, REG_DSI_CTRL, 0); in dsi_ctrl_config()
759 data |= DSI_VID_CFG0_VIRT_CHANNEL(msm_host->channel); in dsi_ctrl_config()
760 dsi_write(msm_host, REG_DSI_VID_CFG0, data); in dsi_ctrl_config()
764 dsi_write(msm_host, REG_DSI_VID_CFG1, 0); in dsi_ctrl_config()
769 dsi_write(msm_host, REG_DSI_CMD_CFG0, data); in dsi_ctrl_config()
776 dsi_write(msm_host, REG_DSI_CMD_CFG1, data); in dsi_ctrl_config()
779 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, in dsi_ctrl_config()
788 data |= DSI_TRIG_CTRL_STREAM(msm_host->channel); in dsi_ctrl_config()
792 dsi_write(msm_host, REG_DSI_TRIG_CTRL, data); in dsi_ctrl_config()
796 dsi_write(msm_host, REG_DSI_CLKOUT_TIMING_CTRL, data); in dsi_ctrl_config()
801 dsi_write(msm_host, REG_DSI_T_CLK_PRE_EXTEND, in dsi_ctrl_config()
807 dsi_write(msm_host, REG_DSI_EOT_PACKET_CTRL, data); in dsi_ctrl_config()
810 dsi_write(msm_host, REG_DSI_ERR_INT_MASK0, 0x13ff3fe0); in dsi_ctrl_config()
812 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_ctrl_config()
814 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_ctrl_config()
818 DBG("lane number=%d", msm_host->lanes); in dsi_ctrl_config()
819 data |= ((DSI_CTRL_LANE0 << msm_host->lanes) - DSI_CTRL_LANE0); in dsi_ctrl_config()
821 dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL, in dsi_ctrl_config()
822 DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(msm_host->dlane_swap)); in dsi_ctrl_config()
825 lane_ctrl = dsi_read(msm_host, REG_DSI_LANE_CTRL); in dsi_ctrl_config()
830 dsi_write(msm_host, REG_DSI_LANE_CTRL, in dsi_ctrl_config()
836 dsi_write(msm_host, REG_DSI_CTRL, data); in dsi_ctrl_config()
838 if (msm_host->cphy_mode) in dsi_ctrl_config()
839 dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0)); in dsi_ctrl_config()
842 static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mode, u32 hdisplay) in dsi_update_dsc_timing() argument
844 struct drm_dsc_config *dsc = msm_host->dsc; in dsi_update_dsc_timing()
888 reg_ctrl = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL); in dsi_update_dsc_timing()
889 reg_ctrl2 = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2); in dsi_update_dsc_timing()
897 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl); in dsi_update_dsc_timing()
898 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2); in dsi_update_dsc_timing()
900 dsi_write(msm_host, REG_DSI_VIDEO_COMPRESSION_MODE_CTRL, reg); in dsi_update_dsc_timing()
904 static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_timing_setup() argument
906 struct drm_display_mode *mode = msm_host->mode; in dsi_timing_setup()
936 if (msm_host->dsc) { in dsi_timing_setup()
937 struct drm_dsc_config *dsc = msm_host->dsc; in dsi_timing_setup()
964 if (msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) { in dsi_timing_setup()
965 if (msm_host->dsc) in dsi_timing_setup()
966 dsi_update_dsc_timing(msm_host, false, mode->hdisplay); in dsi_timing_setup()
968 dsi_write(msm_host, REG_DSI_ACTIVE_H, in dsi_timing_setup()
971 dsi_write(msm_host, REG_DSI_ACTIVE_V, in dsi_timing_setup()
974 dsi_write(msm_host, REG_DSI_TOTAL, in dsi_timing_setup()
978 dsi_write(msm_host, REG_DSI_ACTIVE_HSYNC, in dsi_timing_setup()
981 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_HPOS, 0); in dsi_timing_setup()
982 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_VPOS, in dsi_timing_setup()
986 if (msm_host->dsc) in dsi_timing_setup()
987 dsi_update_dsc_timing(msm_host, true, mode->hdisplay); in dsi_timing_setup()
990 if (!msm_host->dsc) in dsi_timing_setup()
991 wc = hdisplay * dsi_get_bpp(msm_host->format) / 8 + 1; in dsi_timing_setup()
995 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_CTRL, in dsi_timing_setup()
998 msm_host->channel) | in dsi_timing_setup()
1002 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_TOTAL, in dsi_timing_setup()
1008 static void dsi_sw_reset(struct msm_dsi_host *msm_host) in dsi_sw_reset() argument
1012 ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_sw_reset()
1015 dsi_write(msm_host, REG_DSI_CTRL, ctrl & ~DSI_CTRL_ENABLE); in dsi_sw_reset()
1023 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset()
1027 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset()
1029 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset()
1033 dsi_write(msm_host, REG_DSI_CTRL, ctrl); in dsi_sw_reset()
1038 static void dsi_op_mode_config(struct msm_dsi_host *msm_host, in dsi_op_mode_config() argument
1043 dsi_ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_op_mode_config()
1048 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE | in dsi_op_mode_config()
1055 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE, 1); in dsi_op_mode_config()
1060 dsi_write(msm_host, REG_DSI_CTRL, dsi_ctrl); in dsi_op_mode_config()
1063 static void dsi_set_tx_power_mode(int mode, struct msm_dsi_host *msm_host) in dsi_set_tx_power_mode() argument
1067 data = dsi_read(msm_host, REG_DSI_CMD_DMA_CTRL); in dsi_set_tx_power_mode()
1074 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, data); in dsi_set_tx_power_mode()
1077 static void dsi_wait4video_done(struct msm_dsi_host *msm_host) in dsi_wait4video_done() argument
1080 struct device *dev = &msm_host->pdev->dev; in dsi_wait4video_done()
1082 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 1); in dsi_wait4video_done()
1084 reinit_completion(&msm_host->video_comp); in dsi_wait4video_done()
1086 ret = wait_for_completion_timeout(&msm_host->video_comp, in dsi_wait4video_done()
1092 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0); in dsi_wait4video_done()
1095 static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host) in dsi_wait4video_eng_busy() argument
1097 if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO)) in dsi_wait4video_eng_busy()
1100 if (msm_host->power_on && msm_host->enabled) { in dsi_wait4video_eng_busy()
1101 dsi_wait4video_done(msm_host); in dsi_wait4video_eng_busy()
1107 int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_6g() argument
1109 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_6g()
1116 &msm_host->tx_gem_obj, &iova); in dsi_tx_buf_alloc_6g()
1119 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_alloc_6g()
1123 msm_gem_object_set_name(msm_host->tx_gem_obj, "tx_gem"); in dsi_tx_buf_alloc_6g()
1125 msm_host->tx_size = msm_host->tx_gem_obj->size; in dsi_tx_buf_alloc_6g()
1130 int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_v2() argument
1132 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_v2()
1134 msm_host->tx_buf = dma_alloc_coherent(dev->dev, size, in dsi_tx_buf_alloc_v2()
1135 &msm_host->tx_buf_paddr, GFP_KERNEL); in dsi_tx_buf_alloc_v2()
1136 if (!msm_host->tx_buf) in dsi_tx_buf_alloc_v2()
1139 msm_host->tx_size = size; in dsi_tx_buf_alloc_v2()
1144 static void dsi_tx_buf_free(struct msm_dsi_host *msm_host) in dsi_tx_buf_free() argument
1146 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_free()
1159 if (msm_host->tx_gem_obj) { in dsi_tx_buf_free()
1160 msm_gem_unpin_iova(msm_host->tx_gem_obj, priv->kms->aspace); in dsi_tx_buf_free()
1161 drm_gem_object_put(msm_host->tx_gem_obj); in dsi_tx_buf_free()
1162 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_free()
1165 if (msm_host->tx_buf) in dsi_tx_buf_free()
1166 dma_free_coherent(dev->dev, msm_host->tx_size, msm_host->tx_buf, in dsi_tx_buf_free()
1167 msm_host->tx_buf_paddr); in dsi_tx_buf_free()
1170 void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_6g() argument
1172 return msm_gem_get_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_get_6g()
1175 void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_v2() argument
1177 return msm_host->tx_buf; in dsi_tx_buf_get_v2()
1180 void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_put_6g() argument
1182 msm_gem_put_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_put_6g()
1188 static int dsi_cmd_dma_add(struct msm_dsi_host *msm_host, in dsi_cmd_dma_add() argument
1191 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_add()
1204 if (len > msm_host->tx_size) { in dsi_cmd_dma_add()
1209 data = cfg_hnd->ops->tx_buf_get(msm_host); in dsi_cmd_dma_add()
1235 cfg_hnd->ops->tx_buf_put(msm_host); in dsi_cmd_dma_add()
1282 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_6g() argument
1284 struct drm_device *dev = msm_host->dev; in dsi_dma_base_get_6g()
1290 return msm_gem_get_and_pin_iova(msm_host->tx_gem_obj, in dsi_dma_base_get_6g()
1294 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_v2() argument
1299 *dma_base = msm_host->tx_buf_paddr; in dsi_dma_base_get_v2()
1303 static int dsi_cmd_dma_tx(struct msm_dsi_host *msm_host, int len) in dsi_cmd_dma_tx() argument
1305 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_tx()
1310 ret = cfg_hnd->ops->dma_base_get(msm_host, &dma_base); in dsi_cmd_dma_tx()
1316 reinit_completion(&msm_host->dma_comp); in dsi_cmd_dma_tx()
1318 dsi_wait4video_eng_busy(msm_host); in dsi_cmd_dma_tx()
1321 msm_host->id, dma_base, len); in dsi_cmd_dma_tx()
1323 ret = wait_for_completion_timeout(&msm_host->dma_comp, in dsi_cmd_dma_tx()
1336 static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host, in dsi_cmd_dma_rx() argument
1344 int buf_offset = buf - msm_host->rx_buf; in dsi_cmd_dma_rx()
1374 data = dsi_read(msm_host, REG_DSI_RDBK_DATA(i)); in dsi_cmd_dma_rx()
1385 static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, in dsi_cmds2buf_tx() argument
1389 int bllp_len = msm_host->mode->hdisplay * in dsi_cmds2buf_tx()
1390 dsi_get_bpp(msm_host->format) / 8; in dsi_cmds2buf_tx()
1392 len = dsi_cmd_dma_add(msm_host, msg); in dsi_cmds2buf_tx()
1408 if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && (len > bllp_len)) { in dsi_cmds2buf_tx()
1414 ret = dsi_cmd_dma_tx(msm_host, len); in dsi_cmds2buf_tx()
1430 struct msm_dsi_host *msm_host = in dsi_err_worker() local
1432 u32 status = msm_host->err_work_state; in dsi_err_worker()
1436 dsi_sw_reset(msm_host); in dsi_err_worker()
1439 msm_host->err_work_state = 0; in dsi_err_worker()
1442 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_err_worker()
1445 static void dsi_ack_err_status(struct msm_dsi_host *msm_host) in dsi_ack_err_status() argument
1449 status = dsi_read(msm_host, REG_DSI_ACK_ERR_STATUS); in dsi_ack_err_status()
1452 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, status); in dsi_ack_err_status()
1454 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, 0); in dsi_ack_err_status()
1455 msm_host->err_work_state |= DSI_ERR_STATE_ACK; in dsi_ack_err_status()
1459 static void dsi_timeout_status(struct msm_dsi_host *msm_host) in dsi_timeout_status() argument
1463 status = dsi_read(msm_host, REG_DSI_TIMEOUT_STATUS); in dsi_timeout_status()
1466 dsi_write(msm_host, REG_DSI_TIMEOUT_STATUS, status); in dsi_timeout_status()
1467 msm_host->err_work_state |= DSI_ERR_STATE_TIMEOUT; in dsi_timeout_status()
1471 static void dsi_dln0_phy_err(struct msm_dsi_host *msm_host) in dsi_dln0_phy_err() argument
1475 status = dsi_read(msm_host, REG_DSI_DLN0_PHY_ERR); in dsi_dln0_phy_err()
1482 dsi_write(msm_host, REG_DSI_DLN0_PHY_ERR, status); in dsi_dln0_phy_err()
1483 msm_host->err_work_state |= DSI_ERR_STATE_DLN0_PHY; in dsi_dln0_phy_err()
1487 static void dsi_fifo_status(struct msm_dsi_host *msm_host) in dsi_fifo_status() argument
1491 status = dsi_read(msm_host, REG_DSI_FIFO_STATUS); in dsi_fifo_status()
1495 dsi_write(msm_host, REG_DSI_FIFO_STATUS, status); in dsi_fifo_status()
1496 msm_host->err_work_state |= DSI_ERR_STATE_FIFO; in dsi_fifo_status()
1498 msm_host->err_work_state |= in dsi_fifo_status()
1503 static void dsi_status(struct msm_dsi_host *msm_host) in dsi_status() argument
1507 status = dsi_read(msm_host, REG_DSI_STATUS0); in dsi_status()
1510 dsi_write(msm_host, REG_DSI_STATUS0, status); in dsi_status()
1511 msm_host->err_work_state |= in dsi_status()
1516 static void dsi_clk_status(struct msm_dsi_host *msm_host) in dsi_clk_status() argument
1520 status = dsi_read(msm_host, REG_DSI_CLK_STATUS); in dsi_clk_status()
1523 dsi_write(msm_host, REG_DSI_CLK_STATUS, status); in dsi_clk_status()
1524 msm_host->err_work_state |= DSI_ERR_STATE_PLL_UNLOCKED; in dsi_clk_status()
1528 static void dsi_error(struct msm_dsi_host *msm_host) in dsi_error() argument
1531 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 0); in dsi_error()
1533 dsi_clk_status(msm_host); in dsi_error()
1534 dsi_fifo_status(msm_host); in dsi_error()
1535 dsi_ack_err_status(msm_host); in dsi_error()
1536 dsi_timeout_status(msm_host); in dsi_error()
1537 dsi_status(msm_host); in dsi_error()
1538 dsi_dln0_phy_err(msm_host); in dsi_error()
1540 queue_work(msm_host->workqueue, &msm_host->err_work); in dsi_error()
1545 struct msm_dsi_host *msm_host = ptr; in dsi_host_irq() local
1549 if (!msm_host->ctrl_base) in dsi_host_irq()
1552 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_host_irq()
1553 isr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_host_irq()
1554 dsi_write(msm_host, REG_DSI_INTR_CTRL, isr); in dsi_host_irq()
1555 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_host_irq()
1557 DBG("isr=0x%x, id=%d", isr, msm_host->id); in dsi_host_irq()
1560 dsi_error(msm_host); in dsi_host_irq()
1563 complete(&msm_host->video_comp); in dsi_host_irq()
1566 complete(&msm_host->dma_comp); in dsi_host_irq()
1571 static int dsi_host_init_panel_gpios(struct msm_dsi_host *msm_host, in dsi_host_init_panel_gpios() argument
1574 msm_host->disp_en_gpio = devm_gpiod_get_optional(panel_device, in dsi_host_init_panel_gpios()
1577 if (IS_ERR(msm_host->disp_en_gpio)) { in dsi_host_init_panel_gpios()
1579 PTR_ERR(msm_host->disp_en_gpio)); in dsi_host_init_panel_gpios()
1580 return PTR_ERR(msm_host->disp_en_gpio); in dsi_host_init_panel_gpios()
1583 msm_host->te_gpio = devm_gpiod_get_optional(panel_device, "disp-te", in dsi_host_init_panel_gpios()
1585 if (IS_ERR(msm_host->te_gpio)) { in dsi_host_init_panel_gpios()
1586 DBG("cannot get disp-te-gpios %ld", PTR_ERR(msm_host->te_gpio)); in dsi_host_init_panel_gpios()
1587 return PTR_ERR(msm_host->te_gpio); in dsi_host_init_panel_gpios()
1596 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_attach() local
1599 if (dsi->lanes > msm_host->num_data_lanes) in dsi_host_attach()
1602 msm_host->channel = dsi->channel; in dsi_host_attach()
1603 msm_host->lanes = dsi->lanes; in dsi_host_attach()
1604 msm_host->format = dsi->format; in dsi_host_attach()
1605 msm_host->mode_flags = dsi->mode_flags; in dsi_host_attach()
1607 msm_host->dsc = dsi->dsc; in dsi_host_attach()
1610 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); in dsi_host_attach()
1614 ret = dsi_dev_attach(msm_host->pdev); in dsi_host_attach()
1618 DBG("id=%d", msm_host->id); in dsi_host_attach()
1626 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_detach() local
1628 dsi_dev_detach(msm_host->pdev); in dsi_host_detach()
1630 DBG("id=%d", msm_host->id); in dsi_host_detach()
1638 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_transfer() local
1641 if (!msg || !msm_host->power_on) in dsi_host_transfer()
1644 mutex_lock(&msm_host->cmd_mutex); in dsi_host_transfer()
1645 ret = msm_dsi_manager_cmd_xfer(msm_host->id, msg); in dsi_host_transfer()
1646 mutex_unlock(&msm_host->cmd_mutex); in dsi_host_transfer()
1674 static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host, in dsi_host_parse_lane_data() argument
1677 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_lane_data()
1687 msm_host->num_data_lanes = 4; in dsi_host_parse_lane_data()
1697 msm_host->num_data_lanes = num_lanes; in dsi_host_parse_lane_data()
1731 msm_host->dlane_swap = i; in dsi_host_parse_lane_data()
1866 static int dsi_host_parse_dt(struct msm_dsi_host *msm_host) in dsi_host_parse_dt() argument
1868 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_dt()
1885 ret = dsi_host_parse_lane_data(msm_host, endpoint); in dsi_host_parse_dt()
1894 msm_host->sfpb = syscon_regmap_lookup_by_phandle(np, in dsi_host_parse_dt()
1896 if (IS_ERR(msm_host->sfpb)) { in dsi_host_parse_dt()
1899 ret = PTR_ERR(msm_host->sfpb); in dsi_host_parse_dt()
1909 static int dsi_host_get_id(struct msm_dsi_host *msm_host) in dsi_host_get_id() argument
1911 struct platform_device *pdev = msm_host->pdev; in dsi_host_get_id()
1912 const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg; in dsi_host_get_id()
1930 struct msm_dsi_host *msm_host = NULL; in msm_dsi_host_init() local
1935 msm_host = devm_kzalloc(&pdev->dev, sizeof(*msm_host), GFP_KERNEL); in msm_dsi_host_init()
1936 if (!msm_host) { in msm_dsi_host_init()
1941 msm_host->pdev = pdev; in msm_dsi_host_init()
1942 msm_dsi->host = &msm_host->base; in msm_dsi_host_init()
1944 ret = dsi_host_parse_dt(msm_host); in msm_dsi_host_init()
1950 msm_host->ctrl_base = msm_ioremap_size(pdev, "dsi_ctrl", &msm_host->ctrl_size); in msm_dsi_host_init()
1951 if (IS_ERR(msm_host->ctrl_base)) { in msm_dsi_host_init()
1953 ret = PTR_ERR(msm_host->ctrl_base); in msm_dsi_host_init()
1959 msm_host->cfg_hnd = dsi_get_config(msm_host); in msm_dsi_host_init()
1960 if (!msm_host->cfg_hnd) { in msm_dsi_host_init()
1965 cfg = msm_host->cfg_hnd->cfg; in msm_dsi_host_init()
1967 msm_host->id = dsi_host_get_id(msm_host); in msm_dsi_host_init()
1968 if (msm_host->id < 0) { in msm_dsi_host_init()
1969 ret = msm_host->id; in msm_dsi_host_init()
1975 msm_host->ctrl_base += cfg->io_offset; in msm_dsi_host_init()
1979 &msm_host->supplies); in msm_dsi_host_init()
1983 ret = dsi_clk_init(msm_host); in msm_dsi_host_init()
1989 msm_host->rx_buf = devm_kzalloc(&pdev->dev, SZ_4K, GFP_KERNEL); in msm_dsi_host_init()
1990 if (!msm_host->rx_buf) { in msm_dsi_host_init()
2006 msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in msm_dsi_host_init()
2007 if (msm_host->irq < 0) { in msm_dsi_host_init()
2008 ret = msm_host->irq; in msm_dsi_host_init()
2014 ret = devm_request_irq(&pdev->dev, msm_host->irq, dsi_host_irq, in msm_dsi_host_init()
2016 "dsi_isr", msm_host); in msm_dsi_host_init()
2019 msm_host->irq, ret); in msm_dsi_host_init()
2023 init_completion(&msm_host->dma_comp); in msm_dsi_host_init()
2024 init_completion(&msm_host->video_comp); in msm_dsi_host_init()
2025 mutex_init(&msm_host->dev_mutex); in msm_dsi_host_init()
2026 mutex_init(&msm_host->cmd_mutex); in msm_dsi_host_init()
2027 spin_lock_init(&msm_host->intr_lock); in msm_dsi_host_init()
2030 msm_host->workqueue = alloc_ordered_workqueue("dsi_drm_work", 0); in msm_dsi_host_init()
2031 INIT_WORK(&msm_host->err_work, dsi_err_worker); in msm_dsi_host_init()
2033 msm_dsi->id = msm_host->id; in msm_dsi_host_init()
2035 DBG("Dsi Host %d initialized", msm_host->id); in msm_dsi_host_init()
2044 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_destroy() local
2047 dsi_tx_buf_free(msm_host); in msm_dsi_host_destroy()
2048 if (msm_host->workqueue) { in msm_dsi_host_destroy()
2049 destroy_workqueue(msm_host->workqueue); in msm_dsi_host_destroy()
2050 msm_host->workqueue = NULL; in msm_dsi_host_destroy()
2053 mutex_destroy(&msm_host->cmd_mutex); in msm_dsi_host_destroy()
2054 mutex_destroy(&msm_host->dev_mutex); in msm_dsi_host_destroy()
2056 pm_runtime_disable(&msm_host->pdev->dev); in msm_dsi_host_destroy()
2062 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_modeset_init() local
2063 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_modeset_init()
2066 msm_host->dev = dev; in msm_dsi_host_modeset_init()
2068 ret = cfg_hnd->ops->tx_buf_alloc(msm_host, SZ_4K); in msm_dsi_host_modeset_init()
2079 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_register() local
2083 if (!msm_host->registered) { in msm_dsi_host_register()
2084 host->dev = &msm_host->pdev->dev; in msm_dsi_host_register()
2090 msm_host->registered = true; in msm_dsi_host_register()
2098 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_unregister() local
2100 if (msm_host->registered) { in msm_dsi_host_unregister()
2104 msm_host->registered = false; in msm_dsi_host_unregister()
2111 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_prepare() local
2112 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_prepare()
2124 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_xfer_prepare()
2125 cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_xfer_prepare()
2126 cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_xfer_prepare()
2131 dsi_set_tx_power_mode(0, msm_host); in msm_dsi_host_xfer_prepare()
2133 msm_host->dma_cmd_ctrl_restore = dsi_read(msm_host, REG_DSI_CTRL); in msm_dsi_host_xfer_prepare()
2134 dsi_write(msm_host, REG_DSI_CTRL, in msm_dsi_host_xfer_prepare()
2135 msm_host->dma_cmd_ctrl_restore | in msm_dsi_host_xfer_prepare()
2138 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 1); in msm_dsi_host_xfer_prepare()
2146 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_restore() local
2147 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_restore()
2149 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 0); in msm_dsi_host_xfer_restore()
2150 dsi_write(msm_host, REG_DSI_CTRL, msm_host->dma_cmd_ctrl_restore); in msm_dsi_host_xfer_restore()
2153 dsi_set_tx_power_mode(1, msm_host); in msm_dsi_host_xfer_restore()
2157 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_xfer_restore()
2158 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_xfer_restore()
2164 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_tx() local
2166 return dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_tx()
2172 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_rx() local
2173 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_cmd_rx()
2194 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2208 ret = dsi_cmds2buf_tx(msm_host, &max_pkt_size_msg); in msm_dsi_host_cmd_rx()
2218 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, in msm_dsi_host_cmd_rx()
2221 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, 0); in msm_dsi_host_cmd_rx()
2225 ret = dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_rx()
2241 dlen = dsi_cmd_dma_rx(msm_host, buf, rx_byte, pkt_size); in msm_dsi_host_cmd_rx()
2277 buf = msm_host->rx_buf + (10 - rlen); in msm_dsi_host_cmd_rx()
2279 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2310 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_xfer_commit() local
2312 dsi_write(msm_host, REG_DSI_DMA_BASE, dma_base); in msm_dsi_host_cmd_xfer_commit()
2313 dsi_write(msm_host, REG_DSI_DMA_LEN, len); in msm_dsi_host_cmd_xfer_commit()
2314 dsi_write(msm_host, REG_DSI_TRIG_DMA, 1); in msm_dsi_host_cmd_xfer_commit()
2323 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_phy_mode() local
2325 msm_host->cphy_mode = src_phy->cphy_mode; in msm_dsi_host_set_phy_mode()
2330 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_reset_phy() local
2333 dsi_write(msm_host, REG_DSI_PHY_RESET, DSI_PHY_RESET_RESET); in msm_dsi_host_reset_phy()
2337 dsi_write(msm_host, REG_DSI_PHY_RESET, 0); in msm_dsi_host_reset_phy()
2345 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_phy_clk_req() local
2346 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_get_phy_clk_req()
2349 ret = cfg_hnd->ops->calc_clk_rate(msm_host, is_bonded_dsi); in msm_dsi_host_get_phy_clk_req()
2359 if (msm_host->cphy_mode) in msm_dsi_host_get_phy_clk_req()
2360 clk_req->bitclk_rate = msm_host->byte_clk_rate * 7; in msm_dsi_host_get_phy_clk_req()
2362 clk_req->bitclk_rate = msm_host->byte_clk_rate * 8; in msm_dsi_host_get_phy_clk_req()
2363 clk_req->escclk_rate = msm_host->esc_clk_rate; in msm_dsi_host_get_phy_clk_req()
2368 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable_irq() local
2370 enable_irq(msm_host->irq); in msm_dsi_host_enable_irq()
2375 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable_irq() local
2377 disable_irq(msm_host->irq); in msm_dsi_host_disable_irq()
2382 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable() local
2384 dsi_op_mode_config(msm_host, in msm_dsi_host_enable()
2385 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), true); in msm_dsi_host_enable()
2396 msm_host->enabled = true; in msm_dsi_host_enable()
2402 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable() local
2404 msm_host->enabled = false; in msm_dsi_host_disable()
2405 dsi_op_mode_config(msm_host, in msm_dsi_host_disable()
2406 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), false); in msm_dsi_host_disable()
2412 dsi_sw_reset(msm_host); in msm_dsi_host_disable()
2417 static void msm_dsi_sfpb_config(struct msm_dsi_host *msm_host, bool enable) in msm_dsi_sfpb_config() argument
2421 if (!msm_host->sfpb) in msm_dsi_sfpb_config()
2426 regmap_update_bits(msm_host->sfpb, REG_SFPB_GPREG, in msm_dsi_sfpb_config()
2435 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_on() local
2436 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_on()
2439 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2440 if (msm_host->power_on) { in msm_dsi_host_power_on()
2445 msm_dsi_sfpb_config(msm_host, true); in msm_dsi_host_power_on()
2447 ret = regulator_bulk_enable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_on()
2448 msm_host->supplies); in msm_dsi_host_power_on()
2455 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2456 ret = cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_power_on()
2458 ret = cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_power_on()
2465 ret = pinctrl_pm_select_default_state(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2472 dsi_timing_setup(msm_host, is_bonded_dsi); in msm_dsi_host_power_on()
2473 dsi_sw_reset(msm_host); in msm_dsi_host_power_on()
2474 dsi_ctrl_config(msm_host, true, phy_shared_timings, phy); in msm_dsi_host_power_on()
2476 if (msm_host->disp_en_gpio) in msm_dsi_host_power_on()
2477 gpiod_set_value(msm_host->disp_en_gpio, 1); in msm_dsi_host_power_on()
2479 msm_host->power_on = true; in msm_dsi_host_power_on()
2480 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2485 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_on()
2486 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2488 regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_on()
2489 msm_host->supplies); in msm_dsi_host_power_on()
2491 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2497 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_off() local
2498 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_off()
2500 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2501 if (!msm_host->power_on) { in msm_dsi_host_power_off()
2506 dsi_ctrl_config(msm_host, false, NULL, NULL); in msm_dsi_host_power_off()
2508 if (msm_host->disp_en_gpio) in msm_dsi_host_power_off()
2509 gpiod_set_value(msm_host->disp_en_gpio, 0); in msm_dsi_host_power_off()
2511 pinctrl_pm_select_sleep_state(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2513 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_off()
2514 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2516 regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators, in msm_dsi_host_power_off()
2517 msm_host->supplies); in msm_dsi_host_power_off()
2519 msm_dsi_sfpb_config(msm_host, false); in msm_dsi_host_power_off()
2523 msm_host->power_on = false; in msm_dsi_host_power_off()
2526 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2533 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_display_mode() local
2535 if (msm_host->mode) { in msm_dsi_host_set_display_mode()
2536 drm_mode_destroy(msm_host->dev, msm_host->mode); in msm_dsi_host_set_display_mode()
2537 msm_host->mode = NULL; in msm_dsi_host_set_display_mode()
2540 msm_host->mode = drm_mode_duplicate(msm_host->dev, mode); in msm_dsi_host_set_display_mode()
2541 if (!msm_host->mode) { in msm_dsi_host_set_display_mode()
2552 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_check_dsc() local
2553 struct drm_dsc_config *dsc = msm_host->dsc; in msm_dsi_host_check_dsc()
2557 if (!msm_host->dsc) in msm_dsi_host_check_dsc()
2582 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_snapshot() local
2584 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2586 msm_disp_snapshot_add_block(disp_state, msm_host->ctrl_size, in msm_dsi_host_snapshot()
2587 msm_host->ctrl_base, "dsi%d_ctrl", msm_host->id); in msm_dsi_host_snapshot()
2589 pm_runtime_put_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2592 static void msm_dsi_host_video_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_video_test_pattern_setup() argument
2596 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_video_test_pattern_setup()
2598 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_VIDEO_INIT_VAL, 0xff); in msm_dsi_host_video_test_pattern_setup()
2600 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL, in msm_dsi_host_video_test_pattern_setup()
2603 dsi_write(msm_host, REG_DSI_TPG_VIDEO_CONFIG, in msm_dsi_host_video_test_pattern_setup()
2608 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_video_test_pattern_setup()
2613 static void msm_dsi_host_cmd_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_cmd_test_pattern_setup() argument
2617 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_cmd_test_pattern_setup()
2620 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_MDP_INIT_VAL0, 0xff); in msm_dsi_host_cmd_test_pattern_setup()
2624 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_cmd_test_pattern_setup()
2626 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL2, in msm_dsi_host_cmd_test_pattern_setup()
2634 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_test_pattern_en() local
2635 bool is_video_mode = !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO); in msm_dsi_host_test_pattern_en()
2639 msm_dsi_host_video_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2641 msm_dsi_host_cmd_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2643 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_test_pattern_en()
2645 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, (reg | DSI_TEST_PATTERN_GEN_CTRL_EN)); in msm_dsi_host_test_pattern_en()
2649 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER, in msm_dsi_host_test_pattern_en()
2655 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_dsc_config() local
2657 return msm_host->dsc; in msm_dsi_host_get_dsc_config()