Skip to contentSkip to conversation

ARM: DaVinci: ASoC: Add mcasp support for DM646x

PATCH In review Naresh Medisetty 2 participants 2 messages Apr 2, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 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 - that's the topic/asoc branch of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

 sound/soc/davinci/Kconfig             |   12 +
 sound/soc/davinci/Makefile            |    3 +
 sound/soc/davinci/davinci-i2s-mcasp.c |  877 +++++++++++++++++++++++++++++++++
 sound/soc/davinci/davinci-i2s-mcasp.h |   56 +++
 sound/soc/davinci/davinci-pcm.h       |   17 +-
 5 files changed, 957 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 +12 -0
index bd7392c..7f35baa 100644
@@ -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 EVM"
 	depends on SND_DAVINCI_SOC && MACH_DAVINCI_EVM
@@ -18,6 +21,15 @@ config SND_DAVINCI_SOC_EVM
 	  Say Y if you want to add support for SoC audio on TI
 	  DaVinci EVM platform.
 
+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
+        help
+          Say Y if you want to add support for SoC audio on TI
+          DaVinci DM6467 EVM platform.
+
 config SND_DAVINCI_SOC_SFFSDR
 	tristate "SoC Audio support for SFFSDR"
 	depends on SND_DAVINCI_SOC && MACH_SFFSDR
sound/soc/davinci/Makefile +3 -0
index ca8bae1..152d59c 100644
@@ -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 +877 -0

877 lines not on this page · raw message

sound/soc/davinci/davinci-i2s-mcasp.h new file +56 -0

56 lines not on this page · raw message

sound/soc/davinci/davinci-pcm.h +9 -8
index 62cb4eb..3cbe281 100644
@@ -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
#1 lore raw

On Thu, Apr 02, 2009 at 09:47:18PM -0400, Naresh Medisetty wrote:

This all looks pretty good - the comments below are all pretty small, mostly coding style and questions.

sound/soc/davinci/davinci-i2s-mcasp.c line 317

Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4 -0
+
+	/* programming GBLCTL needs to read back from GBLCTL and verfiy */
+	/* loop count is to avoid the lock-up */
+	for (i = 0; (i < 1000) && ((mcasp_get_reg(regs) & val) != val); i++);

Should this warn if the loop times out? For legibility I'd rewrite as:

	for (i = 0; i < 1000; i++)
		if ((mcasp_get_reg(regs) & val) == val)
			break;

The ; should be on a separate line at least.

sound/soc/davinci/davinci-i2s-mcasp.c line 328

Quoted 8 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +8 -0
+int davinci_i2s_startup(struct snd_pcm_substream *substream,
+							struct snd_soc_dai *dai)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+	struct davinci_audio_dev *dev = rtd->dai->cpu_dai->private_data;
+
+	cpu_dai->dma_data = dev->dma_params[substream->stream];

cpu_dai is passed in as the dai parameter, no need to look it up like this (in the past it wasn't - most of the code hasn't yet been fixed up to take advantage of this yet).

sound/soc/davinci/davinci-i2s-mcasp.c line 334

Quoted 2 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +2 -0
+int davinci_i2s_mcasp_probe(struct platform_device *pdev,
+							struct snd_soc_dai *dai)

Indentation?

sound/soc/davinci/davinci-i2s-mcasp.c line 359

Quoted 11 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +11 -0
+		mem = platform_get_resource(pdev, IORESOURCE_MEM, link_cnt);
+		if (!mem) {
+			dev_err(&pdev->dev, "no mem resource?\n");
+			ret = -ENODEV;
+		}
+		ioarea = request_mem_region(mem->start,
+				(mem->end - mem->start) + 1, pdev->name);
+		if (!ioarea) {
+			dev_err(&pdev->dev, "Audio region already claimed\n");
+			ret = -EBUSY;
+		}

Should these be jumping to the unwind code?

sound/soc/davinci/davinci-i2s-mcasp.c line 366

Quoted 7 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +7 -0
+
+		dev = kzalloc(sizeof(struct davinci_audio_dev) *
+			card->num_links, GFP_KERNEL);
+		if (!dev) {
+			return	-ENOMEM;
+			goto err_release_region;
+		}

return followed by goto?

sound/soc/davinci/davinci-i2s-mcasp.c line 370

Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4 -0
+		dma_data = kzalloc(sizeof(struct davinci_pcm_dma_params) *
+					(card->num_links << 1), GFP_KERNEL);
+		if (!dma_data)
+				goto err_release_dev;

Do you need to set ret here?

sound/soc/davinci/davinci-i2s-mcasp.c line 659

Quoted 3 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +3 -0
+	}
+}
+static void davinci_hw_iis_param(struct snd_pcm_substream *substream)

Blank line between functions, please.

sound/soc/davinci/davinci-i2s-mcasp.c line 673

Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4 -0
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		/* bit stream is MSB first */
+		mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG,
+				AHCLKXE);

For I2S you should have one BCLK before MSB - is that happening (it may well be, I've no knowledge of your hardware)?

sound/soc/davinci/davinci-i2s-mcasp.c line 690

Quoted 4 lines
sound/soc/davinci/davinci-i2s-mcasp.c new file +4 -0
+	} else {
+		/* bit stream is MSB first with no delay */
+		mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG,
+				FSRDLY(1) | RXORD);

The comment and code don't look like they match up (but again, I don't have any knowledge of this specific hardware).