32 #include <linux/device.h>
34 #include <linux/module.h>
39 #include <linux/slab.h>
47 #define DRV_NAME "tegra20-i2s"
49 static int tegra20_i2s_runtime_suspend(
struct device *
dev)
53 clk_disable_unprepare(i2s->
clk_i2s);
58 static int tegra20_i2s_runtime_resume(
struct device *
dev)
63 ret = clk_prepare_enable(i2s->
clk_i2s);
65 dev_err(dev,
"clk_enable failed: %d\n", ret);
75 struct tegra20_i2s *i2s = snd_soc_dai_get_drvdata(dai);
133 struct tegra20_i2s *i2s = snd_soc_dai_get_drvdata(dai);
167 dev_err(dev,
"Can't set I2S clock rate: %d\n", ret);
171 bitcnt = (i2sclock / (2 * srate)) - 1;
176 if (i2sclock % (2 * srate))
188 static void tegra20_i2s_start_playback(
struct tegra20_i2s *i2s)
195 static void tegra20_i2s_stop_playback(
struct tegra20_i2s *i2s)
201 static void tegra20_i2s_start_capture(
struct tegra20_i2s *i2s)
208 static void tegra20_i2s_stop_capture(
struct tegra20_i2s *i2s)
217 struct tegra20_i2s *i2s = snd_soc_dai_get_drvdata(dai);
224 tegra20_i2s_start_playback(i2s);
226 tegra20_i2s_start_capture(i2s);
232 tegra20_i2s_stop_playback(i2s);
234 tegra20_i2s_stop_capture(i2s);
243 static int tegra20_i2s_probe(
struct snd_soc_dai *dai)
245 struct tegra20_i2s *i2s = snd_soc_dai_get_drvdata(dai);
254 .set_fmt = tegra20_i2s_set_fmt,
255 .hw_params = tegra20_i2s_hw_params,
256 .trigger = tegra20_i2s_trigger,
260 .probe = tegra20_i2s_probe,
262 .stream_name =
"Playback",
269 .stream_name =
"Capture",
275 .ops = &tegra20_i2s_dai_ops,
276 .symmetric_rates = 1,
279 static bool tegra20_i2s_wr_rd_reg(
struct device *dev,
unsigned int reg)
298 static bool tegra20_i2s_volatile_reg(
struct device *dev,
unsigned int reg)
311 static bool tegra20_i2s_precious_reg(
struct device *dev,
unsigned int reg)
322 static const struct regmap_config tegra20_i2s_regmap_config = {
327 .writeable_reg = tegra20_i2s_wr_rd_reg,
328 .readable_reg = tegra20_i2s_wr_rd_reg,
329 .volatile_reg = tegra20_i2s_volatile_reg,
330 .precious_reg = tegra20_i2s_precious_reg,
345 dev_err(&pdev->
dev,
"Can't allocate tegra20_i2s\n");
351 i2s->
dai = tegra20_i2s_dai_template;
352 i2s->
dai.name = dev_name(&pdev->
dev);
356 dev_err(&pdev->
dev,
"Can't retrieve i2s clock\n");
371 "nvidia,dma-request-selector",
379 dma_ch = dmareq->
start;
385 dev_err(&pdev->
dev,
"Memory region already claimed\n");
398 &tegra20_i2s_regmap_config);
399 if (IS_ERR(i2s->
regmap)) {
401 ret = PTR_ERR(i2s->
regmap);
416 if (!pm_runtime_enabled(&pdev->
dev)) {
417 ret = tegra20_i2s_runtime_resume(&pdev->
dev);
424 dev_err(&pdev->
dev,
"Could not register DAI: %d\n", ret);
431 dev_err(&pdev->
dev,
"Could not register PCM: %d\n", ret);
432 goto err_unregister_dai;
440 if (!pm_runtime_status_suspended(&pdev->
dev))
441 tegra20_i2s_runtime_suspend(&pdev->
dev);
443 pm_runtime_disable(&pdev->
dev);
454 pm_runtime_disable(&pdev->
dev);
455 if (!pm_runtime_status_suspended(&pdev->
dev))
456 tegra20_i2s_runtime_suspend(&pdev->
dev);
467 { .compatible =
"nvidia,tegra20-i2s", },
471 static const struct dev_pm_ops tegra20_i2s_pm_ops __devinitconst = {
473 tegra20_i2s_runtime_resume,
NULL)
480 .of_match_table = tegra20_i2s_of_match,
481 .pm = &tegra20_i2s_pm_ops,
483 .probe = tegra20_i2s_platform_probe,
484 .remove =
__devexit_p(tegra20_i2s_platform_remove),