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