2 * sdp3430.c -- SoC audio for TI OMAP3430 SDP
4 * Author: Misael Lopez Cruz <x0052729@ti.com>
7 * Author: Steve Sakoman <steve@sakoman.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 #include <linux/clk.h>
26 #include <linux/platform_device.h>
27 #include <sound/core.h>
28 #include <sound/pcm.h>
29 #include <sound/soc.h>
30 #include <sound/soc-dapm.h>
32 #include <asm/mach-types.h>
33 #include <mach/hardware.h>
34 #include <mach/gpio.h>
35 #include <mach/mcbsp.h>
37 #include "omap-mcbsp.h"
39 #include "../codecs/twl4030.h"
41 static int sdp3430_hw_params(struct snd_pcm_substream *substream,
42 struct snd_pcm_hw_params *params)
44 struct snd_soc_pcm_runtime *rtd = substream->private_data;
45 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
46 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
49 /* Set codec DAI configuration */
50 ret = snd_soc_dai_set_fmt(codec_dai,
52 SND_SOC_DAIFMT_NB_NF |
53 SND_SOC_DAIFMT_CBM_CFM);
55 printk(KERN_ERR "can't set codec DAI configuration\n");
59 /* Set cpu DAI configuration */
60 ret = snd_soc_dai_set_fmt(cpu_dai,
62 SND_SOC_DAIFMT_NB_NF |
63 SND_SOC_DAIFMT_CBM_CFM);
65 printk(KERN_ERR "can't set cpu DAI configuration\n");
69 /* Set the codec system clock for DAC and ADC */
70 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
73 printk(KERN_ERR "can't set codec system clock\n");
80 static struct snd_soc_ops sdp3430_ops = {
81 .hw_params = sdp3430_hw_params,
84 /* Digital audio interface glue - connects codec <--> CPU */
85 static struct snd_soc_dai_link sdp3430_dai = {
87 .stream_name = "TWL4030",
88 .cpu_dai = &omap_mcbsp_dai[0],
89 .codec_dai = &twl4030_dai,
93 /* Audio machine driver */
94 static struct snd_soc_card snd_soc_sdp3430 = {
96 .platform = &omap_soc_platform,
97 .dai_link = &sdp3430_dai,
101 /* Audio subsystem */
102 static struct snd_soc_device sdp3430_snd_devdata = {
103 .card = &snd_soc_sdp3430,
104 .codec_dev = &soc_codec_dev_twl4030,
107 static struct platform_device *sdp3430_snd_device;
109 static int __init sdp3430_soc_init(void)
113 if (!machine_is_omap_3430sdp()) {
114 pr_debug("Not SDP3430!\n");
117 printk(KERN_INFO "SDP3430 SoC init\n");
119 sdp3430_snd_device = platform_device_alloc("soc-audio", -1);
120 if (!sdp3430_snd_device) {
121 printk(KERN_ERR "Platform device allocation failed\n");
125 platform_set_drvdata(sdp3430_snd_device, &sdp3430_snd_devdata);
126 sdp3430_snd_devdata.dev = &sdp3430_snd_device->dev;
127 *(unsigned int *)sdp3430_dai.cpu_dai->private_data = 1; /* McBSP2 */
129 ret = platform_device_add(sdp3430_snd_device);
136 printk(KERN_ERR "Unable to add platform device\n");
137 platform_device_put(sdp3430_snd_device);
141 module_init(sdp3430_soc_init);
143 static void __exit sdp3430_soc_exit(void)
145 platform_device_unregister(sdp3430_snd_device);
147 module_exit(sdp3430_soc_exit);
149 MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>");
150 MODULE_DESCRIPTION("ALSA SoC SDP3430");
151 MODULE_LICENSE("GPL");