ASoC: DaVinci: Update suspend/resume support for McASP driver
authorChaithrika U S <chaithrika@ti.com>
Thu, 3 Dec 2009 13:26:56 +0000 (18:56 +0530)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 4 Dec 2009 10:49:45 +0000 (10:49 +0000)
Add clock enable and disable calls to resume and suspend respectively.
Also add a member to the audio device data structure which tracks the clock
status.

Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches[1] which
add suspend-to-RAM support to DA850/OMAP-L138 SoC were applied.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

Signed-off-by: Chaithrika U S <chaithrika@ti.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/davinci/davinci-mcasp.c
sound/soc/davinci/davinci-mcasp.h
sound/soc/davinci/davinci-pcm.c

index 0a302e1..a613bbb 100644 (file)
@@ -767,14 +767,27 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
        int ret = 0;
 
        switch (cmd) {
-       case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
+               if (!dev->clk_active) {
+                       clk_enable(dev->clk);
+                       dev->clk_active = 1;
+               }
+               /* Fall through */
+       case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                davinci_mcasp_start(dev, substream->stream);
                break;
 
-       case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
+               davinci_mcasp_stop(dev, substream->stream);
+               if (dev->clk_active) {
+                       clk_disable(dev->clk);
+                       dev->clk_active = 0;
+               }
+
+               break;
+
+       case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                davinci_mcasp_stop(dev, substream->stream);
                break;
@@ -866,6 +879,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        }
 
        clk_enable(dev->clk);
+       dev->clk_active = 1;
 
        dev->base = (void __iomem *)IO_ADDRESS(mem->start);
        dev->op_mode = pdata->op_mode;
index 582c924..e755b51 100644 (file)
@@ -44,6 +44,7 @@ struct davinci_audio_dev {
        int sample_rate;
        struct clk *clk;
        unsigned int codec_fmt;
+       u8 clk_active;
 
        /* McASP specific data */
        int     tdm_slots;
index ad4d7f4..80c7fdf 100644 (file)
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
        .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
                 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-                SNDRV_PCM_INFO_PAUSE),
+                SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
        .formats = (SNDRV_PCM_FMTBIT_S16_LE),
        .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
                  SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |