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"
32 #include <sound/omap-hdmi-audio.h>
38 static struct omap_hdmi hdmi; variable
46 r = pm_runtime_resume_and_get(&hdmi.pdev->dev); in hdmi_runtime_get()
59 r = pm_runtime_put_sync(&hdmi.pdev->dev); in hdmi_runtime_put()
60 WARN_ON(r < 0 && r != -ENOSYS); in hdmi_runtime_put()
76 * time, turn off the PHY, clear interrupts, and restart, which in hdmi_irq_handler()
85 * setting the PHY to LDOON. To ignore those, we force the RXDET in hdmi_irq_handler()
86 * line to 0 until the PHY power state has been changed. in hdmi_irq_handler()
88 v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL); in hdmi_irq_handler()
91 hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v); in hdmi_irq_handler()
98 REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15); in hdmi_irq_handler()
113 if (hdmi.vdda_reg != NULL) in hdmi_init_regulator()
116 reg = devm_regulator_get(&hdmi.pdev->dev, "vdda"); in hdmi_init_regulator()
122 hdmi.vdda_reg = reg; in hdmi_init_regulator()
131 r = regulator_enable(hdmi.vdda_reg); in hdmi_power_on_core()
139 /* Make selection of HDMI in DSS */ in hdmi_power_on_core()
142 hdmi.core_enabled = true; in hdmi_power_on_core()
147 regulator_disable(hdmi.vdda_reg); in hdmi_power_on_core()
154 hdmi.core_enabled = false; in hdmi_power_off_core()
157 regulator_disable(hdmi.vdda_reg); in hdmi_power_off_core()
164 struct omap_overlay_manager *mgr = hdmi.output.manager; in hdmi_power_on_full()
171 p = &hdmi.cfg.timings; in hdmi_power_on_full()
173 DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res); in hdmi_power_on_full()
175 hdmi_pll_compute(&hdmi.pll, p->pixelclock, &hdmi_cinfo); in hdmi_power_on_full()
178 hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff); in hdmi_power_on_full()
179 hdmi_wp_set_irqstatus(&hdmi.wp, in hdmi_power_on_full()
180 hdmi_wp_get_irqstatus(&hdmi.wp)); in hdmi_power_on_full()
182 r = dss_pll_enable(&hdmi.pll.pll); in hdmi_power_on_full()
188 r = dss_pll_set_config(&hdmi.pll.pll, &hdmi_cinfo); in hdmi_power_on_full()
194 r = hdmi_phy_configure(&hdmi.phy, hdmi_cinfo.clkdco, in hdmi_power_on_full()
197 DSSDBG("Failed to start PHY\n"); in hdmi_power_on_full()
201 r = hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_LDOON); in hdmi_power_on_full()
205 hdmi5_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg); in hdmi_power_on_full()
213 r = hdmi_wp_video_start(&hdmi.wp); in hdmi_power_on_full()
221 hdmi_wp_set_irqenable(&hdmi.wp, in hdmi_power_on_full()
227 hdmi_wp_video_stop(&hdmi.wp); in hdmi_power_on_full()
229 hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_on_full()
233 dss_pll_disable(&hdmi.pll.pll); in hdmi_power_on_full()
236 return -EIO; in hdmi_power_on_full()
241 struct omap_overlay_manager *mgr = hdmi.output.manager; in hdmi_power_off_full()
243 hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff); in hdmi_power_off_full()
247 hdmi_wp_video_stop(&hdmi.wp); in hdmi_power_off_full()
249 hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_off_full()
251 dss_pll_disable(&hdmi.pll.pll); in hdmi_power_off_full()
259 struct omap_dss_device *out = &hdmi.output; in hdmi_display_check_timing()
262 if (timings->interlace) in hdmi_display_check_timing()
263 return -EINVAL; in hdmi_display_check_timing()
265 if (!dispc_mgr_timings_ok(out->dispc_channel, timings)) in hdmi_display_check_timing()
266 return -EINVAL; in hdmi_display_check_timing()
274 mutex_lock(&hdmi.lock); in hdmi_display_set_timing()
276 hdmi.cfg.timings = *timings; in hdmi_display_set_timing()
278 dispc_set_tv_pclk(timings->pixelclock); in hdmi_display_set_timing()
280 mutex_unlock(&hdmi.lock); in hdmi_display_set_timing()
286 *timings = hdmi.cfg.timings; in hdmi_display_get_timings()
291 mutex_lock(&hdmi.lock); in hdmi_dump_regs()
294 mutex_unlock(&hdmi.lock); in hdmi_dump_regs()
298 hdmi_wp_dump(&hdmi.wp, s); in hdmi_dump_regs()
299 hdmi_pll_dump(&hdmi.pll, s); in hdmi_dump_regs()
300 hdmi_phy_dump(&hdmi.phy, s); in hdmi_dump_regs()
301 hdmi5_core_dump(&hdmi.core, s); in hdmi_dump_regs()
304 mutex_unlock(&hdmi.lock); in hdmi_dump_regs()
312 mutex_lock(&hdmi.lock); in read_edid()
317 idlemode = REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2); in read_edid()
318 /* No-idle mode */ in read_edid()
319 REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2); in read_edid()
321 r = hdmi5_read_edid(&hdmi.core, buf, len); in read_edid()
323 REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2); in read_edid()
326 mutex_unlock(&hdmi.lock); in read_edid()
333 REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2); in hdmi_start_audio_stream()
334 hdmi_wp_audio_enable(&hd->wp, true); in hdmi_start_audio_stream()
335 hdmi_wp_audio_core_req_enable(&hd->wp, true); in hdmi_start_audio_stream()
340 hdmi_wp_audio_core_req_enable(&hd->wp, false); in hdmi_stop_audio_stream()
341 hdmi_wp_audio_enable(&hd->wp, false); in hdmi_stop_audio_stream()
342 REG_FLD_MOD(hd->wp.base, HDMI_WP_SYSCONFIG, hd->wp_idlemode, 3, 2); in hdmi_stop_audio_stream()
347 struct omap_dss_device *out = &hdmi.output; in hdmi_display_enable()
353 mutex_lock(&hdmi.lock); in hdmi_display_enable()
355 if (out->manager == NULL) { in hdmi_display_enable()
357 r = -ENODEV; in hdmi_display_enable()
367 if (hdmi.audio_configured) { in hdmi_display_enable()
368 r = hdmi5_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config, in hdmi_display_enable()
369 hdmi.cfg.timings.pixelclock); in hdmi_display_enable()
372 hdmi.audio_abort_cb(&hdmi.pdev->dev); in hdmi_display_enable()
373 hdmi.audio_configured = false; in hdmi_display_enable()
377 spin_lock_irqsave(&hdmi.audio_playing_lock, flags); in hdmi_display_enable()
378 if (hdmi.audio_configured && hdmi.audio_playing) in hdmi_display_enable()
379 hdmi_start_audio_stream(&hdmi); in hdmi_display_enable()
380 hdmi.display_enabled = true; in hdmi_display_enable()
381 spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags); in hdmi_display_enable()
383 mutex_unlock(&hdmi.lock); in hdmi_display_enable()
387 mutex_unlock(&hdmi.lock); in hdmi_display_enable()
397 mutex_lock(&hdmi.lock); in hdmi_display_disable()
399 spin_lock_irqsave(&hdmi.audio_playing_lock, flags); in hdmi_display_disable()
400 hdmi_stop_audio_stream(&hdmi); in hdmi_display_disable()
401 hdmi.display_enabled = false; in hdmi_display_disable()
402 spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags); in hdmi_display_disable()
406 mutex_unlock(&hdmi.lock); in hdmi_display_disable()
415 mutex_lock(&hdmi.lock); in hdmi_core_enable()
423 mutex_unlock(&hdmi.lock); in hdmi_core_enable()
427 mutex_unlock(&hdmi.lock); in hdmi_core_enable()
435 mutex_lock(&hdmi.lock); in hdmi_core_disable()
439 mutex_unlock(&hdmi.lock); in hdmi_core_disable()
452 mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel); in hdmi_connect()
454 return -ENODEV; in hdmi_connect()
463 dst->name); in hdmi_connect()
474 WARN_ON(dst != dssdev->dst); in hdmi_disconnect()
476 if (dst != dssdev->dst) in hdmi_disconnect()
481 if (dssdev->manager) in hdmi_disconnect()
482 dss_mgr_disconnect(dssdev->manager, dssdev); in hdmi_disconnect()
491 need_enable = hdmi.core_enabled == false; in hdmi_read_edid()
510 hdmi.cfg.infoframe = *avi; in hdmi_set_infoframe()
517 hdmi.cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI; in hdmi_set_hdmi_mode()
539 struct omap_dss_device *out = &hdmi.output; in hdmi_init_output()
541 out->dev = &pdev->dev; in hdmi_init_output()
542 out->id = OMAP_DSS_OUTPUT_HDMI; in hdmi_init_output()
543 out->output_type = OMAP_DISPLAY_TYPE_HDMI; in hdmi_init_output()
544 out->name = "hdmi.0"; in hdmi_init_output()
545 out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT; in hdmi_init_output()
546 out->ops.hdmi = &hdmi_ops; in hdmi_init_output()
547 out->owner = THIS_MODULE; in hdmi_init_output()
554 struct omap_dss_device *out = &hdmi.output; in hdmi_uninit_output()
561 struct device_node *node = pdev->dev.of_node; in hdmi_probe_of()
565 ep = of_graph_get_endpoint_by_regs(node, 0, -1); in hdmi_probe_of()
569 r = hdmi_parse_lanes_of(pdev, ep, &hdmi.phy); in hdmi_probe_of()
588 mutex_lock(&hd->lock); in hdmi_audio_startup()
590 if (!hdmi_mode_has_audio(&hd->cfg) || !hd->display_enabled) { in hdmi_audio_startup()
591 ret = -EPERM; in hdmi_audio_startup()
595 hd->audio_abort_cb = abort_cb; in hdmi_audio_startup()
598 mutex_unlock(&hd->lock); in hdmi_audio_startup()
607 mutex_lock(&hd->lock); in hdmi_audio_shutdown()
608 hd->audio_abort_cb = NULL; in hdmi_audio_shutdown()
609 hd->audio_configured = false; in hdmi_audio_shutdown()
610 hd->audio_playing = false; in hdmi_audio_shutdown()
611 mutex_unlock(&hd->lock); in hdmi_audio_shutdown()
621 WARN_ON(!hdmi_mode_has_audio(&hd->cfg)); in hdmi_audio_start()
623 spin_lock_irqsave(&hd->audio_playing_lock, flags); in hdmi_audio_start()
625 if (hd->display_enabled) in hdmi_audio_start()
627 hd->audio_playing = true; in hdmi_audio_start()
629 spin_unlock_irqrestore(&hd->audio_playing_lock, flags); in hdmi_audio_start()
638 WARN_ON(!hdmi_mode_has_audio(&hd->cfg)); in hdmi_audio_stop()
640 spin_lock_irqsave(&hd->audio_playing_lock, flags); in hdmi_audio_stop()
642 if (hd->display_enabled) in hdmi_audio_stop()
644 hd->audio_playing = false; in hdmi_audio_stop()
646 spin_unlock_irqrestore(&hd->audio_playing_lock, flags); in hdmi_audio_stop()
655 mutex_lock(&hd->lock); in hdmi_audio_config()
657 if (!hdmi_mode_has_audio(&hd->cfg) || !hd->display_enabled) { in hdmi_audio_config()
658 ret = -EPERM; in hdmi_audio_config()
662 ret = hdmi5_audio_config(&hd->core, &hd->wp, dss_audio, in hdmi_audio_config()
663 hd->cfg.timings.pixelclock); in hdmi_audio_config()
666 hd->audio_configured = true; in hdmi_audio_config()
667 hd->audio_config = *dss_audio; in hdmi_audio_config()
670 mutex_unlock(&hd->lock); in hdmi_audio_config()
688 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp), in hdmi_audio_register()
692 hdmi.audio_pdev = platform_device_register_data( in hdmi_audio_register()
693 dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, in hdmi_audio_register()
696 if (IS_ERR(hdmi.audio_pdev)) in hdmi_audio_register()
697 return PTR_ERR(hdmi.audio_pdev); in hdmi_audio_register()
700 hdmi.wp_idlemode = in hdmi_audio_register()
701 REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2); in hdmi_audio_register()
707 /* HDMI HW IP initialisation */
714 hdmi.pdev = pdev; in hdmi5_bind()
715 platform_set_drvdata(pdev, &hdmi); in hdmi5_bind()
717 mutex_init(&hdmi.lock); in hdmi5_bind()
718 spin_lock_init(&hdmi.audio_playing_lock); in hdmi5_bind()
720 if (pdev->dev.of_node) { in hdmi5_bind()
726 r = hdmi_wp_init(pdev, &hdmi.wp); in hdmi5_bind()
730 r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp); in hdmi5_bind()
734 r = hdmi_phy_init(pdev, &hdmi.phy); in hdmi5_bind()
738 r = hdmi5_core_init(pdev, &hdmi.core); in hdmi5_bind()
745 r = -ENODEV; in hdmi5_bind()
749 r = devm_request_threaded_irq(&pdev->dev, irq, in hdmi5_bind()
751 IRQF_ONESHOT, "OMAP HDMI", &hdmi.wp); in hdmi5_bind()
753 DSSERR("HDMI IRQ request failed\n"); in hdmi5_bind()
757 pm_runtime_enable(&pdev->dev); in hdmi5_bind()
761 r = hdmi_audio_register(&pdev->dev); in hdmi5_bind()
763 DSSERR("Registering HDMI audio failed %d\n", r); in hdmi5_bind()
765 pm_runtime_disable(&pdev->dev); in hdmi5_bind()
769 dss_debugfs_create_file("hdmi", hdmi_dump_regs); in hdmi5_bind()
773 hdmi_pll_uninit(&hdmi.pll); in hdmi5_bind()
781 if (hdmi.audio_pdev) in hdmi5_unbind()
782 platform_device_unregister(hdmi.audio_pdev); in hdmi5_unbind()
786 hdmi_pll_uninit(&hdmi.pll); in hdmi5_unbind()
788 pm_runtime_disable(&pdev->dev); in hdmi5_unbind()
798 return component_add(&pdev->dev, &hdmi5_component_ops); in hdmi5_probe()
803 component_del(&pdev->dev, &hdmi5_component_ops); in hdmi5_remove()
830 { .compatible = "ti,omap5-hdmi", },
831 { .compatible = "ti,dra7-hdmi", },