aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/s3c24xx/s3c2412-i2s.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/s3c24xx/s3c2412-i2s.c')
-rw-r--r--sound/soc/s3c24xx/s3c2412-i2s.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c
index 359e59346ba2..709adef9d043 100644
--- a/sound/soc/s3c24xx/s3c2412-i2s.c
+++ b/sound/soc/s3c24xx/s3c2412-i2s.c
@@ -32,12 +32,11 @@
32#include <sound/soc.h> 32#include <sound/soc.h>
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34 34
35#include <plat/regs-s3c2412-iis.h>
36
37#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
38#include <mach/dma.h> 36#include <mach/dma.h>
39 37
40#include "s3c-dma.h" 38#include "s3c-dma.h"
39#include "regs-i2s-v2.h"
41#include "s3c2412-i2s.h" 40#include "s3c2412-i2s.h"
42 41
43#define S3C2412_I2S_DEBUG 0 42#define S3C2412_I2S_DEBUG 0
@@ -66,44 +65,11 @@ static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = {
66 65
67static struct s3c_i2sv2_info s3c2412_i2s; 66static struct s3c_i2sv2_info s3c2412_i2s;
68 67
69/* 68static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
70 * Set S3C2412 Clock source
71 */
72static int s3c2412_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
73 int clk_id, unsigned int freq, int dir)
74{ 69{
75 u32 iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD); 70 return cpu_dai->private_data;
76
77 pr_debug("%s(%p, %d, %u, %d)\n", __func__, cpu_dai, clk_id,
78 freq, dir);
79
80 switch (clk_id) {
81 case S3C2412_CLKSRC_PCLK:
82 s3c2412_i2s.master = 1;
83 iismod &= ~S3C2412_IISMOD_MASTER_MASK;
84 iismod |= S3C2412_IISMOD_MASTER_INTERNAL;
85 break;
86 case S3C2412_CLKSRC_I2SCLK:
87 s3c2412_i2s.master = 0;
88 iismod &= ~S3C2412_IISMOD_MASTER_MASK;
89 iismod |= S3C2412_IISMOD_MASTER_EXTERNAL;
90 break;
91 default:
92 return -EINVAL;
93 }
94
95 writel(iismod, s3c2412_i2s.regs + S3C2412_IISMOD);
96 return 0;
97} 71}
98 72
99
100struct clk *s3c2412_get_iisclk(void)
101{
102 return s3c2412_i2s.iis_clk;
103}
104EXPORT_SYMBOL_GPL(s3c2412_get_iisclk);
105
106
107static int s3c2412_i2s_probe(struct platform_device *pdev, 73static int s3c2412_i2s_probe(struct platform_device *pdev,
108 struct snd_soc_dai *dai) 74 struct snd_soc_dai *dai)
109{ 75{
@@ -142,13 +108,48 @@ static int s3c2412_i2s_probe(struct platform_device *pdev,
142 return 0; 108 return 0;
143} 109}
144 110
111static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream,
112 struct snd_pcm_hw_params *params,
113 struct snd_soc_dai *cpu_dai)
114{
115 struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
116 struct s3c_dma_params *dma_data;
117 u32 iismod;
118
119 pr_debug("Entered %s\n", __func__);
120
121 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
122 dma_data = i2s->dma_playback;
123 else
124 dma_data = i2s->dma_capture;
125
126 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
127
128 iismod = readl(i2s->regs + S3C2412_IISMOD);
129 pr_debug("%s: r: IISMOD: %x\n", __func__, iismod);
130
131 switch (params_format(params)) {
132 case SNDRV_PCM_FORMAT_S8:
133 iismod |= S3C2412_IISMOD_8BIT;
134 break;
135 case SNDRV_PCM_FORMAT_S16_LE:
136 iismod &= ~S3C2412_IISMOD_8BIT;
137 break;
138 }
139
140 writel(iismod, i2s->regs + S3C2412_IISMOD);
141 pr_debug("%s: w: IISMOD: %x\n", __func__, iismod);
142
143 return 0;
144}
145
145#define S3C2412_I2S_RATES \ 146#define S3C2412_I2S_RATES \
146 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ 147 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
147 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ 148 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
148 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)
149 150
150static struct snd_soc_dai_ops s3c2412_i2s_dai_ops = { 151static struct snd_soc_dai_ops s3c2412_i2s_dai_ops = {
151 .set_sysclk = s3c2412_i2s_set_sysclk, 152 .hw_params = s3c2412_i2s_hw_params,
152}; 153};
153 154
154struct snd_soc_dai s3c2412_i2s_dai = { 155struct snd_soc_dai s3c2412_i2s_dai = {