aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorArun KS <arunks@mistralsolutions.com>2008-11-19 07:15:19 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2008-11-19 08:18:59 -0500
commitdf573d2fd1b077b98ffc3eb62a9908075e69e578 (patch)
treee75257d405baef22da3a7310a68b7b0cf10ae770 /sound
parent08bd16869645f435eba6a612d166532b3047c5f7 (diff)
ASoC: Add support for omap2evm board
This patch adds twl4030 audio support on omap2evm Signed-off-by: Arun KS <arunks@mistralsolutions.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/Kconfig9
-rw-r--r--sound/soc/omap/Makefile2
-rw-r--r--sound/soc/omap/omap2evm.c150
3 files changed, 161 insertions, 0 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index cf40e42954af..6c56277e160b 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -30,4 +30,13 @@ config SND_OMAP_SOC_OVERO
30 help 30 help
31 Say Y if you want to add support for SoC audio on the Gumstix Overo. 31 Say Y if you want to add support for SoC audio on the Gumstix Overo.
32 32
33config SND_OMAP_SOC_OMAP2EVM
34 tristate "SoC Audio support for OMAP2EVM board"
35 depends on SND_OMAP_SOC && MACH_OMAP2EVM
36 select SND_OMAP_SOC_MCBSP
37 select SND_SOC_TWL4030
38 help
39 Say Y if you want to add support for SoC audio on the omap2evm board.
40
41
33 42
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
index fefc9bed053a..f5da3cc764ae 100644
--- a/sound/soc/omap/Makefile
+++ b/sound/soc/omap/Makefile
@@ -9,8 +9,10 @@ obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o
9snd-soc-n810-objs := n810.o 9snd-soc-n810-objs := n810.o
10snd-soc-osk5912-objs := osk5912.o 10snd-soc-osk5912-objs := osk5912.o
11snd-soc-overo-objs := overo.o 11snd-soc-overo-objs := overo.o
12snd-soc-omap2evm-objs := omap2evm.o
12 13
13obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o 14obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o
14obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o 15obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o
15obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o 16obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o
17obj-$(CONFIG_MACH_OMAP2EVM) += snd-soc-omap2evm.o
16 18
diff --git a/sound/soc/omap/omap2evm.c b/sound/soc/omap/omap2evm.c
new file mode 100644
index 000000000000..c37621357d00
--- /dev/null
+++ b/sound/soc/omap/omap2evm.c
@@ -0,0 +1,150 @@
1/*
2 * omap2evm.c -- SoC audio machine driver for omap2evm board
3 *
4 * Author: Arun KS <arunks@mistralsolutions.com>
5 *
6 * Based on sound/soc/omap/overo.c by Steve Sakoman
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#include <linux/clk.h>
25#include <linux/platform_device.h>
26#include <sound/core.h>
27#include <sound/pcm.h>
28#include <sound/soc.h>
29#include <sound/soc-dapm.h>
30
31#include <asm/mach-types.h>
32#include <mach/hardware.h>
33#include <mach/gpio.h>
34#include <mach/mcbsp.h>
35
36#include "omap-mcbsp.h"
37#include "omap-pcm.h"
38#include "../codecs/twl4030.h"
39
40static int omap2evm_hw_params(struct snd_pcm_substream *substream,
41 struct snd_pcm_hw_params *params)
42{
43 struct snd_soc_pcm_runtime *rtd = substream->private_data;
44 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
45 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
46 int ret;
47
48 /* Set codec DAI configuration */
49 ret = snd_soc_dai_set_fmt(codec_dai,
50 SND_SOC_DAIFMT_I2S |
51 SND_SOC_DAIFMT_NB_NF |
52 SND_SOC_DAIFMT_CBM_CFM);
53 if (ret < 0) {
54 printk(KERN_ERR "can't set codec DAI configuration\n");
55 return ret;
56 }
57
58 /* Set cpu DAI configuration */
59 ret = snd_soc_dai_set_fmt(cpu_dai,
60 SND_SOC_DAIFMT_I2S |
61 SND_SOC_DAIFMT_NB_NF |
62 SND_SOC_DAIFMT_CBM_CFM);
63 if (ret < 0) {
64 printk(KERN_ERR "can't set cpu DAI configuration\n");
65 return ret;
66 }
67
68 /* Set the codec system clock for DAC and ADC */
69 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
70 SND_SOC_CLOCK_IN);
71 if (ret < 0) {
72 printk(KERN_ERR "can't set codec system clock\n");
73 return ret;
74 }
75
76 return 0;
77}
78
79static struct snd_soc_ops omap2evm_ops = {
80 .hw_params = omap2evm_hw_params,
81};
82
83/* Digital audio interface glue - connects codec <--> CPU */
84static struct snd_soc_dai_link omap2evm_dai = {
85 .name = "TWL4030",
86 .stream_name = "TWL4030",
87 .cpu_dai = &omap_mcbsp_dai[0],
88 .codec_dai = &twl4030_dai,
89 .ops = &omap2evm_ops,
90};
91
92/* Audio machine driver */
93static struct snd_soc_machine snd_soc_machine_omap2evm = {
94 .name = "omap2evm",
95 .dai_link = &omap2evm_dai,
96 .num_links = 1,
97};
98
99/* Audio subsystem */
100static struct snd_soc_device omap2evm_snd_devdata = {
101 .machine = &snd_soc_machine_omap2evm,
102 .platform = &omap_soc_platform,
103 .codec_dev = &soc_codec_dev_twl4030,
104};
105
106static struct platform_device *omap2evm_snd_device;
107
108static int __init omap2evm_soc_init(void)
109{
110 int ret;
111
112 if (!machine_is_omap2evm()) {
113 pr_debug("Not omap2evm!\n");
114 return -ENODEV;
115 }
116 printk(KERN_INFO "omap2evm SoC init\n");
117
118 omap2evm_snd_device = platform_device_alloc("soc-audio", -1);
119 if (!omap2evm_snd_device) {
120 printk(KERN_ERR "Platform device allocation failed\n");
121 return -ENOMEM;
122 }
123
124 platform_set_drvdata(omap2evm_snd_device, &omap2evm_snd_devdata);
125 omap2evm_snd_devdata.dev = &omap2evm_snd_device->dev;
126 *(unsigned int *)omap2evm_dai.cpu_dai->private_data = 1; /* McBSP2 */
127
128 ret = platform_device_add(omap2evm_snd_device);
129 if (ret)
130 goto err1;
131
132 return 0;
133
134err1:
135 printk(KERN_ERR "Unable to add platform device\n");
136 platform_device_put(omap2evm_snd_device);
137
138 return ret;
139}
140module_init(omap2evm_soc_init);
141
142static void __exit omap2evm_soc_exit(void)
143{
144 platform_device_unregister(omap2evm_snd_device);
145}
146module_exit(omap2evm_soc_exit);
147
148MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
149MODULE_DESCRIPTION("ALSA SoC omap2evm");
150MODULE_LICENSE("GPL");