Lines Matching +full:spdif +full:- +full:mclk

1 // SPDX-License-Identifier: GPL-2.0-only
4 * ALSA SoC Audio Layer - Rockchip I2S Controller driver
7 * Author: Jianqun <jay.xu@rock-chips.com>
36 struct clk *mclk; member
45 { .compatible = "rockchip,rk3066-spdif",
47 { .compatible = "rockchip,rk3188-spdif",
49 { .compatible = "rockchip,rk3228-spdif",
51 { .compatible = "rockchip,rk3288-spdif",
53 { .compatible = "rockchip,rk3328-spdif",
55 { .compatible = "rockchip,rk3366-spdif",
57 { .compatible = "rockchip,rk3368-spdif",
59 { .compatible = "rockchip,rk3399-spdif",
61 { .compatible = "rockchip,rk3568-spdif",
69 struct rk_spdif_dev *spdif = dev_get_drvdata(dev); in rk_spdif_runtime_suspend() local
71 regcache_cache_only(spdif->regmap, true); in rk_spdif_runtime_suspend()
72 clk_disable_unprepare(spdif->mclk); in rk_spdif_runtime_suspend()
73 clk_disable_unprepare(spdif->hclk); in rk_spdif_runtime_suspend()
80 struct rk_spdif_dev *spdif = dev_get_drvdata(dev); in rk_spdif_runtime_resume() local
83 ret = clk_prepare_enable(spdif->mclk); in rk_spdif_runtime_resume()
85 dev_err(spdif->dev, "mclk clock enable failed %d\n", ret); in rk_spdif_runtime_resume()
89 ret = clk_prepare_enable(spdif->hclk); in rk_spdif_runtime_resume()
91 clk_disable_unprepare(spdif->mclk); in rk_spdif_runtime_resume()
92 dev_err(spdif->dev, "hclk clock enable failed %d\n", ret); in rk_spdif_runtime_resume()
96 regcache_cache_only(spdif->regmap, false); in rk_spdif_runtime_resume()
97 regcache_mark_dirty(spdif->regmap); in rk_spdif_runtime_resume()
99 ret = regcache_sync(spdif->regmap); in rk_spdif_runtime_resume()
101 clk_disable_unprepare(spdif->mclk); in rk_spdif_runtime_resume()
102 clk_disable_unprepare(spdif->hclk); in rk_spdif_runtime_resume()
112 struct rk_spdif_dev *spdif = snd_soc_dai_get_drvdata(dai); in rk_spdif_hw_params() local
114 int srate, mclk; in rk_spdif_hw_params() local
118 mclk = srate * 128; in rk_spdif_hw_params()
131 return -EINVAL; in rk_spdif_hw_params()
135 ret = clk_set_rate(spdif->mclk, mclk); in rk_spdif_hw_params()
137 dev_err(spdif->dev, "Failed to set module clock rate: %d\n", in rk_spdif_hw_params()
142 ret = regmap_update_bits(spdif->regmap, SPDIF_CFGR, in rk_spdif_hw_params()
153 struct rk_spdif_dev *spdif = snd_soc_dai_get_drvdata(dai); in rk_spdif_trigger() local
160 ret = regmap_update_bits(spdif->regmap, SPDIF_DMACR, in rk_spdif_trigger()
169 ret = regmap_update_bits(spdif->regmap, SPDIF_XFER, in rk_spdif_trigger()
176 ret = regmap_update_bits(spdif->regmap, SPDIF_DMACR, in rk_spdif_trigger()
183 ret = regmap_update_bits(spdif->regmap, SPDIF_XFER, in rk_spdif_trigger()
188 ret = -EINVAL; in rk_spdif_trigger()
197 struct rk_spdif_dev *spdif = snd_soc_dai_get_drvdata(dai); in rk_spdif_dai_probe() local
199 snd_soc_dai_dma_data_set_playback(dai, &spdif->playback_dma_data); in rk_spdif_dai_probe()
228 .name = "rockchip-spdif",
286 struct device_node *np = pdev->dev.of_node; in rk_spdif_probe()
287 struct rk_spdif_dev *spdif; in rk_spdif_probe() local
294 if (match->data == (void *)RK_SPDIF_RK3288) { in rk_spdif_probe()
299 dev_err(&pdev->dev, in rk_spdif_probe()
304 /* Select the 8 channel SPDIF solution on RK3288 as in rk_spdif_probe()
310 spdif = devm_kzalloc(&pdev->dev, sizeof(*spdif), GFP_KERNEL); in rk_spdif_probe()
311 if (!spdif) in rk_spdif_probe()
312 return -ENOMEM; in rk_spdif_probe()
314 spdif->hclk = devm_clk_get(&pdev->dev, "hclk"); in rk_spdif_probe()
315 if (IS_ERR(spdif->hclk)) in rk_spdif_probe()
316 return PTR_ERR(spdif->hclk); in rk_spdif_probe()
318 spdif->mclk = devm_clk_get(&pdev->dev, "mclk"); in rk_spdif_probe()
319 if (IS_ERR(spdif->mclk)) in rk_spdif_probe()
320 return PTR_ERR(spdif->mclk); in rk_spdif_probe()
326 spdif->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "hclk", regs, in rk_spdif_probe()
328 if (IS_ERR(spdif->regmap)) in rk_spdif_probe()
329 return PTR_ERR(spdif->regmap); in rk_spdif_probe()
331 spdif->playback_dma_data.addr = res->start + SPDIF_SMPDR; in rk_spdif_probe()
332 spdif->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in rk_spdif_probe()
333 spdif->playback_dma_data.maxburst = 4; in rk_spdif_probe()
335 spdif->dev = &pdev->dev; in rk_spdif_probe()
336 dev_set_drvdata(&pdev->dev, spdif); in rk_spdif_probe()
338 pm_runtime_enable(&pdev->dev); in rk_spdif_probe()
339 if (!pm_runtime_enabled(&pdev->dev)) { in rk_spdif_probe()
340 ret = rk_spdif_runtime_resume(&pdev->dev); in rk_spdif_probe()
345 ret = devm_snd_soc_register_component(&pdev->dev, in rk_spdif_probe()
349 dev_err(&pdev->dev, "Could not register DAI\n"); in rk_spdif_probe()
353 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); in rk_spdif_probe()
355 dev_err(&pdev->dev, "Could not register PCM\n"); in rk_spdif_probe()
362 if (!pm_runtime_status_suspended(&pdev->dev)) in rk_spdif_probe()
363 rk_spdif_runtime_suspend(&pdev->dev); in rk_spdif_probe()
365 pm_runtime_disable(&pdev->dev); in rk_spdif_probe()
372 pm_runtime_disable(&pdev->dev); in rk_spdif_remove()
373 if (!pm_runtime_status_suspended(&pdev->dev)) in rk_spdif_remove()
374 rk_spdif_runtime_suspend(&pdev->dev); in rk_spdif_remove()
386 .name = "rockchip-spdif",
393 MODULE_ALIAS("platform:rockchip-spdif");
394 MODULE_DESCRIPTION("ROCKCHIP SPDIF transceiver Interface");