| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * Freescale DMA ALSA SoC PCM driver |
|---|
| 3 | | - * |
|---|
| 4 | | - * Author: Timur Tabi <timur@freescale.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * Copyright 2007-2010 Freescale Semiconductor, Inc. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This file is licensed under the terms of the GNU General Public License |
|---|
| 9 | | - * version 2. This program is licensed "as is" without any warranty of any |
|---|
| 10 | | - * kind, whether express or implied. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This driver implements ASoC support for the Elo DMA controller, which is |
|---|
| 13 | | - * the DMA controller on Freescale 83xx, 85xx, and 86xx SOCs. In ALSA terms, |
|---|
| 14 | | - * the PCM driver is what handles the DMA buffer. |
|---|
| 15 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +// |
|---|
| 3 | +// Freescale DMA ALSA SoC PCM driver |
|---|
| 4 | +// |
|---|
| 5 | +// Author: Timur Tabi <timur@freescale.com> |
|---|
| 6 | +// |
|---|
| 7 | +// Copyright 2007-2010 Freescale Semiconductor, Inc. |
|---|
| 8 | +// |
|---|
| 9 | +// This driver implements ASoC support for the Elo DMA controller, which is |
|---|
| 10 | +// the DMA controller on Freescale 83xx, 85xx, and 86xx SOCs. In ALSA terms, |
|---|
| 11 | +// the PCM driver is what handles the DMA buffer. |
|---|
| 16 | 12 | |
|---|
| 17 | 13 | #include <linux/module.h> |
|---|
| 18 | 14 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 158 | 154 | /** |
|---|
| 159 | 155 | * fsl_dma_update_pointers - update LD pointers to point to the next period |
|---|
| 160 | 156 | * |
|---|
| 161 | | - * As each period is completed, this function changes the the link |
|---|
| 157 | + * As each period is completed, this function changes the link |
|---|
| 162 | 158 | * descriptor pointers for that period to point to the next period. |
|---|
| 163 | 159 | */ |
|---|
| 164 | 160 | static void fsl_dma_update_pointers(struct fsl_dma_private *dma_private) |
|---|
| .. | .. |
|---|
| 204 | 200 | { |
|---|
| 205 | 201 | struct fsl_dma_private *dma_private = dev_id; |
|---|
| 206 | 202 | struct snd_pcm_substream *substream = dma_private->substream; |
|---|
| 207 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 208 | | - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); |
|---|
| 209 | | - struct device *dev = component->dev; |
|---|
| 203 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 204 | + struct device *dev = rtd->dev; |
|---|
| 210 | 205 | struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; |
|---|
| 211 | 206 | irqreturn_t ret = IRQ_NONE; |
|---|
| 212 | 207 | u32 sr, sr2 = 0; |
|---|
| .. | .. |
|---|
| 284 | 279 | * Regardless of where the memory is actually allocated, since the device can |
|---|
| 285 | 280 | * technically DMA to any 36-bit address, we do need to set the DMA mask to 36. |
|---|
| 286 | 281 | */ |
|---|
| 287 | | -static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd) |
|---|
| 282 | +static int fsl_dma_new(struct snd_soc_component *component, |
|---|
| 283 | + struct snd_soc_pcm_runtime *rtd) |
|---|
| 288 | 284 | { |
|---|
| 289 | 285 | struct snd_card *card = rtd->card->snd_card; |
|---|
| 290 | 286 | struct snd_pcm *pcm = rtd->pcm; |
|---|
| .. | .. |
|---|
| 384 | 380 | * buffer, which is what ALSA expects. We're just dividing it into |
|---|
| 385 | 381 | * contiguous parts, and creating a link descriptor for each one. |
|---|
| 386 | 382 | */ |
|---|
| 387 | | -static int fsl_dma_open(struct snd_pcm_substream *substream) |
|---|
| 383 | +static int fsl_dma_open(struct snd_soc_component *component, |
|---|
| 384 | + struct snd_pcm_substream *substream) |
|---|
| 388 | 385 | { |
|---|
| 389 | 386 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 390 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 391 | | - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); |
|---|
| 392 | 387 | struct device *dev = component->dev; |
|---|
| 393 | 388 | struct dma_object *dma = |
|---|
| 394 | 389 | container_of(component->driver, struct dma_object, dai); |
|---|
| .. | .. |
|---|
| 537 | 532 | * and 8 bytes at a time). So we do not support packed 24-bit samples. |
|---|
| 538 | 533 | * 24-bit data must be padded to 32 bits. |
|---|
| 539 | 534 | */ |
|---|
| 540 | | -static int fsl_dma_hw_params(struct snd_pcm_substream *substream, |
|---|
| 541 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 535 | +static int fsl_dma_hw_params(struct snd_soc_component *component, |
|---|
| 536 | + struct snd_pcm_substream *substream, |
|---|
| 537 | + struct snd_pcm_hw_params *hw_params) |
|---|
| 542 | 538 | { |
|---|
| 543 | 539 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 544 | 540 | struct fsl_dma_private *dma_private = runtime->private_data; |
|---|
| 545 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 546 | | - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); |
|---|
| 547 | 541 | struct device *dev = component->dev; |
|---|
| 548 | 542 | |
|---|
| 549 | 543 | /* Number of bits per sample */ |
|---|
| .. | .. |
|---|
| 702 | 696 | * The base address of the buffer is stored in the source_addr field of the |
|---|
| 703 | 697 | * first link descriptor. |
|---|
| 704 | 698 | */ |
|---|
| 705 | | -static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream) |
|---|
| 699 | +static snd_pcm_uframes_t fsl_dma_pointer(struct snd_soc_component *component, |
|---|
| 700 | + struct snd_pcm_substream *substream) |
|---|
| 706 | 701 | { |
|---|
| 707 | 702 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 708 | 703 | struct fsl_dma_private *dma_private = runtime->private_data; |
|---|
| 709 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 710 | | - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); |
|---|
| 711 | 704 | struct device *dev = component->dev; |
|---|
| 712 | 705 | struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; |
|---|
| 713 | 706 | dma_addr_t position; |
|---|
| .. | .. |
|---|
| 767 | 760 | * |
|---|
| 768 | 761 | * This function can be called multiple times. |
|---|
| 769 | 762 | */ |
|---|
| 770 | | -static int fsl_dma_hw_free(struct snd_pcm_substream *substream) |
|---|
| 763 | +static int fsl_dma_hw_free(struct snd_soc_component *component, |
|---|
| 764 | + struct snd_pcm_substream *substream) |
|---|
| 771 | 765 | { |
|---|
| 772 | 766 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 773 | 767 | struct fsl_dma_private *dma_private = runtime->private_data; |
|---|
| .. | .. |
|---|
| 800 | 794 | /** |
|---|
| 801 | 795 | * fsl_dma_close: close the stream. |
|---|
| 802 | 796 | */ |
|---|
| 803 | | -static int fsl_dma_close(struct snd_pcm_substream *substream) |
|---|
| 797 | +static int fsl_dma_close(struct snd_soc_component *component, |
|---|
| 798 | + struct snd_pcm_substream *substream) |
|---|
| 804 | 799 | { |
|---|
| 805 | 800 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 806 | 801 | struct fsl_dma_private *dma_private = runtime->private_data; |
|---|
| 807 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 808 | | - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); |
|---|
| 809 | 802 | struct device *dev = component->dev; |
|---|
| 810 | 803 | struct dma_object *dma = |
|---|
| 811 | 804 | container_of(component->driver, struct dma_object, dai); |
|---|
| .. | .. |
|---|
| 828 | 821 | /* |
|---|
| 829 | 822 | * Remove this PCM driver. |
|---|
| 830 | 823 | */ |
|---|
| 831 | | -static void fsl_dma_free_dma_buffers(struct snd_pcm *pcm) |
|---|
| 824 | +static void fsl_dma_free_dma_buffers(struct snd_soc_component *component, |
|---|
| 825 | + struct snd_pcm *pcm) |
|---|
| 832 | 826 | { |
|---|
| 833 | 827 | struct snd_pcm_substream *substream; |
|---|
| 834 | 828 | unsigned int i; |
|---|
| .. | .. |
|---|
| 876 | 870 | return NULL; |
|---|
| 877 | 871 | } |
|---|
| 878 | 872 | |
|---|
| 879 | | -static const struct snd_pcm_ops fsl_dma_ops = { |
|---|
| 880 | | - .open = fsl_dma_open, |
|---|
| 881 | | - .close = fsl_dma_close, |
|---|
| 882 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 883 | | - .hw_params = fsl_dma_hw_params, |
|---|
| 884 | | - .hw_free = fsl_dma_hw_free, |
|---|
| 885 | | - .pointer = fsl_dma_pointer, |
|---|
| 886 | | -}; |
|---|
| 887 | | - |
|---|
| 888 | 873 | static int fsl_soc_dma_probe(struct platform_device *pdev) |
|---|
| 889 | 874 | { |
|---|
| 890 | 875 | struct dma_object *dma; |
|---|
| .. | .. |
|---|
| 916 | 901 | } |
|---|
| 917 | 902 | |
|---|
| 918 | 903 | dma->dai.name = DRV_NAME; |
|---|
| 919 | | - dma->dai.ops = &fsl_dma_ops; |
|---|
| 920 | | - dma->dai.pcm_new = fsl_dma_new; |
|---|
| 921 | | - dma->dai.pcm_free = fsl_dma_free_dma_buffers; |
|---|
| 904 | + dma->dai.open = fsl_dma_open; |
|---|
| 905 | + dma->dai.close = fsl_dma_close; |
|---|
| 906 | + dma->dai.hw_params = fsl_dma_hw_params; |
|---|
| 907 | + dma->dai.hw_free = fsl_dma_hw_free; |
|---|
| 908 | + dma->dai.pointer = fsl_dma_pointer; |
|---|
| 909 | + dma->dai.pcm_construct = fsl_dma_new; |
|---|
| 910 | + dma->dai.pcm_destruct = fsl_dma_free_dma_buffers; |
|---|
| 922 | 911 | |
|---|
| 923 | 912 | /* Store the SSI-specific information that we need */ |
|---|
| 924 | 913 | dma->ssi_stx_phys = res.start + REG_SSI_STX0; |
|---|