aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJassi Brar <jassi.brar@samsung.com>2010-04-27 02:57:05 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-05-05 10:15:14 -0400
commit8a7c251871eff512fb380ea0e86c77ed901520fe (patch)
treee62703ddd593a38045ce5af8eb45dd2ca9d9faed /sound
parent9e991a4bf3290b0787d33fa72144f6eec656f20d (diff)
ASoC: S3C: I2S: Move set_sysclk to common code
Now that we can specify feature of a particular controller, we can avoid multiple copies of same code by defining the CDCLKCON bit feature in controller specific code and detecting that flag in the code common to all controllers. Signed-off-by: Jassi Brar <jassi.brar@samsung.com> Acked-by: Ben Dooks <ben-linux@fluff.org> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/s3c24xx/s3c-i2s-v2.c47
-rw-r--r--sound/soc/s3c24xx/s3c2412-i2s.c27
-rw-r--r--sound/soc/s3c24xx/s3c64xx-i2s.c43
3 files changed, 50 insertions, 67 deletions
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c
index ac153ca9c628..13311c8cf965 100644
--- a/sound/soc/s3c24xx/s3c-i2s-v2.c
+++ b/sound/soc/s3c24xx/s3c-i2s-v2.c
@@ -342,6 +342,52 @@ static int s3c_i2sv2_hw_params(struct snd_pcm_substream *substream,
342 342
343 writel(iismod, i2s->regs + S3C2412_IISMOD); 343 writel(iismod, i2s->regs + S3C2412_IISMOD);
344 pr_debug("%s: w: IISMOD: %x\n", __func__, iismod); 344 pr_debug("%s: w: IISMOD: %x\n", __func__, iismod);
345
346 return 0;
347}
348
349static int s3c_i2sv2_set_sysclk(struct snd_soc_dai *cpu_dai,
350 int clk_id, unsigned int freq, int dir)
351{
352 struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
353 u32 iismod = readl(i2s->regs + S3C2412_IISMOD);
354
355 pr_debug("Entered %s\n", __func__);
356 pr_debug("%s r: IISMOD: %x\n", __func__, iismod);
357
358 switch (clk_id) {
359 case S3C_I2SV2_CLKSRC_PCLK:
360 iismod &= ~S3C2412_IISMOD_IMS_SYSMUX;
361 break;
362
363 case S3C_I2SV2_CLKSRC_AUDIOBUS:
364 iismod |= S3C2412_IISMOD_IMS_SYSMUX;
365 break;
366
367 case S3C_I2SV2_CLKSRC_CDCLK:
368 /* Error if controller doesn't have the CDCLKCON bit */
369 if (!(i2s->feature & S3C_FEATURE_CDCLKCON))
370 return -EINVAL;
371
372 switch (dir) {
373 case SND_SOC_CLOCK_IN:
374 iismod |= S3C64XX_IISMOD_CDCLKCON;
375 break;
376 case SND_SOC_CLOCK_OUT:
377 iismod &= ~S3C64XX_IISMOD_CDCLKCON;
378 break;
379 default:
380 return -EINVAL;
381 }
382 break;
383
384 default:
385 return -EINVAL;
386 }
387
388 writel(iismod, i2s->regs + S3C2412_IISMOD);
389 pr_debug("%s w: IISMOD: %x\n", __func__, iismod);
390
345 return 0; 391 return 0;
346} 392}
347 393
@@ -714,6 +760,7 @@ int s3c_i2sv2_register_dai(struct snd_soc_dai *dai)
714 ops->hw_params = s3c_i2sv2_hw_params; 760 ops->hw_params = s3c_i2sv2_hw_params;
715 ops->set_fmt = s3c2412_i2s_set_fmt; 761 ops->set_fmt = s3c2412_i2s_set_fmt;
716 ops->set_clkdiv = s3c2412_i2s_set_clkdiv; 762 ops->set_clkdiv = s3c2412_i2s_set_clkdiv;
763 ops->set_sysclk = s3c_i2sv2_set_sysclk;
717 764
718 /* Allow overriding by (for example) IISv4 */ 765 /* Allow overriding by (for example) IISv4 */
719 if (!ops->delay) 766 if (!ops->delay)
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c
index 6b884d75235e..709adef9d043 100644
--- a/sound/soc/s3c24xx/s3c2412-i2s.c
+++ b/sound/soc/s3c24xx/s3c2412-i2s.c
@@ -65,32 +65,6 @@ static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = {
65 65
66static struct s3c_i2sv2_info s3c2412_i2s; 66static struct s3c_i2sv2_info s3c2412_i2s;
67 67
68/*
69 * Set S3C2412 Clock source
70 */
71static int s3c2412_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
72 int clk_id, unsigned int freq, int dir)
73{
74 u32 iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD);
75
76 pr_debug("%s(%p, %d, %u, %d)\n", __func__, cpu_dai, clk_id,
77 freq, dir);
78
79 switch (clk_id) {
80 case S3C2412_CLKSRC_PCLK:
81 iismod &= ~S3C2412_IISMOD_IMS_SYSMUX;
82 break;
83 case S3C2412_CLKSRC_I2SCLK:
84 iismod |= S3C2412_IISMOD_IMS_SYSMUX;
85 break;
86 default:
87 return -EINVAL;
88 }
89
90 writel(iismod, s3c2412_i2s.regs + S3C2412_IISMOD);
91 return 0;
92}
93
94static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) 68static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
95{ 69{
96 return cpu_dai->private_data; 70 return cpu_dai->private_data;
@@ -175,7 +149,6 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream,
175 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 149 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
176 150
177static struct snd_soc_dai_ops s3c2412_i2s_dai_ops = { 151static struct snd_soc_dai_ops s3c2412_i2s_dai_ops = {
178 .set_sysclk = s3c2412_i2s_set_sysclk,
179 .hw_params = s3c2412_i2s_hw_params, 152 .hw_params = s3c2412_i2s_hw_params,
180}; 153};
181 154
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c
index 6d49bd93717b..1d85cb85a7d2 100644
--- a/sound/soc/s3c24xx/s3c64xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c64xx-i2s.c
@@ -54,43 +54,6 @@ static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
54 return cpu_dai->private_data; 54 return cpu_dai->private_data;
55} 55}
56 56
57static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
58 int clk_id, unsigned int freq, int dir)
59{
60 struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
61 u32 iismod = readl(i2s->regs + S3C2412_IISMOD);
62
63 switch (clk_id) {
64 case S3C64XX_CLKSRC_PCLK:
65 iismod &= ~S3C2412_IISMOD_IMS_SYSMUX;
66 break;
67
68 case S3C64XX_CLKSRC_MUX:
69 iismod |= S3C2412_IISMOD_IMS_SYSMUX;
70 break;
71
72 case S3C64XX_CLKSRC_CDCLK:
73 switch (dir) {
74 case SND_SOC_CLOCK_IN:
75 iismod |= S3C64XX_IISMOD_CDCLKCON;
76 break;
77 case SND_SOC_CLOCK_OUT:
78 iismod &= ~S3C64XX_IISMOD_CDCLKCON;
79 break;
80 default:
81 return -EINVAL;
82 }
83 break;
84
85 default:
86 return -EINVAL;
87 }
88
89 writel(iismod, i2s->regs + S3C2412_IISMOD);
90
91 return 0;
92}
93
94static int s3c64xx_i2s_probe(struct platform_device *pdev, 57static int s3c64xx_i2s_probe(struct platform_device *pdev,
95 struct snd_soc_dai *dai) 58 struct snd_soc_dai *dai)
96{ 59{
@@ -115,9 +78,7 @@ static int s3c64xx_i2s_probe(struct platform_device *pdev,
115} 78}
116 79
117 80
118static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops = { 81static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops;
119 .set_sysclk = s3c64xx_i2s_set_sysclk,
120};
121 82
122static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev) 83static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev)
123{ 84{
@@ -147,6 +108,8 @@ static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev)
147 dai->probe = s3c64xx_i2s_probe; 108 dai->probe = s3c64xx_i2s_probe;
148 dai->ops = &s3c64xx_i2s_dai_ops; 109 dai->ops = &s3c64xx_i2s_dai_ops;
149 110
111 i2s->feature |= S3C_FEATURE_CDCLKCON;
112
150 i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id]; 113 i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id];
151 i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id]; 114 i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id];
152 115