]>
Commit | Line | Data |
---|---|---|
c1422a66 BD |
1 | /* |
2 | * s3c24xx-i2s.c -- ALSA Soc Audio Layer | |
3 | * | |
4 | * (c) 2006 Wolfson Microelectronics PLC. | |
5 | * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com | |
6 | * | |
c8efef17 | 7 | * Copyright 2004-2005 Simtec Electronics |
c1422a66 BD |
8 | * http://armlinux.simtec.co.uk/ |
9 | * Ben Dooks <ben@simtec.co.uk> | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify it | |
12 | * under the terms of the GNU General Public License as published by the | |
13 | * Free Software Foundation; either version 2 of the License, or (at your | |
14 | * option) any later version. | |
c1422a66 BD |
15 | */ |
16 | ||
17 | #include <linux/init.h> | |
18 | #include <linux/module.h> | |
19 | #include <linux/device.h> | |
20 | #include <linux/delay.h> | |
21 | #include <linux/clk.h> | |
f11b7992 | 22 | #include <linux/jiffies.h> |
40efc15f | 23 | #include <linux/io.h> |
ec976d6e BD |
24 | #include <linux/gpio.h> |
25 | ||
c1422a66 BD |
26 | #include <sound/core.h> |
27 | #include <sound/pcm.h> | |
28 | #include <sound/pcm_params.h> | |
29 | #include <sound/initval.h> | |
30 | #include <sound/soc.h> | |
31 | ||
a09e64fb RK |
32 | #include <mach/hardware.h> |
33 | #include <mach/regs-gpio.h> | |
34 | #include <mach/regs-clock.h> | |
ed9d040d | 35 | |
c1422a66 | 36 | #include <asm/dma.h> |
a09e64fb | 37 | #include <mach/dma.h> |
c1422a66 | 38 | |
8150bc88 | 39 | #include <plat/regs-iis.h> |
aa9673cf | 40 | |
4b640cf3 | 41 | #include "dma.h" |
c1422a66 BD |
42 | #include "s3c24xx-i2s.h" |
43 | ||
c1422a66 BD |
44 | static struct s3c2410_dma_client s3c24xx_dma_client_out = { |
45 | .name = "I2S PCM Stereo out" | |
46 | }; | |
47 | ||
48 | static struct s3c2410_dma_client s3c24xx_dma_client_in = { | |
49 | .name = "I2S PCM Stereo in" | |
50 | }; | |
51 | ||
faa31776 | 52 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { |
c1422a66 BD |
53 | .client = &s3c24xx_dma_client_out, |
54 | .channel = DMACH_I2S_OUT, | |
e81208fe GG |
55 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, |
56 | .dma_size = 2, | |
c1422a66 BD |
57 | }; |
58 | ||
faa31776 | 59 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { |
c1422a66 BD |
60 | .client = &s3c24xx_dma_client_in, |
61 | .channel = DMACH_I2S_IN, | |
e81208fe GG |
62 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, |
63 | .dma_size = 2, | |
c1422a66 BD |
64 | }; |
65 | ||
66 | struct s3c24xx_i2s_info { | |
67 | void __iomem *regs; | |
68 | struct clk *iis_clk; | |
5cd919a2 GG |
69 | u32 iiscon; |
70 | u32 iismod; | |
71 | u32 iisfcon; | |
72 | u32 iispsr; | |
c1422a66 BD |
73 | }; |
74 | static struct s3c24xx_i2s_info s3c24xx_i2s; | |
75 | ||
76 | static void s3c24xx_snd_txctrl(int on) | |
77 | { | |
78 | u32 iisfcon; | |
79 | u32 iiscon; | |
80 | u32 iismod; | |
81 | ||
ee7d4767 | 82 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
83 | |
84 | iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); | |
85 | iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); | |
86 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | |
87 | ||
5314adc3 | 88 | pr_debug("r: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); |
c1422a66 BD |
89 | |
90 | if (on) { | |
91 | iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE; | |
92 | iiscon |= S3C2410_IISCON_TXDMAEN | S3C2410_IISCON_IISEN; | |
93 | iiscon &= ~S3C2410_IISCON_TXIDLE; | |
94 | iismod |= S3C2410_IISMOD_TXMODE; | |
95 | ||
96 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
97 | writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); | |
98 | writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); | |
99 | } else { | |
100 | /* note, we have to disable the FIFOs otherwise bad things | |
101 | * seem to happen when the DMA stops. According to the | |
102 | * Samsung supplied kernel, this should allow the DMA | |
103 | * engine and FIFOs to reset. If this isn't allowed, the | |
104 | * DMA engine will simply freeze randomly. | |
105 | */ | |
106 | ||
107 | iisfcon &= ~S3C2410_IISFCON_TXENABLE; | |
108 | iisfcon &= ~S3C2410_IISFCON_TXDMA; | |
109 | iiscon |= S3C2410_IISCON_TXIDLE; | |
110 | iiscon &= ~S3C2410_IISCON_TXDMAEN; | |
111 | iismod &= ~S3C2410_IISMOD_TXMODE; | |
112 | ||
113 | writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); | |
114 | writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); | |
115 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
116 | } | |
117 | ||
5314adc3 | 118 | pr_debug("w: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); |
c1422a66 BD |
119 | } |
120 | ||
121 | static void s3c24xx_snd_rxctrl(int on) | |
122 | { | |
123 | u32 iisfcon; | |
124 | u32 iiscon; | |
125 | u32 iismod; | |
126 | ||
ee7d4767 | 127 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
128 | |
129 | iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); | |
130 | iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); | |
131 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | |
132 | ||
5314adc3 | 133 | pr_debug("r: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); |
c1422a66 BD |
134 | |
135 | if (on) { | |
136 | iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE; | |
137 | iiscon |= S3C2410_IISCON_RXDMAEN | S3C2410_IISCON_IISEN; | |
138 | iiscon &= ~S3C2410_IISCON_RXIDLE; | |
139 | iismod |= S3C2410_IISMOD_RXMODE; | |
140 | ||
141 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
142 | writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); | |
143 | writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); | |
144 | } else { | |
145 | /* note, we have to disable the FIFOs otherwise bad things | |
146 | * seem to happen when the DMA stops. According to the | |
147 | * Samsung supplied kernel, this should allow the DMA | |
148 | * engine and FIFOs to reset. If this isn't allowed, the | |
149 | * DMA engine will simply freeze randomly. | |
150 | */ | |
151 | ||
0015e7d1 MB |
152 | iisfcon &= ~S3C2410_IISFCON_RXENABLE; |
153 | iisfcon &= ~S3C2410_IISFCON_RXDMA; | |
154 | iiscon |= S3C2410_IISCON_RXIDLE; | |
155 | iiscon &= ~S3C2410_IISCON_RXDMAEN; | |
c1422a66 BD |
156 | iismod &= ~S3C2410_IISMOD_RXMODE; |
157 | ||
158 | writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); | |
159 | writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); | |
160 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
161 | } | |
162 | ||
5314adc3 | 163 | pr_debug("w: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); |
c1422a66 BD |
164 | } |
165 | ||
166 | /* | |
167 | * Wait for the LR signal to allow synchronisation to the L/R clock | |
168 | * from the codec. May only be needed for slave mode. | |
169 | */ | |
170 | static int s3c24xx_snd_lrsync(void) | |
171 | { | |
172 | u32 iiscon; | |
33e5b222 | 173 | int timeout = 50; /* 5ms */ |
c1422a66 | 174 | |
ee7d4767 | 175 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
176 | |
177 | while (1) { | |
178 | iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); | |
179 | if (iiscon & S3C2410_IISCON_LRINDEX) | |
180 | break; | |
181 | ||
33e5b222 | 182 | if (!timeout--) |
c1422a66 | 183 | return -ETIMEDOUT; |
33e5b222 | 184 | udelay(100); |
c1422a66 BD |
185 | } |
186 | ||
187 | return 0; | |
188 | } | |
189 | ||
190 | /* | |
191 | * Check whether CPU is the master or slave | |
192 | */ | |
193 | static inline int s3c24xx_snd_is_clkmaster(void) | |
194 | { | |
ee7d4767 | 195 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
196 | |
197 | return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1; | |
198 | } | |
199 | ||
200 | /* | |
201 | * Set S3C24xx I2S DAI format | |
202 | */ | |
1992a6fb | 203 | static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, |
c1422a66 BD |
204 | unsigned int fmt) |
205 | { | |
206 | u32 iismod; | |
207 | ||
ee7d4767 | 208 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
209 | |
210 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | |
5314adc3 | 211 | pr_debug("hw_params r: IISMOD: %x \n", iismod); |
c1422a66 BD |
212 | |
213 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | |
214 | case SND_SOC_DAIFMT_CBM_CFM: | |
215 | iismod |= S3C2410_IISMOD_SLAVE; | |
216 | break; | |
217 | case SND_SOC_DAIFMT_CBS_CFS: | |
2c36eecf | 218 | iismod &= ~S3C2410_IISMOD_SLAVE; |
c1422a66 BD |
219 | break; |
220 | default: | |
221 | return -EINVAL; | |
222 | } | |
223 | ||
224 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | |
225 | case SND_SOC_DAIFMT_LEFT_J: | |
226 | iismod |= S3C2410_IISMOD_MSB; | |
227 | break; | |
228 | case SND_SOC_DAIFMT_I2S: | |
2c36eecf | 229 | iismod &= ~S3C2410_IISMOD_MSB; |
c1422a66 BD |
230 | break; |
231 | default: | |
232 | return -EINVAL; | |
233 | } | |
234 | ||
235 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
5314adc3 | 236 | pr_debug("hw_params w: IISMOD: %x \n", iismod); |
c1422a66 BD |
237 | return 0; |
238 | } | |
239 | ||
240 | static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |
dee89c4d MB |
241 | struct snd_pcm_hw_params *params, |
242 | struct snd_soc_dai *dai) | |
c1422a66 BD |
243 | { |
244 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
5f712b2b | 245 | struct s3c_dma_params *dma_data; |
c1422a66 BD |
246 | u32 iismod; |
247 | ||
ee7d4767 | 248 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
249 | |
250 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
5f712b2b | 251 | dma_data = &s3c24xx_i2s_pcm_stereo_out; |
c1422a66 | 252 | else |
5f712b2b DM |
253 | dma_data = &s3c24xx_i2s_pcm_stereo_in; |
254 | ||
f0fba2ad | 255 | snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data); |
c1422a66 BD |
256 | |
257 | /* Working copies of register */ | |
258 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | |
5314adc3 | 259 | pr_debug("hw_params r: IISMOD: %x\n", iismod); |
c1422a66 BD |
260 | |
261 | switch (params_format(params)) { | |
262 | case SNDRV_PCM_FORMAT_S8: | |
53599bbc | 263 | iismod &= ~S3C2410_IISMOD_16BIT; |
5f712b2b | 264 | dma_data->dma_size = 1; |
c1422a66 BD |
265 | break; |
266 | case SNDRV_PCM_FORMAT_S16_LE: | |
267 | iismod |= S3C2410_IISMOD_16BIT; | |
5f712b2b | 268 | dma_data->dma_size = 2; |
c1422a66 | 269 | break; |
53599bbc CP |
270 | default: |
271 | return -EINVAL; | |
c1422a66 BD |
272 | } |
273 | ||
274 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
5314adc3 | 275 | pr_debug("hw_params w: IISMOD: %x\n", iismod); |
c1422a66 BD |
276 | return 0; |
277 | } | |
278 | ||
dee89c4d MB |
279 | static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, |
280 | struct snd_soc_dai *dai) | |
c1422a66 BD |
281 | { |
282 | int ret = 0; | |
5f712b2b | 283 | struct s3c_dma_params *dma_data = |
f0fba2ad | 284 | snd_soc_dai_get_dma_data(dai, substream); |
c1422a66 | 285 | |
ee7d4767 | 286 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
287 | |
288 | switch (cmd) { | |
289 | case SNDRV_PCM_TRIGGER_START: | |
290 | case SNDRV_PCM_TRIGGER_RESUME: | |
291 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | |
292 | if (!s3c24xx_snd_is_clkmaster()) { | |
293 | ret = s3c24xx_snd_lrsync(); | |
294 | if (ret) | |
295 | goto exit_err; | |
296 | } | |
297 | ||
298 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | |
299 | s3c24xx_snd_rxctrl(1); | |
300 | else | |
301 | s3c24xx_snd_txctrl(1); | |
faf907c7 | 302 | |
5f712b2b | 303 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); |
c1422a66 BD |
304 | break; |
305 | case SNDRV_PCM_TRIGGER_STOP: | |
306 | case SNDRV_PCM_TRIGGER_SUSPEND: | |
307 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | |
308 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | |
309 | s3c24xx_snd_rxctrl(0); | |
310 | else | |
311 | s3c24xx_snd_txctrl(0); | |
312 | break; | |
313 | default: | |
314 | ret = -EINVAL; | |
315 | break; | |
316 | } | |
317 | ||
318 | exit_err: | |
319 | return ret; | |
320 | } | |
321 | ||
322 | /* | |
323 | * Set S3C24xx Clock source | |
324 | */ | |
1992a6fb | 325 | static int s3c24xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, |
c1422a66 BD |
326 | int clk_id, unsigned int freq, int dir) |
327 | { | |
328 | u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | |
329 | ||
ee7d4767 | 330 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
331 | |
332 | iismod &= ~S3C2440_IISMOD_MPLL; | |
333 | ||
334 | switch (clk_id) { | |
335 | case S3C24XX_CLKSRC_PCLK: | |
336 | break; | |
337 | case S3C24XX_CLKSRC_MPLL: | |
338 | iismod |= S3C2440_IISMOD_MPLL; | |
339 | break; | |
340 | default: | |
341 | return -EINVAL; | |
342 | } | |
343 | ||
344 | writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
345 | return 0; | |
346 | } | |
347 | ||
348 | /* | |
349 | * Set S3C24xx Clock dividers | |
350 | */ | |
1992a6fb | 351 | static int s3c24xx_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, |
c1422a66 BD |
352 | int div_id, int div) |
353 | { | |
354 | u32 reg; | |
355 | ||
ee7d4767 | 356 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
357 | |
358 | switch (div_id) { | |
82fb159a | 359 | case S3C24XX_DIV_BCLK: |
c1422a66 BD |
360 | reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~S3C2410_IISMOD_FS_MASK; |
361 | writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
362 | break; | |
82fb159a | 363 | case S3C24XX_DIV_MCLK: |
c1422a66 BD |
364 | reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~(S3C2410_IISMOD_384FS); |
365 | writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
366 | break; | |
367 | case S3C24XX_DIV_PRESCALER: | |
368 | writel(div, s3c24xx_i2s.regs + S3C2410_IISPSR); | |
369 | reg = readl(s3c24xx_i2s.regs + S3C2410_IISCON); | |
370 | writel(reg | S3C2410_IISCON_PSCEN, s3c24xx_i2s.regs + S3C2410_IISCON); | |
371 | break; | |
372 | default: | |
373 | return -EINVAL; | |
374 | } | |
375 | ||
376 | return 0; | |
377 | } | |
378 | ||
379 | /* | |
380 | * To avoid duplicating clock code, allow machine driver to | |
381 | * get the clockrate from here. | |
382 | */ | |
383 | u32 s3c24xx_i2s_get_clockrate(void) | |
384 | { | |
385 | return clk_get_rate(s3c24xx_i2s.iis_clk); | |
386 | } | |
387 | EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate); | |
388 | ||
f0fba2ad | 389 | static int s3c24xx_i2s_probe(struct snd_soc_dai *dai) |
c1422a66 | 390 | { |
ee7d4767 | 391 | pr_debug("Entered %s\n", __func__); |
c1422a66 BD |
392 | |
393 | s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); | |
394 | if (s3c24xx_i2s.regs == NULL) | |
395 | return -ENXIO; | |
396 | ||
f0fba2ad | 397 | s3c24xx_i2s.iis_clk = clk_get(dai->dev, "iis"); |
c1422a66 | 398 | if (s3c24xx_i2s.iis_clk == NULL) { |
b52a5195 | 399 | pr_err("failed to get iis_clock\n"); |
8642a4ba | 400 | iounmap(s3c24xx_i2s.regs); |
c1422a66 BD |
401 | return -ENODEV; |
402 | } | |
403 | clk_enable(s3c24xx_i2s.iis_clk); | |
404 | ||
405 | /* Configure the I2S pins in correct mode */ | |
406 | s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK); | |
407 | s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_I2SSCLK); | |
408 | s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_CDCLK); | |
409 | s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI); | |
410 | s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO); | |
411 | ||
412 | writel(S3C2410_IISCON_IISEN, s3c24xx_i2s.regs + S3C2410_IISCON); | |
413 | ||
414 | s3c24xx_snd_txctrl(0); | |
415 | s3c24xx_snd_rxctrl(0); | |
416 | ||
417 | return 0; | |
418 | } | |
419 | ||
5cd919a2 | 420 | #ifdef CONFIG_PM |
dc7d7b83 | 421 | static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) |
5cd919a2 | 422 | { |
ee7d4767 | 423 | pr_debug("Entered %s\n", __func__); |
40920307 | 424 | |
5cd919a2 GG |
425 | s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); |
426 | s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | |
427 | s3c24xx_i2s.iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); | |
428 | s3c24xx_i2s.iispsr = readl(s3c24xx_i2s.regs + S3C2410_IISPSR); | |
429 | ||
430 | clk_disable(s3c24xx_i2s.iis_clk); | |
431 | ||
432 | return 0; | |
433 | } | |
434 | ||
dc7d7b83 | 435 | static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) |
5cd919a2 | 436 | { |
ee7d4767 | 437 | pr_debug("Entered %s\n", __func__); |
5cd919a2 GG |
438 | clk_enable(s3c24xx_i2s.iis_clk); |
439 | ||
440 | writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); | |
441 | writel(s3c24xx_i2s.iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | |
442 | writel(s3c24xx_i2s.iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); | |
443 | writel(s3c24xx_i2s.iispsr, s3c24xx_i2s.regs + S3C2410_IISPSR); | |
444 | ||
445 | return 0; | |
446 | } | |
447 | #else | |
448 | #define s3c24xx_i2s_suspend NULL | |
449 | #define s3c24xx_i2s_resume NULL | |
450 | #endif | |
451 | ||
452 | ||
c1422a66 BD |
453 | #define S3C24XX_I2S_RATES \ |
454 | (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ | |
455 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ | |
456 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) | |
457 | ||
6335d055 EM |
458 | static struct snd_soc_dai_ops s3c24xx_i2s_dai_ops = { |
459 | .trigger = s3c24xx_i2s_trigger, | |
460 | .hw_params = s3c24xx_i2s_hw_params, | |
461 | .set_fmt = s3c24xx_i2s_set_fmt, | |
462 | .set_clkdiv = s3c24xx_i2s_set_clkdiv, | |
463 | .set_sysclk = s3c24xx_i2s_set_sysclk, | |
464 | }; | |
465 | ||
f0fba2ad | 466 | static struct snd_soc_dai_driver s3c24xx_i2s_dai = { |
c1422a66 | 467 | .probe = s3c24xx_i2s_probe, |
5cd919a2 GG |
468 | .suspend = s3c24xx_i2s_suspend, |
469 | .resume = s3c24xx_i2s_resume, | |
c1422a66 BD |
470 | .playback = { |
471 | .channels_min = 2, | |
472 | .channels_max = 2, | |
473 | .rates = S3C24XX_I2S_RATES, | |
474 | .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,}, | |
475 | .capture = { | |
476 | .channels_min = 2, | |
477 | .channels_max = 2, | |
478 | .rates = S3C24XX_I2S_RATES, | |
479 | .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,}, | |
6335d055 | 480 | .ops = &s3c24xx_i2s_dai_ops, |
c1422a66 | 481 | }; |
f0fba2ad LG |
482 | |
483 | static __devinit int s3c24xx_iis_dev_probe(struct platform_device *pdev) | |
484 | { | |
485 | return snd_soc_register_dai(&pdev->dev, &s3c24xx_i2s_dai); | |
486 | } | |
487 | ||
488 | static __devexit int s3c24xx_iis_dev_remove(struct platform_device *pdev) | |
489 | { | |
490 | snd_soc_unregister_dai(&pdev->dev); | |
491 | return 0; | |
492 | } | |
493 | ||
494 | static struct platform_driver s3c24xx_iis_driver = { | |
495 | .probe = s3c24xx_iis_dev_probe, | |
496 | .remove = s3c24xx_iis_dev_remove, | |
497 | .driver = { | |
498 | .name = "s3c24xx-iis", | |
499 | .owner = THIS_MODULE, | |
500 | }, | |
501 | }; | |
c1422a66 | 502 | |
c9b3a40f | 503 | static int __init s3c24xx_i2s_init(void) |
3f4b783c | 504 | { |
f0fba2ad | 505 | return platform_driver_register(&s3c24xx_iis_driver); |
3f4b783c MB |
506 | } |
507 | module_init(s3c24xx_i2s_init); | |
508 | ||
509 | static void __exit s3c24xx_i2s_exit(void) | |
510 | { | |
f0fba2ad | 511 | platform_driver_unregister(&s3c24xx_iis_driver); |
3f4b783c MB |
512 | } |
513 | module_exit(s3c24xx_i2s_exit); | |
514 | ||
c1422a66 BD |
515 | /* Module information */ |
516 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); | |
517 | MODULE_DESCRIPTION("s3c24xx I2S SoC Interface"); | |
518 | MODULE_LICENSE("GPL"); | |
960d0697 | 519 | MODULE_ALIAS("platform:s3c24xx-iis"); |