From: David Brownell <[EMAIL PROTECTED]>

Teach the "davinci-evm" ASoC support to handle both DM6446
and DM355 EVM boards by recognizing which board they're using,
then setting up appropropriately.

The only particularly ugly bit here is clock handling, where
we need to "know" the right clock name to use.  This solution
is simple, but may not work on some yet-to-be-seen boards
that would want "McBSPCLK0".

Note that this includes a minor bugfix:  now that DaVinci
kernels can support multiple boards, board-specific ASoC
components need to verify they're running on the right
board before initializing.

Signed-off-by: David Brownell <[EMAIL PROTECTED]>
---
No, not tested beyond building on top of the other patches.
Looks pleasantly compact though.  :)

 sound/soc/davinci/Kconfig       |    7 ++++---
 sound/soc/davinci/davinci-evm.c |   38 ++++++++++++++++++++++++++++++++++----
 sound/soc/davinci/davinci-i2s.c |    6 +++++-
 3 files changed, 43 insertions(+), 8 deletions(-)

--- a/sound/soc/davinci/Kconfig
+++ b/sound/soc/davinci/Kconfig
@@ -10,13 +10,14 @@ config SND_DAVINCI_SOC_I2S
        tristate
 
 config SND_DAVINCI_SOC_EVM
-       tristate "SoC Audio support for DaVinci EVM"
-       depends on SND_DAVINCI_SOC && MACH_DAVINCI_EVM
+       tristate "SoC Audio support for DaVinci DM6446 or DM355 EVM"
+       depends on SND_DAVINCI_SOC
+       depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM
        select SND_DAVINCI_SOC_I2S
        select SND_SOC_TLV320AIC3X
        help
          Say Y if you want to add support for SoC audio on TI
-         DaVinci EVM platform.
+         DaVinci DM6446 or DM355 EVM platforms.
 
 config SND_DAVINCI_SOC_SFFSDR
        tristate "SoC Audio support for SFFSDR"
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -20,6 +20,8 @@
 #include <sound/soc-dapm.h>
 
 #include <asm/dma.h>
+#include <asm/mach-types.h>
+
 #include <mach/asp.h>
 #include <mach/edma.h>
 
@@ -149,6 +151,7 @@ static struct snd_soc_device evm_snd_dev
        .codec_data = &evm_aic3x_setup,
 };
 
+/* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */
 static struct resource evm_snd_resources[] = {
        {
                .start = DAVINCI_ASP0_BASE,
@@ -162,22 +165,49 @@ static struct evm_snd_platform_data evm_
        .rx_dma_ch      = DAVINCI_DMA_ASP0_RX,
 };
 
+/* DM335 EVM uses ASP1; line-out is a stereo mini-jack */
+static struct resource dm335evm_snd_resources[] = {
+       {
+               .start = DAVINCI_ASP1_BASE,
+               .end = DAVINCI_ASP1_BASE + SZ_8K - 1,
+               .flags = IORESOURCE_MEM,
+       },
+};
+
+static struct evm_snd_platform_data dm335evm_snd_data = {
+       .tx_dma_ch      = DAVINCI_DMA_ASP1_TX,
+       .rx_dma_ch      = DAVINCI_DMA_ASP1_RX,
+};
+
 static struct platform_device *evm_snd_device;
 
 static int __init evm_init(void)
 {
+       struct resource *resources;
+       struct evm_snd_platform_data *data;
+       int index;
        int ret;
 
-       evm_snd_device = platform_device_alloc("soc-audio", 0);
+       if (machine_is_davinci_evm()) {
+               resources = evm_snd_resources;
+               data = &evm_snd_data;
+               index = 0;
+       } else if (machine_is_davinci_dm355_evm()) {
+               resources = dm335evm_snd_resources;
+               data = &dm335evm_snd_data;
+               index = 1;
+       } 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;
-       evm_snd_device->dev.platform_data = &evm_snd_data;
+       evm_snd_device->dev.platform_data = data;
 
-       ret = platform_device_add_resources(evm_snd_device, evm_snd_resources,
-                                           ARRAY_SIZE(evm_snd_resources));
+       ret = platform_device_add_resources(evm_snd_device, resources, 1);
        if (ret) {
                platform_device_put(evm_snd_device);
                return ret;
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -401,6 +401,10 @@ static int davinci_i2s_probe(struct plat
        struct resource *mem, *ioarea;
        struct evm_snd_platform_data *pdata;
        int ret;
+       static const char *clocks[] = { "McBSPCLK", "McBSPCLK1", };
+
+       if (pdev->id < 0 || pdev->id > ARRAY_SIZE(clocks))
+               return -EINVAL;
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!mem) {
@@ -423,7 +427,7 @@ static int davinci_i2s_probe(struct plat
 
        cpu_dai->private_data = dev;
 
-       dev->clk = clk_get(&pdev->dev, "McBSPCLK");
+       dev->clk = clk_get(&pdev->dev, clocks[pdev->id]);
        if (IS_ERR(dev->clk)) {
                ret = -ENODEV;
                goto err_free_mem;

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to