Commit | Line | Data |
---|---|---|
2e74796a JN |
1 | /* |
2 | * omap-mcbsp.c -- OMAP ALSA SoC DAI driver using McBSP port | |
3 | * | |
4 | * Copyright (C) 2008 Nokia Corporation | |
5 | * | |
6 | * Contact: Jarkko Nikula <jarkko.nikula@nokia.com> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
20 | * 02110-1301 USA | |
21 | * | |
22 | */ | |
23 | ||
24 | #include <linux/init.h> | |
25 | #include <linux/module.h> | |
26 | #include <linux/device.h> | |
27 | #include <sound/core.h> | |
28 | #include <sound/pcm.h> | |
29 | #include <sound/pcm_params.h> | |
30 | #include <sound/initval.h> | |
31 | #include <sound/soc.h> | |
32 | ||
a09e64fb RK |
33 | #include <mach/control.h> |
34 | #include <mach/dma.h> | |
35 | #include <mach/mcbsp.h> | |
2e74796a JN |
36 | #include "omap-mcbsp.h" |
37 | #include "omap-pcm.h" | |
38 | ||
0b604856 | 39 | #define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) |
2e74796a JN |
40 | |
41 | struct omap_mcbsp_data { | |
42 | unsigned int bus_id; | |
43 | struct omap_mcbsp_reg_cfg regs; | |
ba9d0fd0 | 44 | unsigned int fmt; |
2e74796a JN |
45 | /* |
46 | * Flags indicating is the bus already activated and configured by | |
47 | * another substream | |
48 | */ | |
49 | int active; | |
50 | int configured; | |
51 | }; | |
52 | ||
53 | #define to_mcbsp(priv) container_of((priv), struct omap_mcbsp_data, bus_id) | |
54 | ||
55 | static struct omap_mcbsp_data mcbsp_data[NUM_LINKS]; | |
56 | ||
57 | /* | |
58 | * Stream DMA parameters. DMA request line and port address are set runtime | |
59 | * since they are different between OMAP1 and later OMAPs | |
60 | */ | |
2e89713a | 61 | static struct omap_pcm_dma_data omap_mcbsp_dai_dma_params[NUM_LINKS][2]; |
2e74796a JN |
62 | |
63 | #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) | |
64 | static const int omap1_dma_reqs[][2] = { | |
65 | { OMAP_DMA_MCBSP1_TX, OMAP_DMA_MCBSP1_RX }, | |
66 | { OMAP_DMA_MCBSP2_TX, OMAP_DMA_MCBSP2_RX }, | |
67 | { OMAP_DMA_MCBSP3_TX, OMAP_DMA_MCBSP3_RX }, | |
68 | }; | |
69 | static const unsigned long omap1_mcbsp_port[][2] = { | |
70 | { OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1, | |
71 | OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 }, | |
72 | { OMAP1510_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1, | |
73 | OMAP1510_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 }, | |
74 | { OMAP1510_MCBSP3_BASE + OMAP_MCBSP_REG_DXR1, | |
75 | OMAP1510_MCBSP3_BASE + OMAP_MCBSP_REG_DRR1 }, | |
76 | }; | |
77 | #else | |
78 | static const int omap1_dma_reqs[][2] = {}; | |
79 | static const unsigned long omap1_mcbsp_port[][2] = {}; | |
80 | #endif | |
406e2c48 JN |
81 | |
82 | #if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) | |
83 | static const int omap24xx_dma_reqs[][2] = { | |
2e74796a JN |
84 | { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX }, |
85 | { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX }, | |
406e2c48 JN |
86 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) |
87 | { OMAP24XX_DMA_MCBSP3_TX, OMAP24XX_DMA_MCBSP3_RX }, | |
88 | { OMAP24XX_DMA_MCBSP4_TX, OMAP24XX_DMA_MCBSP4_RX }, | |
89 | { OMAP24XX_DMA_MCBSP5_TX, OMAP24XX_DMA_MCBSP5_RX }, | |
90 | #endif | |
2e74796a | 91 | }; |
406e2c48 JN |
92 | #else |
93 | static const int omap24xx_dma_reqs[][2] = {}; | |
94 | #endif | |
95 | ||
96 | #if defined(CONFIG_ARCH_OMAP2420) | |
2e74796a JN |
97 | static const unsigned long omap2420_mcbsp_port[][2] = { |
98 | { OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1, | |
99 | OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 }, | |
100 | { OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1, | |
101 | OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 }, | |
102 | }; | |
103 | #else | |
2e74796a JN |
104 | static const unsigned long omap2420_mcbsp_port[][2] = {}; |
105 | #endif | |
106 | ||
406e2c48 JN |
107 | #if defined(CONFIG_ARCH_OMAP2430) |
108 | static const unsigned long omap2430_mcbsp_port[][2] = { | |
109 | { OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR, | |
110 | OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR }, | |
111 | { OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR, | |
112 | OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR }, | |
113 | { OMAP2430_MCBSP3_BASE + OMAP_MCBSP_REG_DXR, | |
114 | OMAP2430_MCBSP3_BASE + OMAP_MCBSP_REG_DRR }, | |
115 | { OMAP2430_MCBSP4_BASE + OMAP_MCBSP_REG_DXR, | |
116 | OMAP2430_MCBSP4_BASE + OMAP_MCBSP_REG_DRR }, | |
117 | { OMAP2430_MCBSP5_BASE + OMAP_MCBSP_REG_DXR, | |
118 | OMAP2430_MCBSP5_BASE + OMAP_MCBSP_REG_DRR }, | |
119 | }; | |
120 | #else | |
121 | static const unsigned long omap2430_mcbsp_port[][2] = {}; | |
122 | #endif | |
123 | ||
124 | #if defined(CONFIG_ARCH_OMAP34XX) | |
125 | static const unsigned long omap34xx_mcbsp_port[][2] = { | |
126 | { OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR, | |
127 | OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR }, | |
128 | { OMAP34XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR, | |
129 | OMAP34XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR }, | |
130 | { OMAP34XX_MCBSP3_BASE + OMAP_MCBSP_REG_DXR, | |
131 | OMAP34XX_MCBSP3_BASE + OMAP_MCBSP_REG_DRR }, | |
132 | { OMAP34XX_MCBSP4_BASE + OMAP_MCBSP_REG_DXR, | |
133 | OMAP34XX_MCBSP4_BASE + OMAP_MCBSP_REG_DRR }, | |
134 | { OMAP34XX_MCBSP5_BASE + OMAP_MCBSP_REG_DXR, | |
135 | OMAP34XX_MCBSP5_BASE + OMAP_MCBSP_REG_DRR }, | |
136 | }; | |
137 | #else | |
138 | static const unsigned long omap34xx_mcbsp_port[][2] = {}; | |
139 | #endif | |
140 | ||
dee89c4d MB |
141 | static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, |
142 | struct snd_soc_dai *dai) | |
2e74796a JN |
143 | { |
144 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
8687eb8b | 145 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
2e74796a JN |
146 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); |
147 | int err = 0; | |
148 | ||
149 | if (!cpu_dai->active) | |
150 | err = omap_mcbsp_request(mcbsp_data->bus_id); | |
151 | ||
152 | return err; | |
153 | } | |
154 | ||
dee89c4d MB |
155 | static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, |
156 | struct snd_soc_dai *dai) | |
2e74796a JN |
157 | { |
158 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
8687eb8b | 159 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
2e74796a JN |
160 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); |
161 | ||
162 | if (!cpu_dai->active) { | |
163 | omap_mcbsp_free(mcbsp_data->bus_id); | |
164 | mcbsp_data->configured = 0; | |
165 | } | |
166 | } | |
167 | ||
dee89c4d MB |
168 | static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, |
169 | struct snd_soc_dai *dai) | |
2e74796a JN |
170 | { |
171 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
8687eb8b | 172 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
2e74796a JN |
173 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); |
174 | int err = 0; | |
175 | ||
176 | switch (cmd) { | |
177 | case SNDRV_PCM_TRIGGER_START: | |
178 | case SNDRV_PCM_TRIGGER_RESUME: | |
179 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | |
180 | if (!mcbsp_data->active++) | |
181 | omap_mcbsp_start(mcbsp_data->bus_id); | |
182 | break; | |
183 | ||
184 | case SNDRV_PCM_TRIGGER_STOP: | |
185 | case SNDRV_PCM_TRIGGER_SUSPEND: | |
186 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | |
187 | if (!--mcbsp_data->active) | |
188 | omap_mcbsp_stop(mcbsp_data->bus_id); | |
189 | break; | |
190 | default: | |
191 | err = -EINVAL; | |
192 | } | |
193 | ||
194 | return err; | |
195 | } | |
196 | ||
197 | static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |
dee89c4d MB |
198 | struct snd_pcm_hw_params *params, |
199 | struct snd_soc_dai *dai) | |
2e74796a JN |
200 | { |
201 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
8687eb8b | 202 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
2e74796a JN |
203 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); |
204 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | |
205 | int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id; | |
ba9d0fd0 | 206 | int wlen; |
2e74796a JN |
207 | unsigned long port; |
208 | ||
209 | if (cpu_class_is_omap1()) { | |
210 | dma = omap1_dma_reqs[bus_id][substream->stream]; | |
211 | port = omap1_mcbsp_port[bus_id][substream->stream]; | |
212 | } else if (cpu_is_omap2420()) { | |
406e2c48 | 213 | dma = omap24xx_dma_reqs[bus_id][substream->stream]; |
2e74796a | 214 | port = omap2420_mcbsp_port[bus_id][substream->stream]; |
406e2c48 JN |
215 | } else if (cpu_is_omap2430()) { |
216 | dma = omap24xx_dma_reqs[bus_id][substream->stream]; | |
217 | port = omap2430_mcbsp_port[bus_id][substream->stream]; | |
218 | } else if (cpu_is_omap343x()) { | |
219 | dma = omap24xx_dma_reqs[bus_id][substream->stream]; | |
220 | port = omap34xx_mcbsp_port[bus_id][substream->stream]; | |
2e74796a | 221 | } else { |
2e74796a JN |
222 | return -ENODEV; |
223 | } | |
2e89713a JN |
224 | omap_mcbsp_dai_dma_params[id][substream->stream].name = |
225 | substream->stream ? "Audio Capture" : "Audio Playback"; | |
2e74796a JN |
226 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; |
227 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; | |
228 | cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream]; | |
229 | ||
230 | if (mcbsp_data->configured) { | |
231 | /* McBSP already configured by another stream */ | |
232 | return 0; | |
233 | } | |
234 | ||
235 | switch (params_channels(params)) { | |
236 | case 2: | |
237 | /* Set 1 word per (McBPSP) frame and use dual-phase frames */ | |
238 | regs->rcr2 |= RFRLEN2(1 - 1) | RPHASE; | |
239 | regs->rcr1 |= RFRLEN1(1 - 1); | |
240 | regs->xcr2 |= XFRLEN2(1 - 1) | XPHASE; | |
241 | regs->xcr1 |= XFRLEN1(1 - 1); | |
242 | break; | |
243 | default: | |
244 | /* Unsupported number of channels */ | |
245 | return -EINVAL; | |
246 | } | |
247 | ||
248 | switch (params_format(params)) { | |
249 | case SNDRV_PCM_FORMAT_S16_LE: | |
250 | /* Set word lengths */ | |
ba9d0fd0 | 251 | wlen = 16; |
2e74796a JN |
252 | regs->rcr2 |= RWDLEN2(OMAP_MCBSP_WORD_16); |
253 | regs->rcr1 |= RWDLEN1(OMAP_MCBSP_WORD_16); | |
254 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_16); | |
255 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_16); | |
2e74796a JN |
256 | break; |
257 | default: | |
258 | /* Unsupported PCM format */ | |
259 | return -EINVAL; | |
260 | } | |
261 | ||
ba9d0fd0 JN |
262 | /* Set FS period and length in terms of bit clock periods */ |
263 | switch (mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | |
264 | case SND_SOC_DAIFMT_I2S: | |
265 | regs->srgr2 |= FPER(wlen * 2 - 1); | |
266 | regs->srgr1 |= FWID(wlen - 1); | |
267 | break; | |
268 | case SND_SOC_DAIFMT_DSP_A: | |
269 | regs->srgr2 |= FPER(wlen * 2 - 1); | |
da6320be | 270 | regs->srgr1 |= FWID(wlen * 2 - 2); |
ba9d0fd0 JN |
271 | break; |
272 | } | |
273 | ||
2e74796a JN |
274 | omap_mcbsp_config(bus_id, &mcbsp_data->regs); |
275 | mcbsp_data->configured = 1; | |
276 | ||
277 | return 0; | |
278 | } | |
279 | ||
280 | /* | |
281 | * This must be called before _set_clkdiv and _set_sysclk since McBSP register | |
282 | * cache is initialized here | |
283 | */ | |
8687eb8b | 284 | static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, |
2e74796a JN |
285 | unsigned int fmt) |
286 | { | |
287 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | |
288 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | |
289 | ||
290 | if (mcbsp_data->configured) | |
291 | return 0; | |
292 | ||
ba9d0fd0 | 293 | mcbsp_data->fmt = fmt; |
2e74796a JN |
294 | memset(regs, 0, sizeof(*regs)); |
295 | /* Generic McBSP register settings */ | |
296 | regs->spcr2 |= XINTM(3) | FREE; | |
297 | regs->spcr1 |= RINTM(3); | |
298 | regs->rcr2 |= RFIG; | |
299 | regs->xcr2 |= XFIG; | |
300 | ||
301 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | |
302 | case SND_SOC_DAIFMT_I2S: | |
303 | /* 1-bit data delay */ | |
304 | regs->rcr2 |= RDATDLY(1); | |
305 | regs->xcr2 |= XDATDLY(1); | |
306 | break; | |
3336c5b5 AK |
307 | case SND_SOC_DAIFMT_DSP_A: |
308 | /* 0-bit data delay */ | |
309 | regs->rcr2 |= RDATDLY(0); | |
310 | regs->xcr2 |= XDATDLY(0); | |
311 | break; | |
2e74796a JN |
312 | default: |
313 | /* Unsupported data format */ | |
314 | return -EINVAL; | |
315 | } | |
316 | ||
317 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | |
318 | case SND_SOC_DAIFMT_CBS_CFS: | |
319 | /* McBSP master. Set FS and bit clocks as outputs */ | |
320 | regs->pcr0 |= FSXM | FSRM | | |
321 | CLKXM | CLKRM; | |
322 | /* Sample rate generator drives the FS */ | |
323 | regs->srgr2 |= FSGM; | |
324 | break; | |
325 | case SND_SOC_DAIFMT_CBM_CFM: | |
326 | /* McBSP slave */ | |
327 | break; | |
328 | default: | |
329 | /* Unsupported master/slave configuration */ | |
330 | return -EINVAL; | |
331 | } | |
332 | ||
333 | /* Set bit clock (CLKX/CLKR) and FS polarities */ | |
da6320be | 334 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
2e74796a JN |
335 | case SND_SOC_DAIFMT_NB_NF: |
336 | /* | |
337 | * Normal BCLK + FS. | |
338 | * FS active low. TX data driven on falling edge of bit clock | |
339 | * and RX data sampled on rising edge of bit clock. | |
340 | */ | |
341 | regs->pcr0 |= FSXP | FSRP | | |
342 | CLKXP | CLKRP; | |
343 | break; | |
344 | case SND_SOC_DAIFMT_NB_IF: | |
345 | regs->pcr0 |= CLKXP | CLKRP; | |
346 | break; | |
347 | case SND_SOC_DAIFMT_IB_NF: | |
348 | regs->pcr0 |= FSXP | FSRP; | |
349 | break; | |
350 | case SND_SOC_DAIFMT_IB_IF: | |
351 | break; | |
352 | default: | |
353 | return -EINVAL; | |
354 | } | |
355 | ||
356 | return 0; | |
357 | } | |
358 | ||
8687eb8b | 359 | static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, |
2e74796a JN |
360 | int div_id, int div) |
361 | { | |
362 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | |
363 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | |
364 | ||
365 | if (div_id != OMAP_MCBSP_CLKGDV) | |
366 | return -ENODEV; | |
367 | ||
368 | regs->srgr1 |= CLKGDV(div - 1); | |
369 | ||
370 | return 0; | |
371 | } | |
372 | ||
373 | static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data, | |
374 | int clk_id) | |
375 | { | |
376 | int sel_bit; | |
406e2c48 | 377 | u16 reg, reg_devconf1 = OMAP243X_CONTROL_DEVCONF1; |
2e74796a JN |
378 | |
379 | if (cpu_class_is_omap1()) { | |
380 | /* OMAP1's can use only external source clock */ | |
381 | if (unlikely(clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK)) | |
382 | return -EINVAL; | |
383 | else | |
384 | return 0; | |
385 | } | |
386 | ||
406e2c48 JN |
387 | if (cpu_is_omap2420() && mcbsp_data->bus_id > 1) |
388 | return -EINVAL; | |
389 | ||
390 | if (cpu_is_omap343x()) | |
391 | reg_devconf1 = OMAP343X_CONTROL_DEVCONF1; | |
392 | ||
2e74796a JN |
393 | switch (mcbsp_data->bus_id) { |
394 | case 0: | |
395 | reg = OMAP2_CONTROL_DEVCONF0; | |
396 | sel_bit = 2; | |
397 | break; | |
398 | case 1: | |
399 | reg = OMAP2_CONTROL_DEVCONF0; | |
400 | sel_bit = 6; | |
401 | break; | |
406e2c48 JN |
402 | case 2: |
403 | reg = reg_devconf1; | |
404 | sel_bit = 0; | |
405 | break; | |
406 | case 3: | |
407 | reg = reg_devconf1; | |
408 | sel_bit = 2; | |
409 | break; | |
410 | case 4: | |
411 | reg = reg_devconf1; | |
412 | sel_bit = 4; | |
413 | break; | |
2e74796a JN |
414 | default: |
415 | return -EINVAL; | |
416 | } | |
417 | ||
406e2c48 JN |
418 | if (clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK) |
419 | omap_ctrl_writel(omap_ctrl_readl(reg) & ~(1 << sel_bit), reg); | |
420 | else | |
421 | omap_ctrl_writel(omap_ctrl_readl(reg) | (1 << sel_bit), reg); | |
2e74796a JN |
422 | |
423 | return 0; | |
424 | } | |
425 | ||
8687eb8b | 426 | static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, |
2e74796a JN |
427 | int clk_id, unsigned int freq, |
428 | int dir) | |
429 | { | |
430 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | |
431 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | |
432 | int err = 0; | |
433 | ||
434 | switch (clk_id) { | |
435 | case OMAP_MCBSP_SYSCLK_CLK: | |
436 | regs->srgr2 |= CLKSM; | |
437 | break; | |
438 | case OMAP_MCBSP_SYSCLK_CLKS_FCLK: | |
439 | case OMAP_MCBSP_SYSCLK_CLKS_EXT: | |
440 | err = omap_mcbsp_dai_set_clks_src(mcbsp_data, clk_id); | |
441 | break; | |
442 | ||
443 | case OMAP_MCBSP_SYSCLK_CLKX_EXT: | |
444 | regs->srgr2 |= CLKSM; | |
445 | case OMAP_MCBSP_SYSCLK_CLKR_EXT: | |
446 | regs->pcr0 |= SCLKME; | |
447 | break; | |
448 | default: | |
449 | err = -ENODEV; | |
450 | } | |
451 | ||
452 | return err; | |
453 | } | |
454 | ||
8def464d JN |
455 | #define OMAP_MCBSP_DAI_BUILDER(link_id) \ |
456 | { \ | |
0c758bdd | 457 | .name = "omap-mcbsp-dai-"#link_id, \ |
8def464d | 458 | .id = (link_id), \ |
8def464d JN |
459 | .playback = { \ |
460 | .channels_min = 2, \ | |
461 | .channels_max = 2, \ | |
462 | .rates = OMAP_MCBSP_RATES, \ | |
463 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | |
464 | }, \ | |
465 | .capture = { \ | |
466 | .channels_min = 2, \ | |
467 | .channels_max = 2, \ | |
468 | .rates = OMAP_MCBSP_RATES, \ | |
469 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | |
470 | }, \ | |
471 | .ops = { \ | |
472 | .startup = omap_mcbsp_dai_startup, \ | |
473 | .shutdown = omap_mcbsp_dai_shutdown, \ | |
474 | .trigger = omap_mcbsp_dai_trigger, \ | |
475 | .hw_params = omap_mcbsp_dai_hw_params, \ | |
8def464d JN |
476 | .set_fmt = omap_mcbsp_dai_set_dai_fmt, \ |
477 | .set_clkdiv = omap_mcbsp_dai_set_clkdiv, \ | |
478 | .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, \ | |
479 | }, \ | |
480 | .private_data = &mcbsp_data[(link_id)].bus_id, \ | |
481 | } | |
482 | ||
483 | struct snd_soc_dai omap_mcbsp_dai[] = { | |
484 | OMAP_MCBSP_DAI_BUILDER(0), | |
485 | OMAP_MCBSP_DAI_BUILDER(1), | |
486 | #if NUM_LINKS >= 3 | |
487 | OMAP_MCBSP_DAI_BUILDER(2), | |
488 | #endif | |
489 | #if NUM_LINKS == 5 | |
490 | OMAP_MCBSP_DAI_BUILDER(3), | |
491 | OMAP_MCBSP_DAI_BUILDER(4), | |
492 | #endif | |
2e74796a | 493 | }; |
8def464d | 494 | |
2e74796a JN |
495 | EXPORT_SYMBOL_GPL(omap_mcbsp_dai); |
496 | ||
497 | MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@nokia.com>"); | |
498 | MODULE_DESCRIPTION("OMAP I2S SoC Interface"); | |
499 | MODULE_LICENSE("GPL"); |