2 * igep0020.c -- SoC audio for IGEP v2
4 * Based on sound/soc/omap/overo.c by Steve Sakoman
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include <linux/clk.h>
23 #include <linux/platform_device.h>
24 #include <sound/core.h>
25 #include <sound/pcm.h>
26 #include <sound/soc.h>
27 #include <sound/soc-dapm.h>
29 #include <asm/mach-types.h>
30 #include <mach/hardware.h>
31 #include <mach/gpio.h>
32 #include <plat/mcbsp.h>
34 #include "omap-mcbsp.h"
36 #include "../codecs/twl4030.h"
38 static int igep2_hw_params(struct snd_pcm_substream
*substream
,
39 struct snd_pcm_hw_params
*params
)
41 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
42 struct snd_soc_dai
*codec_dai
= rtd
->dai
->codec_dai
;
43 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
46 /* Set codec DAI configuration */
47 ret
= snd_soc_dai_set_fmt(codec_dai
,
49 SND_SOC_DAIFMT_NB_NF
|
50 SND_SOC_DAIFMT_CBM_CFM
);
52 printk(KERN_ERR
"can't set codec DAI configuration\n");
56 /* Set cpu DAI configuration */
57 ret
= snd_soc_dai_set_fmt(cpu_dai
,
59 SND_SOC_DAIFMT_NB_NF
|
60 SND_SOC_DAIFMT_CBM_CFM
);
62 printk(KERN_ERR
"can't set cpu DAI configuration\n");
66 /* Set the codec system clock for DAC and ADC */
67 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, 26000000,
70 printk(KERN_ERR
"can't set codec system clock\n");
77 static struct snd_soc_ops igep2_ops
= {
78 .hw_params
= igep2_hw_params
,
81 /* Digital audio interface glue - connects codec <--> CPU */
82 static struct snd_soc_dai_link igep2_dai
= {
84 .stream_name
= "TWL4030",
85 .cpu_dai
= &omap_mcbsp_dai
[0],
86 .codec_dai
= &twl4030_dai
[TWL4030_DAI_HIFI
],
90 /* Audio machine driver */
91 static struct snd_soc_card snd_soc_card_igep2
= {
93 .platform
= &omap_soc_platform
,
94 .dai_link
= &igep2_dai
,
99 static struct snd_soc_device igep2_snd_devdata
= {
100 .card
= &snd_soc_card_igep2
,
101 .codec_dev
= &soc_codec_dev_twl4030
,
104 static struct platform_device
*igep2_snd_device
;
106 static int __init
igep2_soc_init(void)
110 if (!machine_is_igep0020()) {
111 pr_debug("Not IGEP v2!\n");
114 printk(KERN_INFO
"IGEP v2 SoC init\n");
116 igep2_snd_device
= platform_device_alloc("soc-audio", -1);
117 if (!igep2_snd_device
) {
118 printk(KERN_ERR
"Platform device allocation failed\n");
122 platform_set_drvdata(igep2_snd_device
, &igep2_snd_devdata
);
123 igep2_snd_devdata
.dev
= &igep2_snd_device
->dev
;
124 *(unsigned int *)igep2_dai
.cpu_dai
->private_data
= 1; /* McBSP2 */
126 ret
= platform_device_add(igep2_snd_device
);
133 printk(KERN_ERR
"Unable to add platform device\n");
134 platform_device_put(igep2_snd_device
);
138 module_init(igep2_soc_init
);
140 static void __exit
igep2_soc_exit(void)
142 platform_device_unregister(igep2_snd_device
);
144 module_exit(igep2_soc_exit
);
146 MODULE_AUTHOR("Enric Balletbo i Serra <eballetbo@iseebcn.com>");
147 MODULE_DESCRIPTION("ALSA SoC IGEP v2");
148 MODULE_LICENSE("GPL");