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()
206 static int dsi_host_regulator_enable(struct msm_dsi_host *msm_host);
207 static void dsi_host_regulator_disable(struct msm_dsi_host *msm_host);
210 struct msm_dsi_host *msm_host) in dsi_get_config() argument
213 struct device *dev = &msm_host->pdev->dev; in dsi_get_config()
222 ahb_clk = msm_clk_get(msm_host->pdev, "iface"); in dsi_get_config()
236 ret = dsi_get_version(msm_host->ctrl_base, &major, &minor); in dsi_get_config()
259 static void dsi_host_regulator_disable(struct msm_dsi_host *msm_host) in dsi_host_regulator_disable() argument
261 struct regulator_bulk_data *s = msm_host->supplies; in dsi_host_regulator_disable()
262 const struct dsi_reg_entry *regs = msm_host->cfg_hnd->cfg->reg_cfg.regs; in dsi_host_regulator_disable()
263 int num = msm_host->cfg_hnd->cfg->reg_cfg.num; in dsi_host_regulator_disable()
275 static int dsi_host_regulator_enable(struct msm_dsi_host *msm_host) in dsi_host_regulator_enable() argument
277 struct regulator_bulk_data *s = msm_host->supplies; in dsi_host_regulator_enable()
278 const struct dsi_reg_entry *regs = msm_host->cfg_hnd->cfg->reg_cfg.regs; in dsi_host_regulator_enable()
279 int num = msm_host->cfg_hnd->cfg->reg_cfg.num; in dsi_host_regulator_enable()
309 static int dsi_regulator_init(struct msm_dsi_host *msm_host) in dsi_regulator_init() argument
311 struct regulator_bulk_data *s = msm_host->supplies; in dsi_regulator_init()
312 const struct dsi_reg_entry *regs = msm_host->cfg_hnd->cfg->reg_cfg.regs; in dsi_regulator_init()
313 int num = msm_host->cfg_hnd->cfg->reg_cfg.num; in dsi_regulator_init()
319 ret = devm_regulator_bulk_get(&msm_host->pdev->dev, num, s); in dsi_regulator_init()
329 int dsi_clk_init_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_v2() argument
331 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_v2()
334 msm_host->src_clk = msm_clk_get(pdev, "src"); in dsi_clk_init_v2()
336 if (IS_ERR(msm_host->src_clk)) { in dsi_clk_init_v2()
337 ret = PTR_ERR(msm_host->src_clk); in dsi_clk_init_v2()
340 msm_host->src_clk = NULL; in dsi_clk_init_v2()
344 msm_host->esc_clk_src = clk_get_parent(msm_host->esc_clk); in dsi_clk_init_v2()
345 if (!msm_host->esc_clk_src) { in dsi_clk_init_v2()
352 msm_host->dsi_clk_src = clk_get_parent(msm_host->src_clk); in dsi_clk_init_v2()
353 if (!msm_host->dsi_clk_src) { in dsi_clk_init_v2()
362 int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host) in dsi_clk_init_6g_v2() argument
364 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init_6g_v2()
367 msm_host->byte_intf_clk = msm_clk_get(pdev, "byte_intf"); in dsi_clk_init_6g_v2()
368 if (IS_ERR(msm_host->byte_intf_clk)) { in dsi_clk_init_6g_v2()
369 ret = PTR_ERR(msm_host->byte_intf_clk); in dsi_clk_init_6g_v2()
377 static int dsi_clk_init(struct msm_dsi_host *msm_host) in dsi_clk_init() argument
379 struct platform_device *pdev = msm_host->pdev; in dsi_clk_init()
380 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_clk_init()
386 msm_host->bus_clks[i].id = cfg->bus_clk_names[i]; in dsi_clk_init()
387 msm_host->num_bus_clks = cfg->num_bus_clks; in dsi_clk_init()
389 ret = devm_clk_bulk_get(&pdev->dev, msm_host->num_bus_clks, msm_host->bus_clks); in dsi_clk_init()
396 msm_host->byte_clk = msm_clk_get(pdev, "byte"); in dsi_clk_init()
397 if (IS_ERR(msm_host->byte_clk)) { in dsi_clk_init()
398 ret = PTR_ERR(msm_host->byte_clk); in dsi_clk_init()
401 msm_host->byte_clk = NULL; in dsi_clk_init()
405 msm_host->pixel_clk = msm_clk_get(pdev, "pixel"); in dsi_clk_init()
406 if (IS_ERR(msm_host->pixel_clk)) { in dsi_clk_init()
407 ret = PTR_ERR(msm_host->pixel_clk); in dsi_clk_init()
410 msm_host->pixel_clk = NULL; in dsi_clk_init()
414 msm_host->esc_clk = msm_clk_get(pdev, "core"); in dsi_clk_init()
415 if (IS_ERR(msm_host->esc_clk)) { in dsi_clk_init()
416 ret = PTR_ERR(msm_host->esc_clk); in dsi_clk_init()
419 msm_host->esc_clk = NULL; in dsi_clk_init()
423 msm_host->byte_clk_src = clk_get_parent(msm_host->byte_clk); in dsi_clk_init()
424 if (IS_ERR(msm_host->byte_clk_src)) { in dsi_clk_init()
425 ret = PTR_ERR(msm_host->byte_clk_src); in dsi_clk_init()
430 msm_host->pixel_clk_src = clk_get_parent(msm_host->pixel_clk); in dsi_clk_init()
431 if (IS_ERR(msm_host->pixel_clk_src)) { in dsi_clk_init()
432 ret = PTR_ERR(msm_host->pixel_clk_src); in dsi_clk_init()
438 ret = cfg_hnd->ops->clk_init_ver(msm_host); in dsi_clk_init()
448 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_suspend() local
450 if (!msm_host->cfg_hnd) in msm_dsi_runtime_suspend()
453 clk_bulk_disable_unprepare(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_suspend()
463 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_runtime_resume() local
465 if (!msm_host->cfg_hnd) in msm_dsi_runtime_resume()
468 return clk_bulk_prepare_enable(msm_host->num_bus_clks, msm_host->bus_clks); in msm_dsi_runtime_resume()
471 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_6g() argument
477 msm_host->mode->clock, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
479 ret = dev_pm_opp_set_rate(&msm_host->pdev->dev, in dsi_link_clk_set_rate_6g()
480 msm_host->byte_clk_rate); in dsi_link_clk_set_rate_6g()
486 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_6g()
492 if (msm_host->byte_intf_clk) { in dsi_link_clk_set_rate_6g()
494 if (msm_host->cphy_mode) in dsi_link_clk_set_rate_6g()
495 byte_intf_rate = msm_host->byte_clk_rate; in dsi_link_clk_set_rate_6g()
497 byte_intf_rate = msm_host->byte_clk_rate / 2; in dsi_link_clk_set_rate_6g()
499 ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_rate); in dsi_link_clk_set_rate_6g()
511 int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_6g() argument
515 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_6g()
521 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_6g()
527 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
533 ret = clk_prepare_enable(msm_host->byte_intf_clk); in dsi_link_clk_enable_6g()
543 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_enable_6g()
545 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_6g()
547 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_6g()
552 int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_set_rate_v2() argument
557 msm_host->mode->clock, msm_host->byte_clk_rate, in dsi_link_clk_set_rate_v2()
558 msm_host->esc_clk_rate, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
560 ret = clk_set_rate(msm_host->byte_clk, msm_host->byte_clk_rate); in dsi_link_clk_set_rate_v2()
566 ret = clk_set_rate(msm_host->esc_clk, msm_host->esc_clk_rate); in dsi_link_clk_set_rate_v2()
572 ret = clk_set_rate(msm_host->src_clk, msm_host->src_clk_rate); in dsi_link_clk_set_rate_v2()
578 ret = clk_set_rate(msm_host->pixel_clk, msm_host->pixel_clk_rate); in dsi_link_clk_set_rate_v2()
587 int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_enable_v2() argument
591 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable_v2()
597 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable_v2()
603 ret = clk_prepare_enable(msm_host->src_clk); in dsi_link_clk_enable_v2()
609 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable_v2()
618 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_enable_v2()
620 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable_v2()
622 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable_v2()
627 void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_6g() argument
630 dev_pm_opp_set_rate(&msm_host->pdev->dev, 0); in dsi_link_clk_disable_6g()
631 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_6g()
632 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_6g()
633 clk_disable_unprepare(msm_host->byte_intf_clk); in dsi_link_clk_disable_6g()
634 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_6g()
637 void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host) in dsi_link_clk_disable_v2() argument
639 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable_v2()
640 clk_disable_unprepare(msm_host->src_clk); in dsi_link_clk_disable_v2()
641 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable_v2()
642 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable_v2()
645 static unsigned long dsi_get_pclk_rate(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_get_pclk_rate() argument
647 struct drm_display_mode *mode = msm_host->mode; in dsi_get_pclk_rate()
664 static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_pclk() argument
666 u8 lanes = msm_host->lanes; in dsi_calc_pclk()
667 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_pclk()
668 unsigned long pclk_rate = dsi_get_pclk_rate(msm_host, is_bonded_dsi); in dsi_calc_pclk()
677 if (msm_host->cphy_mode) in dsi_calc_pclk()
682 msm_host->pixel_clk_rate = pclk_rate; in dsi_calc_pclk()
683 msm_host->byte_clk_rate = pclk_bpp; in dsi_calc_pclk()
685 DBG("pclk=%lu, bclk=%lu", msm_host->pixel_clk_rate, in dsi_calc_pclk()
686 msm_host->byte_clk_rate); in dsi_calc_pclk()
690 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_6g() argument
692 if (!msm_host->mode) { in dsi_calc_clk_rate_6g()
697 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_6g()
698 msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); in dsi_calc_clk_rate_6g()
702 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_calc_clk_rate_v2() argument
704 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_clk_rate_v2()
709 dsi_calc_pclk(msm_host, is_bonded_dsi); in dsi_calc_clk_rate_v2()
711 pclk_bpp = (u64)dsi_get_pclk_rate(msm_host, is_bonded_dsi) * bpp; in dsi_calc_clk_rate_v2()
713 msm_host->src_clk_rate = pclk_bpp; in dsi_calc_clk_rate_v2()
724 byte_mhz = msm_host->byte_clk_rate / 1000000; in dsi_calc_clk_rate_v2()
742 msm_host->esc_clk_rate = msm_host->byte_clk_rate / esc_div; in dsi_calc_clk_rate_v2()
744 DBG("esc=%lu, src=%lu", msm_host->esc_clk_rate, in dsi_calc_clk_rate_v2()
745 msm_host->src_clk_rate); in dsi_calc_clk_rate_v2()
750 static void dsi_intr_ctrl(struct msm_dsi_host *msm_host, u32 mask, int enable) in dsi_intr_ctrl() argument
755 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
756 intr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_intr_ctrl()
765 dsi_write(msm_host, REG_DSI_INTR_CTRL, intr); in dsi_intr_ctrl()
766 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
803 static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable, in dsi_ctrl_config() argument
806 u32 flags = msm_host->mode_flags; in dsi_ctrl_config()
807 enum mipi_dsi_pixel_format mipi_fmt = msm_host->format; in dsi_ctrl_config()
808 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_ctrl_config()
812 dsi_write(msm_host, REG_DSI_CTRL, 0); in dsi_ctrl_config()
832 data |= DSI_VID_CFG0_VIRT_CHANNEL(msm_host->channel); in dsi_ctrl_config()
833 dsi_write(msm_host, REG_DSI_VID_CFG0, data); in dsi_ctrl_config()
837 dsi_write(msm_host, REG_DSI_VID_CFG1, 0); in dsi_ctrl_config()
842 dsi_write(msm_host, REG_DSI_CMD_CFG0, data); in dsi_ctrl_config()
849 dsi_write(msm_host, REG_DSI_CMD_CFG1, data); in dsi_ctrl_config()
852 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, in dsi_ctrl_config()
861 data |= DSI_TRIG_CTRL_STREAM(msm_host->channel); in dsi_ctrl_config()
865 dsi_write(msm_host, REG_DSI_TRIG_CTRL, data); in dsi_ctrl_config()
869 dsi_write(msm_host, REG_DSI_CLKOUT_TIMING_CTRL, data); in dsi_ctrl_config()
874 dsi_write(msm_host, REG_DSI_T_CLK_PRE_EXTEND, in dsi_ctrl_config()
880 dsi_write(msm_host, REG_DSI_EOT_PACKET_CTRL, data); in dsi_ctrl_config()
883 dsi_write(msm_host, REG_DSI_ERR_INT_MASK0, 0x13ff3fe0); in dsi_ctrl_config()
885 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_ctrl_config()
887 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_ctrl_config()
891 DBG("lane number=%d", msm_host->lanes); in dsi_ctrl_config()
892 data |= ((DSI_CTRL_LANE0 << msm_host->lanes) - DSI_CTRL_LANE0); in dsi_ctrl_config()
894 dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL, in dsi_ctrl_config()
895 DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(msm_host->dlane_swap)); in dsi_ctrl_config()
898 lane_ctrl = dsi_read(msm_host, REG_DSI_LANE_CTRL); in dsi_ctrl_config()
903 dsi_write(msm_host, REG_DSI_LANE_CTRL, in dsi_ctrl_config()
909 dsi_write(msm_host, REG_DSI_CTRL, data); in dsi_ctrl_config()
911 if (msm_host->cphy_mode) in dsi_ctrl_config()
912 dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0)); in dsi_ctrl_config()
915 static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mode, u32 hdisplay) in dsi_update_dsc_timing() argument
917 struct msm_display_dsc_config *dsc = msm_host->dsc; in dsi_update_dsc_timing()
961 reg_ctrl = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL); in dsi_update_dsc_timing()
962 reg_ctrl2 = dsi_read(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2); in dsi_update_dsc_timing()
970 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl); in dsi_update_dsc_timing()
971 dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2); in dsi_update_dsc_timing()
973 dsi_write(msm_host, REG_DSI_VIDEO_COMPRESSION_MODE_CTRL, reg); in dsi_update_dsc_timing()
977 static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi) in dsi_timing_setup() argument
979 struct drm_display_mode *mode = msm_host->mode; in dsi_timing_setup()
1009 if (msm_host->dsc) { in dsi_timing_setup()
1010 struct msm_display_dsc_config *dsc = msm_host->dsc; in dsi_timing_setup()
1037 if (msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) { in dsi_timing_setup()
1038 if (msm_host->dsc) in dsi_timing_setup()
1039 dsi_update_dsc_timing(msm_host, false, mode->hdisplay); in dsi_timing_setup()
1041 dsi_write(msm_host, REG_DSI_ACTIVE_H, in dsi_timing_setup()
1044 dsi_write(msm_host, REG_DSI_ACTIVE_V, in dsi_timing_setup()
1047 dsi_write(msm_host, REG_DSI_TOTAL, in dsi_timing_setup()
1051 dsi_write(msm_host, REG_DSI_ACTIVE_HSYNC, in dsi_timing_setup()
1054 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_HPOS, 0); in dsi_timing_setup()
1055 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_VPOS, in dsi_timing_setup()
1059 if (msm_host->dsc) in dsi_timing_setup()
1060 dsi_update_dsc_timing(msm_host, true, mode->hdisplay); in dsi_timing_setup()
1063 if (!msm_host->dsc) in dsi_timing_setup()
1064 wc = hdisplay * dsi_get_bpp(msm_host->format) / 8 + 1; in dsi_timing_setup()
1068 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_CTRL, in dsi_timing_setup()
1071 msm_host->channel) | in dsi_timing_setup()
1075 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM0_TOTAL, in dsi_timing_setup()
1081 static void dsi_sw_reset(struct msm_dsi_host *msm_host) in dsi_sw_reset() argument
1083 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset()
1086 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset()
1088 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset()
1091 static void dsi_op_mode_config(struct msm_dsi_host *msm_host, in dsi_op_mode_config() argument
1096 dsi_ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_op_mode_config()
1101 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE | in dsi_op_mode_config()
1108 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE, 1); in dsi_op_mode_config()
1113 dsi_write(msm_host, REG_DSI_CTRL, dsi_ctrl); in dsi_op_mode_config()
1116 static void dsi_set_tx_power_mode(int mode, struct msm_dsi_host *msm_host) in dsi_set_tx_power_mode() argument
1120 data = dsi_read(msm_host, REG_DSI_CMD_DMA_CTRL); in dsi_set_tx_power_mode()
1127 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, data); in dsi_set_tx_power_mode()
1130 static void dsi_wait4video_done(struct msm_dsi_host *msm_host) in dsi_wait4video_done() argument
1133 struct device *dev = &msm_host->pdev->dev; in dsi_wait4video_done()
1135 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 1); in dsi_wait4video_done()
1137 reinit_completion(&msm_host->video_comp); in dsi_wait4video_done()
1139 ret = wait_for_completion_timeout(&msm_host->video_comp, in dsi_wait4video_done()
1145 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0); in dsi_wait4video_done()
1148 static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host) in dsi_wait4video_eng_busy() argument
1150 if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO)) in dsi_wait4video_eng_busy()
1153 if (msm_host->power_on && msm_host->enabled) { in dsi_wait4video_eng_busy()
1154 dsi_wait4video_done(msm_host); in dsi_wait4video_eng_busy()
1160 int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_6g() argument
1162 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_6g()
1169 &msm_host->tx_gem_obj, &iova); in dsi_tx_buf_alloc_6g()
1172 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_alloc_6g()
1176 msm_gem_object_set_name(msm_host->tx_gem_obj, "tx_gem"); in dsi_tx_buf_alloc_6g()
1178 msm_host->tx_size = msm_host->tx_gem_obj->size; in dsi_tx_buf_alloc_6g()
1183 int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc_v2() argument
1185 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc_v2()
1187 msm_host->tx_buf = dma_alloc_coherent(dev->dev, size, in dsi_tx_buf_alloc_v2()
1188 &msm_host->tx_buf_paddr, GFP_KERNEL); in dsi_tx_buf_alloc_v2()
1189 if (!msm_host->tx_buf) in dsi_tx_buf_alloc_v2()
1192 msm_host->tx_size = size; in dsi_tx_buf_alloc_v2()
1197 static void dsi_tx_buf_free(struct msm_dsi_host *msm_host) in dsi_tx_buf_free() argument
1199 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_free()
1212 if (msm_host->tx_gem_obj) { in dsi_tx_buf_free()
1213 msm_gem_unpin_iova(msm_host->tx_gem_obj, priv->kms->aspace); in dsi_tx_buf_free()
1214 drm_gem_object_put(msm_host->tx_gem_obj); in dsi_tx_buf_free()
1215 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_free()
1218 if (msm_host->tx_buf) in dsi_tx_buf_free()
1219 dma_free_coherent(dev->dev, msm_host->tx_size, msm_host->tx_buf, in dsi_tx_buf_free()
1220 msm_host->tx_buf_paddr); in dsi_tx_buf_free()
1223 void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_6g() argument
1225 return msm_gem_get_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_get_6g()
1228 void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host) in dsi_tx_buf_get_v2() argument
1230 return msm_host->tx_buf; in dsi_tx_buf_get_v2()
1233 void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host) in dsi_tx_buf_put_6g() argument
1235 msm_gem_put_vaddr(msm_host->tx_gem_obj); in dsi_tx_buf_put_6g()
1241 static int dsi_cmd_dma_add(struct msm_dsi_host *msm_host, in dsi_cmd_dma_add() argument
1244 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_add()
1257 if (len > msm_host->tx_size) { in dsi_cmd_dma_add()
1262 data = cfg_hnd->ops->tx_buf_get(msm_host); in dsi_cmd_dma_add()
1288 cfg_hnd->ops->tx_buf_put(msm_host); in dsi_cmd_dma_add()
1335 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_6g() argument
1337 struct drm_device *dev = msm_host->dev; in dsi_dma_base_get_6g()
1343 return msm_gem_get_and_pin_iova(msm_host->tx_gem_obj, in dsi_dma_base_get_6g()
1347 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *dma_base) in dsi_dma_base_get_v2() argument
1352 *dma_base = msm_host->tx_buf_paddr; in dsi_dma_base_get_v2()
1356 static int dsi_cmd_dma_tx(struct msm_dsi_host *msm_host, int len) in dsi_cmd_dma_tx() argument
1358 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_cmd_dma_tx()
1363 ret = cfg_hnd->ops->dma_base_get(msm_host, &dma_base); in dsi_cmd_dma_tx()
1369 reinit_completion(&msm_host->dma_comp); in dsi_cmd_dma_tx()
1371 dsi_wait4video_eng_busy(msm_host); in dsi_cmd_dma_tx()
1374 msm_host->id, dma_base, len); in dsi_cmd_dma_tx()
1376 ret = wait_for_completion_timeout(&msm_host->dma_comp, in dsi_cmd_dma_tx()
1389 static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host, in dsi_cmd_dma_rx() argument
1397 int buf_offset = buf - msm_host->rx_buf; in dsi_cmd_dma_rx()
1427 data = dsi_read(msm_host, REG_DSI_RDBK_DATA(i)); in dsi_cmd_dma_rx()
1438 static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, in dsi_cmds2buf_tx() argument
1442 int bllp_len = msm_host->mode->hdisplay * in dsi_cmds2buf_tx()
1443 dsi_get_bpp(msm_host->format) / 8; in dsi_cmds2buf_tx()
1445 len = dsi_cmd_dma_add(msm_host, msg); in dsi_cmds2buf_tx()
1461 if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && (len > bllp_len)) { in dsi_cmds2buf_tx()
1467 ret = dsi_cmd_dma_tx(msm_host, len); in dsi_cmds2buf_tx()
1481 static void dsi_sw_reset_restore(struct msm_dsi_host *msm_host) in dsi_sw_reset_restore() argument
1485 data0 = dsi_read(msm_host, REG_DSI_CTRL); in dsi_sw_reset_restore()
1488 dsi_write(msm_host, REG_DSI_CTRL, data1); in dsi_sw_reset_restore()
1495 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset_restore()
1499 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset_restore()
1501 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset_restore()
1503 dsi_write(msm_host, REG_DSI_CTRL, data0); in dsi_sw_reset_restore()
1509 struct msm_dsi_host *msm_host = in dsi_hpd_worker() local
1512 drm_helper_hpd_irq_event(msm_host->dev); in dsi_hpd_worker()
1517 struct msm_dsi_host *msm_host = in dsi_err_worker() local
1519 u32 status = msm_host->err_work_state; in dsi_err_worker()
1523 dsi_sw_reset_restore(msm_host); in dsi_err_worker()
1526 msm_host->err_work_state = 0; in dsi_err_worker()
1529 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_err_worker()
1532 static void dsi_ack_err_status(struct msm_dsi_host *msm_host) in dsi_ack_err_status() argument
1536 status = dsi_read(msm_host, REG_DSI_ACK_ERR_STATUS); in dsi_ack_err_status()
1539 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, status); in dsi_ack_err_status()
1541 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, 0); in dsi_ack_err_status()
1542 msm_host->err_work_state |= DSI_ERR_STATE_ACK; in dsi_ack_err_status()
1546 static void dsi_timeout_status(struct msm_dsi_host *msm_host) in dsi_timeout_status() argument
1550 status = dsi_read(msm_host, REG_DSI_TIMEOUT_STATUS); in dsi_timeout_status()
1553 dsi_write(msm_host, REG_DSI_TIMEOUT_STATUS, status); in dsi_timeout_status()
1554 msm_host->err_work_state |= DSI_ERR_STATE_TIMEOUT; in dsi_timeout_status()
1558 static void dsi_dln0_phy_err(struct msm_dsi_host *msm_host) in dsi_dln0_phy_err() argument
1562 status = dsi_read(msm_host, REG_DSI_DLN0_PHY_ERR); in dsi_dln0_phy_err()
1569 dsi_write(msm_host, REG_DSI_DLN0_PHY_ERR, status); in dsi_dln0_phy_err()
1570 msm_host->err_work_state |= DSI_ERR_STATE_DLN0_PHY; in dsi_dln0_phy_err()
1574 static void dsi_fifo_status(struct msm_dsi_host *msm_host) in dsi_fifo_status() argument
1578 status = dsi_read(msm_host, REG_DSI_FIFO_STATUS); in dsi_fifo_status()
1582 dsi_write(msm_host, REG_DSI_FIFO_STATUS, status); in dsi_fifo_status()
1583 msm_host->err_work_state |= DSI_ERR_STATE_FIFO; in dsi_fifo_status()
1585 msm_host->err_work_state |= in dsi_fifo_status()
1590 static void dsi_status(struct msm_dsi_host *msm_host) in dsi_status() argument
1594 status = dsi_read(msm_host, REG_DSI_STATUS0); in dsi_status()
1597 dsi_write(msm_host, REG_DSI_STATUS0, status); in dsi_status()
1598 msm_host->err_work_state |= in dsi_status()
1603 static void dsi_clk_status(struct msm_dsi_host *msm_host) in dsi_clk_status() argument
1607 status = dsi_read(msm_host, REG_DSI_CLK_STATUS); in dsi_clk_status()
1610 dsi_write(msm_host, REG_DSI_CLK_STATUS, status); in dsi_clk_status()
1611 msm_host->err_work_state |= DSI_ERR_STATE_PLL_UNLOCKED; in dsi_clk_status()
1615 static void dsi_error(struct msm_dsi_host *msm_host) in dsi_error() argument
1618 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 0); in dsi_error()
1620 dsi_clk_status(msm_host); in dsi_error()
1621 dsi_fifo_status(msm_host); in dsi_error()
1622 dsi_ack_err_status(msm_host); in dsi_error()
1623 dsi_timeout_status(msm_host); in dsi_error()
1624 dsi_status(msm_host); in dsi_error()
1625 dsi_dln0_phy_err(msm_host); in dsi_error()
1627 queue_work(msm_host->workqueue, &msm_host->err_work); in dsi_error()
1632 struct msm_dsi_host *msm_host = ptr; in dsi_host_irq() local
1636 if (!msm_host->ctrl_base) in dsi_host_irq()
1639 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_host_irq()
1640 isr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_host_irq()
1641 dsi_write(msm_host, REG_DSI_INTR_CTRL, isr); in dsi_host_irq()
1642 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_host_irq()
1644 DBG("isr=0x%x, id=%d", isr, msm_host->id); in dsi_host_irq()
1647 dsi_error(msm_host); in dsi_host_irq()
1650 complete(&msm_host->video_comp); in dsi_host_irq()
1653 complete(&msm_host->dma_comp); in dsi_host_irq()
1658 static int dsi_host_init_panel_gpios(struct msm_dsi_host *msm_host, in dsi_host_init_panel_gpios() argument
1661 msm_host->disp_en_gpio = devm_gpiod_get_optional(panel_device, in dsi_host_init_panel_gpios()
1664 if (IS_ERR(msm_host->disp_en_gpio)) { in dsi_host_init_panel_gpios()
1666 PTR_ERR(msm_host->disp_en_gpio)); in dsi_host_init_panel_gpios()
1667 return PTR_ERR(msm_host->disp_en_gpio); in dsi_host_init_panel_gpios()
1670 msm_host->te_gpio = devm_gpiod_get_optional(panel_device, "disp-te", in dsi_host_init_panel_gpios()
1672 if (IS_ERR(msm_host->te_gpio)) { in dsi_host_init_panel_gpios()
1673 DBG("cannot get disp-te-gpios %ld", PTR_ERR(msm_host->te_gpio)); in dsi_host_init_panel_gpios()
1674 return PTR_ERR(msm_host->te_gpio); in dsi_host_init_panel_gpios()
1683 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_attach() local
1686 if (dsi->lanes > msm_host->num_data_lanes) in dsi_host_attach()
1689 msm_host->channel = dsi->channel; in dsi_host_attach()
1690 msm_host->lanes = dsi->lanes; in dsi_host_attach()
1691 msm_host->format = dsi->format; in dsi_host_attach()
1692 msm_host->mode_flags = dsi->mode_flags; in dsi_host_attach()
1695 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); in dsi_host_attach()
1699 ret = dsi_dev_attach(msm_host->pdev); in dsi_host_attach()
1703 DBG("id=%d", msm_host->id); in dsi_host_attach()
1704 if (msm_host->dev) in dsi_host_attach()
1705 queue_work(msm_host->workqueue, &msm_host->hpd_work); in dsi_host_attach()
1713 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_detach() local
1715 dsi_dev_detach(msm_host->pdev); in dsi_host_detach()
1717 msm_host->device_node = NULL; in dsi_host_detach()
1719 DBG("id=%d", msm_host->id); in dsi_host_detach()
1720 if (msm_host->dev) in dsi_host_detach()
1721 queue_work(msm_host->workqueue, &msm_host->hpd_work); in dsi_host_detach()
1729 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_transfer() local
1732 if (!msg || !msm_host->power_on) in dsi_host_transfer()
1735 mutex_lock(&msm_host->cmd_mutex); in dsi_host_transfer()
1736 ret = msm_dsi_manager_cmd_xfer(msm_host->id, msg); in dsi_host_transfer()
1737 mutex_unlock(&msm_host->cmd_mutex); in dsi_host_transfer()
1765 static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host, in dsi_host_parse_lane_data() argument
1768 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_lane_data()
1778 msm_host->num_data_lanes = 4; in dsi_host_parse_lane_data()
1789 msm_host->num_data_lanes = num_lanes; in dsi_host_parse_lane_data()
1823 msm_host->dlane_swap = i; in dsi_host_parse_lane_data()
1958 static int dsi_host_parse_dt(struct msm_dsi_host *msm_host) in dsi_host_parse_dt() argument
1960 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_dt()
1977 ret = dsi_host_parse_lane_data(msm_host, endpoint); in dsi_host_parse_dt()
1993 msm_host->device_node = device_node; in dsi_host_parse_dt()
1996 msm_host->sfpb = syscon_regmap_lookup_by_phandle(np, in dsi_host_parse_dt()
1998 if (IS_ERR(msm_host->sfpb)) { in dsi_host_parse_dt()
2001 ret = PTR_ERR(msm_host->sfpb); in dsi_host_parse_dt()
2013 static int dsi_host_get_id(struct msm_dsi_host *msm_host) in dsi_host_get_id() argument
2015 struct platform_device *pdev = msm_host->pdev; in dsi_host_get_id()
2016 const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg; in dsi_host_get_id()
2034 struct msm_dsi_host *msm_host = NULL; in msm_dsi_host_init() local
2038 msm_host = devm_kzalloc(&pdev->dev, sizeof(*msm_host), GFP_KERNEL); in msm_dsi_host_init()
2039 if (!msm_host) { in msm_dsi_host_init()
2044 msm_host->pdev = pdev; in msm_dsi_host_init()
2045 msm_dsi->host = &msm_host->base; in msm_dsi_host_init()
2047 ret = dsi_host_parse_dt(msm_host); in msm_dsi_host_init()
2053 msm_host->ctrl_base = msm_ioremap_size(pdev, "dsi_ctrl", &msm_host->ctrl_size); in msm_dsi_host_init()
2054 if (IS_ERR(msm_host->ctrl_base)) { in msm_dsi_host_init()
2056 ret = PTR_ERR(msm_host->ctrl_base); in msm_dsi_host_init()
2062 msm_host->cfg_hnd = dsi_get_config(msm_host); in msm_dsi_host_init()
2063 if (!msm_host->cfg_hnd) { in msm_dsi_host_init()
2069 msm_host->id = dsi_host_get_id(msm_host); in msm_dsi_host_init()
2070 if (msm_host->id < 0) { in msm_dsi_host_init()
2071 ret = msm_host->id; in msm_dsi_host_init()
2077 msm_host->ctrl_base += msm_host->cfg_hnd->cfg->io_offset; in msm_dsi_host_init()
2079 ret = dsi_regulator_init(msm_host); in msm_dsi_host_init()
2085 ret = dsi_clk_init(msm_host); in msm_dsi_host_init()
2091 msm_host->rx_buf = devm_kzalloc(&pdev->dev, SZ_4K, GFP_KERNEL); in msm_dsi_host_init()
2092 if (!msm_host->rx_buf) { in msm_dsi_host_init()
2108 msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in msm_dsi_host_init()
2109 if (msm_host->irq < 0) { in msm_dsi_host_init()
2110 ret = msm_host->irq; in msm_dsi_host_init()
2116 ret = devm_request_irq(&pdev->dev, msm_host->irq, dsi_host_irq, in msm_dsi_host_init()
2118 "dsi_isr", msm_host); in msm_dsi_host_init()
2121 msm_host->irq, ret); in msm_dsi_host_init()
2125 init_completion(&msm_host->dma_comp); in msm_dsi_host_init()
2126 init_completion(&msm_host->video_comp); in msm_dsi_host_init()
2127 mutex_init(&msm_host->dev_mutex); in msm_dsi_host_init()
2128 mutex_init(&msm_host->cmd_mutex); in msm_dsi_host_init()
2129 spin_lock_init(&msm_host->intr_lock); in msm_dsi_host_init()
2132 msm_host->workqueue = alloc_ordered_workqueue("dsi_drm_work", 0); in msm_dsi_host_init()
2133 INIT_WORK(&msm_host->err_work, dsi_err_worker); in msm_dsi_host_init()
2134 INIT_WORK(&msm_host->hpd_work, dsi_hpd_worker); in msm_dsi_host_init()
2136 msm_dsi->id = msm_host->id; in msm_dsi_host_init()
2138 DBG("Dsi Host %d initialized", msm_host->id); in msm_dsi_host_init()
2147 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_destroy() local
2150 dsi_tx_buf_free(msm_host); in msm_dsi_host_destroy()
2151 if (msm_host->workqueue) { in msm_dsi_host_destroy()
2152 destroy_workqueue(msm_host->workqueue); in msm_dsi_host_destroy()
2153 msm_host->workqueue = NULL; in msm_dsi_host_destroy()
2156 mutex_destroy(&msm_host->cmd_mutex); in msm_dsi_host_destroy()
2157 mutex_destroy(&msm_host->dev_mutex); in msm_dsi_host_destroy()
2159 pm_runtime_disable(&msm_host->pdev->dev); in msm_dsi_host_destroy()
2165 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_modeset_init() local
2166 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_modeset_init()
2170 msm_host->dev = dev; in msm_dsi_host_modeset_init()
2171 panel = msm_dsi_host_get_panel(&msm_host->base); in msm_dsi_host_modeset_init()
2174 struct msm_display_dsc_config *dsc = msm_host->dsc; in msm_dsi_host_modeset_init()
2177 dsc = devm_kzalloc(&msm_host->pdev->dev, sizeof(*dsc), GFP_KERNEL); in msm_dsi_host_modeset_init()
2181 msm_host->dsc = dsc; in msm_dsi_host_modeset_init()
2185 ret = cfg_hnd->ops->tx_buf_alloc(msm_host, SZ_4K); in msm_dsi_host_modeset_init()
2196 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_register() local
2200 if (!msm_host->registered) { in msm_dsi_host_register()
2201 host->dev = &msm_host->pdev->dev; in msm_dsi_host_register()
2207 msm_host->registered = true; in msm_dsi_host_register()
2215 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_unregister() local
2217 if (msm_host->registered) { in msm_dsi_host_unregister()
2221 msm_host->registered = false; in msm_dsi_host_unregister()
2228 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_prepare() local
2229 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_prepare()
2241 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_xfer_prepare()
2242 cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_xfer_prepare()
2243 cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_xfer_prepare()
2248 dsi_set_tx_power_mode(0, msm_host); in msm_dsi_host_xfer_prepare()
2250 msm_host->dma_cmd_ctrl_restore = dsi_read(msm_host, REG_DSI_CTRL); in msm_dsi_host_xfer_prepare()
2251 dsi_write(msm_host, REG_DSI_CTRL, in msm_dsi_host_xfer_prepare()
2252 msm_host->dma_cmd_ctrl_restore | in msm_dsi_host_xfer_prepare()
2255 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 1); in msm_dsi_host_xfer_prepare()
2263 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_restore() local
2264 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_xfer_restore()
2266 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 0); in msm_dsi_host_xfer_restore()
2267 dsi_write(msm_host, REG_DSI_CTRL, msm_host->dma_cmd_ctrl_restore); in msm_dsi_host_xfer_restore()
2270 dsi_set_tx_power_mode(1, msm_host); in msm_dsi_host_xfer_restore()
2274 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_xfer_restore()
2275 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_xfer_restore()
2281 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_tx() local
2283 return dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_tx()
2289 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_rx() local
2290 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_cmd_rx()
2311 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2325 ret = dsi_cmds2buf_tx(msm_host, &max_pkt_size_msg); in msm_dsi_host_cmd_rx()
2335 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, in msm_dsi_host_cmd_rx()
2338 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, 0); in msm_dsi_host_cmd_rx()
2342 ret = dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_rx()
2358 dlen = dsi_cmd_dma_rx(msm_host, buf, rx_byte, pkt_size); in msm_dsi_host_cmd_rx()
2394 buf = msm_host->rx_buf + (10 - rlen); in msm_dsi_host_cmd_rx()
2396 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
2427 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_xfer_commit() local
2429 dsi_write(msm_host, REG_DSI_DMA_BASE, dma_base); in msm_dsi_host_cmd_xfer_commit()
2430 dsi_write(msm_host, REG_DSI_DMA_LEN, len); in msm_dsi_host_cmd_xfer_commit()
2431 dsi_write(msm_host, REG_DSI_TRIG_DMA, 1); in msm_dsi_host_cmd_xfer_commit()
2440 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_phy_mode() local
2442 msm_host->cphy_mode = src_phy->cphy_mode; in msm_dsi_host_set_phy_mode()
2447 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_reset_phy() local
2450 dsi_write(msm_host, REG_DSI_PHY_RESET, DSI_PHY_RESET_RESET); in msm_dsi_host_reset_phy()
2454 dsi_write(msm_host, REG_DSI_PHY_RESET, 0); in msm_dsi_host_reset_phy()
2462 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_phy_clk_req() local
2463 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_get_phy_clk_req()
2466 ret = cfg_hnd->ops->calc_clk_rate(msm_host, is_bonded_dsi); in msm_dsi_host_get_phy_clk_req()
2476 if (msm_host->cphy_mode) in msm_dsi_host_get_phy_clk_req()
2477 clk_req->bitclk_rate = msm_host->byte_clk_rate * 7; in msm_dsi_host_get_phy_clk_req()
2479 clk_req->bitclk_rate = msm_host->byte_clk_rate * 8; in msm_dsi_host_get_phy_clk_req()
2480 clk_req->escclk_rate = msm_host->esc_clk_rate; in msm_dsi_host_get_phy_clk_req()
2485 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable_irq() local
2487 enable_irq(msm_host->irq); in msm_dsi_host_enable_irq()
2492 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable_irq() local
2494 disable_irq(msm_host->irq); in msm_dsi_host_disable_irq()
2499 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable() local
2501 dsi_op_mode_config(msm_host, in msm_dsi_host_enable()
2502 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), true); in msm_dsi_host_enable()
2513 msm_host->enabled = true; in msm_dsi_host_enable()
2519 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable() local
2521 msm_host->enabled = false; in msm_dsi_host_disable()
2522 dsi_op_mode_config(msm_host, in msm_dsi_host_disable()
2523 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), false); in msm_dsi_host_disable()
2529 dsi_sw_reset(msm_host); in msm_dsi_host_disable()
2534 static void msm_dsi_sfpb_config(struct msm_dsi_host *msm_host, bool enable) in msm_dsi_sfpb_config() argument
2538 if (!msm_host->sfpb) in msm_dsi_sfpb_config()
2543 regmap_update_bits(msm_host->sfpb, REG_SFPB_GPREG, in msm_dsi_sfpb_config()
2552 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_on() local
2553 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_on()
2556 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2557 if (msm_host->power_on) { in msm_dsi_host_power_on()
2562 msm_dsi_sfpb_config(msm_host, true); in msm_dsi_host_power_on()
2564 ret = dsi_host_regulator_enable(msm_host); in msm_dsi_host_power_on()
2571 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2572 ret = cfg_hnd->ops->link_clk_set_rate(msm_host); in msm_dsi_host_power_on()
2574 ret = cfg_hnd->ops->link_clk_enable(msm_host); in msm_dsi_host_power_on()
2581 ret = pinctrl_pm_select_default_state(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2588 dsi_timing_setup(msm_host, is_bonded_dsi); in msm_dsi_host_power_on()
2589 dsi_sw_reset(msm_host); in msm_dsi_host_power_on()
2590 dsi_ctrl_config(msm_host, true, phy_shared_timings, phy); in msm_dsi_host_power_on()
2592 if (msm_host->disp_en_gpio) in msm_dsi_host_power_on()
2593 gpiod_set_value(msm_host->disp_en_gpio, 1); in msm_dsi_host_power_on()
2595 msm_host->power_on = true; in msm_dsi_host_power_on()
2596 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2601 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_on()
2602 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_on()
2604 dsi_host_regulator_disable(msm_host); in msm_dsi_host_power_on()
2606 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
2612 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_off() local
2613 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_power_off()
2615 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2616 if (!msm_host->power_on) { in msm_dsi_host_power_off()
2621 dsi_ctrl_config(msm_host, false, NULL, NULL); in msm_dsi_host_power_off()
2623 if (msm_host->disp_en_gpio) in msm_dsi_host_power_off()
2624 gpiod_set_value(msm_host->disp_en_gpio, 0); in msm_dsi_host_power_off()
2626 pinctrl_pm_select_sleep_state(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2628 cfg_hnd->ops->link_clk_disable(msm_host); in msm_dsi_host_power_off()
2629 pm_runtime_put(&msm_host->pdev->dev); in msm_dsi_host_power_off()
2631 dsi_host_regulator_disable(msm_host); in msm_dsi_host_power_off()
2633 msm_dsi_sfpb_config(msm_host, false); in msm_dsi_host_power_off()
2637 msm_host->power_on = false; in msm_dsi_host_power_off()
2640 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
2647 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_display_mode() local
2649 if (msm_host->mode) { in msm_dsi_host_set_display_mode()
2650 drm_mode_destroy(msm_host->dev, msm_host->mode); in msm_dsi_host_set_display_mode()
2651 msm_host->mode = NULL; in msm_dsi_host_set_display_mode()
2654 msm_host->mode = drm_mode_duplicate(msm_host->dev, mode); in msm_dsi_host_set_display_mode()
2655 if (!msm_host->mode) { in msm_dsi_host_set_display_mode()
2666 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_check_dsc() local
2667 struct msm_display_dsc_config *dsc = msm_host->dsc; in msm_dsi_host_check_dsc()
2671 if (!msm_host->dsc) in msm_dsi_host_check_dsc()
2701 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_bridge() local
2703 return of_drm_find_bridge(msm_host->device_node); in msm_dsi_host_get_bridge()
2708 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_snapshot() local
2710 pm_runtime_get_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2712 msm_disp_snapshot_add_block(disp_state, msm_host->ctrl_size, in msm_dsi_host_snapshot()
2713 msm_host->ctrl_base, "dsi%d_ctrl", msm_host->id); in msm_dsi_host_snapshot()
2715 pm_runtime_put_sync(&msm_host->pdev->dev); in msm_dsi_host_snapshot()
2718 static void msm_dsi_host_video_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_video_test_pattern_setup() argument
2722 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_video_test_pattern_setup()
2724 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_VIDEO_INIT_VAL, 0xff); in msm_dsi_host_video_test_pattern_setup()
2726 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL, in msm_dsi_host_video_test_pattern_setup()
2729 dsi_write(msm_host, REG_DSI_TPG_VIDEO_CONFIG, in msm_dsi_host_video_test_pattern_setup()
2734 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_video_test_pattern_setup()
2739 static void msm_dsi_host_cmd_test_pattern_setup(struct msm_dsi_host *msm_host) in msm_dsi_host_cmd_test_pattern_setup() argument
2743 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_cmd_test_pattern_setup()
2746 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_MDP_INIT_VAL0, 0xff); in msm_dsi_host_cmd_test_pattern_setup()
2750 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg); in msm_dsi_host_cmd_test_pattern_setup()
2752 dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL2, in msm_dsi_host_cmd_test_pattern_setup()
2760 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_test_pattern_en() local
2761 bool is_video_mode = !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO); in msm_dsi_host_test_pattern_en()
2765 msm_dsi_host_video_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2767 msm_dsi_host_cmd_test_pattern_setup(msm_host); in msm_dsi_host_test_pattern_en()
2769 reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL); in msm_dsi_host_test_pattern_en()
2771 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, (reg | DSI_TEST_PATTERN_GEN_CTRL_EN)); in msm_dsi_host_test_pattern_en()
2775 dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER, in msm_dsi_host_test_pattern_en()
2781 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_dsc_config() local
2783 return msm_host->dsc; in msm_dsi_host_get_dsc_config()