1 From c1dad0b6b434300ae64c902d11611c54c513ea10 Mon Sep 17 00:00:00 2001
2 From: Anuj Aggarwal <anuj.aggarwal@ti.com>
3 Date: Fri, 21 Nov 2008 17:41:03 +0530
4 Subject: [PATCH] ASoC: Add support for OMAP3 EVM
6 This patch adds ALSA SoC support for OMAP3 EVM using TWL4030 audio codec.
8 Signed-off-by: Anuj Aggarwal <anuj.aggarwal@ti.com>
10 sound/soc/omap/Kconfig | 8 +++
11 sound/soc/omap/Makefile | 3 +-
12 sound/soc/omap/omap3evm.c | 147 +++++++++++++++++++++++++++++++++++++++++++++
13 3 files changed, 157 insertions(+), 1 deletions(-)
14 create mode 100644 sound/soc/omap/omap3evm.c
16 diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
17 index 0daeee4..deb6ba9 100644
18 --- a/sound/soc/omap/Kconfig
19 +++ b/sound/soc/omap/Kconfig
20 @@ -22,6 +22,14 @@ config SND_OMAP_SOC_OMAP3_BEAGLE
22 Say Y if you want to add support for SoC audio on the Beagleboard.
24 +config SND_OMAP_SOC_OMAP3EVM
25 + tristate "SoC Audio support for OMAP3EVM board"
26 + depends on SND_OMAP_SOC && MACH_OMAP3EVM
27 + select SND_OMAP_SOC_MCBSP
28 + select SND_SOC_TWL4030
30 + Say Y if you want to add support for SoC audio on the omap3evm board.
32 config SND_OMAP_SOC_OSK5912
33 tristate "SoC Audio support for omap osk5912"
34 depends on SND_OMAP_SOC && MACH_OMAP_OSK
35 diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
36 index 4bae404..ef31c25 100644
37 --- a/sound/soc/omap/Makefile
38 +++ b/sound/soc/omap/Makefile
39 @@ -10,9 +10,10 @@ snd-soc-n810-objs := n810.o
40 snd-soc-omap3beagle-objs := omap3beagle.o
41 snd-soc-osk5912-objs := osk5912.o
42 snd-soc-overo-objs := overo.o
43 +snd-soc-omap3evm-objs := omap3evm.o
45 obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o
46 obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o
47 obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o
48 obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o
50 +obj-$(CONFIG_MACH_OMAP3EVM) += snd-soc-omap3evm.o
51 diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c
53 index 0000000..570af55
55 +++ b/sound/soc/omap/omap3evm.c
58 + * omap3evm.c -- ALSA SoC support for OMAP3 EVM
60 + * Author: Anuj Aggarwal <anuj.aggarwal@ti.com>
62 + * Based on sound/soc/omap/beagle.c by Steve Sakoman
64 + * Copyright (C) 2008 Texas Instruments, Incorporated
66 + * This program is free software; you can redistribute it and/or modify it
67 + * under the terms of the GNU General Public License as published by the
68 + * Free Software Foundation version 2.
70 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
71 + * whether express or implied; without even the implied warranty of
72 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
73 + * General Public License for more details.
76 +#include <linux/clk.h>
77 +#include <linux/platform_device.h>
78 +#include <sound/core.h>
79 +#include <sound/pcm.h>
80 +#include <sound/soc.h>
81 +#include <sound/soc-dapm.h>
83 +#include <asm/mach-types.h>
84 +#include <mach/hardware.h>
85 +#include <mach/gpio.h>
86 +#include <mach/mcbsp.h>
88 +#include "omap-mcbsp.h"
89 +#include "omap-pcm.h"
90 +#include "../codecs/twl4030.h"
92 +static int omap3evm_hw_params(struct snd_pcm_substream *substream,
93 + struct snd_pcm_hw_params *params)
95 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
96 + struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
97 + struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
100 + /* Set codec DAI configuration */
101 + ret = snd_soc_dai_set_fmt(codec_dai,
102 + SND_SOC_DAIFMT_I2S |
103 + SND_SOC_DAIFMT_NB_NF |
104 + SND_SOC_DAIFMT_CBM_CFM);
106 + printk(KERN_ERR "can't set codec DAI configuration\n");
110 + /* Set cpu DAI configuration */
111 + ret = snd_soc_dai_set_fmt(cpu_dai,
112 + SND_SOC_DAIFMT_I2S |
113 + SND_SOC_DAIFMT_NB_NF |
114 + SND_SOC_DAIFMT_CBM_CFM);
116 + printk(KERN_ERR "can't set cpu DAI configuration\n");
120 + /* Set the codec system clock for DAC and ADC */
121 + ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
124 + printk(KERN_ERR "can't set codec system clock\n");
131 +static struct snd_soc_ops omap3evm_ops = {
132 + .hw_params = omap3evm_hw_params,
135 +/* Digital audio interface glue - connects codec <--> CPU */
136 +static struct snd_soc_dai_link omap3evm_dai = {
138 + .stream_name = "TWL4030",
139 + .cpu_dai = &omap_mcbsp_dai[0],
140 + .codec_dai = &twl4030_dai,
141 + .ops = &omap3evm_ops,
144 +/* Audio machine driver */
145 +static struct snd_soc_machine snd_soc_machine_omap3evm = {
146 + .name = "omap3evm",
147 + .dai_link = &omap3evm_dai,
151 +/* Audio subsystem */
152 +static struct snd_soc_device omap3evm_snd_devdata = {
153 + .machine = &snd_soc_machine_omap3evm,
154 + .platform = &omap_soc_platform,
155 + .codec_dev = &soc_codec_dev_twl4030,
158 +static struct platform_device *omap3evm_snd_device;
160 +static int __init omap3evm_soc_init(void)
164 + if (!machine_is_omap3evm()) {
165 + pr_debug("Not OMAP3 EVM!\n");
168 + pr_info("OMAP3 EVM SoC init\n");
170 + omap3evm_snd_device = platform_device_alloc("soc-audio", -1);
171 + if (!omap3evm_snd_device) {
172 + printk(KERN_ERR "Platform device allocation failed\n");
176 + platform_set_drvdata(omap3evm_snd_device, &omap3evm_snd_devdata);
177 + omap3evm_snd_devdata.dev = &omap3evm_snd_device->dev;
178 + *(unsigned int *)omap3evm_dai.cpu_dai->private_data = 1; /* McBSP2 */
180 + ret = platform_device_add(omap3evm_snd_device);
187 + printk(KERN_ERR "Unable to add platform device\n");
188 + platform_device_put(omap3evm_snd_device);
193 +static void __exit omap3evm_soc_exit(void)
195 + platform_device_unregister(omap3evm_snd_device);
198 +module_init(omap3evm_soc_init);
199 +module_exit(omap3evm_soc_exit);
201 +MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
202 +MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM");
203 +MODULE_LICENSE("GPL");