Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305602
b: refs/heads/master
c: 82ef0ae
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Warren authored and Mark Brown committed Apr 9, 2012
1 parent fa0f04b commit 769a094
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1eecb8280b038019f2f914abc01b28caf5d0a168
refs/heads/master: 82ef0ae46b8614f052cc3ee856c5624eff614063
54 changes: 47 additions & 7 deletions trunk/sound/soc/tegra/tegra20_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <sound/core.h>
Expand All @@ -56,6 +57,29 @@ static inline u32 tegra20_i2s_read(struct tegra20_i2s *i2s, u32 reg)
return __raw_readl(i2s->regs + reg);
}

static int tegra20_i2s_runtime_suspend(struct device *dev)
{
struct tegra20_i2s *i2s = dev_get_drvdata(dev);

clk_disable(i2s->clk_i2s);

return 0;
}

static int tegra20_i2s_runtime_resume(struct device *dev)
{
struct tegra20_i2s *i2s = dev_get_drvdata(dev);
int ret;

ret = clk_enable(i2s->clk_i2s);
if (ret) {
dev_err(dev, "clk_enable failed: %d\n", ret);
return ret;
}

return 0;
}

#ifdef CONFIG_DEBUG_FS
static int tegra20_i2s_show(struct seq_file *s, void *unused)
{
Expand Down Expand Up @@ -219,16 +243,12 @@ static int tegra20_i2s_hw_params(struct snd_pcm_substream *substream,
if (i2sclock % (2 * srate))
reg |= TEGRA20_I2S_TIMING_NON_SYM_ENABLE;

clk_enable(i2s->clk_i2s);

tegra20_i2s_write(i2s, TEGRA20_I2S_TIMING, reg);

tegra20_i2s_write(i2s, TEGRA20_I2S_FIFO_SCR,
TEGRA20_I2S_FIFO_SCR_FIFO2_ATN_LVL_FOUR_SLOTS |
TEGRA20_I2S_FIFO_SCR_FIFO1_ATN_LVL_FOUR_SLOTS);

clk_disable(i2s->clk_i2s);

return 0;
}

Expand Down Expand Up @@ -265,7 +285,6 @@ static int tegra20_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
case SNDRV_PCM_TRIGGER_RESUME:
clk_enable(i2s->clk_i2s);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
tegra20_i2s_start_playback(i2s);
else
Expand All @@ -278,7 +297,6 @@ static int tegra20_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
tegra20_i2s_stop_playback(i2s);
else
tegra20_i2s_stop_capture(i2s);
clk_disable(i2s->clk_i2s);
break;
default:
return -EINVAL;
Expand Down Expand Up @@ -395,11 +413,18 @@ static __devinit int tegra20_i2s_platform_probe(struct platform_device *pdev)

i2s->reg_ctrl = TEGRA20_I2S_CTRL_FIFO_FORMAT_PACKED;

pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra20_i2s_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}

ret = snd_soc_register_dai(&pdev->dev, &i2s->dai);
if (ret) {
dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
ret = -ENOMEM;
goto err_clk_put;
goto err_suspend;
}

ret = tegra_pcm_platform_register(&pdev->dev);
Expand All @@ -414,6 +439,11 @@ static __devinit int tegra20_i2s_platform_probe(struct platform_device *pdev)

