14 #include <linux/module.h>
15 #include <linux/device.h>
17 #include <linux/slab.h>
24 #define KIRKWOOD_RATES \
25 (SNDRV_PCM_RATE_44100 | \
26 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
27 #define KIRKWOOD_FORMATS \
28 (SNDRV_PCM_FMTBIT_S16_LE | \
29 SNDRV_PCM_FMTBIT_S24_LE | \
30 SNDRV_PCM_FMTBIT_S32_LE)
97 kirkwood_dma_conf_mbus_windows(
void __iomem *base,
int win,
108 for (i = 0; i < dram->
num_cs; i++) {
109 const struct mbus_dram_window *
cs = dram->
cs +
i;
110 if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
111 writel(cs->base & 0xffff0000,
113 writel(((cs->size - 1) & 0xffff0000) |
114 (cs->mbus_attr << 8) |
133 priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
156 if (prdata ==
NULL) {
164 "kirkwood-i2s", prdata);
170 snd_soc_platform_set_drvdata(platform, prdata);
183 kirkwood_dma_conf_mbus_windows(priv->
io,
187 kirkwood_dma_conf_mbus_windows(priv->
io,
202 priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
204 if (!prdata || !priv)
216 snd_soc_platform_set_drvdata(platform,
NULL);
227 snd_pcm_set_runtime_buffer(substream, &substream->
dma_buffer);
235 snd_pcm_set_runtime_buffer(substream,
NULL);
247 priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
250 size = frames_to_bytes(runtime, runtime->
buffer_size);
252 count = snd_pcm_lib_period_bytes(substream);
276 priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
279 count = bytes_to_frames(substream->
runtime,
282 count = bytes_to_frames(substream->
runtime,
289 .open = kirkwood_dma_open,
290 .close = kirkwood_dma_close,
292 .hw_params = kirkwood_dma_hw_params,
293 .hw_free = kirkwood_dma_hw_free,
294 .prepare = kirkwood_dma_prepare,
295 .pointer = kirkwood_dma_pointer,
298 static int kirkwood_dma_preallocate_dma_buffer(
struct snd_pcm *pcm,
323 if (!card->
dev->dma_mask)
324 card->
dev->dma_mask = &kirkwood_dma_dmamask;
325 if (!card->
dev->coherent_dma_mask)
329 ret = kirkwood_dma_preallocate_dma_buffer(pcm,
336 ret = kirkwood_dma_preallocate_dma_buffer(pcm,
345 static void kirkwood_dma_free_dma_buffers(
struct snd_pcm *pcm)
351 for (stream = 0; stream < 2; stream++) {
352 substream = pcm->
streams[stream].substream;
367 .pcm_new = kirkwood_dma_new,
368 .pcm_free = kirkwood_dma_free_dma_buffers,
384 .name =
"kirkwood-pcm-audio",
388 .probe = kirkwood_soc_platform_probe,
389 .remove =
__devexit_p(kirkwood_soc_platform_remove),