Lines Matching +full:hdmi +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
3 * HDMI driver for OMAP5
14 #define DSS_SUBSYS_NAME "HDMI"
31 #include <sound/omap-hdmi-audio.h>
37 static struct omap_hdmi hdmi; variable
45 r = pm_runtime_resume_and_get(&hdmi.pdev->dev); in hdmi_runtime_get()
58 r = pm_runtime_put_sync(&hdmi.pdev->dev); in hdmi_runtime_put()
59 WARN_ON(r < 0 && r != -ENOSYS); in hdmi_runtime_put()
75 * time, turn off the PHY, clear interrupts, and restart, which in hdmi_irq_handler()
84 * setting the PHY to LDOON. To ignore those, we force the RXDET in hdmi_irq_handler()
85 * line to 0 until the PHY power state has been changed. in hdmi_irq_handler()
87 v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL); in hdmi_irq_handler()
90 hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v); in hdmi_irq_handler()
97 REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15); in hdmi_irq_handler()
112 if (hdmi.vdda_reg != NULL) in hdmi_init_regulator()
115 reg = devm_regulator_get(&hdmi.pdev->dev, "vdda"); in hdmi_init_regulator()
121 hdmi.vdda_reg = reg; in hdmi_init_regulator()
130 r = regulator_enable(hdmi.vdda_reg); in hdmi_power_on_core()
138 /* Make selection of HDMI in DSS */ in hdmi_power_on_core()
141 hdmi.core_enabled = true; in hdmi_power_on_core()
146 regulator_disable(hdmi.vdda_reg); in hdmi_power_on_core()
153 hdmi.core_enabled = false; in hdmi_power_off_core()
156 regulator_disable(hdmi.vdda_reg); in hdmi_power_off_core()
163 struct omap_overlay_manager *mgr = hdmi.output.manager; in hdmi_power_on_full()
170 p = &hdmi.cfg.timings; in hdmi_power_on_full()
172 DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res); in hdmi_power_on_full()
174 hdmi_pll_compute(&hdmi.pll, p->pixelclock, &hdmi_cinfo); in hdmi_power_on_full()
177 hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff); in hdmi_power_on_full()
178 hdmi_wp_set_irqstatus(&hdmi.wp, in hdmi_power_on_full()
179 hdmi_wp_get_irqstatus(&hdmi.wp)); in hdmi_power_on_full()
181 r = dss_pll_enable(&hdmi.pll.pll); in hdmi_power_on_full()
187 r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo); in hdmi_power_on_full()
193 r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco, in hdmi_power_on_full()
196 DSSDBG("Failed to start PHY\n"); in hdmi_power_on_full()
200 r = hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_LDOON); in hdmi_power_on_full()
204 hdmi5_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg); in hdmi_power_on_full()
212 r = hdmi_wp_video_start(&hdmi.wp); in hdmi_power_on_full()
220 hdmi_wp_set_irqenable(&hdmi.wp, in hdmi_power_on_full()
226 hdmi_wp_video_stop(&hdmi.wp); in hdmi_power_on_full()
228 hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_on_full()
232 dss_pll_disable(&hdmi.pll.pll); in hdmi_power_on_full()
235 return -EIO; in hdmi_power_on_full()
240 struct omap_overlay_manager *mgr = hdmi.output.manager; in hdmi_power_off_full()
242 hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff); in hdmi_power_off_full()
246 hdmi_wp_video_stop(&hdmi.wp); in hdmi_power_off_full()
248 hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_off_full()
250 dss_pll_disable(&hdmi.pll.pll); in hdmi_power_off_full()
258 struct omap_dss_device *out = &hdmi.output; in hdmi_display_check_timing()
261 if (timings->interlace) in hdmi_display_check_timing()
262 return -EINVAL; in hdmi_display_check_timing()
264 if (!dispc_mgr_timings_ok(out->dispc_channel, timings)) in hdmi_display_check_timing()
265 return -EINVAL; in hdmi_display_check_timing()
273 mutex_lock(&hdmi.lock); in hdmi_display_set_timing()
275 hdmi.cfg.timings = *timings; in hdmi_display_set_timing()
277 dispc_set_tv_pclk(timings->pixelclock); in hdmi_display_set_timing()
279 mutex_unlock(&hdmi.lock); in hdmi_display_set_timing()
285 *timings = hdmi.cfg.timings; in hdmi_display_get_timings()
290 mutex_lock(&hdmi.lock); in hdmi_dump_regs()
293 mutex_unlock(&hdmi.lock); in hdmi_dump_regs()
297 hdmi_wp_dump(&hdmi.wp, s); in hdmi_dump_regs()
298 hdmi_pll_dump(&hdmi.pll, s); in hdmi_dump_regs()
299 hdmi_phy_dump(&hdmi.phy, s); in hdmi_dump_regs()
300 hdmi5_core_dump(&hdmi.core, s); in hdmi_dump_regs()
303 mutex_unlock(&hdmi.lock); in hdmi_dump_regs()
311 mutex_lock(&hdmi.lock); in read_edid()
316 idlemode = REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2); in read_edid()
317 /* No-idle mode */ in read_edid()
318 REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2); in read_edid()
320 r = hdmi5_read_edid(&hdmi.core, buf, len); in read_edid()
322 REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2); in read_edid()
325 mutex_unlock(&hdmi.lock); in read_edid()
332 REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2); in hdmi_start_audio_stream()
333 hdmi_wp_audio_enable(&hd->wp, true); in hdmi_start_audio_stream()
334 hdmi_wp_audio_core_req_enable(&hd->wp, true); in hdmi_start_audio_stream()
339 hdmi_wp_audio_core_req_enable(&hd->wp, false); in hdmi_stop_audio_stream()
340 hdmi_wp_audio_enable(&hd->wp, false); in hdmi_stop_audio_stream()
341 REG_FLD_MOD(hd->wp.base, HDMI_WP_SYSCONFIG, hd->wp_idlemode, 3, 2); in hdmi_stop_audio_stream()
346 struct omap_dss_device *out = &hdmi.output; in hdmi_display_enable()
352 mutex_lock(&hdmi.lock); in hdmi_display_enable()
354 if (out->manager == NULL) { in hdmi_display_enable()
356 r = -ENODEV; in hdmi_display_enable()
366 if (hdmi.audio_configured) { in hdmi_display_enable()
367 r = hdmi5_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config, in hdmi_display_enable()
368 hdmi.cfg.timings.pixelclock); in hdmi_display_enable()
371 hdmi.audio_abort_cb(&hdmi.pdev->dev); in hdmi_display_enable()
372 hdmi.audio_configured = false; in hdmi_display_enable()
376 spin_lock_irqsave(&hdmi.audio_playing_lock, flags); in hdmi_display_enable()
377 if (hdmi.audio_configured && hdmi.audio_playing) in hdmi_display_enable()
378 hdmi_start_audio_stream(&hdmi); in hdmi_display_enable()
379 hdmi.display_enabled = true; in hdmi_display_enable()
380 spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags); in hdmi_display_enable()
382 mutex_unlock(&hdmi.lock); in hdmi_display_enable()
386 mutex_unlock(&hdmi.lock); in hdmi_display_enable()
396 mutex_lock(&hdmi.lock); in hdmi_display_disable()
398 spin_lock_irqsave(&hdmi.audio_playing_lock, flags); in hdmi_display_disable()
399 hdmi_stop_audio_stream(&hdmi); in hdmi_display_disable()
400 hdmi.display_enabled = false; in hdmi_display_disable()
401 spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags); in hdmi_display_disable()
405 mutex_unlock(&hdmi.lock); in hdmi_display_disable()
414 mutex_lock(&hdmi.lock); in hdmi_core_enable()
422 mutex_unlock(&hdmi.lock); in hdmi_core_enable()
426 mutex_unlock(&hdmi.lock); in hdmi_core_enable()
434 mutex_lock(&hdmi.lock); in hdmi_core_disable()
438 mutex_unlock(&hdmi.lock); in hdmi_core_disable()
451 mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel); in hdmi_connect()
453 return -ENODEV; in hdmi_connect()
462 dst->name); in hdmi_connect()
473 WARN_ON(dst != dssdev->dst); in hdmi_disconnect()
475 if (dst != dssdev->dst) in hdmi_disconnect()
480 if (dssdev->manager) in hdmi_disconnect()
481 dss_mgr_disconnect(dssdev->manager, dssdev); in hdmi_disconnect()
490 need_enable = hdmi.core_enabled == false; in hdmi_read_edid()
509 hdmi.cfg.infoframe = *avi; in hdmi_set_infoframe()
516 hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI; in hdmi_set_hdmi_mode()
538 struct omap_dss_device *out = &hdmi.output; in hdmi_init_output()
540 out->dev = &pdev->dev; in hdmi_init_output()
541 out->id = OMAP_DSS_OUTPUT_HDMI; in hdmi_init_output()
542 out->output_type = OMAP_DISPLAY_TYPE_HDMI; in hdmi_init_output()
543 out->name = "hdmi.0"; in hdmi_init_output()
544 out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT; in hdmi_init_output()
545 out->ops.hdmi = &hdmi_ops; in hdmi_init_output()
546 out->owner = THIS_MODULE; in hdmi_init_output()
553 struct omap_dss_device *out = &hdmi.output; in hdmi_uninit_output()
560 struct device_node *node = pdev->dev.of_node; in hdmi_probe_of()
568 r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy); in hdmi_probe_of()
587 mutex_lock(&hd->lock); in hdmi_audio_startup()
589 if (!hdmi_mode_has_audio(&hd->cfg) || !hd->display_enabled) { in hdmi_audio_startup()
590 ret = -EPERM; in hdmi_audio_startup()
594 hd->audio_abort_cb = abort_cb; in hdmi_audio_startup()
597 mutex_unlock(&hd->lock); in hdmi_audio_startup()
606 mutex_lock(&hd->lock); in hdmi_audio_shutdown()
607 hd->audio_abort_cb = NULL; in hdmi_audio_shutdown()
608 hd->audio_configured = false; in hdmi_audio_shutdown()
609 hd->audio_playing = false; in hdmi_audio_shutdown()
610 mutex_unlock(&hd->lock); in hdmi_audio_shutdown()
620 WARN_ON(!hdmi_mode_has_audio(&hd->cfg)); in hdmi_audio_start()
622 spin_lock_irqsave(&hd->audio_playing_lock, flags); in hdmi_audio_start()
624 if (hd->display_enabled) in hdmi_audio_start()
626 hd->audio_playing = true; in hdmi_audio_start()
628 spin_unlock_irqrestore(&hd->audio_playing_lock, flags); in hdmi_audio_start()
637 WARN_ON(!hdmi_mode_has_audio(&hd->cfg)); in hdmi_audio_stop()
639 spin_lock_irqsave(&hd->audio_playing_lock, flags); in hdmi_audio_stop()
641 if (hd->display_enabled) in hdmi_audio_stop()
643 hd->audio_playing = false; in hdmi_audio_stop()
645 spin_unlock_irqrestore(&hd->audio_playing_lock, flags); in hdmi_audio_stop()
654 mutex_lock(&hd->lock); in hdmi_audio_config()
656 if (!hdmi_mode_has_audio(&hd->cfg) || !hd->display_enabled) { in hdmi_audio_config()
657 ret = -EPERM; in hdmi_audio_config()
661 ret = hdmi5_audio_config(&hd->core, &hd->wp, dss_audio, in hdmi_audio_config()
662 hd->cfg.timings.pixelclock); in hdmi_audio_config()
665 hd->audio_configured = true; in hdmi_audio_config()
666 hd->audio_config = *dss_audio; in hdmi_audio_config()
669 mutex_unlock(&hd->lock); in hdmi_audio_config()
687 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp), in hdmi_audio_register()
691 hdmi.audio_pdev = platform_device_register_data( in hdmi_audio_register()
692 dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, in hdmi_audio_register()
695 if (IS_ERR(hdmi.audio_pdev)) in hdmi_audio_register()
696 return PTR_ERR(hdmi.audio_pdev); in hdmi_audio_register()
699 hdmi.wp_idlemode = in hdmi_audio_register()
700 REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2); in hdmi_audio_register()
706 /* HDMI HW IP initialisation */
713 hdmi.pdev = pdev; in hdmi5_bind()
714 platform_set_drvdata(pdev, &hdmi); in hdmi5_bind()
716 mutex_init(&hdmi.lock); in hdmi5_bind()
717 spin_lock_init(&hdmi.audio_playing_lock); in hdmi5_bind()
719 if (pdev->dev.of_node) { in hdmi5_bind()
725 r = hdmi_wp_init(pdev, &hdmi.wp); in hdmi5_bind()
729 r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp); in hdmi5_bind()
733 r = hdmi_phy_init(pdev, &hdmi.phy); in hdmi5_bind()
737 r = hdmi5_core_init(pdev, &hdmi.core); in hdmi5_bind()
744 r = -ENODEV; in hdmi5_bind()
748 r = devm_request_threaded_irq(&pdev->dev, irq, in hdmi5_bind()
750 IRQF_ONESHOT, "OMAP HDMI", &hdmi.wp); in hdmi5_bind()
752 DSSERR("HDMI IRQ request failed\n"); in hdmi5_bind()
756 pm_runtime_enable(&pdev->dev); in hdmi5_bind()
760 r = hdmi_audio_register(&pdev->dev); in hdmi5_bind()
762 DSSERR("Registering HDMI audio failed %d\n", r); in hdmi5_bind()
764 pm_runtime_disable(&pdev->dev); in hdmi5_bind()
768 dss_debugfs_create_file("hdmi", hdmi_dump_regs); in hdmi5_bind()
772 hdmi_pll_uninit(&hdmi.pll); in hdmi5_bind()
780 if (hdmi.audio_pdev) in hdmi5_unbind()
781 platform_device_unregister(hdmi.audio_pdev); in hdmi5_unbind()
785 hdmi_pll_uninit(&hdmi.pll); in hdmi5_unbind()
787 pm_runtime_disable(&pdev->dev); in hdmi5_unbind()
797 return component_add(&pdev->dev, &hdmi5_component_ops); in hdmi5_probe()
802 component_del(&pdev->dev, &hdmi5_component_ops); in hdmi5_remove()
830 { .compatible = "ti,omap5-hdmi", },
831 { .compatible = "ti,dra7-hdmi", },