blob: 84615a7de6adcd98ff7d808f73439a51a67df49d [file] [log] [blame]
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +01001/*
2 * igep0020.c -- SoC audio for IGEP v2
3 *
4 * Based on sound/soc/omap/overo.c by Steve Sakoman
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>
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010027
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"
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010035
36static int igep2_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;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000040 struct snd_soc_dai *codec_dai = rtd->codec_dai;
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010041 int ret;
42
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010043 /* 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
54static struct snd_soc_ops igep2_ops = {
55 .hw_params = igep2_hw_params,
56};
57
58/* Digital audio interface glue - connects codec <--> CPU */
59static struct snd_soc_dai_link igep2_dai = {
60 .name = "TWL4030",
61 .stream_name = "TWL4030",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000062 .cpu_dai_name = "omap-mcbsp-dai.1",
63 .codec_dai_name = "twl4030-hifi",
64 .platform_name = "omap-pcm-audio",
65 .codec_name = "twl4030-codec",
Jarkko Nikulacf9feff2011-09-30 16:07:45 +030066 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
67 SND_SOC_DAIFMT_CBM_CFM,
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010068 .ops = &igep2_ops,
69};
70
71/* Audio machine driver */
72static struct snd_soc_card snd_soc_card_igep2 = {
73 .name = "igep2",
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010074 .dai_link = &igep2_dai,
75 .num_links = 1,
76};
77
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010078static struct platform_device *igep2_snd_device;
79
80static int __init igep2_soc_init(void)
81{
82 int ret;
83
Jarkko Nikulaec588ae2010-10-06 16:47:26 +030084 if (!machine_is_igep0020())
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010085 return -ENODEV;
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010086 printk(KERN_INFO "IGEP v2 SoC init\n");
87
88 igep2_snd_device = platform_device_alloc("soc-audio", -1);
89 if (!igep2_snd_device) {
90 printk(KERN_ERR "Platform device allocation failed\n");
91 return -ENOMEM;
92 }
93
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000094 platform_set_drvdata(igep2_snd_device, &snd_soc_card_igep2);
Enric Balletbò i Serrab2a22362009-11-18 15:59:24 +010095
96 ret = platform_device_add(igep2_snd_device);
97 if (ret)
98 goto err1;
99
100 return 0;
101
102err1:
103 printk(KERN_ERR "Unable to add platform device\n");
104 platform_device_put(igep2_snd_device);
105
106 return ret;
107}
108module_init(igep2_soc_init);
109
110static void __exit igep2_soc_exit(void)
111{
112 platform_device_unregister(igep2_snd_device);
113}
114module_exit(igep2_soc_exit);
115
116MODULE_AUTHOR("Enric Balletbo i Serra <eballetbo@iseebcn.com>");
117MODULE_DESCRIPTION("ALSA SoC IGEP v2");
118MODULE_LICENSE("GPL");