Lines Matching full:dsi
223 static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data) in mtk_dsi_mask() argument
225 u32 temp = readl(dsi->regs + offset); in mtk_dsi_mask()
227 writel((temp & ~mask) | (data & mask), dsi->regs + offset); in mtk_dsi_mask()
230 static void mtk_dsi_phy_timconfig(struct mtk_dsi *dsi) in mtk_dsi_phy_timconfig() argument
233 u32 data_rate_mhz = DIV_ROUND_UP(dsi->data_rate, 1000000); in mtk_dsi_phy_timconfig()
234 struct mtk_phy_timing *timing = &dsi->phy_timing; in mtk_dsi_phy_timconfig()
262 writel(timcon0, dsi->regs + DSI_PHY_TIMECON0); in mtk_dsi_phy_timconfig()
263 writel(timcon1, dsi->regs + DSI_PHY_TIMECON1); in mtk_dsi_phy_timconfig()
264 writel(timcon2, dsi->regs + DSI_PHY_TIMECON2); in mtk_dsi_phy_timconfig()
265 writel(timcon3, dsi->regs + DSI_PHY_TIMECON3); in mtk_dsi_phy_timconfig()
268 static void mtk_dsi_enable(struct mtk_dsi *dsi) in mtk_dsi_enable() argument
270 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_EN, DSI_EN); in mtk_dsi_enable()
273 static void mtk_dsi_disable(struct mtk_dsi *dsi) in mtk_dsi_disable() argument
275 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_EN, 0); in mtk_dsi_disable()
278 static void mtk_dsi_reset_engine(struct mtk_dsi *dsi) in mtk_dsi_reset_engine() argument
280 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_RESET, DSI_RESET); in mtk_dsi_reset_engine()
281 mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_RESET, 0); in mtk_dsi_reset_engine()
284 static void mtk_dsi_reset_dphy(struct mtk_dsi *dsi) in mtk_dsi_reset_dphy() argument
286 mtk_dsi_mask(dsi, DSI_CON_CTRL, DPHY_RESET, DPHY_RESET); in mtk_dsi_reset_dphy()
287 mtk_dsi_mask(dsi, DSI_CON_CTRL, DPHY_RESET, 0); in mtk_dsi_reset_dphy()
290 static void mtk_dsi_clk_ulp_mode_enter(struct mtk_dsi *dsi) in mtk_dsi_clk_ulp_mode_enter() argument
292 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_HS_TX_EN, 0); in mtk_dsi_clk_ulp_mode_enter()
293 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_ULPM_EN, 0); in mtk_dsi_clk_ulp_mode_enter()
296 static void mtk_dsi_clk_ulp_mode_leave(struct mtk_dsi *dsi) in mtk_dsi_clk_ulp_mode_leave() argument
298 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_ULPM_EN, 0); in mtk_dsi_clk_ulp_mode_leave()
299 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_WAKEUP_EN, LC_WAKEUP_EN); in mtk_dsi_clk_ulp_mode_leave()
300 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_WAKEUP_EN, 0); in mtk_dsi_clk_ulp_mode_leave()
303 static void mtk_dsi_lane0_ulp_mode_enter(struct mtk_dsi *dsi) in mtk_dsi_lane0_ulp_mode_enter() argument
305 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_HS_TX_EN, 0); in mtk_dsi_lane0_ulp_mode_enter()
306 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_ULPM_EN, 0); in mtk_dsi_lane0_ulp_mode_enter()
309 static void mtk_dsi_lane0_ulp_mode_leave(struct mtk_dsi *dsi) in mtk_dsi_lane0_ulp_mode_leave() argument
311 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_ULPM_EN, 0); in mtk_dsi_lane0_ulp_mode_leave()
312 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_WAKEUP_EN, LD0_WAKEUP_EN); in mtk_dsi_lane0_ulp_mode_leave()
313 mtk_dsi_mask(dsi, DSI_PHY_LD0CON, LD0_WAKEUP_EN, 0); in mtk_dsi_lane0_ulp_mode_leave()
316 static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi) in mtk_dsi_clk_hs_state() argument
318 return readl(dsi->regs + DSI_PHY_LCCON) & LC_HS_TX_EN; in mtk_dsi_clk_hs_state()
321 static void mtk_dsi_clk_hs_mode(struct mtk_dsi *dsi, bool enter) in mtk_dsi_clk_hs_mode() argument
323 if (enter && !mtk_dsi_clk_hs_state(dsi)) in mtk_dsi_clk_hs_mode()
324 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_HS_TX_EN, LC_HS_TX_EN); in mtk_dsi_clk_hs_mode()
325 else if (!enter && mtk_dsi_clk_hs_state(dsi)) in mtk_dsi_clk_hs_mode()
326 mtk_dsi_mask(dsi, DSI_PHY_LCCON, LC_HS_TX_EN, 0); in mtk_dsi_clk_hs_mode()
329 static void mtk_dsi_set_mode(struct mtk_dsi *dsi) in mtk_dsi_set_mode() argument
333 if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { in mtk_dsi_set_mode()
334 if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) in mtk_dsi_set_mode()
336 else if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) in mtk_dsi_set_mode()
342 writel(vid_mode, dsi->regs + DSI_MODE_CTRL); in mtk_dsi_set_mode()
345 static void mtk_dsi_set_vm_cmd(struct mtk_dsi *dsi) in mtk_dsi_set_vm_cmd() argument
347 mtk_dsi_mask(dsi, DSI_VM_CMD_CON, VM_CMD_EN, VM_CMD_EN); in mtk_dsi_set_vm_cmd()
348 mtk_dsi_mask(dsi, DSI_VM_CMD_CON, TS_VFP_EN, TS_VFP_EN); in mtk_dsi_set_vm_cmd()
351 static void mtk_dsi_ps_control_vact(struct mtk_dsi *dsi) in mtk_dsi_ps_control_vact() argument
353 struct videomode *vm = &dsi->vm; in mtk_dsi_ps_control_vact()
357 if (dsi->format == MIPI_DSI_FMT_RGB565) in mtk_dsi_ps_control_vact()
365 switch (dsi->format) { in mtk_dsi_ps_control_vact()
380 writel(vm->vactive, dsi->regs + DSI_VACT_NL); in mtk_dsi_ps_control_vact()
381 writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); in mtk_dsi_ps_control_vact()
382 writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); in mtk_dsi_ps_control_vact()
385 static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) in mtk_dsi_rxtx_control() argument
389 switch (dsi->lanes) { in mtk_dsi_rxtx_control()
407 if (dsi->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS) in mtk_dsi_rxtx_control()
410 if (dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET) in mtk_dsi_rxtx_control()
413 writel(tmp_reg, dsi->regs + DSI_TXRX_CTRL); in mtk_dsi_rxtx_control()
416 static void mtk_dsi_ps_control(struct mtk_dsi *dsi) in mtk_dsi_ps_control() argument
421 switch (dsi->format) { in mtk_dsi_ps_control()
444 tmp_reg += dsi->vm.hactive * dsi_tmp_buf_bpp & DSI_PS_WC; in mtk_dsi_ps_control()
445 writel(tmp_reg, dsi->regs + DSI_PSCTRL); in mtk_dsi_ps_control()
448 static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) in mtk_dsi_config_vdo_timing() argument
457 struct mtk_phy_timing *timing = &dsi->phy_timing; in mtk_dsi_config_vdo_timing()
459 struct videomode *vm = &dsi->vm; in mtk_dsi_config_vdo_timing()
461 if (dsi->format == MIPI_DSI_FMT_RGB565) in mtk_dsi_config_vdo_timing()
466 writel(vm->vsync_len, dsi->regs + DSI_VSA_NL); in mtk_dsi_config_vdo_timing()
467 writel(vm->vback_porch, dsi->regs + DSI_VBP_NL); in mtk_dsi_config_vdo_timing()
468 writel(vm->vfront_porch, dsi->regs + DSI_VFP_NL); in mtk_dsi_config_vdo_timing()
469 writel(vm->vactive, dsi->regs + DSI_VACT_NL); in mtk_dsi_config_vdo_timing()
471 if (dsi->driver_data->has_size_ctl) in mtk_dsi_config_vdo_timing()
473 dsi->regs + DSI_SIZE_CON); in mtk_dsi_config_vdo_timing()
477 if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) in mtk_dsi_config_vdo_timing()
486 delta = dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 : 12; in mtk_dsi_config_vdo_timing()
487 delta += dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET ? 0 : 2; in mtk_dsi_config_vdo_timing()
491 data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta; in mtk_dsi_config_vdo_timing()
505 if ((dsi->mode_flags & MIPI_DSI_HS_PKT_END_ALIGNED) && in mtk_dsi_config_vdo_timing()
506 (dsi->lanes == 4)) { in mtk_dsi_config_vdo_timing()
508 roundup(horizontal_sync_active_byte, dsi->lanes) - 2; in mtk_dsi_config_vdo_timing()
510 roundup(horizontal_frontporch_byte, dsi->lanes) - 2; in mtk_dsi_config_vdo_timing()
512 roundup(horizontal_backporch_byte, dsi->lanes) - 2; in mtk_dsi_config_vdo_timing()
514 (vm->hactive * dsi_tmp_buf_bpp + 2) % dsi->lanes; in mtk_dsi_config_vdo_timing()
517 writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC); in mtk_dsi_config_vdo_timing()
518 writel(horizontal_backporch_byte, dsi->regs + DSI_HBP_WC); in mtk_dsi_config_vdo_timing()
519 writel(horizontal_frontporch_byte, dsi->regs + DSI_HFP_WC); in mtk_dsi_config_vdo_timing()
521 mtk_dsi_ps_control(dsi); in mtk_dsi_config_vdo_timing()
524 static void mtk_dsi_start(struct mtk_dsi *dsi) in mtk_dsi_start() argument
526 writel(0, dsi->regs + DSI_START); in mtk_dsi_start()
527 writel(1, dsi->regs + DSI_START); in mtk_dsi_start()
530 static void mtk_dsi_stop(struct mtk_dsi *dsi) in mtk_dsi_stop() argument
532 writel(0, dsi->regs + DSI_START); in mtk_dsi_stop()
535 static void mtk_dsi_set_cmd_mode(struct mtk_dsi *dsi) in mtk_dsi_set_cmd_mode() argument
537 writel(CMD_MODE, dsi->regs + DSI_MODE_CTRL); in mtk_dsi_set_cmd_mode()
540 static void mtk_dsi_set_interrupt_enable(struct mtk_dsi *dsi) in mtk_dsi_set_interrupt_enable() argument
544 writel(inten, dsi->regs + DSI_INTEN); in mtk_dsi_set_interrupt_enable()
547 static void mtk_dsi_irq_data_set(struct mtk_dsi *dsi, u32 irq_bit) in mtk_dsi_irq_data_set() argument
549 dsi->irq_data |= irq_bit; in mtk_dsi_irq_data_set()
552 static void mtk_dsi_irq_data_clear(struct mtk_dsi *dsi, u32 irq_bit) in mtk_dsi_irq_data_clear() argument
554 dsi->irq_data &= ~irq_bit; in mtk_dsi_irq_data_clear()
557 static s32 mtk_dsi_wait_for_irq_done(struct mtk_dsi *dsi, u32 irq_flag, in mtk_dsi_wait_for_irq_done() argument
563 ret = wait_event_interruptible_timeout(dsi->irq_wait_queue, in mtk_dsi_wait_for_irq_done()
564 dsi->irq_data & irq_flag, in mtk_dsi_wait_for_irq_done()
567 DRM_WARN("Wait DSI IRQ(0x%08x) Timeout\n", irq_flag); in mtk_dsi_wait_for_irq_done()
569 mtk_dsi_enable(dsi); in mtk_dsi_wait_for_irq_done()
570 mtk_dsi_reset_engine(dsi); in mtk_dsi_wait_for_irq_done()
578 struct mtk_dsi *dsi = dev_id; in mtk_dsi_irq() local
582 status = readl(dsi->regs + DSI_INTSTA) & flag; in mtk_dsi_irq()
586 mtk_dsi_mask(dsi, DSI_RACK, RACK, RACK); in mtk_dsi_irq()
587 tmp = readl(dsi->regs + DSI_INTSTA); in mtk_dsi_irq()
590 mtk_dsi_mask(dsi, DSI_INTSTA, status, 0); in mtk_dsi_irq()
591 mtk_dsi_irq_data_set(dsi, status); in mtk_dsi_irq()
592 wake_up_interruptible(&dsi->irq_wait_queue); in mtk_dsi_irq()
598 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
600 mtk_dsi_irq_data_clear(dsi, irq_flag); in mtk_dsi_switch_to_cmd_mode()
601 mtk_dsi_set_cmd_mode(dsi); in mtk_dsi_switch_to_cmd_mode()
603 if (!mtk_dsi_wait_for_irq_done(dsi, irq_flag, t)) { in mtk_dsi_switch_to_cmd_mode()
611 static int mtk_dsi_poweron(struct mtk_dsi *dsi) in mtk_dsi_poweron() argument
613 struct device *dev = dsi->host.dev; in mtk_dsi_poweron()
617 if (++dsi->refcount != 1) in mtk_dsi_poweron()
620 switch (dsi->format) { in mtk_dsi_poweron()
634 dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel, in mtk_dsi_poweron()
635 dsi->lanes); in mtk_dsi_poweron()
637 ret = clk_set_rate(dsi->hs_clk, dsi->data_rate); in mtk_dsi_poweron()
643 phy_power_on(dsi->phy); in mtk_dsi_poweron()
645 ret = clk_prepare_enable(dsi->engine_clk); in mtk_dsi_poweron()
651 ret = clk_prepare_enable(dsi->digital_clk); in mtk_dsi_poweron()
657 mtk_dsi_enable(dsi); in mtk_dsi_poweron()
659 if (dsi->driver_data->has_shadow_ctl) in mtk_dsi_poweron()
661 dsi->regs + DSI_SHADOW_DEBUG); in mtk_dsi_poweron()
663 mtk_dsi_reset_engine(dsi); in mtk_dsi_poweron()
664 mtk_dsi_phy_timconfig(dsi); in mtk_dsi_poweron()
666 mtk_dsi_ps_control_vact(dsi); in mtk_dsi_poweron()
667 mtk_dsi_set_vm_cmd(dsi); in mtk_dsi_poweron()
668 mtk_dsi_config_vdo_timing(dsi); in mtk_dsi_poweron()
669 mtk_dsi_set_interrupt_enable(dsi); in mtk_dsi_poweron()
673 clk_disable_unprepare(dsi->engine_clk); in mtk_dsi_poweron()
675 phy_power_off(dsi->phy); in mtk_dsi_poweron()
677 dsi->refcount--; in mtk_dsi_poweron()
681 static void mtk_dsi_poweroff(struct mtk_dsi *dsi) in mtk_dsi_poweroff() argument
683 if (WARN_ON(dsi->refcount == 0)) in mtk_dsi_poweroff()
686 if (--dsi->refcount != 0) in mtk_dsi_poweroff()
694 * after dsi is fully set. in mtk_dsi_poweroff()
696 mtk_dsi_stop(dsi); in mtk_dsi_poweroff()
698 mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); in mtk_dsi_poweroff()
699 mtk_dsi_reset_engine(dsi); in mtk_dsi_poweroff()
700 mtk_dsi_lane0_ulp_mode_enter(dsi); in mtk_dsi_poweroff()
701 mtk_dsi_clk_ulp_mode_enter(dsi); in mtk_dsi_poweroff()
703 writel(0, dsi->regs + DSI_TXRX_CTRL); in mtk_dsi_poweroff()
705 mtk_dsi_disable(dsi); in mtk_dsi_poweroff()
707 clk_disable_unprepare(dsi->engine_clk); in mtk_dsi_poweroff()
708 clk_disable_unprepare(dsi->digital_clk); in mtk_dsi_poweroff()
710 phy_power_off(dsi->phy); in mtk_dsi_poweroff()
712 dsi->lanes_ready = false; in mtk_dsi_poweroff()
715 static void mtk_dsi_lane_ready(struct mtk_dsi *dsi) in mtk_dsi_lane_ready() argument
717 if (!dsi->lanes_ready) { in mtk_dsi_lane_ready()
718 dsi->lanes_ready = true; in mtk_dsi_lane_ready()
719 mtk_dsi_rxtx_control(dsi); in mtk_dsi_lane_ready()
721 mtk_dsi_reset_dphy(dsi); in mtk_dsi_lane_ready()
722 mtk_dsi_clk_ulp_mode_leave(dsi); in mtk_dsi_lane_ready()
723 mtk_dsi_lane0_ulp_mode_leave(dsi); in mtk_dsi_lane_ready()
724 mtk_dsi_clk_hs_mode(dsi, 0); in mtk_dsi_lane_ready()
730 static void mtk_output_dsi_enable(struct mtk_dsi *dsi) in mtk_output_dsi_enable() argument
732 if (dsi->enabled) in mtk_output_dsi_enable()
735 mtk_dsi_lane_ready(dsi); in mtk_output_dsi_enable()
736 mtk_dsi_set_mode(dsi); in mtk_output_dsi_enable()
737 mtk_dsi_clk_hs_mode(dsi, 1); in mtk_output_dsi_enable()
739 mtk_dsi_start(dsi); in mtk_output_dsi_enable()
741 dsi->enabled = true; in mtk_output_dsi_enable()
744 static void mtk_output_dsi_disable(struct mtk_dsi *dsi) in mtk_output_dsi_disable() argument
746 if (!dsi->enabled) in mtk_output_dsi_disable()
749 dsi->enabled = false; in mtk_output_dsi_disable()
755 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_attach() local
757 /* Attach the panel or bridge to the dsi bridge */ in mtk_dsi_bridge_attach()
758 return drm_bridge_attach(bridge->encoder, dsi->next_bridge, in mtk_dsi_bridge_attach()
759 &dsi->bridge, flags); in mtk_dsi_bridge_attach()
766 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_mode_set() local
768 drm_display_mode_to_videomode(adjusted, &dsi->vm); in mtk_dsi_bridge_mode_set()
774 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_disable() local
776 mtk_output_dsi_disable(dsi); in mtk_dsi_bridge_atomic_disable()
782 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_enable() local
784 if (dsi->refcount == 0) in mtk_dsi_bridge_atomic_enable()
787 mtk_output_dsi_enable(dsi); in mtk_dsi_bridge_atomic_enable()
793 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_pre_enable() local
796 ret = mtk_dsi_poweron(dsi); in mtk_dsi_bridge_atomic_pre_enable()
798 DRM_ERROR("failed to power on dsi\n"); in mtk_dsi_bridge_atomic_pre_enable()
804 struct mtk_dsi *dsi = bridge_to_dsi(bridge); in mtk_dsi_bridge_atomic_post_disable() local
806 mtk_dsi_poweroff(dsi); in mtk_dsi_bridge_atomic_post_disable()
823 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_ddp_start() local
825 mtk_dsi_poweron(dsi); in mtk_dsi_ddp_start()
830 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_ddp_stop() local
832 mtk_dsi_poweroff(dsi); in mtk_dsi_ddp_stop()
835 static int mtk_dsi_encoder_init(struct drm_device *drm, struct mtk_dsi *dsi) in mtk_dsi_encoder_init() argument
839 ret = drm_simple_encoder_init(drm, &dsi->encoder, in mtk_dsi_encoder_init()
846 dsi->encoder.possible_crtcs = mtk_drm_find_possible_crtc_by_comp(drm, dsi->host.dev); in mtk_dsi_encoder_init()
848 ret = drm_bridge_attach(&dsi->encoder, &dsi->bridge, NULL, in mtk_dsi_encoder_init()
853 dsi->connector = drm_bridge_connector_init(drm, &dsi->encoder); in mtk_dsi_encoder_init()
854 if (IS_ERR(dsi->connector)) { in mtk_dsi_encoder_init()
856 ret = PTR_ERR(dsi->connector); in mtk_dsi_encoder_init()
859 drm_connector_attach_encoder(dsi->connector, &dsi->encoder); in mtk_dsi_encoder_init()
864 drm_encoder_cleanup(&dsi->encoder); in mtk_dsi_encoder_init()
872 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_bind() local
874 ret = mtk_dsi_encoder_init(drm, dsi); in mtk_dsi_bind()
884 struct mtk_dsi *dsi = dev_get_drvdata(dev); in mtk_dsi_unbind() local
886 drm_encoder_cleanup(&dsi->encoder); in mtk_dsi_unbind()
897 struct mtk_dsi *dsi = host_to_dsi(host); in mtk_dsi_host_attach() local
901 dsi->lanes = device->lanes; in mtk_dsi_host_attach()
902 dsi->format = device->format; in mtk_dsi_host_attach()
903 dsi->mode_flags = device->mode_flags; in mtk_dsi_host_attach()
904 dsi->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0); in mtk_dsi_host_attach()
905 if (IS_ERR(dsi->next_bridge)) in mtk_dsi_host_attach()
906 return PTR_ERR(dsi->next_bridge); in mtk_dsi_host_attach()
908 drm_bridge_add(&dsi->bridge); in mtk_dsi_host_attach()
913 drm_bridge_remove(&dsi->bridge); in mtk_dsi_host_attach()
923 struct mtk_dsi *dsi = host_to_dsi(host); in mtk_dsi_host_detach() local
926 drm_bridge_remove(&dsi->bridge); in mtk_dsi_host_detach()
930 static void mtk_dsi_wait_for_idle(struct mtk_dsi *dsi) in mtk_dsi_wait_for_idle() argument
935 ret = readl_poll_timeout(dsi->regs + DSI_INTSTA, val, !(val & DSI_BUSY), in mtk_dsi_wait_for_idle()
938 DRM_WARN("polling dsi wait not busy timeout!\n"); in mtk_dsi_wait_for_idle()
940 mtk_dsi_enable(dsi); in mtk_dsi_wait_for_idle()
941 mtk_dsi_reset_engine(dsi); in mtk_dsi_wait_for_idle()
968 static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct mipi_dsi_msg *msg) in mtk_dsi_cmdq() argument
973 u32 reg_cmdq_off = dsi->driver_data->reg_cmdq_off; in mtk_dsi_cmdq()
993 mtk_dsi_mask(dsi, (reg_cmdq_off + cmdq_off + i) & (~0x3U), in mtk_dsi_cmdq()
997 mtk_dsi_mask(dsi, reg_cmdq_off, cmdq_mask, reg_val); in mtk_dsi_cmdq()
998 mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE, cmdq_size); in mtk_dsi_cmdq()
1001 static ssize_t mtk_dsi_host_send_cmd(struct mtk_dsi *dsi, in mtk_dsi_host_send_cmd() argument
1004 mtk_dsi_wait_for_idle(dsi); in mtk_dsi_host_send_cmd()
1005 mtk_dsi_irq_data_clear(dsi, flag); in mtk_dsi_host_send_cmd()
1006 mtk_dsi_cmdq(dsi, msg); in mtk_dsi_host_send_cmd()
1007 mtk_dsi_start(dsi); in mtk_dsi_host_send_cmd()
1009 if (!mtk_dsi_wait_for_irq_done(dsi, flag, 2000)) in mtk_dsi_host_send_cmd()
1018 struct mtk_dsi *dsi = host_to_dsi(host); in mtk_dsi_host_transfer() local
1026 dsi_mode = readl(dsi->regs + DSI_MODE_CTRL); in mtk_dsi_host_transfer()
1028 mtk_dsi_stop(dsi); in mtk_dsi_host_transfer()
1029 ret = mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500); in mtk_dsi_host_transfer()
1037 mtk_dsi_lane_ready(dsi); in mtk_dsi_host_transfer()
1039 ret = mtk_dsi_host_send_cmd(dsi, msg, irq_flag); in mtk_dsi_host_transfer()
1049 DRM_ERROR("dsi receive buffer size may be NULL\n"); in mtk_dsi_host_transfer()
1055 *(read_data + i) = readb(dsi->regs + DSI_RX_DATA0 + i); in mtk_dsi_host_transfer()
1073 DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n", in mtk_dsi_host_transfer()
1078 mtk_dsi_set_mode(dsi); in mtk_dsi_host_transfer()
1079 mtk_dsi_start(dsi); in mtk_dsi_host_transfer()
1093 struct mtk_dsi *dsi; in mtk_dsi_probe() local
1099 dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); in mtk_dsi_probe()
1100 if (!dsi) in mtk_dsi_probe()
1103 dsi->host.ops = &mtk_dsi_ops; in mtk_dsi_probe()
1104 dsi->host.dev = dev; in mtk_dsi_probe()
1105 ret = mipi_dsi_host_register(&dsi->host); in mtk_dsi_probe()
1107 dev_err(dev, "failed to register DSI host: %d\n", ret); in mtk_dsi_probe()
1111 dsi->driver_data = of_device_get_match_data(dev); in mtk_dsi_probe()
1113 dsi->engine_clk = devm_clk_get(dev, "engine"); in mtk_dsi_probe()
1114 if (IS_ERR(dsi->engine_clk)) { in mtk_dsi_probe()
1115 ret = PTR_ERR(dsi->engine_clk); in mtk_dsi_probe()
1122 dsi->digital_clk = devm_clk_get(dev, "digital"); in mtk_dsi_probe()
1123 if (IS_ERR(dsi->digital_clk)) { in mtk_dsi_probe()
1124 ret = PTR_ERR(dsi->digital_clk); in mtk_dsi_probe()
1131 dsi->hs_clk = devm_clk_get(dev, "hs"); in mtk_dsi_probe()
1132 if (IS_ERR(dsi->hs_clk)) { in mtk_dsi_probe()
1133 ret = PTR_ERR(dsi->hs_clk); in mtk_dsi_probe()
1139 dsi->regs = devm_ioremap_resource(dev, regs); in mtk_dsi_probe()
1140 if (IS_ERR(dsi->regs)) { in mtk_dsi_probe()
1141 ret = PTR_ERR(dsi->regs); in mtk_dsi_probe()
1146 dsi->phy = devm_phy_get(dev, "dphy"); in mtk_dsi_probe()
1147 if (IS_ERR(dsi->phy)) { in mtk_dsi_probe()
1148 ret = PTR_ERR(dsi->phy); in mtk_dsi_probe()
1160 IRQF_TRIGGER_NONE, dev_name(&pdev->dev), dsi); in mtk_dsi_probe()
1162 dev_err(&pdev->dev, "failed to request mediatek dsi irq\n"); in mtk_dsi_probe()
1166 init_waitqueue_head(&dsi->irq_wait_queue); in mtk_dsi_probe()
1168 platform_set_drvdata(pdev, dsi); in mtk_dsi_probe()
1170 dsi->bridge.funcs = &mtk_dsi_bridge_funcs; in mtk_dsi_probe()
1171 dsi->bridge.of_node = dev->of_node; in mtk_dsi_probe()
1172 dsi->bridge.type = DRM_MODE_CONNECTOR_DSI; in mtk_dsi_probe()
1177 mipi_dsi_host_unregister(&dsi->host); in mtk_dsi_probe()
1183 struct mtk_dsi *dsi = platform_get_drvdata(pdev); in mtk_dsi_remove() local
1185 mtk_output_dsi_disable(dsi); in mtk_dsi_remove()
1186 mipi_dsi_host_unregister(&dsi->host); in mtk_dsi_remove()
1210 { .compatible = "mediatek,mt2701-dsi",
1212 { .compatible = "mediatek,mt8173-dsi",
1214 { .compatible = "mediatek,mt8183-dsi",
1216 { .compatible = "mediatek,mt8186-dsi",
1226 .name = "mtk-dsi",