]> git.karo-electronics.de Git - karo-tx-linux.git/blob - sound/soc/omap/overo.c
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[karo-tx-linux.git] / sound / soc / omap / overo.c
1 /*
2  * overo.c  --  SoC audio for Gumstix Overo
3  *
4  * Author: Steve Sakoman <steve@sakoman.com>
5  *
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.
9  *
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.
14  *
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
18  * 02110-1301 USA
19  *
20  */
21
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
28 #include <asm/mach-types.h>
29 #include <mach/hardware.h>
30 #include <mach/gpio.h>
31 #include <plat/mcbsp.h>
32
33 #include "omap-mcbsp.h"
34 #include "omap-pcm.h"
35
36 static int overo_hw_params(struct snd_pcm_substream *substream,
37         struct snd_pcm_hw_params *params)
38 {
39         struct snd_soc_pcm_runtime *rtd = substream->private_data;
40         struct snd_soc_dai *codec_dai = rtd->codec_dai;
41         int ret;
42
43         /* Set the codec system clock for DAC and ADC */
44         ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
45                                             SND_SOC_CLOCK_IN);
46         if (ret < 0) {
47                 printk(KERN_ERR "can't set codec system clock\n");
48                 return ret;
49         }
50
51         return 0;
52 }
53
54 static struct snd_soc_ops overo_ops = {
55         .hw_params = overo_hw_params,
56 };
57
58 /* Digital audio interface glue - connects codec <--> CPU */
59 static struct snd_soc_dai_link overo_dai = {
60         .name = "TWL4030",
61         .stream_name = "TWL4030",
62         .cpu_dai_name = "omap-mcbsp-dai.1",
63         .codec_dai_name = "twl4030-hifi",
64         .platform_name = "omap-pcm-audio",
65         .codec_name = "twl4030-codec",
66         .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
67                    SND_SOC_DAIFMT_CBM_CFM,
68         .ops = &overo_ops,
69 };
70
71 /* Audio machine driver */
72 static struct snd_soc_card snd_soc_card_overo = {
73         .name = "overo",
74         .dai_link = &overo_dai,
75         .num_links = 1,
76 };
77
78 static struct platform_device *overo_snd_device;
79
80 static int __init overo_soc_init(void)
81 {
82         int ret;
83
84         if (!(machine_is_overo() || machine_is_cm_t35())) {
85                 pr_debug("Incomatible machine!\n");
86                 return -ENODEV;
87         }
88         printk(KERN_INFO "overo SoC init\n");
89
90         overo_snd_device = platform_device_alloc("soc-audio", -1);
91         if (!overo_snd_device) {
92                 printk(KERN_ERR "Platform device allocation failed\n");
93                 return -ENOMEM;
94         }
95
96         platform_set_drvdata(overo_snd_device, &snd_soc_card_overo);
97
98         ret = platform_device_add(overo_snd_device);
99         if (ret)
100                 goto err1;
101
102         return 0;
103
104 err1:
105         printk(KERN_ERR "Unable to add platform device\n");
106         platform_device_put(overo_snd_device);
107
108         return ret;
109 }
110 module_init(overo_soc_init);
111
112 static void __exit overo_soc_exit(void)
113 {
114         platform_device_unregister(overo_snd_device);
115 }
116 module_exit(overo_soc_exit);
117
118 MODULE_AUTHOR("Steve Sakoman <steve@sakoman.com>");
119 MODULE_DESCRIPTION("ALSA SoC overo");
120 MODULE_LICENSE("GPL");