17 #include <linux/module.h>
25 #include <linux/list.h>
26 #include <linux/slab.h>
42 #define FSLDMA_PCM_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
43 SNDRV_PCM_FMTBIT_U8 | \
44 SNDRV_PCM_FMTBIT_S16_LE | \
45 SNDRV_PCM_FMTBIT_S16_BE | \
46 SNDRV_PCM_FMTBIT_U16_LE | \
47 SNDRV_PCM_FMTBIT_U16_BE | \
48 SNDRV_PCM_FMTBIT_S24_LE | \
49 SNDRV_PCM_FMTBIT_S24_BE | \
50 SNDRV_PCM_FMTBIT_U24_LE | \
51 SNDRV_PCM_FMTBIT_U24_BE | \
52 SNDRV_PCM_FMTBIT_S32_LE | \
53 SNDRV_PCM_FMTBIT_S32_BE | \
54 SNDRV_PCM_FMTBIT_U32_LE | \
55 SNDRV_PCM_FMTBIT_U32_BE)
57 #define FSLDMA_PCM_RATES (SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000 | \
58 SNDRV_PCM_RATE_CONTINUOUS)
75 #define NUM_DMA_LINKS 2
144 .period_bytes_min = 512,
145 .period_bytes_max = (
u32) -1,
148 .buffer_bytes_max = 128 * 1024,
163 if (snd_pcm_running(substream))
175 static void fsl_dma_update_pointers(
struct fsl_dma_private *dma_private)
186 #ifdef CONFIG_PHYS_64BIT
192 #ifdef CONFIG_PHYS_64BIT
227 sr =
in_be32(&dma_channel->sr);
230 dev_err(dev,
"dma transmit error\n");
231 fsl_dma_abort_stream(substream);
240 dev_err(dev,
"dma programming error\n");
241 fsl_dma_abort_stream(substream);
264 fsl_dma_update_pointers(dma_private);
304 if (!card->
dev->dma_mask)
305 card->
dev->dma_mask = &fsl_dma_dmamask;
307 if (!card->
dev->coherent_dma_mask)
308 card->
dev->coherent_dma_mask = fsl_dma_dmamask;
319 dev_err(card->
dev,
"can't alloc playback dma buffer\n");
329 dev_err(card->
dev,
"can't alloc capture dma buffer\n");
408 struct ccsr_dma_channel
__iomem *dma_channel;
424 dev_err(dev,
"invalid buffer size\n");
431 dev_err(dev,
"dma channel already assigned\n");
438 dev_err(dev,
"can't allocate dma private data\n");
448 dma_private->
irq = dma->
irq;
453 ret =
request_irq(dma_private->
irq, fsl_dma_isr, 0,
"fsldma-audio",
456 dev_err(dev,
"can't register ISR for IRQ %u (ret=%i)\n",
457 dma_private->
irq, ret);
465 snd_pcm_set_runtime_buffer(substream, &substream->
dma_buffer);
497 mr =
in_be32(&dma_channel->mr) &
561 unsigned int sample_bits =
565 unsigned int sample_bytes = sample_bits / 8;
574 size_t period_size = params_period_bytes(hw_params);
591 (NUM_DMA_LINKS * period_size);
605 switch (sample_bits) {
619 dev_err(dev,
"unsupported sample size %u\n", sample_bits);
698 temp_addr += period_size;
731 position =
in_be32(&dma_channel->sar);
732 #ifdef CONFIG_PHYS_64BIT
733 position |= (
u64)(
in_be32(&dma_channel->satr) &
737 position =
in_be32(&dma_channel->dar);
738 #ifdef CONFIG_PHYS_64BIT
739 position |= (
u64)(
in_be32(&dma_channel->datr) &
754 if ((position < dma_private->dma_buf_phys) ||
756 dev_err(dev,
"dma pointer is out of range, halting stream\n");
760 frames = bytes_to_frames(runtime, position - dma_private->
dma_buf_phys);
786 struct ccsr_dma_channel
__iomem *dma_channel;
823 if (dma_private->
irq)
840 static void fsl_dma_free_dma_buffers(
struct snd_pcm *pcm)
846 substream = pcm->
streams[
i].substream;
870 for_each_compatible_node(ssi_np,
NULL,
"fsl,mpc8610-ssi") {
876 if (np == dma_channel_np)
881 if (np == dma_channel_np)
889 .open = fsl_dma_open,
890 .close = fsl_dma_close,
892 .hw_params = fsl_dma_hw_params,
893 .hw_free = fsl_dma_hw_free,
894 .pointer = fsl_dma_pointer,
907 ssi_np = find_ssi_node(np);
909 dev_err(&pdev->
dev,
"cannot find parent SSI node\n");
915 dev_err(&pdev->
dev,
"could not determine resources for %s\n",
923 dev_err(&pdev->
dev,
"could not allocate dma object\n");
929 dma->
dai.ops = &fsl_dma_ops;
930 dma->
dai.pcm_new = fsl_dma_new;
931 dma->
dai.pcm_free = fsl_dma_free_dma_buffers;
948 dev_err(&pdev->
dev,
"could not register platform\n");
974 { .compatible =
"fsl,ssi-dma-channel", },
981 .name =
"fsl-pcm-audio",
983 .of_match_table = fsl_soc_dma_ids,
985 .probe = fsl_soc_dma_probe,