Lines Matching +full:tegra20 +full:- +full:spdif
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tegra20_spdif.c - Tegra20 SPDIF driver
6 * Copyright (C) 2011-2012 - NVIDIA, Inc.
25 #define DRV_NAME "tegra20-spdif"
29 struct tegra20_spdif *spdif = dev_get_drvdata(dev); in tegra20_spdif_runtime_suspend() local
31 clk_disable_unprepare(spdif->clk_spdif_out); in tegra20_spdif_runtime_suspend()
38 struct tegra20_spdif *spdif = dev_get_drvdata(dev); in tegra20_spdif_runtime_resume() local
41 ret = clk_prepare_enable(spdif->clk_spdif_out); in tegra20_spdif_runtime_resume()
54 struct device *dev = dai->dev; in tegra20_spdif_hw_params()
55 struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai); in tegra20_spdif_hw_params() local
67 return -EINVAL; in tegra20_spdif_hw_params()
70 regmap_update_bits(spdif->regmap, TEGRA20_SPDIF_CTRL, mask, val); in tegra20_spdif_hw_params()
95 return -EINVAL; in tegra20_spdif_hw_params()
98 ret = clk_set_rate(spdif->clk_spdif_out, spdifclock); in tegra20_spdif_hw_params()
100 dev_err(dev, "Can't set SPDIF clock rate: %d\n", ret); in tegra20_spdif_hw_params()
107 static void tegra20_spdif_start_playback(struct tegra20_spdif *spdif) in tegra20_spdif_start_playback() argument
109 regmap_update_bits(spdif->regmap, TEGRA20_SPDIF_CTRL, in tegra20_spdif_start_playback()
114 static void tegra20_spdif_stop_playback(struct tegra20_spdif *spdif) in tegra20_spdif_stop_playback() argument
116 regmap_update_bits(spdif->regmap, TEGRA20_SPDIF_CTRL, in tegra20_spdif_stop_playback()
123 struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai); in tegra20_spdif_trigger() local
129 tegra20_spdif_start_playback(spdif); in tegra20_spdif_trigger()
134 tegra20_spdif_stop_playback(spdif); in tegra20_spdif_trigger()
137 return -EINVAL; in tegra20_spdif_trigger()
145 struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai); in tegra20_spdif_probe() local
147 dai->capture_dma_data = NULL; in tegra20_spdif_probe()
148 dai->playback_dma_data = &spdif->playback_dma_data; in tegra20_spdif_probe()
253 struct tegra20_spdif *spdif; in tegra20_spdif_platform_probe() local
258 spdif = devm_kzalloc(&pdev->dev, sizeof(struct tegra20_spdif), in tegra20_spdif_platform_probe()
260 if (!spdif) in tegra20_spdif_platform_probe()
261 return -ENOMEM; in tegra20_spdif_platform_probe()
263 dev_set_drvdata(&pdev->dev, spdif); in tegra20_spdif_platform_probe()
265 spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out"); in tegra20_spdif_platform_probe()
266 if (IS_ERR(spdif->clk_spdif_out)) { in tegra20_spdif_platform_probe()
267 pr_err("Can't retrieve spdif clock\n"); in tegra20_spdif_platform_probe()
268 ret = PTR_ERR(spdif->clk_spdif_out); in tegra20_spdif_platform_probe()
273 regs = devm_ioremap_resource(&pdev->dev, mem); in tegra20_spdif_platform_probe()
279 dev_err(&pdev->dev, "No DMA resource\n"); in tegra20_spdif_platform_probe()
280 return -ENODEV; in tegra20_spdif_platform_probe()
283 spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs, in tegra20_spdif_platform_probe()
285 if (IS_ERR(spdif->regmap)) { in tegra20_spdif_platform_probe()
286 dev_err(&pdev->dev, "regmap init failed\n"); in tegra20_spdif_platform_probe()
287 ret = PTR_ERR(spdif->regmap); in tegra20_spdif_platform_probe()
291 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; in tegra20_spdif_platform_probe()
292 spdif->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in tegra20_spdif_platform_probe()
293 spdif->playback_dma_data.maxburst = 4; in tegra20_spdif_platform_probe()
294 spdif->playback_dma_data.slave_id = dmareq->start; in tegra20_spdif_platform_probe()
296 pm_runtime_enable(&pdev->dev); in tegra20_spdif_platform_probe()
297 if (!pm_runtime_enabled(&pdev->dev)) { in tegra20_spdif_platform_probe()
298 ret = tegra20_spdif_runtime_resume(&pdev->dev); in tegra20_spdif_platform_probe()
303 ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component, in tegra20_spdif_platform_probe()
306 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); in tegra20_spdif_platform_probe()
307 ret = -ENOMEM; in tegra20_spdif_platform_probe()
311 ret = tegra_pcm_platform_register(&pdev->dev); in tegra20_spdif_platform_probe()
313 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); in tegra20_spdif_platform_probe()
320 snd_soc_unregister_component(&pdev->dev); in tegra20_spdif_platform_probe()
322 if (!pm_runtime_status_suspended(&pdev->dev)) in tegra20_spdif_platform_probe()
323 tegra20_spdif_runtime_suspend(&pdev->dev); in tegra20_spdif_platform_probe()
325 pm_runtime_disable(&pdev->dev); in tegra20_spdif_platform_probe()
332 pm_runtime_disable(&pdev->dev); in tegra20_spdif_platform_remove()
333 if (!pm_runtime_status_suspended(&pdev->dev)) in tegra20_spdif_platform_remove()
334 tegra20_spdif_runtime_suspend(&pdev->dev); in tegra20_spdif_platform_remove()
336 tegra_pcm_platform_unregister(&pdev->dev); in tegra20_spdif_platform_remove()
337 snd_soc_unregister_component(&pdev->dev); in tegra20_spdif_platform_remove()
359 MODULE_DESCRIPTION("Tegra20 SPDIF ASoC driver");