aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSongjun Wu <songjun.wu@atmel.com>2016-03-02 06:15:25 -0500
committerMark Brown <broonie@kernel.org>2016-03-02 09:43:11 -0500
commitc706f2e55f04d25d212e34186521a38e8a6e459e (patch)
treecd79582d64aa18ea89da3950781eb68b5abc8e77
parent92e963f50fc74041b5e9e744c330dca48e04f08d (diff)
ASoC: atmel_ssc_dai: distinguish the different SSC
Cpu_dai id always equals 0, can't distinguish the different SSC. Use platform_device id to record and distinguish the different SSC. Signed-off-by: Songjun Wu <songjun.wu@atmel.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/misc/atmel-ssc.c1
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c27
2 files changed, 19 insertions, 9 deletions
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index e11a0bd6c66e..0516ecda54d3 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -34,6 +34,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
34 if (ssc->pdev->dev.of_node) { 34 if (ssc->pdev->dev.of_node) {
35 if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc") 35 if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
36 == ssc_num) { 36 == ssc_num) {
37 ssc->pdev->id = ssc_num;
37 ssc_valid = 1; 38 ssc_valid = 1;
38 break; 39 break;
39 } 40 }
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index ba8def5665c4..276897033639 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -285,7 +285,8 @@ static int atmel_ssc_hw_rule_rate(struct snd_pcm_hw_params *params,
285static int atmel_ssc_startup(struct snd_pcm_substream *substream, 285static int atmel_ssc_startup(struct snd_pcm_substream *substream,
286 struct snd_soc_dai *dai) 286 struct snd_soc_dai *dai)
287{ 287{
288 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 288 struct platform_device *pdev = to_platform_device(dai->dev);
289 struct atmel_ssc_info *ssc_p = &ssc_info[pdev->id];
289 struct atmel_pcm_dma_params *dma_params; 290 struct atmel_pcm_dma_params *dma_params;
290 int dir, dir_mask; 291 int dir, dir_mask;
291 int ret; 292 int ret;
@@ -346,7 +347,8 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
346static void atmel_ssc_shutdown(struct snd_pcm_substream *substream, 347static void atmel_ssc_shutdown(struct snd_pcm_substream *substream,
347 struct snd_soc_dai *dai) 348 struct snd_soc_dai *dai)
348{ 349{
349 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 350 struct platform_device *pdev = to_platform_device(dai->dev);
351 struct atmel_ssc_info *ssc_p = &ssc_info[pdev->id];
350 struct atmel_pcm_dma_params *dma_params; 352 struct atmel_pcm_dma_params *dma_params;
351 int dir, dir_mask; 353 int dir, dir_mask;
352 354
@@ -392,7 +394,8 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream,
392static int atmel_ssc_set_dai_fmt(struct snd_soc_dai *cpu_dai, 394static int atmel_ssc_set_dai_fmt(struct snd_soc_dai *cpu_dai,
393 unsigned int fmt) 395 unsigned int fmt)
394{ 396{
395 struct atmel_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; 397 struct platform_device *pdev = to_platform_device(cpu_dai->dev);
398 struct atmel_ssc_info *ssc_p = &ssc_info[pdev->id];
396 399
397 ssc_p->daifmt = fmt; 400 ssc_p->daifmt = fmt;
398 return 0; 401 return 0;
@@ -404,7 +407,8 @@ static int atmel_ssc_set_dai_fmt(struct snd_soc_dai *cpu_dai,
404static int atmel_ssc_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, 407static int atmel_ssc_set_dai_clkdiv(struct snd_soc_dai *cpu_dai,
405 int div_id, int div) 408 int div_id, int div)
406{ 409{
407 struct atmel_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; 410 struct platform_device *pdev = to_platform_device(cpu_dai->dev);
411 struct atmel_ssc_info *ssc_p = &ssc_info[pdev->id];
408 412
409 switch (div_id) { 413 switch (div_id) {
410 case ATMEL_SSC_CMR_DIV: 414 case ATMEL_SSC_CMR_DIV:
@@ -445,7 +449,8 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
445 struct snd_pcm_hw_params *params, 449 struct snd_pcm_hw_params *params,
446 struct snd_soc_dai *dai) 450 struct snd_soc_dai *dai)
447{ 451{
448 int id = dai->id; 452 struct platform_device *pdev = to_platform_device(dai->dev);
453 int id = pdev->id;
449 struct atmel_ssc_info *ssc_p = &ssc_info[id]; 454 struct atmel_ssc_info *ssc_p = &ssc_info[id];
450 struct ssc_device *ssc = ssc_p->ssc; 455 struct ssc_device *ssc = ssc_p->ssc;
451 struct atmel_pcm_dma_params *dma_params; 456 struct atmel_pcm_dma_params *dma_params;
@@ -772,7 +777,8 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
772static int atmel_ssc_prepare(struct snd_pcm_substream *substream, 777static int atmel_ssc_prepare(struct snd_pcm_substream *substream,
773 struct snd_soc_dai *dai) 778 struct snd_soc_dai *dai)
774{ 779{
775 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 780 struct platform_device *pdev = to_platform_device(dai->dev);
781 struct atmel_ssc_info *ssc_p = &ssc_info[pdev->id];
776 struct atmel_pcm_dma_params *dma_params; 782 struct atmel_pcm_dma_params *dma_params;
777 int dir; 783 int dir;
778 784
@@ -795,7 +801,8 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream,
795static int atmel_ssc_trigger(struct snd_pcm_substream *substream, 801static int atmel_ssc_trigger(struct snd_pcm_substream *substream,
796 int cmd, struct snd_soc_dai *dai) 802 int cmd, struct snd_soc_dai *dai)
797{ 803{
798 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 804 struct platform_device *pdev = to_platform_device(dai->dev);
805 struct atmel_ssc_info *ssc_p = &ssc_info[pdev->id];
799 struct atmel_pcm_dma_params *dma_params; 806 struct atmel_pcm_dma_params *dma_params;
800 int dir; 807 int dir;
801 808
@@ -824,11 +831,12 @@ static int atmel_ssc_trigger(struct snd_pcm_substream *substream,
824static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) 831static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai)
825{ 832{
826 struct atmel_ssc_info *ssc_p; 833 struct atmel_ssc_info *ssc_p;
834 struct platform_device *pdev = to_platform_device(cpu_dai->dev);
827 835
828 if (!cpu_dai->active) 836 if (!cpu_dai->active)
829 return 0; 837 return 0;
830 838
831 ssc_p = &ssc_info[cpu_dai->id]; 839 ssc_p = &ssc_info[pdev->id];
832 840
833 /* Save the status register before disabling transmit and receive */ 841 /* Save the status register before disabling transmit and receive */
834 ssc_p->ssc_state.ssc_sr = ssc_readl(ssc_p->ssc->regs, SR); 842 ssc_p->ssc_state.ssc_sr = ssc_readl(ssc_p->ssc->regs, SR);
@@ -852,12 +860,13 @@ static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai)
852static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai) 860static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai)
853{ 861{
854 struct atmel_ssc_info *ssc_p; 862 struct atmel_ssc_info *ssc_p;
863 struct platform_device *pdev = to_platform_device(cpu_dai->dev);
855 u32 cr; 864 u32 cr;
856 865
857 if (!cpu_dai->active) 866 if (!cpu_dai->active)
858 return 0; 867 return 0;
859 868
860 ssc_p = &ssc_info[cpu_dai->id]; 869 ssc_p = &ssc_info[pdev->id];
861 870
862 /* restore SSC register settings */ 871 /* restore SSC register settings */
863 ssc_writel(ssc_p->ssc->regs, TFMR, ssc_p->ssc_state.ssc_tfmr); 872 ssc_writel(ssc_p->ssc->regs, TFMR, ssc_p->ssc_state.ssc_tfmr);