Lines Matching full:dpi
124 static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask) in mtk_dpi_mask() argument
126 u32 tmp = readl(dpi->regs + offset) & ~mask; in mtk_dpi_mask()
129 writel(tmp, dpi->regs + offset); in mtk_dpi_mask()
132 static void mtk_dpi_sw_reset(struct mtk_dpi *dpi, bool reset) in mtk_dpi_sw_reset() argument
134 mtk_dpi_mask(dpi, DPI_RET, reset ? RST : 0, RST); in mtk_dpi_sw_reset()
137 static void mtk_dpi_enable(struct mtk_dpi *dpi) in mtk_dpi_enable() argument
139 mtk_dpi_mask(dpi, DPI_EN, EN, EN); in mtk_dpi_enable()
142 static void mtk_dpi_disable(struct mtk_dpi *dpi) in mtk_dpi_disable() argument
144 mtk_dpi_mask(dpi, DPI_EN, 0, EN); in mtk_dpi_disable()
147 static void mtk_dpi_config_hsync(struct mtk_dpi *dpi, in mtk_dpi_config_hsync() argument
150 mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH, in mtk_dpi_config_hsync()
152 mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, in mtk_dpi_config_hsync()
154 mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->front_porch << HFP, in mtk_dpi_config_hsync()
158 static void mtk_dpi_config_vsync(struct mtk_dpi *dpi, in mtk_dpi_config_vsync() argument
162 mtk_dpi_mask(dpi, width_addr, in mtk_dpi_config_vsync()
165 mtk_dpi_mask(dpi, width_addr, in mtk_dpi_config_vsync()
168 mtk_dpi_mask(dpi, porch_addr, in mtk_dpi_config_vsync()
171 mtk_dpi_mask(dpi, porch_addr, in mtk_dpi_config_vsync()
176 static void mtk_dpi_config_vsync_lodd(struct mtk_dpi *dpi, in mtk_dpi_config_vsync_lodd() argument
179 mtk_dpi_config_vsync(dpi, sync, DPI_TGEN_VWIDTH, DPI_TGEN_VPORCH); in mtk_dpi_config_vsync_lodd()
182 static void mtk_dpi_config_vsync_leven(struct mtk_dpi *dpi, in mtk_dpi_config_vsync_leven() argument
185 mtk_dpi_config_vsync(dpi, sync, DPI_TGEN_VWIDTH_LEVEN, in mtk_dpi_config_vsync_leven()
189 static void mtk_dpi_config_vsync_rodd(struct mtk_dpi *dpi, in mtk_dpi_config_vsync_rodd() argument
192 mtk_dpi_config_vsync(dpi, sync, DPI_TGEN_VWIDTH_RODD, in mtk_dpi_config_vsync_rodd()
196 static void mtk_dpi_config_vsync_reven(struct mtk_dpi *dpi, in mtk_dpi_config_vsync_reven() argument
199 mtk_dpi_config_vsync(dpi, sync, DPI_TGEN_VWIDTH_REVEN, in mtk_dpi_config_vsync_reven()
203 static void mtk_dpi_config_pol(struct mtk_dpi *dpi, in mtk_dpi_config_pol() argument
212 mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol, in mtk_dpi_config_pol()
216 static void mtk_dpi_config_3d(struct mtk_dpi *dpi, bool en_3d) in mtk_dpi_config_3d() argument
218 mtk_dpi_mask(dpi, DPI_CON, en_3d ? TDFP_EN : 0, TDFP_EN); in mtk_dpi_config_3d()
221 static void mtk_dpi_config_interface(struct mtk_dpi *dpi, bool inter) in mtk_dpi_config_interface() argument
223 mtk_dpi_mask(dpi, DPI_CON, inter ? INTL_EN : 0, INTL_EN); in mtk_dpi_config_interface()
226 static void mtk_dpi_config_fb_size(struct mtk_dpi *dpi, u32 width, u32 height) in mtk_dpi_config_fb_size() argument
228 mtk_dpi_mask(dpi, DPI_SIZE, width << HSIZE, HSIZE_MASK); in mtk_dpi_config_fb_size()
229 mtk_dpi_mask(dpi, DPI_SIZE, height << VSIZE, VSIZE_MASK); in mtk_dpi_config_fb_size()
232 static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi, in mtk_dpi_config_channel_limit() argument
235 mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_bottom << Y_LIMINT_BOT, in mtk_dpi_config_channel_limit()
237 mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_top << Y_LIMINT_TOP, in mtk_dpi_config_channel_limit()
239 mtk_dpi_mask(dpi, DPI_C_LIMIT, limit->c_bottom << C_LIMIT_BOT, in mtk_dpi_config_channel_limit()
241 mtk_dpi_mask(dpi, DPI_C_LIMIT, limit->c_top << C_LIMIT_TOP, in mtk_dpi_config_channel_limit()
245 static void mtk_dpi_config_bit_num(struct mtk_dpi *dpi, in mtk_dpi_config_bit_num() argument
267 mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << OUT_BIT, in mtk_dpi_config_bit_num()
271 static void mtk_dpi_config_yc_map(struct mtk_dpi *dpi, in mtk_dpi_config_yc_map() argument
297 mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << YC_MAP, YC_MAP_MASK); in mtk_dpi_config_yc_map()
300 static void mtk_dpi_config_channel_swap(struct mtk_dpi *dpi, in mtk_dpi_config_channel_swap() argument
329 mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << CH_SWAP, CH_SWAP_MASK); in mtk_dpi_config_channel_swap()
332 static void mtk_dpi_config_yuv422_enable(struct mtk_dpi *dpi, bool enable) in mtk_dpi_config_yuv422_enable() argument
334 mtk_dpi_mask(dpi, DPI_CON, enable ? YUV422_EN : 0, YUV422_EN); in mtk_dpi_config_yuv422_enable()
337 static void mtk_dpi_config_csc_enable(struct mtk_dpi *dpi, bool enable) in mtk_dpi_config_csc_enable() argument
339 mtk_dpi_mask(dpi, DPI_CON, enable ? CSC_ENABLE : 0, CSC_ENABLE); in mtk_dpi_config_csc_enable()
342 static void mtk_dpi_config_swap_input(struct mtk_dpi *dpi, bool enable) in mtk_dpi_config_swap_input() argument
344 mtk_dpi_mask(dpi, DPI_CON, enable ? IN_RB_SWAP : 0, IN_RB_SWAP); in mtk_dpi_config_swap_input()
347 static void mtk_dpi_config_2n_h_fre(struct mtk_dpi *dpi) in mtk_dpi_config_2n_h_fre() argument
349 mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, H_FRE_2N, H_FRE_2N); in mtk_dpi_config_2n_h_fre()
352 static void mtk_dpi_config_disable_edge(struct mtk_dpi *dpi) in mtk_dpi_config_disable_edge() argument
354 if (dpi->conf->edge_sel_en) in mtk_dpi_config_disable_edge()
355 mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, 0, EDGE_SEL_EN); in mtk_dpi_config_disable_edge()
358 static void mtk_dpi_config_color_format(struct mtk_dpi *dpi, in mtk_dpi_config_color_format() argument
363 mtk_dpi_config_yuv422_enable(dpi, false); in mtk_dpi_config_color_format()
364 mtk_dpi_config_csc_enable(dpi, true); in mtk_dpi_config_color_format()
365 mtk_dpi_config_swap_input(dpi, false); in mtk_dpi_config_color_format()
366 mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_BGR); in mtk_dpi_config_color_format()
369 mtk_dpi_config_yuv422_enable(dpi, true); in mtk_dpi_config_color_format()
370 mtk_dpi_config_csc_enable(dpi, true); in mtk_dpi_config_color_format()
371 mtk_dpi_config_swap_input(dpi, true); in mtk_dpi_config_color_format()
372 mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB); in mtk_dpi_config_color_format()
374 mtk_dpi_config_yuv422_enable(dpi, false); in mtk_dpi_config_color_format()
375 mtk_dpi_config_csc_enable(dpi, false); in mtk_dpi_config_color_format()
376 mtk_dpi_config_swap_input(dpi, false); in mtk_dpi_config_color_format()
377 mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB); in mtk_dpi_config_color_format()
381 static void mtk_dpi_power_off(struct mtk_dpi *dpi) in mtk_dpi_power_off() argument
383 if (WARN_ON(dpi->refcount == 0)) in mtk_dpi_power_off()
386 if (--dpi->refcount != 0) in mtk_dpi_power_off()
389 if (dpi->pinctrl && dpi->pins_gpio) in mtk_dpi_power_off()
390 pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); in mtk_dpi_power_off()
392 mtk_dpi_disable(dpi); in mtk_dpi_power_off()
393 clk_disable_unprepare(dpi->pixel_clk); in mtk_dpi_power_off()
394 clk_disable_unprepare(dpi->engine_clk); in mtk_dpi_power_off()
397 static int mtk_dpi_power_on(struct mtk_dpi *dpi) in mtk_dpi_power_on() argument
401 if (++dpi->refcount != 1) in mtk_dpi_power_on()
404 ret = clk_prepare_enable(dpi->engine_clk); in mtk_dpi_power_on()
406 dev_err(dpi->dev, "Failed to enable engine clock: %d\n", ret); in mtk_dpi_power_on()
410 ret = clk_prepare_enable(dpi->pixel_clk); in mtk_dpi_power_on()
412 dev_err(dpi->dev, "Failed to enable pixel clock: %d\n", ret); in mtk_dpi_power_on()
416 if (dpi->pinctrl && dpi->pins_dpi) in mtk_dpi_power_on()
417 pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi); in mtk_dpi_power_on()
419 mtk_dpi_enable(dpi); in mtk_dpi_power_on()
423 clk_disable_unprepare(dpi->engine_clk); in mtk_dpi_power_on()
425 dpi->refcount--; in mtk_dpi_power_on()
429 static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, in mtk_dpi_set_display_mode() argument
444 factor = dpi->conf->cal_factor(mode->clock); in mtk_dpi_set_display_mode()
448 dev_dbg(dpi->dev, "Want PLL %lu Hz, pixel clock %lu Hz\n", in mtk_dpi_set_display_mode()
451 clk_set_rate(dpi->tvd_clk, pll_rate); in mtk_dpi_set_display_mode()
452 pll_rate = clk_get_rate(dpi->tvd_clk); in mtk_dpi_set_display_mode()
455 clk_set_rate(dpi->pixel_clk, vm.pixelclock); in mtk_dpi_set_display_mode()
456 vm.pixelclock = clk_get_rate(dpi->pixel_clk); in mtk_dpi_set_display_mode()
458 dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n", in mtk_dpi_set_display_mode()
496 mtk_dpi_sw_reset(dpi, true); in mtk_dpi_set_display_mode()
497 mtk_dpi_config_pol(dpi, &dpi_pol); in mtk_dpi_set_display_mode()
499 mtk_dpi_config_hsync(dpi, &hsync); in mtk_dpi_set_display_mode()
500 mtk_dpi_config_vsync_lodd(dpi, &vsync_lodd); in mtk_dpi_set_display_mode()
501 mtk_dpi_config_vsync_rodd(dpi, &vsync_rodd); in mtk_dpi_set_display_mode()
502 mtk_dpi_config_vsync_leven(dpi, &vsync_leven); in mtk_dpi_set_display_mode()
503 mtk_dpi_config_vsync_reven(dpi, &vsync_reven); in mtk_dpi_set_display_mode()
505 mtk_dpi_config_3d(dpi, !!(mode->flags & DRM_MODE_FLAG_3D_MASK)); in mtk_dpi_set_display_mode()
506 mtk_dpi_config_interface(dpi, !!(vm.flags & in mtk_dpi_set_display_mode()
509 mtk_dpi_config_fb_size(dpi, vm.hactive, vm.vactive >> 1); in mtk_dpi_set_display_mode()
511 mtk_dpi_config_fb_size(dpi, vm.hactive, vm.vactive); in mtk_dpi_set_display_mode()
513 mtk_dpi_config_channel_limit(dpi, &limit); in mtk_dpi_set_display_mode()
514 mtk_dpi_config_bit_num(dpi, dpi->bit_num); in mtk_dpi_set_display_mode()
515 mtk_dpi_config_channel_swap(dpi, dpi->channel_swap); in mtk_dpi_set_display_mode()
516 mtk_dpi_config_yc_map(dpi, dpi->yc_map); in mtk_dpi_set_display_mode()
517 mtk_dpi_config_color_format(dpi, dpi->color_format); in mtk_dpi_set_display_mode()
518 mtk_dpi_config_2n_h_fre(dpi); in mtk_dpi_set_display_mode()
519 mtk_dpi_config_disable_edge(dpi); in mtk_dpi_set_display_mode()
520 mtk_dpi_sw_reset(dpi, false); in mtk_dpi_set_display_mode()
528 struct mtk_dpi *dpi = bridge_to_dpi(bridge); in mtk_dpi_bridge_attach() local
530 return drm_bridge_attach(bridge->encoder, dpi->next_bridge, in mtk_dpi_bridge_attach()
531 &dpi->bridge, flags); in mtk_dpi_bridge_attach()
538 struct mtk_dpi *dpi = bridge_to_dpi(bridge); in mtk_dpi_bridge_mode_set() local
540 drm_mode_copy(&dpi->mode, adjusted_mode); in mtk_dpi_bridge_mode_set()
545 struct mtk_dpi *dpi = bridge_to_dpi(bridge); in mtk_dpi_bridge_disable() local
547 mtk_dpi_power_off(dpi); in mtk_dpi_bridge_disable()
552 struct mtk_dpi *dpi = bridge_to_dpi(bridge); in mtk_dpi_bridge_enable() local
554 mtk_dpi_power_on(dpi); in mtk_dpi_bridge_enable()
555 mtk_dpi_set_display_mode(dpi, &dpi->mode); in mtk_dpi_bridge_enable()
567 struct mtk_dpi *dpi = container_of(comp, struct mtk_dpi, ddp_comp); in mtk_dpi_start() local
569 mtk_dpi_power_on(dpi); in mtk_dpi_start()
574 struct mtk_dpi *dpi = container_of(comp, struct mtk_dpi, ddp_comp); in mtk_dpi_stop() local
576 mtk_dpi_power_off(dpi); in mtk_dpi_stop()
586 struct mtk_dpi *dpi = dev_get_drvdata(dev); in mtk_dpi_bind() local
590 ret = mtk_ddp_comp_register(drm_dev, &dpi->ddp_comp); in mtk_dpi_bind()
597 ret = drm_simple_encoder_init(drm_dev, &dpi->encoder, in mtk_dpi_bind()
604 dpi->encoder.possible_crtcs = mtk_drm_find_possible_crtc_by_comp(drm_dev, dpi->ddp_comp); in mtk_dpi_bind()
606 ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0); in mtk_dpi_bind()
612 dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS; in mtk_dpi_bind()
613 dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB; in mtk_dpi_bind()
614 dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB; in mtk_dpi_bind()
615 dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB; in mtk_dpi_bind()
620 drm_encoder_cleanup(&dpi->encoder); in mtk_dpi_bind()
622 mtk_ddp_comp_unregister(drm_dev, &dpi->ddp_comp); in mtk_dpi_bind()
629 struct mtk_dpi *dpi = dev_get_drvdata(dev); in mtk_dpi_unbind() local
632 drm_encoder_cleanup(&dpi->encoder); in mtk_dpi_unbind()
633 mtk_ddp_comp_unregister(drm_dev, &dpi->ddp_comp); in mtk_dpi_unbind()
692 struct mtk_dpi *dpi; in mtk_dpi_probe() local
697 dpi = devm_kzalloc(dev, sizeof(*dpi), GFP_KERNEL); in mtk_dpi_probe()
698 if (!dpi) in mtk_dpi_probe()
701 dpi->dev = dev; in mtk_dpi_probe()
702 dpi->conf = (struct mtk_dpi_conf *)of_device_get_match_data(dev); in mtk_dpi_probe()
704 dpi->pinctrl = devm_pinctrl_get(&pdev->dev); in mtk_dpi_probe()
705 if (IS_ERR(dpi->pinctrl)) { in mtk_dpi_probe()
706 dpi->pinctrl = NULL; in mtk_dpi_probe()
709 if (dpi->pinctrl) { in mtk_dpi_probe()
710 dpi->pins_gpio = pinctrl_lookup_state(dpi->pinctrl, "sleep"); in mtk_dpi_probe()
711 if (IS_ERR(dpi->pins_gpio)) { in mtk_dpi_probe()
712 dpi->pins_gpio = NULL; in mtk_dpi_probe()
715 if (dpi->pins_gpio) in mtk_dpi_probe()
716 pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); in mtk_dpi_probe()
718 dpi->pins_dpi = pinctrl_lookup_state(dpi->pinctrl, "default"); in mtk_dpi_probe()
719 if (IS_ERR(dpi->pins_dpi)) { in mtk_dpi_probe()
720 dpi->pins_dpi = NULL; in mtk_dpi_probe()
725 dpi->regs = devm_ioremap_resource(dev, mem); in mtk_dpi_probe()
726 if (IS_ERR(dpi->regs)) { in mtk_dpi_probe()
727 ret = PTR_ERR(dpi->regs); in mtk_dpi_probe()
732 dpi->engine_clk = devm_clk_get(dev, "engine"); in mtk_dpi_probe()
733 if (IS_ERR(dpi->engine_clk)) { in mtk_dpi_probe()
734 ret = PTR_ERR(dpi->engine_clk); in mtk_dpi_probe()
741 dpi->pixel_clk = devm_clk_get(dev, "pixel"); in mtk_dpi_probe()
742 if (IS_ERR(dpi->pixel_clk)) { in mtk_dpi_probe()
743 ret = PTR_ERR(dpi->pixel_clk); in mtk_dpi_probe()
750 dpi->tvd_clk = devm_clk_get(dev, "pll"); in mtk_dpi_probe()
751 if (IS_ERR(dpi->tvd_clk)) { in mtk_dpi_probe()
752 ret = PTR_ERR(dpi->tvd_clk); in mtk_dpi_probe()
759 dpi->irq = platform_get_irq(pdev, 0); in mtk_dpi_probe()
760 if (dpi->irq <= 0) { in mtk_dpi_probe()
761 dev_err(dev, "Failed to get irq: %d\n", dpi->irq); in mtk_dpi_probe()
766 NULL, &dpi->next_bridge); in mtk_dpi_probe()
770 dev_info(dev, "Found bridge node: %pOF\n", dpi->next_bridge->of_node); in mtk_dpi_probe()
778 ret = mtk_ddp_comp_init(dev, dev->of_node, &dpi->ddp_comp, comp_id, in mtk_dpi_probe()
785 platform_set_drvdata(pdev, dpi); in mtk_dpi_probe()
787 dpi->bridge.funcs = &mtk_dpi_bridge_funcs; in mtk_dpi_probe()
788 dpi->bridge.of_node = dev->of_node; in mtk_dpi_probe()
789 dpi->bridge.type = DRM_MODE_CONNECTOR_DPI; in mtk_dpi_probe()
791 drm_bridge_add(&dpi->bridge); in mtk_dpi_probe()
795 drm_bridge_remove(&dpi->bridge); in mtk_dpi_probe()
805 struct mtk_dpi *dpi = platform_get_drvdata(pdev); in mtk_dpi_remove() local
808 drm_bridge_remove(&dpi->bridge); in mtk_dpi_remove()
814 { .compatible = "mediatek,mt2701-dpi",
817 { .compatible = "mediatek,mt8173-dpi",
820 { .compatible = "mediatek,mt8183-dpi",
830 .name = "mediatek-dpi",