diff options
author | Hebbar, Gururaja <gururaja.hebbar@ti.com> | 2012-08-08 11:10:32 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-09 09:06:10 -0400 |
commit | 10884347f18842aa9b8ae18ebb16272d9b7fafa2 (patch) | |
tree | 5c76a175a657756ecdf7ad79a282f30dfa354a23 /sound/soc/davinci | |
parent | 8f245499791a4701bfe1ce9b0df90cea9d2f13e5 (diff) |
ASoC: McASP: Convert driver to use Runtime PM API
* Add Runtime PM support to McASP host controller.
* Use Runtime PM API to enable/disable McASP clock.
This was tested on AM18x Board using suspend/resume
Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.c | 40 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.h | 3 |
2 files changed, 20 insertions, 23 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 95441bfc8190..d919fb8de7a3 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/clk.h> | 24 | #include <linux/pm_runtime.h> |
25 | 25 | ||
26 | #include <sound/core.h> | 26 | #include <sound/core.h> |
27 | #include <sound/pcm.h> | 27 | #include <sound/pcm.h> |
@@ -776,20 +776,17 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, | |||
776 | case SNDRV_PCM_TRIGGER_RESUME: | 776 | case SNDRV_PCM_TRIGGER_RESUME: |
777 | case SNDRV_PCM_TRIGGER_START: | 777 | case SNDRV_PCM_TRIGGER_START: |
778 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 778 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
779 | if (!dev->clk_active) { | 779 | ret = pm_runtime_get_sync(dev->dev); |
780 | clk_enable(dev->clk); | 780 | if (IS_ERR_VALUE(ret)) |
781 | dev->clk_active = 1; | 781 | dev_err(dev->dev, "pm_runtime_get_sync() failed\n"); |
782 | } | ||
783 | davinci_mcasp_start(dev, substream->stream); | 782 | davinci_mcasp_start(dev, substream->stream); |
784 | break; | 783 | break; |
785 | 784 | ||
786 | case SNDRV_PCM_TRIGGER_SUSPEND: | 785 | case SNDRV_PCM_TRIGGER_SUSPEND: |
787 | davinci_mcasp_stop(dev, substream->stream); | 786 | davinci_mcasp_stop(dev, substream->stream); |
788 | if (dev->clk_active) { | 787 | ret = pm_runtime_put_sync(dev->dev); |
789 | clk_disable(dev->clk); | 788 | if (IS_ERR_VALUE(ret)) |
790 | dev->clk_active = 0; | 789 | dev_err(dev->dev, "pm_runtime_put_sync() failed\n"); |
791 | } | ||
792 | |||
793 | break; | 790 | break; |
794 | 791 | ||
795 | case SNDRV_PCM_TRIGGER_STOP: | 792 | case SNDRV_PCM_TRIGGER_STOP: |
@@ -886,12 +883,13 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
886 | } | 883 | } |
887 | 884 | ||
888 | pdata = pdev->dev.platform_data; | 885 | pdata = pdev->dev.platform_data; |
889 | dev->clk = clk_get(&pdev->dev, NULL); | 886 | pm_runtime_enable(&pdev->dev); |
890 | if (IS_ERR(dev->clk)) | ||
891 | return -ENODEV; | ||
892 | 887 | ||
893 | clk_enable(dev->clk); | 888 | ret = pm_runtime_get_sync(&pdev->dev); |
894 | dev->clk_active = 1; | 889 | if (IS_ERR_VALUE(ret)) { |
890 | dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n"); | ||
891 | return ret; | ||
892 | } | ||
895 | 893 | ||
896 | dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); | 894 | dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); |
897 | if (!dev->base) { | 895 | if (!dev->base) { |
@@ -908,6 +906,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
908 | dev->version = pdata->version; | 906 | dev->version = pdata->version; |
909 | dev->txnumevt = pdata->txnumevt; | 907 | dev->txnumevt = pdata->txnumevt; |
910 | dev->rxnumevt = pdata->rxnumevt; | 908 | dev->rxnumevt = pdata->rxnumevt; |
909 | dev->dev = &pdev->dev; | ||
911 | 910 | ||
912 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; | 911 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; |
913 | dma_data->asp_chan_q = pdata->asp_chan_q; | 912 | dma_data->asp_chan_q = pdata->asp_chan_q; |
@@ -949,19 +948,18 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
949 | return 0; | 948 | return 0; |
950 | 949 | ||
951 | err_release_clk: | 950 | err_release_clk: |
952 | clk_disable(dev->clk); | 951 | pm_runtime_put_sync(&pdev->dev); |
953 | clk_put(dev->clk); | 952 | pm_runtime_disable(&pdev->dev); |
954 | return ret; | 953 | return ret; |
955 | } | 954 | } |
956 | 955 | ||
957 | static int davinci_mcasp_remove(struct platform_device *pdev) | 956 | static int davinci_mcasp_remove(struct platform_device *pdev) |
958 | { | 957 | { |
959 | struct davinci_audio_dev *dev = dev_get_drvdata(&pdev->dev); | ||
960 | 958 | ||
961 | snd_soc_unregister_dai(&pdev->dev); | 959 | snd_soc_unregister_dai(&pdev->dev); |
962 | clk_disable(dev->clk); | 960 | |
963 | clk_put(dev->clk); | 961 | pm_runtime_put_sync(&pdev->dev); |
964 | dev->clk = NULL; | 962 | pm_runtime_disable(&pdev->dev); |
965 | 963 | ||
966 | return 0; | 964 | return 0; |
967 | } | 965 | } |
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index 4681acc63606..51479f9ee909 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h | |||
@@ -40,9 +40,8 @@ struct davinci_audio_dev { | |||
40 | struct davinci_pcm_dma_params dma_params[2]; | 40 | struct davinci_pcm_dma_params dma_params[2]; |
41 | void __iomem *base; | 41 | void __iomem *base; |
42 | int sample_rate; | 42 | int sample_rate; |
43 | struct clk *clk; | 43 | struct device *dev; |
44 | unsigned int codec_fmt; | 44 | unsigned int codec_fmt; |
45 | u8 clk_active; | ||
46 | 45 | ||
47 | /* McASP specific data */ | 46 | /* McASP specific data */ |
48 | int tdm_slots; | 47 | int tdm_slots; |