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>
28 #include <asm/mach-types.h>
29 #include <mach/hardware.h>
30 #include <mach/gpio.h>
31 #include <plat/mcbsp.h>
33 #include "omap-mcbsp.h"
36 static int igep2_hw_params(struct snd_pcm_substream
*substream
,
37 struct snd_pcm_hw_params
*params
)
39 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
40 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
41 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
44 /* Set codec DAI configuration */
45 ret
= snd_soc_dai_set_fmt(codec_dai
,
47 SND_SOC_DAIFMT_NB_NF
|
48 SND_SOC_DAIFMT_CBM_CFM
);
50 printk(KERN_ERR
"can't set codec DAI configuration\n");
54 /* Set cpu DAI configuration */
55 ret
= snd_soc_dai_set_fmt(cpu_dai
,
57 SND_SOC_DAIFMT_NB_NF
|
58 SND_SOC_DAIFMT_CBM_CFM
);
60 printk(KERN_ERR
"can't set cpu DAI configuration\n");
64 /* Set the codec system clock for DAC and ADC */
65 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, 26000000,
68 printk(KERN_ERR
"can't set codec system clock\n");
75 static struct snd_soc_ops igep2_ops
= {
76 .hw_params
= igep2_hw_params
,
79 /* Digital audio interface glue - connects codec <--> CPU */
80 static struct snd_soc_dai_link igep2_dai
= {
82 .stream_name
= "TWL4030",
83 .cpu_dai_name
= "omap-mcbsp-dai.1",
84 .codec_dai_name
= "twl4030-hifi",
85 .platform_name
= "omap-pcm-audio",
86 .codec_name
= "twl4030-codec",
90 /* Audio machine driver */
91 static struct snd_soc_card snd_soc_card_igep2
= {
93 .dai_link
= &igep2_dai
,
97 static struct platform_device
*igep2_snd_device
;
99 static int __init
igep2_soc_init(void)
103 if (!machine_is_igep0020())
105 printk(KERN_INFO
"IGEP v2 SoC init\n");
107 igep2_snd_device
= platform_device_alloc("soc-audio", -1);
108 if (!igep2_snd_device
) {
109 printk(KERN_ERR
"Platform device allocation failed\n");
113 platform_set_drvdata(igep2_snd_device
, &snd_soc_card_igep2
);
115 ret
= platform_device_add(igep2_snd_device
);
122 printk(KERN_ERR
"Unable to add platform device\n");
123 platform_device_put(igep2_snd_device
);
127 module_init(igep2_soc_init
);
129 static void __exit
igep2_soc_exit(void)
131 platform_device_unregister(igep2_snd_device
);
133 module_exit(igep2_soc_exit
);
135 MODULE_AUTHOR("Enric Balletbo i Serra <eballetbo@iseebcn.com>");
136 MODULE_DESCRIPTION("ALSA SoC IGEP v2");
137 MODULE_LICENSE("GPL");