Lines Matching full:dsi
222 static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data) in mtk_dsi_mask() argument
224 u32 temp = readl(dsi->regs + offset); in mtk_dsi_mask()
226 writel((temp & ~mask) | (data & mask), dsi->regs + offset); in mtk_dsi_mask()
229 static void mtk_dsi_phy_timconfig(struct mtk_dsi *dsi) in mtk_dsi_phy_timconfig() argument
232 u32 data_rate_mhz = DIV_ROUND_UP(dsi->data_rate, 1000000); in mtk_dsi_phy_timconfig()
233 struct mtk_phy_timing *timing = &dsi->phy_timing; in mtk_dsi_phy_timconfig()
261 writel(timcon0, dsi->regs + DSI_PHY_TIMECON0); in mtk_dsi_phy_timconfig()
262 writel(timcon1, dsi->regs + DSI_PHY_TIMECON1); in mtk_dsi_phy_timconfig()
263 writel(timcon2, dsi->regs + DSI_PHY_TIMECON2); in mtk_dsi_phy_timconfig()
264 writel(timcon3, dsi->regs + DSI_PHY_TIMECON3); in mtk_dsi_phy_timconfig()
267 static void mtk_dsi_enable(struct mtk_dsi *dsi) in mtk_dsi_enable() argument
269 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_EN, DSI_EN); in mtk_dsi_enable()
272 static void mtk_dsi_disable(struct mtk_dsi *dsi) in mtk_dsi_disable() argument
274 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_EN, 0); in mtk_dsi_disable()
277 static void mtk_dsi_reset_engine(struct mtk_dsi *dsi) in mtk_dsi_reset_engine() argument
279 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_RESET, DSI_RESET); in mtk_dsi_reset_engine()
280 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_RESET, 0); in mtk_dsi_reset_engine()
283 static void mtk_dsi_reset_dphy(struct mtk_dsi *dsi) in mtk_dsi_reset_dphy() argument
285 mtk_dsi_mask(dsi, DSI_CON_CTRL, DPHY_RESET, DPHY_RESET); in mtk_dsi_reset_dphy()
286 mtk_dsi_mask(dsi, DSI_CON_CTRL, DPHY_RESET, 0); in mtk_dsi_reset_dphy()
289 static void mtk_dsi_clk_ulp_mode_enter(struct mtk_dsi *dsi) in mtk_dsi_clk_ulp_mode_enter() argument
291 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_HS_TX_EN, 0); in mtk_dsi_clk_ulp_mode_enter()
292 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_ULPM_EN, 0); in mtk_dsi_clk_ulp_mode_enter()
295 static void mtk_dsi_clk_ulp_mode_leave(struct mtk_dsi *dsi) in mtk_dsi_clk_ulp_mode_leave() argument
297 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_ULPM_EN, 0); in mtk_dsi_clk_ulp_mode_leave()
298 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_WAKEUP_EN, LC_WAKEUP_EN); in mtk_dsi_clk_ulp_mode_leave()
299 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_WAKEUP_EN, 0); in mtk_dsi_clk_ulp_mode_leave()
302 static void mtk_dsi_lane0_ulp_mode_enter(struct mtk_dsi *dsi) in mtk_dsi_lane0_ulp_mode_enter() argument
304 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_HS_TX_EN, 0); in mtk_dsi_lane0_ulp_mode_enter()
305 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_ULPM_EN, 0); in mtk_dsi_lane0_ulp_mode_enter()
308 static void mtk_dsi_lane0_ulp_mode_leave(struct mtk_dsi *dsi) in mtk_dsi_lane0_ulp_mode_leave() argument
310 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_ULPM_EN, 0); in mtk_dsi_lane0_ulp_mode_leave()
311 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_WAKEUP_EN, LD0_WAKEUP_EN); in mtk_dsi_lane0_ulp_mode_leave()
312 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_WAKEUP_EN, 0); in mtk_dsi_lane0_ulp_mode_leave()
315 static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi) in mtk_dsi_clk_hs_state() argument
317 return readl(dsi->regs + DSI_PHY_LCCON) & LC_HS_TX_EN; in mtk_dsi_clk_hs_state()
320 static void mtk_dsi_clk_hs_mode(struct mtk_dsi *dsi, bool enter) in mtk_dsi_clk_hs_mode() argument
322 if (enter && !mtk_dsi_clk_hs_state(dsi)) in mtk_dsi_clk_hs_mode()
323 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_HS_TX_EN, LC_HS_TX_EN); in mtk_dsi_clk_hs_mode()
324 else if (!enter && mtk_dsi_clk_hs_state(dsi)) in mtk_dsi_clk_hs_mode()
325 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_HS_TX_EN, 0); in mtk_dsi_clk_hs_mode()
328 static void mtk_dsi_set_mode(struct mtk_dsi *dsi) in mtk_dsi_set_mode() argument
332 if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { in mtk_dsi_set_mode()
333 if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) in mtk_dsi_set_mode()
335 else if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) in mtk_dsi_set_mode()
341 writel(vid_mode, dsi->regs + DSI_MODE_CTRL); in mtk_dsi_set_mode()
344 static void mtk_dsi_set_vm_cmd(struct mtk_dsi *dsi) in mtk_dsi_set_vm_cmd() argument
346 mtk_dsi_mask(dsi, DSI_VM_CMD_CON, VM_CMD_EN, VM_CMD_EN); in mtk_dsi_set_vm_cmd()
347 mtk_dsi_mask(dsi, DSI_VM_CMD_CON, TS_VFP_EN, TS_VFP_EN); in mtk_dsi_set_vm_cmd()
350 static void mtk_dsi_ps_control_vact(struct mtk_dsi *dsi) in mtk_dsi_ps_control_vact() argument
352 struct videomode *vm = &dsi->vm; in mtk_dsi_ps_control_vact()
356 if (dsi->format == MIPI_DSI_FMT_RGB565) in mtk_dsi_ps_control_vact()
364 switch (dsi->format) { in mtk_dsi_ps_control_vact()
379 writel(vm->vactive, dsi->regs + DSI_VACT_NL); in mtk_dsi_ps_control_vact()
380 writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); in mtk_dsi_ps_control_vact()
381 writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); in mtk_dsi_ps_control_vact()
384 static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) in mtk_dsi_rxtx_control() argument
388 switch (dsi->lanes) { in mtk_dsi_rxtx_control()
406 if (dsi->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS) in mtk_dsi_rxtx_control()
409 if (!(dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)) in mtk_dsi_rxtx_control()
412 writel(tmp_reg, dsi->regs + DSI_TXRX_CTRL); in mtk_dsi_rxtx_control()
415 static void mtk_dsi_ps_control(struct mtk_dsi *dsi) in mtk_dsi_ps_control() argument
420 switch (dsi->format) { in mtk_dsi_ps_control()
443 tmp_reg += dsi->vm.hactive * dsi_tmp_buf_bpp & DSI_PS_WC; in mtk_dsi_ps_control()
444 writel(tmp_reg, dsi->regs + DSI_PSCTRL); in mtk_dsi_ps_control()
447 static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) in mtk_dsi_config_vdo_timing() argument
456 struct mtk_phy_timing *timing = &dsi->phy_timing; in mtk_dsi_config_vdo_timing()
458 struct videomode *vm = &dsi->vm; in mtk_dsi_config_vdo_timing()
460 if (dsi->format == MIPI_DSI_FMT_RGB565) in mtk_dsi_config_vdo_timing()
465 writel(vm->vsync_len, dsi->regs + DSI_VSA_NL); in mtk_dsi_config_vdo_timing()
466 writel(vm->vback_porch, dsi->regs + DSI_VBP_NL); in mtk_dsi_config_vdo_timing()
467 writel(vm->vfront_porch, dsi->regs + DSI_VFP_NL); in mtk_dsi_config_vdo_timing()
468 writel(vm->vactive, dsi->regs + DSI_VACT_NL); in mtk_dsi_config_vdo_timing()
470 if (dsi->driver_data->has_size_ctl) in mtk_dsi_config_vdo_timing()
472 dsi->regs + DSI_SIZE_CON); in mtk_dsi_config_vdo_timing()
476 if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) in mtk_dsi_config_vdo_timing()
485 delta = dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 : 12; in mtk_dsi_config_vdo_timing()
486 delta += dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET ? 2 : 0; in mtk_dsi_config_vdo_timing()
490 data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta; in mtk_dsi_config_vdo_timing()
504 if ((dsi->mode_flags & MIPI_DSI_HS_PKT_END_ALIGNED) && in mtk_dsi_config_vdo_timing()
505 (dsi->lanes == 4)) { in mtk_dsi_config_vdo_timing()
507 roundup(horizontal_sync_active_byte, dsi->lanes) - 2; in mtk_dsi_config_vdo_timing()
509 roundup(horizontal_frontporch_byte, dsi->lanes) - 2; in mtk_dsi_config_vdo_timing()
511 roundup(horizontal_backporch_byte, dsi->lanes) - 2; in mtk_dsi_config_vdo_timing()
513 (vm->hactive * dsi_tmp_buf_bpp + 2) % dsi->lanes; in mtk_dsi_config_vdo_timing()
516 writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC); in mtk_dsi_config_vdo_timing()
517 writel(horizontal_backporch_byte, dsi->regs + DSI_HBP_WC); in mtk_dsi_config_vdo_timing()
518 writel(horizontal_frontporch_byte, dsi->regs + DSI_HFP_WC); in mtk_dsi_config_vdo_timing()
520 mtk_dsi_ps_control(dsi); in mtk_dsi_config_vdo_timing()
523 static void mtk_dsi_start(struct mtk_dsi *dsi) in mtk_dsi_start() argument
525 writel(0, dsi->regs + DSI_START); in mtk_dsi_start()
526 writel(1, dsi->regs + DSI_START); in mtk_dsi_start()
529 static void mtk_dsi_stop(struct mtk_dsi *dsi) in mtk_dsi_stop() argument
531 writel(0, dsi->regs + DSI_START); in mtk_dsi_stop()
534 static void mtk_dsi_set_cmd_mode(struct mtk_dsi *dsi) in mtk_dsi_set_cmd_mode() argument
536 writel(CMD_MODE, dsi->regs + DSI_MODE_CTRL); in mtk_dsi_set_cmd_mode()
539 static void mtk_dsi_set_interrupt_enable(struct mtk_dsi *dsi) in mtk_dsi_set_interrupt_enable() argument
543 writel(inten, dsi->regs + DSI_INTEN); in mtk_dsi_set_interrupt_enable()
546 static void mtk_dsi_irq_data_set(struct mtk_dsi *dsi, u32 irq_bit) in mtk_dsi_irq_data_set() argument
548 dsi->irq_data |= irq_bit; in mtk_dsi_irq_data_set()
551 static void mtk_dsi_irq_data_clear(struct mtk_dsi *dsi, u32 irq_bit) in mtk_dsi_irq_data_clear() argument
553 dsi->irq_data &= ~irq_bit; in mtk_dsi_irq_data_clear()
556 static s32 mtk_dsi_wait_for_irq_done(struct mtk_dsi *dsi, u32 irq_flag, in mtk_dsi_wait_for_irq_done() argument
562 ret = wait_event_interruptible_timeout(dsi->irq_wait_queue, in mtk_dsi_wait_for_irq_done()
563 dsi->irq_data & irq_flag, in mtk_dsi_wait_for_irq_done()
566 DRM_WARN("Wait DSI IRQ(0x%08x) Timeout\n", irq_flag); in mtk_dsi_wait_for_irq_done()
568 mtk_dsi_enable(dsi); in mtk_dsi_wait_for_irq_done()
569 mtk_dsi_reset_engine(dsi); in mtk_dsi_wait_for_irq_done()
577 struct mtk_dsi *dsi = dev_id; in mtk_dsi_irq() local
581 status = readl(dsi->regs + DSI_INTSTA) & flag; in mtk_dsi_irq()
585 mtk_dsi_mask(dsi, DSI_RACK, RACK, RACK); in mtk_dsi_irq()
586 tmp = readl(dsi->regs + DSI_INTSTA); in mtk_dsi_irq()
589 mtk_dsi_mask(dsi, DSI_INTSTA, status, 0); in mtk_dsi_irq()
590 mtk_dsi_irq_data_set(dsi, status); in mtk_dsi_irq()
591 wake_up_interruptible(&dsi->irq_wait_queue); in mtk_dsi_irq()
597 static s32 mtk_dsi_switch_to_cmd_mode(struct mtk_dsi *dsi, u8 irq_flag, u32 t) in mtk_dsi_switch_to_cmd_mode() argument
599 mtk_dsi_irq_data_clear(dsi, irq_flag); in mtk_dsi_switch_to_cmd_mode()
600 mtk_dsi_set_cmd_mode(dsi); in mtk_dsi_switch_to_cmd_mode()
602 if (!mtk_dsi_wait_for_irq_done(dsi, irq_flag, t)) { in mtk_dsi_switch_to_cmd_mode()
610 static int mtk_dsi_poweron(struct mtk_dsi *dsi) in mtk_dsi_poweron() argument
612 struct device *dev = dsi->host.dev; in mtk_dsi_poweron()
616 if (++dsi->refcount != 1) in mtk_dsi_poweron()
619 switch (dsi->format) { in mtk_dsi_poweron()
633 dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel, in mtk_dsi_poweron()
634 dsi->lanes); in mtk_dsi_poweron()
636 ret = clk_set_rate(dsi->hs_clk, dsi->data_rate); in mtk_dsi_poweron()
642 phy_power_on(dsi->phy); in mtk_dsi_poweron()
644 ret = clk_prepare_enable(dsi->engine_clk); in mtk_dsi_poweron()
650 ret = clk_prepare_enable(dsi->digital_clk); in mtk_dsi_poweron()
656 mtk_dsi_enable(dsi); in mtk_dsi_poweron()
658 if (dsi->driver_data->has_shadow_ctl) in mtk_dsi_poweron()
660 dsi->regs + DSI_SHADOW_DEBUG); in mtk_dsi_poweron()
662 mtk_dsi_reset_engine(dsi); in mtk_dsi_poweron()
663 mtk_dsi_phy_timconfig(dsi); in mtk_dsi_poweron()
665 mtk_dsi_ps_control_vact(dsi); in mtk_dsi_poweron()
666 mtk_dsi_set_vm_cmd(dsi); in mtk_dsi_poweron()
667 mtk_dsi_config_vdo_timing(dsi); in mtk_dsi_poweron()
668 mtk_dsi_set_interrupt_enable(dsi); in mtk_dsi_poweron()
672 clk_disable_unprepare(dsi->engine_clk); in mtk_dsi_poweron()
674 phy_power_off(dsi->phy); in mtk_dsi_poweron()
676 dsi->refcount--; in mtk_dsi_poweron()
680 static void mtk_dsi_poweroff(struct mtk_dsi *dsi) in mtk_dsi_poweroff() argument
682 if (WARN_ON(dsi->refcount == 0)) in mtk_dsi_poweroff()
685 if (--dsi->refcount != 0) in mtk_dsi_poweroff()
693 * after dsi is fully set. in mtk_dsi_poweroff()
695 mtk_dsi_stop(dsi); in mtk_dsi_poweroff()
697 mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); in mtk_dsi_poweroff()
698 mtk_dsi_reset_engine(dsi); in mtk_dsi_poweroff()
699 mtk_dsi_lane0_ulp_mode_enter(dsi); in mtk_dsi_poweroff()
700 mtk_dsi_clk_ulp_mode_enter(dsi); in mtk_dsi_poweroff()
702 writel(0, dsi->regs + DSI_TXRX_CTRL); in mtk_dsi_poweroff()
704 mtk_dsi_disable(dsi); in mtk_dsi_poweroff()
706 clk_disable_unprepare(dsi->engine_clk); in mtk_dsi_poweroff()
707 clk_disable_unprepare(dsi->digital_clk); in mtk_dsi_poweroff()
709 phy_power_off(dsi->phy); in mtk_dsi_poweroff()
711 dsi->lanes_ready = false; in mtk_dsi_poweroff()
714 static void mtk_dsi_lane_ready(struct mtk_dsi *dsi) in mtk_dsi_lane_ready() argument
716 if (!dsi->lanes_ready) { in mtk_dsi_lane_ready()
717 dsi->lanes_ready = true; in mtk_dsi_lane_ready()
718 mtk_dsi_rxtx_control(dsi); in mtk_dsi_lane_ready()
720 mtk_dsi_reset_dphy(dsi); in mtk_dsi_lane_ready()
721 mtk_dsi_clk_ulp_mode_leave(dsi); in mtk_dsi_lane_ready()
722 mtk_dsi_lane0_ulp_mode_leave(dsi); in mtk_dsi_lane_ready()
723 mtk_dsi_clk_hs_mode(dsi, 0); in mtk_dsi_lane_ready()
729 static void mtk_output_dsi_enable(struct mtk_dsi *dsi) in mtk_output_dsi_enable() argument
731 if (dsi->enabled) in mtk_output_dsi_enable()
734 mtk_dsi_lane_ready(dsi); in mtk_output_dsi_enable()
735 mtk_dsi_set_mode(dsi); in mtk_output_dsi_enable()
736 mtk_dsi_clk_hs_mode(dsi, 1); in mtk_output_dsi_enable()
738 mtk_dsi_start(dsi); in mtk_output_dsi_enable()
740 dsi->enabled = true; in mtk_output_dsi_enable()
743 static void mtk_output_dsi_disable(struct mtk_dsi *dsi) in mtk_output_dsi_disable() argument
745 if (!dsi->enabled) in mtk_output_dsi_disable()
748 dsi->enabled = false; in mtk_output_dsi_disable()
754 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_attach() local
756 /* Attach the panel or bridge to the dsi bridge */ in mtk_dsi_bridge_attach()
757 return drm_bridge_attach(bridge->encoder, dsi->next_bridge, in mtk_dsi_bridge_attach()
758 &dsi->bridge, flags); in mtk_dsi_bridge_attach()
765 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_mode_set() local
767 drm_display_mode_to_videomode(adjusted, &dsi->vm); in mtk_dsi_bridge_mode_set()
773 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_disable() local
775 mtk_output_dsi_disable(dsi); in mtk_dsi_bridge_atomic_disable()
781 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_enable() local
783 if (dsi->refcount == 0) in mtk_dsi_bridge_atomic_enable()
786 mtk_output_dsi_enable(dsi); in mtk_dsi_bridge_atomic_enable()
792 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_pre_enable() local
795 ret = mtk_dsi_poweron(dsi); in mtk_dsi_bridge_atomic_pre_enable()
797 DRM_ERROR("failed to power on dsi\n"); in mtk_dsi_bridge_atomic_pre_enable()
803 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_post_disable() local
805 mtk_dsi_poweroff(dsi); in mtk_dsi_bridge_atomic_post_disable()
822 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_ddp_start() local
824 mtk_dsi_poweron(dsi); in mtk_dsi_ddp_start()
829 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_ddp_stop() local
831 mtk_dsi_poweroff(dsi); in mtk_dsi_ddp_stop()
834 static int mtk_dsi_encoder_init(struct drm_device *drm, struct mtk_dsi *dsi) in mtk_dsi_encoder_init() argument
838 ret = drm_simple_encoder_init(drm, &dsi->encoder, in mtk_dsi_encoder_init()
845 dsi->encoder.possible_crtcs = mtk_drm_find_possible_crtc_by_comp(drm, dsi->host.dev); in mtk_dsi_encoder_init()
847 ret = drm_bridge_attach(&dsi->encoder, &dsi->bridge, NULL, in mtk_dsi_encoder_init()
852 dsi->connector = drm_bridge_connector_init(drm, &dsi->encoder); in mtk_dsi_encoder_init()
853 if (IS_ERR(dsi->connector)) { in mtk_dsi_encoder_init()
855 ret = PTR_ERR(dsi->connector); in mtk_dsi_encoder_init()
858 drm_connector_attach_encoder(dsi->connector, &dsi->encoder); in mtk_dsi_encoder_init()
863 drm_encoder_cleanup(&dsi->encoder); in mtk_dsi_encoder_init()
871 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_bind() local
873 ret = mtk_dsi_encoder_init(drm, dsi); in mtk_dsi_bind()
883 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_unbind() local
885 drm_encoder_cleanup(&dsi->encoder); in mtk_dsi_unbind()
896 struct mtk_dsi *dsi = host_to_dsi(host); in mtk_dsi_host_attach() local
900 dsi->lanes = device->lanes; in mtk_dsi_host_attach()
901 dsi->format = device->format; in mtk_dsi_host_attach()
902 dsi->mode_flags = device->mode_flags; in mtk_dsi_host_attach()
903 dsi->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0); in mtk_dsi_host_attach()
904 if (IS_ERR(dsi->next_bridge)) in mtk_dsi_host_attach()
905 return PTR_ERR(dsi->next_bridge); in mtk_dsi_host_attach()
907 drm_bridge_add(&dsi->bridge); in mtk_dsi_host_attach()
912 drm_bridge_remove(&dsi->bridge); in mtk_dsi_host_attach()
922 struct mtk_dsi *dsi = host_to_dsi(host); in mtk_dsi_host_detach() local
925 drm_bridge_remove(&dsi->bridge); in mtk_dsi_host_detach()
929 static void mtk_dsi_wait_for_idle(struct mtk_dsi *dsi) in mtk_dsi_wait_for_idle() argument
934 ret = readl_poll_timeout(dsi->regs + DSI_INTSTA, val, !(val & DSI_BUSY), in mtk_dsi_wait_for_idle()
937 DRM_WARN("polling dsi wait not busy timeout!\n"); in mtk_dsi_wait_for_idle()
939 mtk_dsi_enable(dsi); in mtk_dsi_wait_for_idle()
940 mtk_dsi_reset_engine(dsi); in mtk_dsi_wait_for_idle()
967 static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct mipi_dsi_msg *msg) in mtk_dsi_cmdq() argument
972 u32 reg_cmdq_off = dsi->driver_data->reg_cmdq_off; in mtk_dsi_cmdq()
992 mtk_dsi_mask(dsi, (reg_cmdq_off + cmdq_off + i) & (~0x3U), in mtk_dsi_cmdq()
996 mtk_dsi_mask(dsi, reg_cmdq_off, cmdq_mask, reg_val); in mtk_dsi_cmdq()
997 mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE, cmdq_size); in mtk_dsi_cmdq()
1000 static ssize_t mtk_dsi_host_send_cmd(struct mtk_dsi *dsi, in mtk_dsi_host_send_cmd() argument
1003 mtk_dsi_wait_for_idle(dsi); in mtk_dsi_host_send_cmd()
1004 mtk_dsi_irq_data_clear(dsi, flag); in mtk_dsi_host_send_cmd()
1005 mtk_dsi_cmdq(dsi, msg); in mtk_dsi_host_send_cmd()
1006 mtk_dsi_start(dsi); in mtk_dsi_host_send_cmd()
1008 if (!mtk_dsi_wait_for_irq_done(dsi, flag, 2000)) in mtk_dsi_host_send_cmd()
1017 struct mtk_dsi *dsi = host_to_dsi(host); in mtk_dsi_host_transfer() local
1025 dsi_mode = readl(dsi->regs + DSI_MODE_CTRL); in mtk_dsi_host_transfer()
1027 mtk_dsi_stop(dsi); in mtk_dsi_host_transfer()
1028 ret = mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); in mtk_dsi_host_transfer()
1036 mtk_dsi_lane_ready(dsi); in mtk_dsi_host_transfer()
1038 ret = mtk_dsi_host_send_cmd(dsi, msg, irq_flag); in mtk_dsi_host_transfer()
1048 DRM_ERROR("dsi receive buffer size may be NULL\n"); in mtk_dsi_host_transfer()
1054 *(read_data + i) = readb(dsi->regs + DSI_RX_DATA0 + i); in mtk_dsi_host_transfer()
1072 DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n", in mtk_dsi_host_transfer()
1077 mtk_dsi_set_mode(dsi); in mtk_dsi_host_transfer()
1078 mtk_dsi_start(dsi); in mtk_dsi_host_transfer()
1092 struct mtk_dsi *dsi; in mtk_dsi_probe() local
1098 dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); in mtk_dsi_probe()
1099 if (!dsi) in mtk_dsi_probe()
1102 dsi->host.ops = &mtk_dsi_ops; in mtk_dsi_probe()
1103 dsi->host.dev = dev; in mtk_dsi_probe()
1104 ret = mipi_dsi_host_register(&dsi->host); in mtk_dsi_probe()
1106 dev_err(dev, "failed to register DSI host: %d\n", ret); in mtk_dsi_probe()
1110 dsi->driver_data = of_device_get_match_data(dev); in mtk_dsi_probe()
1112 dsi->engine_clk = devm_clk_get(dev, "engine"); in mtk_dsi_probe()
1113 if (IS_ERR(dsi->engine_clk)) { in mtk_dsi_probe()
1114 ret = PTR_ERR(dsi->engine_clk); in mtk_dsi_probe()
1121 dsi->digital_clk = devm_clk_get(dev, "digital"); in mtk_dsi_probe()
1122 if (IS_ERR(dsi->digital_clk)) { in mtk_dsi_probe()
1123 ret = PTR_ERR(dsi->digital_clk); in mtk_dsi_probe()
1130 dsi->hs_clk = devm_clk_get(dev, "hs"); in mtk_dsi_probe()
1131 if (IS_ERR(dsi->hs_clk)) { in mtk_dsi_probe()
1132 ret = PTR_ERR(dsi->hs_clk); in mtk_dsi_probe()
1138 dsi->regs = devm_ioremap_resource(dev, regs); in mtk_dsi_probe()
1139 if (IS_ERR(dsi->regs)) { in mtk_dsi_probe()
1140 ret = PTR_ERR(dsi->regs); in mtk_dsi_probe()
1145 dsi->phy = devm_phy_get(dev, "dphy"); in mtk_dsi_probe()
1146 if (IS_ERR(dsi->phy)) { in mtk_dsi_probe()
1147 ret = PTR_ERR(dsi->phy); in mtk_dsi_probe()
1159 IRQF_TRIGGER_NONE, dev_name(&pdev->dev), dsi); in mtk_dsi_probe()
1161 dev_err(&pdev->dev, "failed to request mediatek dsi irq\n"); in mtk_dsi_probe()
1165 init_waitqueue_head(&dsi->irq_wait_queue); in mtk_dsi_probe()
1167 platform_set_drvdata(pdev, dsi); in mtk_dsi_probe()
1169 dsi->bridge.funcs = &mtk_dsi_bridge_funcs; in mtk_dsi_probe()
1170 dsi->bridge.of_node = dev->of_node; in mtk_dsi_probe()
1171 dsi->bridge.type = DRM_MODE_CONNECTOR_DSI; in mtk_dsi_probe()
1176 mipi_dsi_host_unregister(&dsi->host); in mtk_dsi_probe()
1182 struct mtk_dsi *dsi = platform_get_drvdata(pdev); in mtk_dsi_remove() local
1184 mtk_output_dsi_disable(dsi); in mtk_dsi_remove()
1185 mipi_dsi_host_unregister(&dsi->host); in mtk_dsi_remove()
1211 { .compatible = "mediatek,mt2701-dsi",
1213 { .compatible = "mediatek,mt8173-dsi",
1215 { .compatible = "mediatek,mt8183-dsi",
1217 { .compatible = "mediatek,mt8186-dsi",
1227 .name = "mtk-dsi",