Lines Matching refs:msm_host
154 static inline u32 dsi_read(struct msm_dsi_host *msm_host, u32 reg) in dsi_read() argument
156 return msm_readl(msm_host->ctrl_base + reg); in dsi_read()
158 static inline void dsi_write(struct msm_dsi_host *msm_host, u32 reg, u32 data) in dsi_write() argument
160 msm_writel(data, msm_host->ctrl_base + reg); in dsi_write()
163 static int dsi_host_regulator_enable(struct msm_dsi_host *msm_host);
164 static void dsi_host_regulator_disable(struct msm_dsi_host *msm_host);
167 struct msm_dsi_host *msm_host) in dsi_get_config() argument
174 gdsc_reg = regulator_get(&msm_host->pdev->dev, "gdsc"); in dsi_get_config()
184 ret = clk_prepare_enable(msm_host->ahb_clk); in dsi_get_config()
190 ret = dsi_get_version(msm_host->ctrl_base, &major, &minor); in dsi_get_config()
201 clk_disable_unprepare(msm_host->ahb_clk); in dsi_get_config()
215 static void dsi_host_regulator_disable(struct msm_dsi_host *msm_host) in dsi_host_regulator_disable() argument
217 struct regulator_bulk_data *s = msm_host->supplies; in dsi_host_regulator_disable()
218 const struct dsi_reg_entry *regs = msm_host->cfg_hnd->cfg->reg_cfg.regs; in dsi_host_regulator_disable()
219 int num = msm_host->cfg_hnd->cfg->reg_cfg.num; in dsi_host_regulator_disable()
231 static int dsi_host_regulator_enable(struct msm_dsi_host *msm_host) in dsi_host_regulator_enable() argument
233 struct regulator_bulk_data *s = msm_host->supplies; in dsi_host_regulator_enable()
234 const struct dsi_reg_entry *regs = msm_host->cfg_hnd->cfg->reg_cfg.regs; in dsi_host_regulator_enable()
235 int num = msm_host->cfg_hnd->cfg->reg_cfg.num; in dsi_host_regulator_enable()
265 static int dsi_regulator_init(struct msm_dsi_host *msm_host) in dsi_regulator_init() argument
267 struct regulator_bulk_data *s = msm_host->supplies; in dsi_regulator_init()
268 const struct dsi_reg_entry *regs = msm_host->cfg_hnd->cfg->reg_cfg.regs; in dsi_regulator_init()
269 int num = msm_host->cfg_hnd->cfg->reg_cfg.num; in dsi_regulator_init()
275 ret = devm_regulator_bulk_get(&msm_host->pdev->dev, num, s); in dsi_regulator_init()
297 static int dsi_clk_init(struct msm_dsi_host *msm_host) in dsi_clk_init() argument
299 struct device *dev = &msm_host->pdev->dev; in dsi_clk_init()
302 msm_host->mdp_core_clk = devm_clk_get(dev, "mdp_core_clk"); in dsi_clk_init()
303 if (IS_ERR(msm_host->mdp_core_clk)) { in dsi_clk_init()
304 ret = PTR_ERR(msm_host->mdp_core_clk); in dsi_clk_init()
310 msm_host->ahb_clk = devm_clk_get(dev, "iface_clk"); in dsi_clk_init()
311 if (IS_ERR(msm_host->ahb_clk)) { in dsi_clk_init()
312 ret = PTR_ERR(msm_host->ahb_clk); in dsi_clk_init()
318 msm_host->axi_clk = devm_clk_get(dev, "bus_clk"); in dsi_clk_init()
319 if (IS_ERR(msm_host->axi_clk)) { in dsi_clk_init()
320 ret = PTR_ERR(msm_host->axi_clk); in dsi_clk_init()
326 msm_host->mmss_misc_ahb_clk = devm_clk_get(dev, "core_mmss_clk"); in dsi_clk_init()
327 if (IS_ERR(msm_host->mmss_misc_ahb_clk)) { in dsi_clk_init()
328 ret = PTR_ERR(msm_host->mmss_misc_ahb_clk); in dsi_clk_init()
334 msm_host->byte_clk = devm_clk_get(dev, "byte_clk"); in dsi_clk_init()
335 if (IS_ERR(msm_host->byte_clk)) { in dsi_clk_init()
336 ret = PTR_ERR(msm_host->byte_clk); in dsi_clk_init()
339 msm_host->byte_clk = NULL; in dsi_clk_init()
343 msm_host->pixel_clk = devm_clk_get(dev, "pixel_clk"); in dsi_clk_init()
344 if (IS_ERR(msm_host->pixel_clk)) { in dsi_clk_init()
345 ret = PTR_ERR(msm_host->pixel_clk); in dsi_clk_init()
348 msm_host->pixel_clk = NULL; in dsi_clk_init()
352 msm_host->esc_clk = devm_clk_get(dev, "core_clk"); in dsi_clk_init()
353 if (IS_ERR(msm_host->esc_clk)) { in dsi_clk_init()
354 ret = PTR_ERR(msm_host->esc_clk); in dsi_clk_init()
357 msm_host->esc_clk = NULL; in dsi_clk_init()
361 msm_host->byte_clk_src = devm_clk_get(dev, "byte_clk_src"); in dsi_clk_init()
362 if (IS_ERR(msm_host->byte_clk_src)) { in dsi_clk_init()
363 ret = PTR_ERR(msm_host->byte_clk_src); in dsi_clk_init()
365 msm_host->byte_clk_src = NULL; in dsi_clk_init()
369 msm_host->pixel_clk_src = devm_clk_get(dev, "pixel_clk_src"); in dsi_clk_init()
370 if (IS_ERR(msm_host->pixel_clk_src)) { in dsi_clk_init()
371 ret = PTR_ERR(msm_host->pixel_clk_src); in dsi_clk_init()
373 msm_host->pixel_clk_src = NULL; in dsi_clk_init()
381 static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host) in dsi_bus_clk_enable() argument
385 DBG("id=%d", msm_host->id); in dsi_bus_clk_enable()
387 ret = clk_prepare_enable(msm_host->mdp_core_clk); in dsi_bus_clk_enable()
394 ret = clk_prepare_enable(msm_host->ahb_clk); in dsi_bus_clk_enable()
400 ret = clk_prepare_enable(msm_host->axi_clk); in dsi_bus_clk_enable()
406 ret = clk_prepare_enable(msm_host->mmss_misc_ahb_clk); in dsi_bus_clk_enable()
416 clk_disable_unprepare(msm_host->axi_clk); in dsi_bus_clk_enable()
418 clk_disable_unprepare(msm_host->ahb_clk); in dsi_bus_clk_enable()
420 clk_disable_unprepare(msm_host->mdp_core_clk); in dsi_bus_clk_enable()
425 static void dsi_bus_clk_disable(struct msm_dsi_host *msm_host) in dsi_bus_clk_disable() argument
428 clk_disable_unprepare(msm_host->mmss_misc_ahb_clk); in dsi_bus_clk_disable()
429 clk_disable_unprepare(msm_host->axi_clk); in dsi_bus_clk_disable()
430 clk_disable_unprepare(msm_host->ahb_clk); in dsi_bus_clk_disable()
431 clk_disable_unprepare(msm_host->mdp_core_clk); in dsi_bus_clk_disable()
434 static int dsi_link_clk_enable(struct msm_dsi_host *msm_host) in dsi_link_clk_enable() argument
439 msm_host->mode->clock, msm_host->byte_clk_rate); in dsi_link_clk_enable()
441 ret = clk_set_rate(msm_host->byte_clk, msm_host->byte_clk_rate); in dsi_link_clk_enable()
447 ret = clk_set_rate(msm_host->pixel_clk, msm_host->mode->clock * 1000); in dsi_link_clk_enable()
453 ret = clk_prepare_enable(msm_host->esc_clk); in dsi_link_clk_enable()
459 ret = clk_prepare_enable(msm_host->byte_clk); in dsi_link_clk_enable()
465 ret = clk_prepare_enable(msm_host->pixel_clk); in dsi_link_clk_enable()
474 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_enable()
476 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_enable()
481 static void dsi_link_clk_disable(struct msm_dsi_host *msm_host) in dsi_link_clk_disable() argument
483 clk_disable_unprepare(msm_host->esc_clk); in dsi_link_clk_disable()
484 clk_disable_unprepare(msm_host->pixel_clk); in dsi_link_clk_disable()
485 clk_disable_unprepare(msm_host->byte_clk); in dsi_link_clk_disable()
488 static int dsi_clk_ctrl(struct msm_dsi_host *msm_host, bool enable) in dsi_clk_ctrl() argument
492 mutex_lock(&msm_host->clk_mutex); in dsi_clk_ctrl()
494 ret = dsi_bus_clk_enable(msm_host); in dsi_clk_ctrl()
500 ret = dsi_link_clk_enable(msm_host); in dsi_clk_ctrl()
504 dsi_bus_clk_disable(msm_host); in dsi_clk_ctrl()
508 dsi_link_clk_disable(msm_host); in dsi_clk_ctrl()
509 dsi_bus_clk_disable(msm_host); in dsi_clk_ctrl()
513 mutex_unlock(&msm_host->clk_mutex); in dsi_clk_ctrl()
517 static int dsi_calc_clk_rate(struct msm_dsi_host *msm_host) in dsi_calc_clk_rate() argument
519 struct drm_display_mode *mode = msm_host->mode; in dsi_calc_clk_rate()
520 u8 lanes = msm_host->lanes; in dsi_calc_clk_rate()
521 u32 bpp = dsi_get_bpp(msm_host->format); in dsi_calc_clk_rate()
531 msm_host->byte_clk_rate = (pclk_rate * bpp) / (8 * lanes); in dsi_calc_clk_rate()
534 msm_host->byte_clk_rate = (pclk_rate * bpp) / 8; in dsi_calc_clk_rate()
537 DBG("pclk=%d, bclk=%d", pclk_rate, msm_host->byte_clk_rate); in dsi_calc_clk_rate()
542 static void dsi_phy_sw_reset(struct msm_dsi_host *msm_host) in dsi_phy_sw_reset() argument
545 dsi_write(msm_host, REG_DSI_PHY_RESET, DSI_PHY_RESET_RESET); in dsi_phy_sw_reset()
549 dsi_write(msm_host, REG_DSI_PHY_RESET, 0); in dsi_phy_sw_reset()
553 static void dsi_intr_ctrl(struct msm_dsi_host *msm_host, u32 mask, int enable) in dsi_intr_ctrl() argument
558 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
559 intr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_intr_ctrl()
568 dsi_write(msm_host, REG_DSI_INTR_CTRL, intr); in dsi_intr_ctrl()
569 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_intr_ctrl()
606 static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable, in dsi_ctrl_config() argument
609 u32 flags = msm_host->mode_flags; in dsi_ctrl_config()
610 enum mipi_dsi_pixel_format mipi_fmt = msm_host->format; in dsi_ctrl_config()
611 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in dsi_ctrl_config()
615 dsi_write(msm_host, REG_DSI_CTRL, 0); in dsi_ctrl_config()
635 data |= DSI_VID_CFG0_VIRT_CHANNEL(msm_host->channel); in dsi_ctrl_config()
636 dsi_write(msm_host, REG_DSI_VID_CFG0, data); in dsi_ctrl_config()
640 dsi_write(msm_host, REG_DSI_VID_CFG1, 0); in dsi_ctrl_config()
645 dsi_write(msm_host, REG_DSI_CMD_CFG0, data); in dsi_ctrl_config()
652 dsi_write(msm_host, REG_DSI_CMD_CFG1, data); in dsi_ctrl_config()
655 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, in dsi_ctrl_config()
664 data |= DSI_TRIG_CTRL_STREAM(msm_host->channel); in dsi_ctrl_config()
668 dsi_write(msm_host, REG_DSI_TRIG_CTRL, data); in dsi_ctrl_config()
672 dsi_write(msm_host, REG_DSI_CLKOUT_TIMING_CTRL, data); in dsi_ctrl_config()
677 dsi_write(msm_host, REG_DSI_EOT_PACKET_CTRL, data); in dsi_ctrl_config()
680 dsi_write(msm_host, REG_DSI_ERR_INT_MASK0, 0x13ff3fe0); in dsi_ctrl_config()
682 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_ctrl_config()
684 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_ctrl_config()
688 DBG("lane number=%d", msm_host->lanes); in dsi_ctrl_config()
689 if (msm_host->lanes == 2) { in dsi_ctrl_config()
692 dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL, in dsi_ctrl_config()
699 dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL, in dsi_ctrl_config()
704 dsi_write(msm_host, REG_DSI_LANE_CTRL, in dsi_ctrl_config()
709 dsi_write(msm_host, REG_DSI_CTRL, data); in dsi_ctrl_config()
712 static void dsi_timing_setup(struct msm_dsi_host *msm_host) in dsi_timing_setup() argument
714 struct drm_display_mode *mode = msm_host->mode; in dsi_timing_setup()
728 if (msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) { in dsi_timing_setup()
729 dsi_write(msm_host, REG_DSI_ACTIVE_H, in dsi_timing_setup()
732 dsi_write(msm_host, REG_DSI_ACTIVE_V, in dsi_timing_setup()
735 dsi_write(msm_host, REG_DSI_TOTAL, in dsi_timing_setup()
739 dsi_write(msm_host, REG_DSI_ACTIVE_HSYNC, in dsi_timing_setup()
742 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_HPOS, 0); in dsi_timing_setup()
743 dsi_write(msm_host, REG_DSI_ACTIVE_VSYNC_VPOS, in dsi_timing_setup()
748 wc = mode->hdisplay * dsi_get_bpp(msm_host->format) / 8 + 1; in dsi_timing_setup()
750 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM_CTRL, in dsi_timing_setup()
753 msm_host->channel) | in dsi_timing_setup()
757 dsi_write(msm_host, REG_DSI_CMD_MDP_STREAM_TOTAL, in dsi_timing_setup()
763 static void dsi_sw_reset(struct msm_dsi_host *msm_host) in dsi_sw_reset() argument
765 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset()
768 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset()
770 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset()
773 static void dsi_op_mode_config(struct msm_dsi_host *msm_host, in dsi_op_mode_config() argument
778 dsi_ctrl = dsi_read(msm_host, REG_DSI_CTRL); in dsi_op_mode_config()
783 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE | in dsi_op_mode_config()
790 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_MDP_DONE, 1); in dsi_op_mode_config()
795 dsi_write(msm_host, REG_DSI_CTRL, dsi_ctrl); in dsi_op_mode_config()
798 static void dsi_set_tx_power_mode(int mode, struct msm_dsi_host *msm_host) in dsi_set_tx_power_mode() argument
802 data = dsi_read(msm_host, REG_DSI_CMD_DMA_CTRL); in dsi_set_tx_power_mode()
809 dsi_write(msm_host, REG_DSI_CMD_DMA_CTRL, data); in dsi_set_tx_power_mode()
812 static void dsi_wait4video_done(struct msm_dsi_host *msm_host) in dsi_wait4video_done() argument
814 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 1); in dsi_wait4video_done()
816 reinit_completion(&msm_host->video_comp); in dsi_wait4video_done()
818 wait_for_completion_timeout(&msm_host->video_comp, in dsi_wait4video_done()
821 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0); in dsi_wait4video_done()
824 static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host) in dsi_wait4video_eng_busy() argument
826 if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO)) in dsi_wait4video_eng_busy()
829 if (msm_host->power_on) { in dsi_wait4video_eng_busy()
830 dsi_wait4video_done(msm_host); in dsi_wait4video_eng_busy()
837 static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size) in dsi_tx_buf_alloc() argument
839 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_alloc()
844 msm_host->tx_gem_obj = msm_gem_new(dev, size, MSM_BO_UNCACHED); in dsi_tx_buf_alloc()
845 if (IS_ERR(msm_host->tx_gem_obj)) { in dsi_tx_buf_alloc()
846 ret = PTR_ERR(msm_host->tx_gem_obj); in dsi_tx_buf_alloc()
848 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_alloc()
853 ret = msm_gem_get_iova_locked(msm_host->tx_gem_obj, 0, &iova); in dsi_tx_buf_alloc()
868 static void dsi_tx_buf_free(struct msm_dsi_host *msm_host) in dsi_tx_buf_free() argument
870 struct drm_device *dev = msm_host->dev; in dsi_tx_buf_free()
872 if (msm_host->tx_gem_obj) { in dsi_tx_buf_free()
873 msm_gem_put_iova(msm_host->tx_gem_obj, 0); in dsi_tx_buf_free()
875 msm_gem_free_object(msm_host->tx_gem_obj); in dsi_tx_buf_free()
876 msm_host->tx_gem_obj = NULL; in dsi_tx_buf_free()
976 static int dsi_cmd_dma_tx(struct msm_dsi_host *msm_host, int len) in dsi_cmd_dma_tx() argument
982 ret = msm_gem_get_iova(msm_host->tx_gem_obj, 0, &iova); in dsi_cmd_dma_tx()
988 reinit_completion(&msm_host->dma_comp); in dsi_cmd_dma_tx()
990 dsi_wait4video_eng_busy(msm_host); in dsi_cmd_dma_tx()
993 msm_host->id, iova, len); in dsi_cmd_dma_tx()
995 ret = wait_for_completion_timeout(&msm_host->dma_comp, in dsi_cmd_dma_tx()
1008 static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host, in dsi_cmd_dma_rx() argument
1016 int buf_offset = buf - msm_host->rx_buf; in dsi_cmd_dma_rx()
1047 data = dsi_read(msm_host, REG_DSI_RDBK_DATA(i)); in dsi_cmd_dma_rx()
1058 static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, in dsi_cmds2buf_tx() argument
1062 int bllp_len = msm_host->mode->hdisplay * in dsi_cmds2buf_tx()
1063 dsi_get_bpp(msm_host->format) / 8; in dsi_cmds2buf_tx()
1065 len = dsi_cmd_dma_add(msm_host->tx_gem_obj, msg); in dsi_cmds2buf_tx()
1081 if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && (len > bllp_len)) { in dsi_cmds2buf_tx()
1087 ret = dsi_cmd_dma_tx(msm_host, len); in dsi_cmds2buf_tx()
1097 static void dsi_sw_reset_restore(struct msm_dsi_host *msm_host) in dsi_sw_reset_restore() argument
1101 data0 = dsi_read(msm_host, REG_DSI_CTRL); in dsi_sw_reset_restore()
1104 dsi_write(msm_host, REG_DSI_CTRL, data1); in dsi_sw_reset_restore()
1111 dsi_write(msm_host, REG_DSI_CLK_CTRL, DSI_CLK_CTRL_ENABLE_CLKS); in dsi_sw_reset_restore()
1115 dsi_write(msm_host, REG_DSI_RESET, 1); in dsi_sw_reset_restore()
1117 dsi_write(msm_host, REG_DSI_RESET, 0); in dsi_sw_reset_restore()
1119 dsi_write(msm_host, REG_DSI_CTRL, data0); in dsi_sw_reset_restore()
1125 struct msm_dsi_host *msm_host = in dsi_err_worker() local
1127 u32 status = msm_host->err_work_state; in dsi_err_worker()
1131 dsi_sw_reset_restore(msm_host); in dsi_err_worker()
1134 msm_host->err_work_state = 0; in dsi_err_worker()
1137 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 1); in dsi_err_worker()
1140 static void dsi_ack_err_status(struct msm_dsi_host *msm_host) in dsi_ack_err_status() argument
1144 status = dsi_read(msm_host, REG_DSI_ACK_ERR_STATUS); in dsi_ack_err_status()
1147 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, status); in dsi_ack_err_status()
1149 dsi_write(msm_host, REG_DSI_ACK_ERR_STATUS, 0); in dsi_ack_err_status()
1150 msm_host->err_work_state |= DSI_ERR_STATE_ACK; in dsi_ack_err_status()
1154 static void dsi_timeout_status(struct msm_dsi_host *msm_host) in dsi_timeout_status() argument
1158 status = dsi_read(msm_host, REG_DSI_TIMEOUT_STATUS); in dsi_timeout_status()
1161 dsi_write(msm_host, REG_DSI_TIMEOUT_STATUS, status); in dsi_timeout_status()
1162 msm_host->err_work_state |= DSI_ERR_STATE_TIMEOUT; in dsi_timeout_status()
1166 static void dsi_dln0_phy_err(struct msm_dsi_host *msm_host) in dsi_dln0_phy_err() argument
1170 status = dsi_read(msm_host, REG_DSI_DLN0_PHY_ERR); in dsi_dln0_phy_err()
1177 dsi_write(msm_host, REG_DSI_DLN0_PHY_ERR, status); in dsi_dln0_phy_err()
1178 msm_host->err_work_state |= DSI_ERR_STATE_DLN0_PHY; in dsi_dln0_phy_err()
1182 static void dsi_fifo_status(struct msm_dsi_host *msm_host) in dsi_fifo_status() argument
1186 status = dsi_read(msm_host, REG_DSI_FIFO_STATUS); in dsi_fifo_status()
1190 dsi_write(msm_host, REG_DSI_FIFO_STATUS, status); in dsi_fifo_status()
1191 msm_host->err_work_state |= DSI_ERR_STATE_FIFO; in dsi_fifo_status()
1193 msm_host->err_work_state |= in dsi_fifo_status()
1198 static void dsi_status(struct msm_dsi_host *msm_host) in dsi_status() argument
1202 status = dsi_read(msm_host, REG_DSI_STATUS0); in dsi_status()
1205 dsi_write(msm_host, REG_DSI_STATUS0, status); in dsi_status()
1206 msm_host->err_work_state |= in dsi_status()
1211 static void dsi_clk_status(struct msm_dsi_host *msm_host) in dsi_clk_status() argument
1215 status = dsi_read(msm_host, REG_DSI_CLK_STATUS); in dsi_clk_status()
1218 dsi_write(msm_host, REG_DSI_CLK_STATUS, status); in dsi_clk_status()
1219 msm_host->err_work_state |= DSI_ERR_STATE_PLL_UNLOCKED; in dsi_clk_status()
1223 static void dsi_error(struct msm_dsi_host *msm_host) in dsi_error() argument
1226 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_ERROR, 0); in dsi_error()
1228 dsi_clk_status(msm_host); in dsi_error()
1229 dsi_fifo_status(msm_host); in dsi_error()
1230 dsi_ack_err_status(msm_host); in dsi_error()
1231 dsi_timeout_status(msm_host); in dsi_error()
1232 dsi_status(msm_host); in dsi_error()
1233 dsi_dln0_phy_err(msm_host); in dsi_error()
1235 queue_work(msm_host->workqueue, &msm_host->err_work); in dsi_error()
1240 struct msm_dsi_host *msm_host = ptr; in dsi_host_irq() local
1244 if (!msm_host->ctrl_base) in dsi_host_irq()
1247 spin_lock_irqsave(&msm_host->intr_lock, flags); in dsi_host_irq()
1248 isr = dsi_read(msm_host, REG_DSI_INTR_CTRL); in dsi_host_irq()
1249 dsi_write(msm_host, REG_DSI_INTR_CTRL, isr); in dsi_host_irq()
1250 spin_unlock_irqrestore(&msm_host->intr_lock, flags); in dsi_host_irq()
1252 DBG("isr=0x%x, id=%d", isr, msm_host->id); in dsi_host_irq()
1255 dsi_error(msm_host); in dsi_host_irq()
1258 complete(&msm_host->video_comp); in dsi_host_irq()
1261 complete(&msm_host->dma_comp); in dsi_host_irq()
1266 static int dsi_host_init_panel_gpios(struct msm_dsi_host *msm_host, in dsi_host_init_panel_gpios() argument
1269 msm_host->disp_en_gpio = devm_gpiod_get_optional(panel_device, in dsi_host_init_panel_gpios()
1272 if (IS_ERR(msm_host->disp_en_gpio)) { in dsi_host_init_panel_gpios()
1274 PTR_ERR(msm_host->disp_en_gpio)); in dsi_host_init_panel_gpios()
1275 return PTR_ERR(msm_host->disp_en_gpio); in dsi_host_init_panel_gpios()
1278 msm_host->te_gpio = devm_gpiod_get_optional(panel_device, "disp-te", in dsi_host_init_panel_gpios()
1280 if (IS_ERR(msm_host->te_gpio)) { in dsi_host_init_panel_gpios()
1281 DBG("cannot get disp-te-gpios %ld", PTR_ERR(msm_host->te_gpio)); in dsi_host_init_panel_gpios()
1282 return PTR_ERR(msm_host->te_gpio); in dsi_host_init_panel_gpios()
1291 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_attach() local
1294 msm_host->channel = dsi->channel; in dsi_host_attach()
1295 msm_host->lanes = dsi->lanes; in dsi_host_attach()
1296 msm_host->format = dsi->format; in dsi_host_attach()
1297 msm_host->mode_flags = dsi->mode_flags; in dsi_host_attach()
1299 WARN_ON(dsi->dev.of_node != msm_host->device_node); in dsi_host_attach()
1302 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); in dsi_host_attach()
1306 DBG("id=%d", msm_host->id); in dsi_host_attach()
1307 if (msm_host->dev) in dsi_host_attach()
1308 drm_helper_hpd_irq_event(msm_host->dev); in dsi_host_attach()
1316 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_detach() local
1318 msm_host->device_node = NULL; in dsi_host_detach()
1320 DBG("id=%d", msm_host->id); in dsi_host_detach()
1321 if (msm_host->dev) in dsi_host_detach()
1322 drm_helper_hpd_irq_event(msm_host->dev); in dsi_host_detach()
1330 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in dsi_host_transfer() local
1333 if (!msg || !msm_host->power_on) in dsi_host_transfer()
1336 mutex_lock(&msm_host->cmd_mutex); in dsi_host_transfer()
1337 ret = msm_dsi_manager_cmd_xfer(msm_host->id, msg); in dsi_host_transfer()
1338 mutex_unlock(&msm_host->cmd_mutex); in dsi_host_transfer()
1349 static int dsi_host_parse_dt(struct msm_dsi_host *msm_host) in dsi_host_parse_dt() argument
1351 struct device *dev = &msm_host->pdev->dev; in dsi_host_parse_dt()
1356 ret = of_property_read_u32(np, "qcom,dsi-host-index", &msm_host->id); in dsi_host_parse_dt()
1386 msm_host->device_node = device_node; in dsi_host_parse_dt()
1393 struct msm_dsi_host *msm_host = NULL; in msm_dsi_host_init() local
1397 msm_host = devm_kzalloc(&pdev->dev, sizeof(*msm_host), GFP_KERNEL); in msm_dsi_host_init()
1398 if (!msm_host) { in msm_dsi_host_init()
1405 msm_host->pdev = pdev; in msm_dsi_host_init()
1407 ret = dsi_host_parse_dt(msm_host); in msm_dsi_host_init()
1413 ret = dsi_clk_init(msm_host); in msm_dsi_host_init()
1419 msm_host->ctrl_base = msm_ioremap(pdev, "dsi_ctrl", "DSI CTRL"); in msm_dsi_host_init()
1420 if (IS_ERR(msm_host->ctrl_base)) { in msm_dsi_host_init()
1422 ret = PTR_ERR(msm_host->ctrl_base); in msm_dsi_host_init()
1426 msm_host->cfg_hnd = dsi_get_config(msm_host); in msm_dsi_host_init()
1427 if (!msm_host->cfg_hnd) { in msm_dsi_host_init()
1434 msm_host->ctrl_base += msm_host->cfg_hnd->cfg->io_offset; in msm_dsi_host_init()
1436 ret = dsi_regulator_init(msm_host); in msm_dsi_host_init()
1442 msm_host->rx_buf = devm_kzalloc(&pdev->dev, SZ_4K, GFP_KERNEL); in msm_dsi_host_init()
1443 if (!msm_host->rx_buf) { in msm_dsi_host_init()
1448 init_completion(&msm_host->dma_comp); in msm_dsi_host_init()
1449 init_completion(&msm_host->video_comp); in msm_dsi_host_init()
1450 mutex_init(&msm_host->dev_mutex); in msm_dsi_host_init()
1451 mutex_init(&msm_host->cmd_mutex); in msm_dsi_host_init()
1452 mutex_init(&msm_host->clk_mutex); in msm_dsi_host_init()
1453 spin_lock_init(&msm_host->intr_lock); in msm_dsi_host_init()
1456 msm_host->workqueue = alloc_ordered_workqueue("dsi_drm_work", 0); in msm_dsi_host_init()
1457 INIT_WORK(&msm_host->err_work, dsi_err_worker); in msm_dsi_host_init()
1459 msm_dsi->host = &msm_host->base; in msm_dsi_host_init()
1460 msm_dsi->id = msm_host->id; in msm_dsi_host_init()
1462 DBG("Dsi Host %d initialized", msm_host->id); in msm_dsi_host_init()
1471 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_destroy() local
1474 dsi_tx_buf_free(msm_host); in msm_dsi_host_destroy()
1475 if (msm_host->workqueue) { in msm_dsi_host_destroy()
1476 flush_workqueue(msm_host->workqueue); in msm_dsi_host_destroy()
1477 destroy_workqueue(msm_host->workqueue); in msm_dsi_host_destroy()
1478 msm_host->workqueue = NULL; in msm_dsi_host_destroy()
1481 mutex_destroy(&msm_host->clk_mutex); in msm_dsi_host_destroy()
1482 mutex_destroy(&msm_host->cmd_mutex); in msm_dsi_host_destroy()
1483 mutex_destroy(&msm_host->dev_mutex); in msm_dsi_host_destroy()
1489 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_modeset_init() local
1490 struct platform_device *pdev = msm_host->pdev; in msm_dsi_host_modeset_init()
1493 msm_host->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in msm_dsi_host_modeset_init()
1494 if (msm_host->irq < 0) { in msm_dsi_host_modeset_init()
1495 ret = msm_host->irq; in msm_dsi_host_modeset_init()
1500 ret = devm_request_irq(&pdev->dev, msm_host->irq, in msm_dsi_host_modeset_init()
1502 "dsi_isr", msm_host); in msm_dsi_host_modeset_init()
1505 msm_host->irq, ret); in msm_dsi_host_modeset_init()
1509 msm_host->dev = dev; in msm_dsi_host_modeset_init()
1510 ret = dsi_tx_buf_alloc(msm_host, SZ_4K); in msm_dsi_host_modeset_init()
1521 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_register() local
1525 if (!msm_host->registered) { in msm_dsi_host_register()
1526 host->dev = &msm_host->pdev->dev; in msm_dsi_host_register()
1532 msm_host->registered = true; in msm_dsi_host_register()
1542 if (check_defer && msm_host->device_node) { in msm_dsi_host_register()
1543 if (!of_drm_find_panel(msm_host->device_node)) in msm_dsi_host_register()
1544 if (!of_drm_find_bridge(msm_host->device_node)) in msm_dsi_host_register()
1554 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_unregister() local
1556 if (msm_host->registered) { in msm_dsi_host_unregister()
1560 msm_host->registered = false; in msm_dsi_host_unregister()
1567 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_prepare() local
1579 dsi_clk_ctrl(msm_host, 1); in msm_dsi_host_xfer_prepare()
1584 dsi_set_tx_power_mode(0, msm_host); in msm_dsi_host_xfer_prepare()
1586 msm_host->dma_cmd_ctrl_restore = dsi_read(msm_host, REG_DSI_CTRL); in msm_dsi_host_xfer_prepare()
1587 dsi_write(msm_host, REG_DSI_CTRL, in msm_dsi_host_xfer_prepare()
1588 msm_host->dma_cmd_ctrl_restore | in msm_dsi_host_xfer_prepare()
1591 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 1); in msm_dsi_host_xfer_prepare()
1599 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_xfer_restore() local
1601 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_CMD_DMA_DONE, 0); in msm_dsi_host_xfer_restore()
1602 dsi_write(msm_host, REG_DSI_CTRL, msm_host->dma_cmd_ctrl_restore); in msm_dsi_host_xfer_restore()
1605 dsi_set_tx_power_mode(1, msm_host); in msm_dsi_host_xfer_restore()
1609 dsi_clk_ctrl(msm_host, 0); in msm_dsi_host_xfer_restore()
1615 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_tx() local
1617 return dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_tx()
1623 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_rx() local
1624 const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd; in msm_dsi_host_cmd_rx()
1645 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
1659 ret = dsi_cmds2buf_tx(msm_host, &max_pkt_size_msg); in msm_dsi_host_cmd_rx()
1669 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, in msm_dsi_host_cmd_rx()
1672 dsi_write(msm_host, REG_DSI_RDBK_DATA_CTRL, 0); in msm_dsi_host_cmd_rx()
1676 ret = dsi_cmds2buf_tx(msm_host, msg); in msm_dsi_host_cmd_rx()
1689 dlen = dsi_cmd_dma_rx(msm_host, buf, rx_byte, pkt_size); in msm_dsi_host_cmd_rx()
1725 buf = msm_host->rx_buf + (10 - rlen); in msm_dsi_host_cmd_rx()
1727 buf = msm_host->rx_buf; in msm_dsi_host_cmd_rx()
1757 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_cmd_xfer_commit() local
1759 dsi_write(msm_host, REG_DSI_DMA_BASE, iova); in msm_dsi_host_cmd_xfer_commit()
1760 dsi_write(msm_host, REG_DSI_DMA_LEN, len); in msm_dsi_host_cmd_xfer_commit()
1761 dsi_write(msm_host, REG_DSI_TRIG_DMA, 1); in msm_dsi_host_cmd_xfer_commit()
1770 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_src_pll() local
1782 ret = clk_set_parent(msm_host->byte_clk_src, byte_clk_provider); in msm_dsi_host_set_src_pll()
1789 ret = clk_set_parent(msm_host->pixel_clk_src, pixel_clk_provider); in msm_dsi_host_set_src_pll()
1802 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_enable() local
1804 dsi_op_mode_config(msm_host, in msm_dsi_host_enable()
1805 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), true); in msm_dsi_host_enable()
1819 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_disable() local
1821 dsi_op_mode_config(msm_host, in msm_dsi_host_disable()
1822 !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO), false); in msm_dsi_host_disable()
1828 dsi_sw_reset(msm_host); in msm_dsi_host_disable()
1835 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_on() local
1839 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
1840 if (msm_host->power_on) { in msm_dsi_host_power_on()
1845 ret = dsi_calc_clk_rate(msm_host); in msm_dsi_host_power_on()
1851 ret = dsi_host_regulator_enable(msm_host); in msm_dsi_host_power_on()
1858 ret = dsi_bus_clk_enable(msm_host); in msm_dsi_host_power_on()
1864 dsi_phy_sw_reset(msm_host); in msm_dsi_host_power_on()
1865 ret = msm_dsi_manager_phy_enable(msm_host->id, in msm_dsi_host_power_on()
1866 msm_host->byte_clk_rate * 8, in msm_dsi_host_power_on()
1867 clk_get_rate(msm_host->esc_clk), in msm_dsi_host_power_on()
1869 dsi_bus_clk_disable(msm_host); in msm_dsi_host_power_on()
1875 ret = dsi_clk_ctrl(msm_host, 1); in msm_dsi_host_power_on()
1881 ret = pinctrl_pm_select_default_state(&msm_host->pdev->dev); in msm_dsi_host_power_on()
1888 dsi_timing_setup(msm_host); in msm_dsi_host_power_on()
1889 dsi_sw_reset(msm_host); in msm_dsi_host_power_on()
1890 dsi_ctrl_config(msm_host, true, clk_pre, clk_post); in msm_dsi_host_power_on()
1892 if (msm_host->disp_en_gpio) in msm_dsi_host_power_on()
1893 gpiod_set_value(msm_host->disp_en_gpio, 1); in msm_dsi_host_power_on()
1895 msm_host->power_on = true; in msm_dsi_host_power_on()
1896 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
1901 dsi_clk_ctrl(msm_host, 0); in msm_dsi_host_power_on()
1903 dsi_host_regulator_disable(msm_host); in msm_dsi_host_power_on()
1905 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_on()
1911 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_power_off() local
1913 mutex_lock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
1914 if (!msm_host->power_on) { in msm_dsi_host_power_off()
1919 dsi_ctrl_config(msm_host, false, 0, 0); in msm_dsi_host_power_off()
1921 if (msm_host->disp_en_gpio) in msm_dsi_host_power_off()
1922 gpiod_set_value(msm_host->disp_en_gpio, 0); in msm_dsi_host_power_off()
1924 pinctrl_pm_select_sleep_state(&msm_host->pdev->dev); in msm_dsi_host_power_off()
1926 msm_dsi_manager_phy_disable(msm_host->id); in msm_dsi_host_power_off()
1928 dsi_clk_ctrl(msm_host, 0); in msm_dsi_host_power_off()
1930 dsi_host_regulator_disable(msm_host); in msm_dsi_host_power_off()
1934 msm_host->power_on = false; in msm_dsi_host_power_off()
1937 mutex_unlock(&msm_host->dev_mutex); in msm_dsi_host_power_off()
1944 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_set_display_mode() local
1946 if (msm_host->mode) { in msm_dsi_host_set_display_mode()
1947 drm_mode_destroy(msm_host->dev, msm_host->mode); in msm_dsi_host_set_display_mode()
1948 msm_host->mode = NULL; in msm_dsi_host_set_display_mode()
1951 msm_host->mode = drm_mode_duplicate(msm_host->dev, mode); in msm_dsi_host_set_display_mode()
1952 if (IS_ERR(msm_host->mode)) { in msm_dsi_host_set_display_mode()
1954 return PTR_ERR(msm_host->mode); in msm_dsi_host_set_display_mode()
1963 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_panel() local
1966 panel = of_drm_find_panel(msm_host->device_node); in msm_dsi_host_get_panel()
1968 *panel_flags = msm_host->mode_flags; in msm_dsi_host_get_panel()
1975 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); in msm_dsi_host_get_bridge() local
1977 return of_drm_find_bridge(msm_host->device_node); in msm_dsi_host_get_bridge()