2 * omap2evm.c -- SoC audio machine driver for omap2evm board
4 * Author: Arun KS <arunks@mistralsolutions.com>
6 * Based on sound/soc/omap/overo.c by Steve Sakoman
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.
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.
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
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>
31 #include <asm/mach-types.h>
32 #include <mach/hardware.h>
33 #include <mach/gpio.h>
34 #include <mach/mcbsp.h>
36 #include "omap-mcbsp.h"
38 #include "../codecs/twl4030.h"
40 static int omap2evm_hw_params(struct snd_pcm_substream
*substream
,
41 struct snd_pcm_hw_params
*params
)
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
;
48 /* Set codec DAI configuration */
49 ret
= snd_soc_dai_set_fmt(codec_dai
,
51 SND_SOC_DAIFMT_NB_NF
|
52 SND_SOC_DAIFMT_CBM_CFM
);
54 printk(KERN_ERR
"can't set codec DAI configuration\n");
58 /* Set cpu DAI configuration */
59 ret
= snd_soc_dai_set_fmt(cpu_dai
,
61 SND_SOC_DAIFMT_NB_NF
|
62 SND_SOC_DAIFMT_CBM_CFM
);
64 printk(KERN_ERR
"can't set cpu DAI configuration\n");
68 /* Set the codec system clock for DAC and ADC */
69 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, 26000000,
72 printk(KERN_ERR
"can't set codec system clock\n");
79 static struct snd_soc_ops omap2evm_ops
= {
80 .hw_params
= omap2evm_hw_params
,
83 /* Digital audio interface glue - connects codec <--> CPU */
84 static struct snd_soc_dai_link omap2evm_dai
= {
86 .stream_name
= "TWL4030",
87 .cpu_dai
= &omap_mcbsp_dai
[0],
88 .codec_dai
= &twl4030_dai
,
92 /* Audio machine driver */
93 static struct snd_soc_card snd_soc_omap2evm
= {
95 .dai_link
= &omap2evm_dai
,
100 static struct snd_soc_device omap2evm_snd_devdata
= {
101 .card
= &snd_soc_omap2evm
,
102 .platform
= &omap_soc_platform
,
103 .codec_dev
= &soc_codec_dev_twl4030
,
106 static struct platform_device
*omap2evm_snd_device
;
108 static int __init
omap2evm_soc_init(void)
112 if (!machine_is_omap2evm()) {
113 pr_debug("Not omap2evm!\n");
116 printk(KERN_INFO
"omap2evm SoC init\n");
118 omap2evm_snd_device
= platform_device_alloc("soc-audio", -1);
119 if (!omap2evm_snd_device
) {
120 printk(KERN_ERR
"Platform device allocation failed\n");
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 */
128 ret
= platform_device_add(omap2evm_snd_device
);
135 printk(KERN_ERR
"Unable to add platform device\n");
136 platform_device_put(omap2evm_snd_device
);
140 module_init(omap2evm_soc_init
);
142 static void __exit
omap2evm_soc_exit(void)
144 platform_device_unregister(omap2evm_snd_device
);
146 module_exit(omap2evm_soc_exit
);
148 MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
149 MODULE_DESCRIPTION("ALSA SoC omap2evm");
150 MODULE_LICENSE("GPL");