err_unregister_dai:
snd_soc_unregister_dai(&pdev->dev);
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra20_i2s_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err_clk_put:
clk_put(i2s->clk_i2s);
err:
Expand All @@ -424,6 +454,10 @@ static int __devexit tegra20_i2s_platform_remove(struct platform_device *pdev)
{
struct tegra20_i2s *i2s = dev_get_drvdata(&pdev->dev);

pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
tegra20_i2s_runtime_suspend(&pdev->dev);

tegra_pcm_platform_unregister(&pdev->dev);
snd_soc_unregister_dai(&pdev->dev);

Expand All @@ -439,11 +473,17 @@ static const struct of_device_id tegra20_i2s_of_match[] __devinitconst = {
{},
};

static const struct dev_pm_ops tegra20_i2s_pm_ops __devinitconst = {
SET_RUNTIME_PM_OPS(tegra20_i2s_runtime_suspend,
tegra20_i2s_runtime_resume, NULL)
};

static struct platform_driver tegra20_i2s_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = tegra20_i2s_of_match,
.pm = &tegra20_i2s_pm_ops,
},
.probe = tegra20_i2s_platform_probe,
.remove = __devexit_p(tegra20_i2s_platform_remove),
Expand Down
50 changes: 47 additions & 3 deletions trunk/sound/soc/tegra/tegra20_spdif.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <sound/core.h>
Expand All @@ -48,6 +49,29 @@ static inline u32 tegra20_spdif_read(struct tegra20_spdif *spdif, u32 reg)
return __raw_readl(spdif->regs + reg);
}

static int tegra20_spdif_runtime_suspend(struct device *dev)
{
struct tegra20_spdif *spdif = dev_get_drvdata(dev);

clk_disable(spdif->clk_spdif_out);

return 0;
}

static int tegra20_spdif_runtime_resume(struct device *dev)
{
struct tegra20_spdif *spdif = dev_get_drvdata(dev);
int ret;

ret = clk_enable(spdif->clk_spdif_out);
if (ret) {
dev_err(dev, "clk_enable failed: %d\n", ret);
return ret;
}

return 0;
}

#ifdef CONFIG_DEBUG_FS
static int tegra20_spdif_show(struct seq_file *s, void *unused)
{
Expand Down Expand Up @@ -195,14 +219,12 @@ static int tegra20_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
case SNDRV_PCM_TRIGGER_RESUME:
clk_enable(spdif->clk_spdif_out);
tegra20_spdif_start_playback(spdif);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
case SNDRV_PCM_TRIGGER_SUSPEND:
tegra20_spdif_stop_playback(spdif);
clk_disable(spdif->clk_spdif_out);
break;
default:
return -EINVAL;
Expand Down Expand Up @@ -295,11 +317,18 @@ static __devinit int tegra20_spdif_platform_probe(struct platform_device *pdev)
spdif->playback_dma_data.width = 32;
spdif->playback_dma_data.req_sel = dmareq->start;

pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra20_spdif_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}

ret = snd_soc_register_dai(&pdev->dev, &tegra20_spdif_dai);
if (ret) {
dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
ret = -ENOMEM;
goto err_clk_put;
goto err_suspend;
}

ret = tegra_pcm_platform_register(&pdev->dev);
Expand All @@ -314,6 +343,11 @@ static __devinit int tegra20_spdif_platform_probe(struct platform_device *pdev)

err_unregister_dai:
snd_soc_unregister_dai(&pdev->dev);
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra20_spdif_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err_clk_put:
clk_put(spdif->clk_spdif_out);
err:
Expand All @@ -324,6 +358,10 @@ static int __devexit tegra20_spdif_platform_remove(struct platform_device *pdev)
{
struct tegra20_spdif *spdif = dev_get_drvdata(&pdev->dev);

pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
tegra20_spdif_runtime_suspend(&pdev->dev);

tegra_pcm_platform_unregister(&pdev->dev);
snd_soc_unregister_dai(&pdev->dev);

Expand All @@ -334,10 +372,16 @@ static int __devexit tegra20_spdif_platform_remove(struct platform_device *pdev)
return 0;
}

static const struct dev_pm_ops tegra20_spdif_pm_ops __devinitconst = {
SET_RUNTIME_PM_OPS(tegra20_spdif_runtime_suspend,
tegra20_spdif_runtime_resume, NULL)
};

static struct platform_driver tegra20_spdif_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.pm = &tegra20_spdif_pm_ops,
},
.probe = tegra20_spdif_platform_probe,
.remove = __devexit_p(tegra20_spdif_platform_remove),
Expand Down

0 comments on commit 769a094

Please sign in to comment.