Lines Matching +full:pll +full:- +full:master
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com/
31 #include <sound/omap-hdmi-audio.h>
47 r = pm_runtime_get_sync(&hdmi->pdev->dev); in hdmi_runtime_get()
49 pm_runtime_put_noidle(&hdmi->pdev->dev); in hdmi_runtime_get()
61 r = pm_runtime_put_sync(&hdmi->pdev->dev); in hdmi_runtime_put()
62 WARN_ON(r < 0 && r != -ENOSYS); in hdmi_runtime_put()
68 struct hdmi_wp_data *wp = &hdmi->wp; in hdmi_irq_handler()
91 v = hdmi_read_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL); in hdmi_irq_handler()
94 hdmi_write_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v); in hdmi_irq_handler()
101 REG_FLD_MOD(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15); in hdmi_irq_handler()
116 r = regulator_enable(hdmi->vdda_reg); in hdmi_power_on_core()
125 dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK); in hdmi_power_on_core()
127 hdmi->core_enabled = true; in hdmi_power_on_core()
132 regulator_disable(hdmi->vdda_reg); in hdmi_power_on_core()
139 hdmi->core_enabled = false; in hdmi_power_off_core()
142 regulator_disable(hdmi->vdda_reg); in hdmi_power_off_core()
156 vm = &hdmi->cfg.vm; in hdmi_power_on_full()
158 DSSDBG("hdmi_power_on hactive= %d vactive = %d\n", vm->hactive, in hdmi_power_on_full()
159 vm->vactive); in hdmi_power_on_full()
161 pc = vm->pixelclock; in hdmi_power_on_full()
162 if (vm->flags & DISPLAY_FLAGS_DOUBLECLK) in hdmi_power_on_full()
168 dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin), in hdmi_power_on_full()
172 hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff); in hdmi_power_on_full()
173 hdmi_wp_set_irqstatus(&hdmi->wp, in hdmi_power_on_full()
174 hdmi_wp_get_irqstatus(&hdmi->wp)); in hdmi_power_on_full()
176 r = dss_pll_enable(&hdmi->pll.pll); in hdmi_power_on_full()
178 DSSERR("Failed to enable PLL\n"); in hdmi_power_on_full()
182 r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo); in hdmi_power_on_full()
184 DSSERR("Failed to configure PLL\n"); in hdmi_power_on_full()
188 r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco, in hdmi_power_on_full()
195 r = hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_LDOON); in hdmi_power_on_full()
199 hdmi5_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg); in hdmi_power_on_full()
201 r = dss_mgr_enable(&hdmi->output); in hdmi_power_on_full()
205 r = hdmi_wp_video_start(&hdmi->wp); in hdmi_power_on_full()
209 hdmi_wp_set_irqenable(&hdmi->wp, in hdmi_power_on_full()
215 dss_mgr_disable(&hdmi->output); in hdmi_power_on_full()
217 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_on_full()
221 dss_pll_disable(&hdmi->pll.pll); in hdmi_power_on_full()
224 return -EIO; in hdmi_power_on_full()
229 hdmi_wp_clear_irqenable(&hdmi->wp, 0xffffffff); in hdmi_power_off_full()
231 hdmi_wp_video_stop(&hdmi->wp); in hdmi_power_off_full()
233 dss_mgr_disable(&hdmi->output); in hdmi_power_off_full()
235 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_off_full()
237 dss_pll_disable(&hdmi->pll.pll); in hdmi_power_off_full()
244 struct omap_hdmi *hdmi = s->private; in hdmi_dump_regs()
246 mutex_lock(&hdmi->lock); in hdmi_dump_regs()
249 mutex_unlock(&hdmi->lock); in hdmi_dump_regs()
253 hdmi_wp_dump(&hdmi->wp, s); in hdmi_dump_regs()
254 hdmi_pll_dump(&hdmi->pll, s); in hdmi_dump_regs()
255 hdmi_phy_dump(&hdmi->phy, s); in hdmi_dump_regs()
256 hdmi5_core_dump(&hdmi->core, s); in hdmi_dump_regs()
259 mutex_unlock(&hdmi->lock); in hdmi_dump_regs()
265 REG_FLD_MOD(hd->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2); in hdmi_start_audio_stream()
266 hdmi_wp_audio_enable(&hd->wp, true); in hdmi_start_audio_stream()
267 hdmi_wp_audio_core_req_enable(&hd->wp, true); in hdmi_start_audio_stream()
272 hdmi_wp_audio_core_req_enable(&hd->wp, false); in hdmi_stop_audio_stream()
273 hdmi_wp_audio_enable(&hd->wp, false); in hdmi_stop_audio_stream()
274 REG_FLD_MOD(hd->wp.base, HDMI_WP_SYSCONFIG, hd->wp_idlemode, 3, 2); in hdmi_stop_audio_stream()
283 mutex_lock(&hdmi->lock); in hdmi_core_enable()
291 mutex_unlock(&hdmi->lock); in hdmi_core_enable()
295 mutex_unlock(&hdmi->lock); in hdmi_core_enable()
303 mutex_lock(&hdmi->lock); in hdmi_core_disable()
307 mutex_unlock(&hdmi->lock); in hdmi_core_disable()
310 /* -----------------------------------------------------------------------------
320 return -EINVAL; in hdmi5_bridge_attach()
322 return drm_bridge_attach(bridge->encoder, hdmi->output.next_bridge, in hdmi5_bridge_attach()
332 mutex_lock(&hdmi->lock); in hdmi5_bridge_mode_set()
334 drm_display_mode_to_videomode(adjusted_mode, &hdmi->cfg.vm); in hdmi5_bridge_mode_set()
336 dispc_set_tv_pclk(hdmi->dss->dispc, adjusted_mode->clock * 1000); in hdmi5_bridge_mode_set()
338 mutex_unlock(&hdmi->lock); in hdmi5_bridge_mode_set()
345 struct drm_atomic_state *state = bridge_state->base.state; in hdmi5_bridge_enable()
357 bridge->encoder); in hdmi5_bridge_enable()
363 crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); in hdmi5_bridge_enable()
367 hdmi->cfg.hdmi_dvi_mode = connector->display_info.is_hdmi in hdmi5_bridge_enable()
370 if (connector->display_info.is_hdmi) { in hdmi5_bridge_enable()
374 mode = &crtc_state->adjusted_mode; in hdmi5_bridge_enable()
378 hdmi->cfg.infoframe = avi; in hdmi5_bridge_enable()
381 mutex_lock(&hdmi->lock); in hdmi5_bridge_enable()
389 if (hdmi->audio_configured) { in hdmi5_bridge_enable()
390 ret = hdmi5_audio_config(&hdmi->core, &hdmi->wp, in hdmi5_bridge_enable()
391 &hdmi->audio_config, in hdmi5_bridge_enable()
392 hdmi->cfg.vm.pixelclock); in hdmi5_bridge_enable()
395 hdmi->audio_abort_cb(&hdmi->pdev->dev); in hdmi5_bridge_enable()
396 hdmi->audio_configured = false; in hdmi5_bridge_enable()
400 spin_lock_irqsave(&hdmi->audio_playing_lock, flags); in hdmi5_bridge_enable()
401 if (hdmi->audio_configured && hdmi->audio_playing) in hdmi5_bridge_enable()
403 hdmi->display_enabled = true; in hdmi5_bridge_enable()
404 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags); in hdmi5_bridge_enable()
407 mutex_unlock(&hdmi->lock); in hdmi5_bridge_enable()
416 mutex_lock(&hdmi->lock); in hdmi5_bridge_disable()
418 spin_lock_irqsave(&hdmi->audio_playing_lock, flags); in hdmi5_bridge_disable()
420 hdmi->display_enabled = false; in hdmi5_bridge_disable()
421 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags); in hdmi5_bridge_disable()
425 mutex_unlock(&hdmi->lock); in hdmi5_bridge_disable()
437 need_enable = hdmi->core_enabled == false; in hdmi5_bridge_edid_read()
445 mutex_lock(&hdmi->lock); in hdmi5_bridge_edid_read()
449 idlemode = REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2); in hdmi5_bridge_edid_read()
450 /* No-idle mode */ in hdmi5_bridge_edid_read()
451 REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2); in hdmi5_bridge_edid_read()
453 hdmi5_core_ddc_init(&hdmi->core); in hdmi5_bridge_edid_read()
455 drm_edid = drm_edid_read_custom(connector, hdmi5_core_ddc_read, &hdmi->core); in hdmi5_bridge_edid_read()
457 hdmi5_core_ddc_uninit(&hdmi->core); in hdmi5_bridge_edid_read()
459 REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2); in hdmi5_bridge_edid_read()
462 mutex_unlock(&hdmi->lock); in hdmi5_bridge_edid_read()
483 hdmi->bridge.funcs = &hdmi5_bridge_funcs; in hdmi5_bridge_init()
484 hdmi->bridge.of_node = hdmi->pdev->dev.of_node; in hdmi5_bridge_init()
485 hdmi->bridge.ops = DRM_BRIDGE_OP_EDID; in hdmi5_bridge_init()
486 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in hdmi5_bridge_init()
488 drm_bridge_add(&hdmi->bridge); in hdmi5_bridge_init()
493 drm_bridge_remove(&hdmi->bridge); in hdmi5_bridge_cleanup()
496 /* -----------------------------------------------------------------------------
505 mutex_lock(&hd->lock); in hdmi_audio_startup()
507 WARN_ON(hd->audio_abort_cb != NULL); in hdmi_audio_startup()
509 hd->audio_abort_cb = abort_cb; in hdmi_audio_startup()
511 mutex_unlock(&hd->lock); in hdmi_audio_startup()
520 mutex_lock(&hd->lock); in hdmi_audio_shutdown()
521 hd->audio_abort_cb = NULL; in hdmi_audio_shutdown()
522 hd->audio_configured = false; in hdmi_audio_shutdown()
523 hd->audio_playing = false; in hdmi_audio_shutdown()
524 mutex_unlock(&hd->lock); in hdmi_audio_shutdown()
534 spin_lock_irqsave(&hd->audio_playing_lock, flags); in hdmi_audio_start()
536 if (hd->display_enabled) { in hdmi_audio_start()
537 if (!hdmi_mode_has_audio(&hd->cfg)) in hdmi_audio_start()
542 hd->audio_playing = true; in hdmi_audio_start()
544 spin_unlock_irqrestore(&hd->audio_playing_lock, flags); in hdmi_audio_start()
553 if (!hdmi_mode_has_audio(&hd->cfg)) in hdmi_audio_stop()
556 spin_lock_irqsave(&hd->audio_playing_lock, flags); in hdmi_audio_stop()
558 if (hd->display_enabled) in hdmi_audio_stop()
560 hd->audio_playing = false; in hdmi_audio_stop()
562 spin_unlock_irqrestore(&hd->audio_playing_lock, flags); in hdmi_audio_stop()
571 mutex_lock(&hd->lock); in hdmi_audio_config()
573 if (hd->display_enabled) { in hdmi_audio_config()
574 ret = hdmi5_audio_config(&hd->core, &hd->wp, dss_audio, in hdmi_audio_config()
575 hd->cfg.vm.pixelclock); in hdmi_audio_config()
580 hd->audio_configured = true; in hdmi_audio_config()
581 hd->audio_config = *dss_audio; in hdmi_audio_config()
583 mutex_unlock(&hd->lock); in hdmi_audio_config()
599 .dev = &hdmi->pdev->dev, in hdmi_audio_register()
601 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp), in hdmi_audio_register()
605 hdmi->audio_pdev = platform_device_register_data( in hdmi_audio_register()
606 &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, in hdmi_audio_register()
609 if (IS_ERR(hdmi->audio_pdev)) in hdmi_audio_register()
610 return PTR_ERR(hdmi->audio_pdev); in hdmi_audio_register()
613 hdmi->wp_idlemode = in hdmi_audio_register()
614 REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2); in hdmi_audio_register()
620 /* -----------------------------------------------------------------------------
624 static int hdmi5_bind(struct device *dev, struct device *master, void *data) in hdmi5_bind() argument
626 struct dss_device *dss = dss_get_device(master); in hdmi5_bind()
630 hdmi->dss = dss; in hdmi5_bind()
632 r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp); in hdmi5_bind()
642 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs, in hdmi5_bind()
648 hdmi_pll_uninit(&hdmi->pll); in hdmi5_bind()
652 static void hdmi5_unbind(struct device *dev, struct device *master, void *data) in hdmi5_unbind() argument
656 dss_debugfs_remove_file(hdmi->debugfs); in hdmi5_unbind()
658 if (hdmi->audio_pdev) in hdmi5_unbind()
659 platform_device_unregister(hdmi->audio_pdev); in hdmi5_unbind()
661 hdmi_pll_uninit(&hdmi->pll); in hdmi5_unbind()
669 /* -----------------------------------------------------------------------------
675 struct omap_dss_device *out = &hdmi->output; in hdmi5_init_output()
680 out->dev = &hdmi->pdev->dev; in hdmi5_init_output()
681 out->id = OMAP_DSS_OUTPUT_HDMI; in hdmi5_init_output()
682 out->type = OMAP_DISPLAY_TYPE_HDMI; in hdmi5_init_output()
683 out->name = "hdmi.0"; in hdmi5_init_output()
684 out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT; in hdmi5_init_output()
685 out->of_port = 0; in hdmi5_init_output()
687 r = omapdss_device_init_output(out, &hdmi->bridge); in hdmi5_init_output()
700 struct omap_dss_device *out = &hdmi->output; in hdmi5_uninit_output()
710 struct platform_device *pdev = hdmi->pdev; in hdmi5_probe_of()
711 struct device_node *node = pdev->dev.of_node; in hdmi5_probe_of()
719 r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy); in hdmi5_probe_of()
732 return -ENOMEM; in hdmi5_probe()
734 hdmi->pdev = pdev; in hdmi5_probe()
736 dev_set_drvdata(&pdev->dev, hdmi); in hdmi5_probe()
738 mutex_init(&hdmi->lock); in hdmi5_probe()
739 spin_lock_init(&hdmi->audio_playing_lock); in hdmi5_probe()
745 r = hdmi_wp_init(pdev, &hdmi->wp, 5); in hdmi5_probe()
749 r = hdmi_phy_init(pdev, &hdmi->phy, 5); in hdmi5_probe()
753 r = hdmi5_core_init(pdev, &hdmi->core); in hdmi5_probe()
760 r = -ENODEV; in hdmi5_probe()
764 r = devm_request_threaded_irq(&pdev->dev, irq, in hdmi5_probe()
772 hdmi->vdda_reg = devm_regulator_get(&pdev->dev, "vdda"); in hdmi5_probe()
773 if (IS_ERR(hdmi->vdda_reg)) { in hdmi5_probe()
774 r = PTR_ERR(hdmi->vdda_reg); in hdmi5_probe()
775 if (r != -EPROBE_DEFER) in hdmi5_probe()
780 pm_runtime_enable(&pdev->dev); in hdmi5_probe()
786 r = component_add(&pdev->dev, &hdmi5_component_ops); in hdmi5_probe()
795 pm_runtime_disable(&pdev->dev); in hdmi5_probe()
805 component_del(&pdev->dev, &hdmi5_component_ops); in hdmi5_remove()
809 pm_runtime_disable(&pdev->dev); in hdmi5_remove()
815 { .compatible = "ti,omap5-hdmi", },
816 { .compatible = "ti,dra7-hdmi", },