Skip to contentSkip to conversation

ARM: DaVinci: ASoC: Add machine driver support for DM646x

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

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

PATCH v2 5/6 ARM: DaVinci: ASoC: Add machine driver support for DM646x

From: Naresh.Medisetty <[email protected]>

This patch does the following:
(1) Add support for the DM646x machine
(2)Modifications required to introduce the platform driver model to get platform data for all the machines including dm355 and dm644x.

---
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/davinci-evm.c |   99 ++++++++++++++++++++++++++++-----------
 1 files changed, 72 insertions(+), 27 deletions(-)
sound/soc/davinci/davinci-evm.c +72 -27
index 9b90b34..bb26abe 100644
@@ -20,11 +20,19 @@
 #include <sound/soc-dapm.h>
 
 #include <asm/dma.h>
-#include <mach/hardware.h>
+#include <asm/mach-types.h>
+
+#include <mach/asp.h>
+#include <mach/edma.h>
+#include <mach/mux.h>
+#include <mach/cpu.h>
+
 
 #include "../codecs/tlv320aic3x.h"
+#include "../codecs/spdif_transciever.h"
 #include "davinci-pcm.h"
 #include "davinci-i2s.h"
+#include "davinci-i2s-mcasp.h"
 
 
 #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
@@ -39,7 +47,7 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
 	unsigned sysclk;
 
 	/* ASP1 on DM355 EVM is clocked by an external oscillator */
