ARM: DaVinci: ASoC: Add mcasp support for DM646x
PATCH v3 5/6 ARM: DaVinci: ASoC: Add mcasp support for DM646x
Adds driver support for the two instances of McASP on TI's DM646x.
The multichannel audio serial port (McASP) functions as a general-purpose audio serial port optimized for the needs of multichannel audio application.
(http://www.ti.com/litv/pdf/spruer1b).
There are two instances of McASP on DM646x. The McASP0 module includes up to 4 serializers that can be individually enabled to either transmit or receive in different modes. The McASP1 module is limited with only 1 pinned-out serializer that can be enabled to only transmit in DIT mode (neither receiving in any mode nor transmitting in either Burst or TDM mode is supported).
The codec on the DM646x EVM is AIC32 which is connected to Serializer0 and Serializer1 of McASP0. The McASP0 consists of transmit and receive sections that may operate synchronized, or completely independently with separate master clocks, bit clocks, and frame syncs, and using different transmit modes with different bit-stream formats.
---
This patch applies against ALSA mainline - the topic/asoc branch of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git
sound/soc/davinci/Kconfig | 13 + sound/soc/davinci/Makefile | 3 + sound/soc/davinci/davinci-i2s-mcasp.c | 908 +++++++++++++++++++++++++++++++++ sound/soc/davinci/davinci-i2s-mcasp.h | 58 +++ sound/soc/davinci/davinci-pcm.h | 17 +- 5 files changed, 991 insertions(+), 8 deletions(-) create mode 100644 sound/soc/davinci/davinci-i2s-mcasp.c create mode 100644 sound/soc/davinci/davinci-i2s-mcasp.h
sound/soc/davinci/Kconfig +13 -0
@@ -9,6 +9,9 @@ config SND_DAVINCI_SOC config SND_DAVINCI_SOC_I2S tristate +config SND_DAVINCI_SOC_I2S_MCASP + tristate + config SND_DAVINCI_SOC_EVM tristate "SoC Audio support for DaVinci DM6446 or DM355 EVM" depends on SND_DAVINCI_SOC
@@ -19,6 +22,16 @@ config SND_DAVINCI_SOC_EVM Say Y if you want to add support for SoC audio on TI DaVinci DM6446 or DM355 EVM platforms. +config SND_DM6467_SOC_EVM + tristate "SoC Audio support for DaVinci DM6467 EVM" + depends on SND_DAVINCI_SOC && MACH_DAVINCI_DM6467_EVM + select SND_DAVINCI_SOC_I2S_MCASP + select SND_SOC_TLV320AIC3X + select SND_SOC_SPDIF + + help + Say Y if you want to add support for SoC audio on TI + config SND_DAVINCI_SOC_SFFSDR tristate "SoC Audio support for SFFSDR" depends on SND_DAVINCI_SOC && MACH_SFFSDR
sound/soc/davinci/Makefile +3 -0
@@ -1,13 +1,16 @@ # DAVINCI Platform Support snd-soc-davinci-objs := davinci-pcm.o snd-soc-davinci-i2s-objs := davinci-i2s.o +snd-soc-davinci-i2s-mcasp-objs:= davinci-i2s-mcasp.o obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o +obj-$(CONFIG_SND_DAVINCI_SOC_I2S_MCASP) += snd-soc-davinci-i2s-mcasp.o # DAVINCI Machine Support snd-soc-evm-objs := davinci-evm.o snd-soc-sffsdr-objs := davinci-sffsdr.o obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o +obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DAVINCI_SOC_SFFSDR) += snd-soc-sffsdr.o
sound/soc/davinci/davinci-i2s-mcasp.c new file +908 -0
908 lines not on this page · raw message
sound/soc/davinci/davinci-i2s-mcasp.h new file +58 -0
58 lines not on this page · raw message
sound/soc/davinci/davinci-pcm.h +9 -8
@@ -12,17 +12,18 @@#ifndef _DAVINCI_PCM_H#define _DAVINCI_PCM_H +#include <mach/edma.h> +#include <mach/asp.h> + +struct davinci_pcm_dma_params { -char *name;/* stream identifier */ -int channel;/* sync dma channel ID */ -dma_addr_t dma_addr;/* device physical address for DMA */ -unsigned int data_type;/* xfer data type */ +char *name;/* stream identifier */ +int channel;/* sync dma channel ID */ +dma_addr_t dma_addr;/* device physical address for DMA */ +unsigned int data_type;/* xfer data type */ +enum dma_event_q eventq_no;/* event queue number */ }; -struct evm_snd_platform_data { -int tx_dma_ch; -int rx_dma_ch; -};extern struct snd_soc_platform davinci_soc_platform;
Signature · 1 line
1.5.6
Quoted 5 lines · Chaithrika U S
The codec on the DM646x EVM is AIC32 which is connected to Serializer0 and Serializer1 of McASP0. The McASP0 consists of transmit and receive sections that may operate synchronized, or completely independently with separate master clocks, bit clocks, and frame syncs, and using different transmit modes with different bit-stream formats.
The particular configuration used for the EVM should not be relevant for the McASP driver.
sound/soc/davinci/davinci-i2s-mcasp.c line 87
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+/* Left (even TDM Slot) Channel Status Register File*/ +#define DAVINCI_MCASP_DITCSRA_REG 0x100 +/* Right (odd TDM slot) Channel Status RegisterFile*/ +#define DAVINCI_MCASP_DITCSRB_REG 0x118
Interesting spacing in the comments...
sound/soc/davinci/davinci-i2s-mcasp.c line 502
Quoted 7 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +7
-0+case DAVINCI_AUDIO_WORD_32 : + fmt =0x0F ; +break ; + +default : +return -1 ; + }
Should be a real error code.
sound/soc/davinci/davinci-i2s-mcasp.c line 548
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+static void davinci_hw_param (struct snd_pcm_substream *substream) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct davinci_audio_dev *dev = rtd->dai->cpu_dai->private_data;
It might be easier with a lot of these functions to just pass the davinci_audio_dev as a parameter.
sound/soc/davinci/davinci-i2s-mcasp.c line 558
Quoted 3 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +3
-0+if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +/* bit stream is MSB first with no delay */ +/* DSP_B mode */
Your driver consistently refers to itself as an I2S driver but it appears that in actual fact it only implements DSP mode B. This might be a bit confusing for users.
sound/soc/davinci/davinci-i2s-mcasp.c line 608
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+/* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 +and LSB first */ +mcasp_set_bits (dev->base +DAVINCI_MCASP_TXFMT_REG , +TXROT (6 ) |TXSSZ (15 ));
I suspect looking at some of the indentation that you're writing this code with 4 character tabs.
sound/soc/davinci/davinci-i2s-mcasp.c line 747
Quoted 6 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +6
-0+static int davinci_i2s_mcasp_probe (struct platform_device *pdev) +{ +struct evm_snd_platform_data *parray = pdev->dev.platform_data; +struct davinci_pcm_dma_params *dma_data; +struct resource *mem, *ioarea, *res; +struct evm_snd_platform_data *pdata;
Why is the McASP driver using platform data called 'evm_snd_patform_data'? This suggests that there's some abstraction problem with the separation between the machine and McASP drivers.
Are the two DAIs directly tied to each other in hardware? If not it'd probably be better to have them registered as separate devices and probe separately so that if another chip comes along with a different set of DAIs it can be accommodated more readily - if the register interfaces stay consistent it may simply be a case of registering the new device.
sound/soc/davinci/davinci-i2s-mcasp.c line 838
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+ ret =snd_soc_register_dais (davinci_iis_mcasp_dai, +ARRAY_SIZE (davinci_iis_mcasp_dai)); +if (ret !=0 ) + goto err_release_region;
You should initialise dev within the DAI to be the struct device for the platform driver you were probed with. It might also be nice to tie this in to num_links somehow.
Quoted 17 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Saturday, May 30, 2009 9:57 PM
To: Chaithrika U S
Cc: [email protected]; davinci-linux-open- [email protected]; Steve Chen; Naresh Medisetty; Pavel Kiryukhin
Subject: Re: [alsa-devel] [PATCH v3 5/6] ARM: DaVinci: ASoC: Add mcasp support for DM646xQuoted 1 line · Chaithrika U S
The codec on the DM646x EVM is AIC32 which is connected to
Serializer0 and
Quoted 1 line
Serializer1 of McASP0. The McASP0 consists of transmit and receive
sections
Quoted 1 line
that may operate synchronized, or completely independently with
Quoted 8 lines
separate master
Quoted 1 line
clocks, bit clocks, and frame syncs, and using different transmit
modes with
Quoted 1 line
different bit-stream formats.
The particular configuration used for the EVM should not be relevant for
the McASP driver.
Yes, agree.
Quoted 8 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 87
Quoted 5 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+/* Left (even TDM Slot) Channel Status Register File*/ +#define DAVINCI_MCASP_DITCSRA_REG 0x100 +/* Right (odd TDM slot) Channel Status RegisterFile*/ +#define DAVINCI_MCASP_DITCSRB_REG 0x118Interesting spacing in the comments...
Quoted 10 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 502
Quoted 7 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +7
-0+case DAVINCI_AUDIO_WORD_32 : + fmt =0x0F ; +break ; + +default : +return -1 ; + }Should be a real error code.
Agree.
Quoted 7 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 548
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+static void davinci_hw_param (struct snd_pcm_substream *substream) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct davinci_audio_dev *dev = rtd->dai->cpu_dai->private_data;It might be easier with a lot of these functions to just pass the
davinci_audio_devas a parameter.
OK.I will change this wherever possible.
Quoted 9 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 558
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +3
-0+if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +/* bit stream is MSB first with no delay */ +/* DSP_B mode */ Your driver consistently refers to itself as an I2S driver but it appears that in actual fact it only implements DSP mode B. This might be a bit confusing for users.
The hardware supports I2S, DSP A/B modes, currently it is configured in DSP B mode. May be changing all the function names from davinci_i2s_mcasp_XXX() to davinci_mcasp_xxx() will avoid confusion. Along with this, the file names can be changed to davinci-mcasp.c[h].
Quoted 20 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 608
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+/* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 +and LSB first */ +mcasp_set_bits (dev->base +DAVINCI_MCASP_TXFMT_REG , +TXROT (6 ) |TXSSZ (15 ));I suspect looking at some of the indentation that you're writing this code with 4 character tabs.
sound/soc/davinci/davinci-i2s-mcasp.c line 747
Quoted 6 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +6
-0+static int davinci_i2s_mcasp_probe (struct platform_device *pdev) +{ +struct evm_snd_platform_data *parray = pdev->dev.platform_data; +struct davinci_pcm_dma_params *dma_data; +struct resource *mem, *ioarea, *res; +struct evm_snd_platform_data *pdata;Why is the McASP driver using platform data called '
evm_snd_patform_data'?
This suggests that there's some abstraction problem with the separation between the machine and McASP drivers.
Quoted 7 lines
Are the two DAIs directly tied to each other in hardware? If not it'd probably be better to have them registered as separate devices and probe
separately so that if another chip comes along with a different set of DAIs it can be accommodated more readily - if the register interfaces stay consistent it may simply be a case of registering the new device.
Are you referring to the two DAI links in this driver?
They are two instances of the same hardware, therefore tied to each other. For future chips, the instances may change. Therefore, the number of links should come from the platform data and hard coding it to 2 is not right. I will correct this.
Quoted 10 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 838
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+ ret =snd_soc_register_dais (davinci_iis_mcasp_dai, +ARRAY_SIZE (davinci_iis_mcasp_dai)); +if (ret !=0 ) + goto err_release_region;You should initialise dev within the DAI to be the struct device for the
platform driver you were probed with. It might also be nice to tie this
in tonum_linkssomehow.
OK, will look into this.
Regards,
Chaithrika
Mark,
Quoted 12 lines
sound/soc/davinci/davinci-i2s-mcasp.c line 747
Quoted 6 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +6
-0+static int davinci_i2s_mcasp_probe (struct platform_device *pdev) +{ +struct evm_snd_platform_data *parray = pdev->dev.platform_data; +struct davinci_pcm_dma_params *dma_data; +struct resource *mem, *ioarea, *res; +struct evm_snd_platform_data *pdata;Why is the McASP driver using platform data called '
evm_snd_patform_data'?
This suggests that there's some abstraction problem with the separation between the machine and McASP drivers.
The platform data consists of information specific to EVM and SoC and is used by the platform driver (McASP driver) to get relevant data. Therefore it seems right to use the platform data here. Please let me know your opinion.
Regards,
Chaithrika
Quoted 17 lines
Are the two DAIs directly tied to each other in hardware? If not it'd probably be better to have them registered as separate devices and probe
separately so that if another chip comes along with a different set of DAIs it can be accommodated more readily - if the register interfaces stay consistent it may simply be a case of registering the new device.sound/soc/davinci/davinci-i2s-mcasp.c line 838
Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4
-0+ ret =snd_soc_register_dais (davinci_iis_mcasp_dai, +ARRAY_SIZE (davinci_iis_mcasp_dai)); +if (ret !=0 ) + goto err_release_region;You should initialise dev within the DAI to be the struct device for the
platform driver you were probed with. It might also be nice to tie this
in tonum_linkssomehow.
Quoted 9 lines · chaithrika
Quoted 4 lines
Why is the McASP driver using platform data called '
evm_snd_patform_data'?
This suggests that there's some abstraction problem with the separation between the machine and McASP drivers.The platform data consists of information specific to EVM and SoC and is used by the platform driver (McASP driver) to get relevant data. Therefore it seems right to use the platform data here. Please let me know your opinion.
It's not the *use* of platform data, it's the fact that you are calling this *EVM* platform data. This suggests an abstraction issue somewhere along the line - presumably not all machines with these processors are EVMs. Some of the other issues myself and David identified suggest that there are some issues there.
If this is system-specific configuration data purely for the McBSP port it shouldn't mention the EVMs in the name.
Quoted 5 lines · Mark Brown
Quoted 3 lines · chaithrika
Quoted 3 lines
Why is the McASP driver using platform data called '
evm_snd_patform_data'?
This suggests that there's some abstraction problem with the
separation
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
between the machine and McASP drivers.
The platform data consists of information specific to EVM and SoC and is used by the platform driver (McASP driver) to get relevant data. Therefore it seems right to use the platform data here. Please let me know your opinion.
Quoted 9 lines
It's not the *use* of platform data, it's the fact that you are calling this *EVM* platform data. This suggests an abstraction issue somewhere along the line - presumably not all machines with these processors are EVMs. Some of the other issues myself and David identified suggest that there are some issues there.
If this is system-specific configuration data purely for the McBSP port it shouldn't mention the EVMs in the name.
OK. I will rename the structure to 'snd_platform_data'.
Thanks,
Chaithrika