24 #include <linux/device.h>
26 #include <linux/module.h>
30 #include <linux/slab.h>
38 #define DRV_NAME "tegra20-spdif"
40 static int tegra20_spdif_runtime_suspend(
struct device *
dev)
49 static int tegra20_spdif_runtime_resume(
struct device *
dev)
56 dev_err(dev,
"clk_enable failed: %d\n", ret);
96 spdifclock = 11289600;
99 spdifclock = 12288000;
102 spdifclock = 22579200;
105 spdifclock = 24576000;
113 dev_err(dev,
"Can't set SPDIF clock rate: %d\n", ret);
120 static void tegra20_spdif_start_playback(
struct tegra20_spdif *spdif)
127 static void tegra20_spdif_stop_playback(
struct tegra20_spdif *spdif)
142 tegra20_spdif_start_playback(spdif);
147 tegra20_spdif_stop_playback(spdif);
156 static int tegra20_spdif_probe(
struct snd_soc_dai *dai)
167 .hw_params = tegra20_spdif_hw_params,
168 .trigger = tegra20_spdif_trigger,
173 .probe = tegra20_spdif_probe,
175 .stream_name =
"Playback",
182 .ops = &tegra20_spdif_dai_ops,
185 static bool tegra20_spdif_wr_rd_reg(
struct device *dev,
unsigned int reg)
214 static bool tegra20_spdif_volatile_reg(
struct device *dev,
unsigned int reg)
235 static bool tegra20_spdif_precious_reg(
struct device *dev,
unsigned int reg)
248 static const struct regmap_config tegra20_spdif_regmap_config = {
253 .writeable_reg = tegra20_spdif_wr_rd_reg,
254 .readable_reg = tegra20_spdif_wr_rd_reg,
255 .volatile_reg = tegra20_spdif_volatile_reg,
256 .precious_reg = tegra20_spdif_precious_reg,
270 dev_err(&pdev->
dev,
"Can't allocate tegra20_spdif\n");
278 pr_err(
"Can't retrieve spdif clock\n");
300 dev_err(&pdev->
dev,
"Memory region already claimed\n");
313 &tegra20_spdif_regmap_config);
314 if (IS_ERR(spdif->
regmap)) {
316 ret = PTR_ERR(spdif->
regmap);
326 if (!pm_runtime_enabled(&pdev->
dev)) {
327 ret = tegra20_spdif_runtime_resume(&pdev->
dev);
334 dev_err(&pdev->
dev,
"Could not register DAI: %d\n", ret);
341 dev_err(&pdev->
dev,
"Could not register PCM: %d\n", ret);
342 goto err_unregister_dai;
350 if (!pm_runtime_status_suspended(&pdev->
dev))
351 tegra20_spdif_runtime_suspend(&pdev->
dev);
353 pm_runtime_disable(&pdev->
dev);
364 pm_runtime_disable(&pdev->
dev);
365 if (!pm_runtime_status_suspended(&pdev->
dev))
366 tegra20_spdif_runtime_suspend(&pdev->
dev);
378 tegra20_spdif_runtime_resume,
NULL)
385 .pm = &tegra20_spdif_pm_ops,
387 .probe = tegra20_spdif_platform_probe,
388 .remove =
__devexit_p(tegra20_spdif_platform_remove),