-	if (machine_is_davinci_dm355_evm())
+	if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm())
 		sysclk = 27000000;
 
 	/* ASP0 in DM6446 EVM is clocked by U55, as configured by
@@ -140,6 +148,25 @@ static struct snd_soc_dai_link evm_dai = {
 	.ops = &evm_ops,
 };
 
+static struct snd_soc_dai_link dm6467_evm_dai[] = {
+	{
+		.name = "TLV320AIC3X",
+		.stream_name = "AIC3X",
+		.cpu_dai = davinci_iis_mcasp_dai,
+		.codec_dai = &aic3x_dai,
+		.init = evm_aic3x_init,
+		.ops = &evm_ops,
+	},
+	{
+		.name = "MCASP S/PDIF",
+		.stream_name = "spdif",
+		.cpu_dai = &davinci_iis_mcasp_dai[1],
+		.codec_dai = &dit_stub_dai,
+		.ops = &evm_ops,
+	},
+};
+
+
 /* davinci-evm audio machine driver */
 static struct snd_soc_card snd_soc_card_evm = {
 	.name = "DaVinci EVM",
@@ -148,12 +175,27 @@ static struct snd_soc_card snd_soc_card_evm = {
 	.num_links = 1,
 };
 
+/* davinci dm6467 evm audio machine driver */
+static struct snd_soc_card dm6467_snd_soc_card_evm = {
+		.name = "DaVinci DM6467 EVM",
+		.platform = &davinci_soc_platform,
+		.dai_link = dm6467_evm_dai,
+		.num_links = 2,
+};
+
 /* evm audio private data */
 static struct aic3x_setup_data evm_aic3x_setup = {
-	.i2c_bus = 0,
+	.i2c_bus = 1,
 	.i2c_address = 0x1b,
 };
 
+/* dm6467 evm audio private data */
+static struct aic3x_setup_data dm6467_evm_aic3x_setup = {
+       .i2c_bus = 1,
+       .i2c_address = 0x18,
+};
+
+
 /* evm audio subsystem */
 static struct snd_soc_device evm_snd_devdata = {
 	.card = &snd_soc_card_evm,
@@ -161,51 +203,54 @@ static struct snd_soc_device evm_snd_devdata = {
 	.codec_data = &evm_aic3x_setup,
 };
 
-static struct resource evm_snd_resources[] = {
-	{
-		.start = DAVINCI_MCBSP_BASE,
-		.end = DAVINCI_MCBSP_BASE + SZ_8K - 1,
-		.flags = IORESOURCE_MEM,
-	},
-};
-
-static struct evm_snd_platform_data evm_snd_data = {
-	.tx_dma_ch	= DM644X_DMACH_MCBSP_TX,
-	.rx_dma_ch	= DM644X_DMACH_MCBSP_RX,
+/* evm audio subsystem */
+static struct snd_soc_device dm6467_evm_snd_devdata = {
+	.card = &dm6467_snd_soc_card_evm,
+	.codec_dev = &soc_codec_dev_aic3x,
+	.codec_data = &dm6467_evm_aic3x_setup,
 };
 
 static struct platform_device *evm_snd_device;
 
 static int __init evm_init(void)
 {
+	struct snd_soc_device *evm_snd_dev_data;
+	int index;
 	int ret;
 
-	evm_snd_device = platform_device_alloc("soc-audio", 0);
+	if (machine_is_davinci_evm()) {
+		davinci_cfg_reg(DM644X_MCBSP);
+		evm_snd_dev_data = &evm_snd_devdata;
+		index = 0;
+	} else if (machine_is_davinci_dm355_evm()) {
+		/* we don't use ASP1 IRQs, or we'd need to mux them ... */
+		davinci_cfg_reg(DM355_EVT8_ASP1_TX);
+		davinci_cfg_reg(DM355_EVT9_ASP1_RX);
+		evm_snd_dev_data = &evm_snd_devdata;
+		index = 1;
+	} else if (machine_is_davinci_dm6467_evm()) {
+		evm_snd_dev_data = &dm6467_evm_snd_devdata;
+		index = 0;
+	} else
+		return -EINVAL;
+	evm_snd_device = platform_device_alloc("soc-audio", index);
 	if (!evm_snd_device)
 		return -ENOMEM;
 
-	platform_set_drvdata(evm_snd_device, &evm_snd_devdata);
-	evm_snd_devdata.dev = &evm_snd_device->dev;
-	platform_device_add_data(evm_snd_device, &evm_snd_data,
-				 sizeof(evm_snd_data));
-
-	ret = platform_device_add_resources(evm_snd_device, evm_snd_resources,
-					    ARRAY_SIZE(evm_snd_resources));
-	if (ret) {
-		platform_device_put(evm_snd_device);
-		return ret;
-	}
-
+	platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
+	evm_snd_dev_data->dev = &evm_snd_device->dev;
 	ret = platform_device_add(evm_snd_device);
 	if (ret)
 		platform_device_put(evm_snd_device);
 
 	return ret;
+
 }
 
 static void __exit evm_exit(void)
 {
 	platform_device_unregister(evm_snd_device);
+
 }
 
 module_init(evm_init);
Signature · 1 line
1.5.6
#1 lore raw

sound/soc/davinci/davinci-evm.c static struct snd_soc_dai_link evm_dai = { · line 155

Quoted 5 lines · Naresh Medisetty
sound/soc/davinci/davinci-evm.c +5 -0
+static struct snd_soc_dai_link dm6467_evm_dai[] = {
+	{
+		.name = "TLV320AIC3X",
+		.stream_name = "AIC3X",
+		.cpu_dai = davinci_iis_mcasp_dai,

It'd be better to refer to the element in the array here. It'd also be better if your DAI driver provided constants which the machine drivers could use to get the array indexes rather than hard coding them.

sound/soc/davinci/davinci-evm.c static struct snd_soc_dai_link evm_dai = { · line 161

Quoted 1 line
sound/soc/davinci/davinci-evm.c +1 -0
+		.name = "MCASP S/PDIF",

McASP instead? These names are mostly for human consumption.

sound/soc/davinci/davinci-evm.c static struct snd_soc_card snd_soc_card_evm = { · line 183

Quoted 6 lines
sound/soc/davinci/davinci-evm.c +6 -0
+/* davinci dm6467 evm audio machine driver */
+static struct snd_soc_card dm6467_snd_soc_card_evm = {
+		.name = "DaVinci DM6467 EVM",
+		.platform = &davinci_soc_platform,
+		.dai_link = dm6467_evm_dai,
+		.num_links = 2,

ARRAY_SIZE().

sound/soc/davinci/davinci-evm.c static struct snd_soc_card snd_soc_card_evm = { · line 190

Quoted 6 lines

/* evm audio private data */
static struct aic3x_setup_data evm_aic3x_setup = {

sound/soc/davinci/davinci-evm.c +1 -1
-	.i2c_bus = 0,
+	.i2c_bus = 1,
 	.i2c_address = 0x1b,
 };

This looks like a separate bug fix which should be split out and sent for merge in 2.6.30?

sound/soc/davinci/davinci-evm.c static struct snd_soc_device evm_snd_devdata = { · line 254

Quoted 5 lines

static void __exit evm_exit(void)
{

sound/soc/davinci/davinci-evm.c +1 -0
 	platform_device_unregister(evm_snd_device);
+
 }

Extra blank line added here.