29 #include <linux/device.h>
31 #include <linux/module.h>
36 #include <linux/slab.h>
45 #define DRV_NAME "tegra30-i2s"
47 static int tegra30_i2s_runtime_suspend(
struct device *
dev)
53 clk_disable_unprepare(i2s->
clk_i2s);
58 static int tegra30_i2s_runtime_resume(
struct device *
dev)
63 ret = clk_prepare_enable(i2s->
clk_i2s);
65 dev_err(dev,
"clk_enable failed: %d\n", ret);
77 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
104 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
118 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
166 pm_runtime_get_sync(dai->
dev);
168 pm_runtime_put(dai->
dev);
178 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
202 bitcnt = (i2sclock / (2 * srate)) - 1;
208 dev_err(dev,
"Can't set I2S clock rate: %d\n", ret);
214 if (i2sclock % (2 * srate))
242 static void tegra30_i2s_start_playback(
struct tegra30_i2s *i2s)
250 static void tegra30_i2s_stop_playback(
struct tegra30_i2s *i2s)
257 static void tegra30_i2s_start_capture(
struct tegra30_i2s *i2s)
265 static void tegra30_i2s_stop_capture(
struct tegra30_i2s *i2s)
275 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
282 tegra30_i2s_start_playback(i2s);
284 tegra30_i2s_start_capture(i2s);
290 tegra30_i2s_stop_playback(i2s);
292 tegra30_i2s_stop_capture(i2s);
301 static int tegra30_i2s_probe(
struct snd_soc_dai *dai)
303 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
314 .set_fmt = tegra30_i2s_set_fmt,
315 .hw_params = tegra30_i2s_hw_params,
316 .trigger = tegra30_i2s_trigger,
320 .probe = tegra30_i2s_probe,
322 .stream_name =
"Playback",
329 .stream_name =
"Capture",
335 .ops = &tegra30_i2s_dai_ops,
336 .symmetric_rates = 1,
339 static bool tegra30_i2s_wr_rd_reg(
struct device *dev,
unsigned int reg)
370 static bool tegra30_i2s_volatile_reg(
struct device *dev,
unsigned int reg)
383 static const struct regmap_config tegra30_i2s_regmap_config = {
388 .writeable_reg = tegra30_i2s_wr_rd_reg,
389 .readable_reg = tegra30_i2s_wr_rd_reg,
390 .volatile_reg = tegra30_i2s_volatile_reg,
404 dev_err(&pdev->
dev,
"Can't allocate tegra30_i2s\n");
410 i2s->
dai = tegra30_i2s_dai_template;
411 i2s->
dai.name = dev_name(&pdev->
dev);
414 "nvidia,ahub-cif-ids", cif_ids,
424 dev_err(&pdev->
dev,
"Can't retrieve i2s clock\n");
439 dev_err(&pdev->
dev,
"Memory region already claimed\n");
452 &tegra30_i2s_regmap_config);
453 if (IS_ERR(i2s->
regmap)) {
455 ret = PTR_ERR(i2s->
regmap);
461 if (!pm_runtime_enabled(&pdev->
dev)) {
462 ret = tegra30_i2s_runtime_resume(&pdev->
dev);
469 dev_err(&pdev->
dev,
"Could not register DAI: %d\n", ret);
476 dev_err(&pdev->
dev,
"Could not register PCM: %d\n", ret);
477 goto err_unregister_dai;
485 if (!pm_runtime_status_suspended(&pdev->
dev))
486 tegra30_i2s_runtime_suspend(&pdev->
dev);
488 pm_runtime_disable(&pdev->
dev);
499 pm_runtime_disable(&pdev->
dev);
500 if (!pm_runtime_status_suspended(&pdev->
dev))
501 tegra30_i2s_runtime_suspend(&pdev->
dev);
512 { .compatible =
"nvidia,tegra30-i2s", },
516 static const struct dev_pm_ops tegra30_i2s_pm_ops __devinitconst = {
518 tegra30_i2s_runtime_resume,
NULL)
525 .of_match_table = tegra30_i2s_of_match,
526 .pm = &tegra30_i2s_pm_ops,
528 .probe = tegra30_i2s_platform_probe,
529 .remove =
__devexit_p(tegra30_i2s_platform_remove),