aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/s3c24xx/s3c24xx-i2s.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/s3c24xx/s3c24xx-i2s.c')
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.c71
1 files changed, 33 insertions, 38 deletions
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c
index 6f4d439b57aa..cc066964dad6 100644
--- a/sound/soc/s3c24xx/s3c24xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.c
@@ -4,7 +4,7 @@
4 * (c) 2006 Wolfson Microelectronics PLC. 4 * (c) 2006 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com 5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 * 6 *
7 * (c) 2004-2005 Simtec Electronics 7 * Copyright 2004-2005 Simtec Electronics
8 * http://armlinux.simtec.co.uk/ 8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk> 9 * Ben Dooks <ben@simtec.co.uk>
10 * 10 *
@@ -30,22 +30,15 @@
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <mach/regs-gpio.h> 31#include <mach/regs-gpio.h>
32#include <mach/regs-clock.h> 32#include <mach/regs-clock.h>
33#include <mach/audio.h> 33#include <plat/audio.h>
34#include <asm/dma.h> 34#include <asm/dma.h>
35#include <mach/dma.h> 35#include <mach/dma.h>
36 36
37#include <asm/plat-s3c24xx/regs-iis.h> 37#include <plat/regs-iis.h>
38 38
39#include "s3c24xx-pcm.h" 39#include "s3c24xx-pcm.h"
40#include "s3c24xx-i2s.h" 40#include "s3c24xx-i2s.h"
41 41
42#define S3C24XX_I2S_DEBUG 0
43#if S3C24XX_I2S_DEBUG
44#define DBG(x...) printk(KERN_DEBUG "s3c24xx-i2s: " x)
45#else
46#define DBG(x...)
47#endif
48
49static struct s3c2410_dma_client s3c24xx_dma_client_out = { 42static struct s3c2410_dma_client s3c24xx_dma_client_out = {
50 .name = "I2S PCM Stereo out" 43 .name = "I2S PCM Stereo out"
51}; 44};
@@ -84,13 +77,13 @@ static void s3c24xx_snd_txctrl(int on)
84 u32 iiscon; 77 u32 iiscon;
85 u32 iismod; 78 u32 iismod;
86 79
87 DBG("Entered %s\n", __func__); 80 pr_debug("Entered %s\n", __func__);
88 81
89 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); 82 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
90 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 83 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
91 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 84 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
92 85
93 DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); 86 pr_debug("r: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon);
94 87
95 if (on) { 88 if (on) {
96 iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE; 89 iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE;
@@ -120,7 +113,7 @@ static void s3c24xx_snd_txctrl(int on)
120 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); 113 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
121 } 114 }
122 115
123 DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); 116 pr_debug("w: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon);
124} 117}
125 118
126static void s3c24xx_snd_rxctrl(int on) 119static void s3c24xx_snd_rxctrl(int on)
@@ -129,13 +122,13 @@ static void s3c24xx_snd_rxctrl(int on)
129 u32 iiscon; 122 u32 iiscon;
130 u32 iismod; 123 u32 iismod;
131 124
132 DBG("Entered %s\n", __func__); 125 pr_debug("Entered %s\n", __func__);
133 126
134 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); 127 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
135 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 128 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
136 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 129 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
137 130
138 DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); 131 pr_debug("r: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon);
139 132
140 if (on) { 133 if (on) {
141 iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE; 134 iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE;
@@ -165,7 +158,7 @@ static void s3c24xx_snd_rxctrl(int on)
165 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); 158 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
166 } 159 }
167 160
168 DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); 161 pr_debug("w: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon);
169} 162}
170 163
171/* 164/*
@@ -177,7 +170,7 @@ static int s3c24xx_snd_lrsync(void)
177 u32 iiscon; 170 u32 iiscon;
178 int timeout = 50; /* 5ms */ 171 int timeout = 50; /* 5ms */
179 172
180 DBG("Entered %s\n", __func__); 173 pr_debug("Entered %s\n", __func__);
181 174
182 while (1) { 175 while (1) {
183 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 176 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
@@ -197,7 +190,7 @@ static int s3c24xx_snd_lrsync(void)
197 */ 190 */
198static inline int s3c24xx_snd_is_clkmaster(void) 191static inline int s3c24xx_snd_is_clkmaster(void)
199{ 192{
200 DBG("Entered %s\n", __func__); 193 pr_debug("Entered %s\n", __func__);
201 194
202 return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1; 195 return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1;
203} 196}
@@ -210,10 +203,10 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
210{ 203{
211 u32 iismod; 204 u32 iismod;
212 205
213 DBG("Entered %s\n", __func__); 206 pr_debug("Entered %s\n", __func__);
214 207
215 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 208 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
216 DBG("hw_params r: IISMOD: %lx \n", iismod); 209 pr_debug("hw_params r: IISMOD: %x \n", iismod);
217 210
218 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 211 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
219 case SND_SOC_DAIFMT_CBM_CFM: 212 case SND_SOC_DAIFMT_CBM_CFM:
@@ -238,7 +231,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
238 } 231 }
239 232
240 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); 233 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
241 DBG("hw_params w: IISMOD: %lx \n", iismod); 234 pr_debug("hw_params w: IISMOD: %x \n", iismod);
242 return 0; 235 return 0;
243} 236}
244 237
@@ -249,7 +242,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
249 struct snd_soc_pcm_runtime *rtd = substream->private_data; 242 struct snd_soc_pcm_runtime *rtd = substream->private_data;
250 u32 iismod; 243 u32 iismod;
251 244
252 DBG("Entered %s\n", __func__); 245 pr_debug("Entered %s\n", __func__);
253 246
254 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 247 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
255 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out; 248 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out;
@@ -258,7 +251,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
258 251
259 /* Working copies of register */ 252 /* Working copies of register */
260 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 253 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
261 DBG("hw_params r: IISMOD: %lx\n", iismod); 254 pr_debug("hw_params r: IISMOD: %x\n", iismod);
262 255
263 switch (params_format(params)) { 256 switch (params_format(params)) {
264 case SNDRV_PCM_FORMAT_S8: 257 case SNDRV_PCM_FORMAT_S8:
@@ -276,7 +269,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
276 } 269 }
277 270
278 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); 271 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
279 DBG("hw_params w: IISMOD: %lx\n", iismod); 272 pr_debug("hw_params w: IISMOD: %x\n", iismod);
280 return 0; 273 return 0;
281} 274}
282 275
@@ -285,7 +278,7 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
285{ 278{
286 int ret = 0; 279 int ret = 0;
287 280
288 DBG("Entered %s\n", __func__); 281 pr_debug("Entered %s\n", __func__);
289 282
290 switch (cmd) { 283 switch (cmd) {
291 case SNDRV_PCM_TRIGGER_START: 284 case SNDRV_PCM_TRIGGER_START:
@@ -327,7 +320,7 @@ static int s3c24xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
327{ 320{
328 u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 321 u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
329 322
330 DBG("Entered %s\n", __func__); 323 pr_debug("Entered %s\n", __func__);
331 324
332 iismod &= ~S3C2440_IISMOD_MPLL; 325 iismod &= ~S3C2440_IISMOD_MPLL;
333 326
@@ -353,7 +346,7 @@ static int s3c24xx_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
353{ 346{
354 u32 reg; 347 u32 reg;
355 348
356 DBG("Entered %s\n", __func__); 349 pr_debug("Entered %s\n", __func__);
357 350
358 switch (div_id) { 351 switch (div_id) {
359 case S3C24XX_DIV_BCLK: 352 case S3C24XX_DIV_BCLK:
@@ -389,7 +382,7 @@ EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate);
389static int s3c24xx_i2s_probe(struct platform_device *pdev, 382static int s3c24xx_i2s_probe(struct platform_device *pdev,
390 struct snd_soc_dai *dai) 383 struct snd_soc_dai *dai)
391{ 384{
392 DBG("Entered %s\n", __func__); 385 pr_debug("Entered %s\n", __func__);
393 386
394 s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); 387 s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100);
395 if (s3c24xx_i2s.regs == NULL) 388 if (s3c24xx_i2s.regs == NULL)
@@ -397,7 +390,7 @@ static int s3c24xx_i2s_probe(struct platform_device *pdev,
397 390
398 s3c24xx_i2s.iis_clk = clk_get(&pdev->dev, "iis"); 391 s3c24xx_i2s.iis_clk = clk_get(&pdev->dev, "iis");
399 if (s3c24xx_i2s.iis_clk == NULL) { 392 if (s3c24xx_i2s.iis_clk == NULL) {
400 DBG("failed to get iis_clock\n"); 393 pr_err("failed to get iis_clock\n");
401 iounmap(s3c24xx_i2s.regs); 394 iounmap(s3c24xx_i2s.regs);
402 return -ENODEV; 395 return -ENODEV;
403 } 396 }
@@ -421,7 +414,7 @@ static int s3c24xx_i2s_probe(struct platform_device *pdev,
421#ifdef CONFIG_PM 414#ifdef CONFIG_PM
422static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) 415static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai)
423{ 416{
424 DBG("Entered %s\n", __func__); 417 pr_debug("Entered %s\n", __func__);
425 418
426 s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 419 s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
427 s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 420 s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
@@ -435,7 +428,7 @@ static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai)
435 428
436static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) 429static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai)
437{ 430{
438 DBG("Entered %s\n", __func__); 431 pr_debug("Entered %s\n", __func__);
439 clk_enable(s3c24xx_i2s.iis_clk); 432 clk_enable(s3c24xx_i2s.iis_clk);
440 433
441 writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); 434 writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
@@ -456,6 +449,14 @@ static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai)
456 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ 449 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
457 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 450 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
458 451
452static struct snd_soc_dai_ops s3c24xx_i2s_dai_ops = {
453 .trigger = s3c24xx_i2s_trigger,
454 .hw_params = s3c24xx_i2s_hw_params,
455 .set_fmt = s3c24xx_i2s_set_fmt,
456 .set_clkdiv = s3c24xx_i2s_set_clkdiv,
457 .set_sysclk = s3c24xx_i2s_set_sysclk,
458};
459
459struct snd_soc_dai s3c24xx_i2s_dai = { 460struct snd_soc_dai s3c24xx_i2s_dai = {
460 .name = "s3c24xx-i2s", 461 .name = "s3c24xx-i2s",
461 .id = 0, 462 .id = 0,
@@ -472,13 +473,7 @@ struct snd_soc_dai s3c24xx_i2s_dai = {
472 .channels_max = 2, 473 .channels_max = 2,
473 .rates = S3C24XX_I2S_RATES, 474 .rates = S3C24XX_I2S_RATES,
474 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,}, 475 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,},
475 .ops = { 476 .ops = &s3c24xx_i2s_dai_ops,
476 .trigger = s3c24xx_i2s_trigger,
477 .hw_params = s3c24xx_i2s_hw_params,
478 .set_fmt = s3c24xx_i2s_set_fmt,
479 .set_clkdiv = s3c24xx_i2s_set_clkdiv,
480 .set_sysclk = s3c24xx_i2s_set_sysclk,
481 },
482}; 477};
483EXPORT_SYMBOL_GPL(s3c24xx_i2s_dai); 478EXPORT_SYMBOL_GPL(s3c24xx_i2s_dai);
484 479