]> bbs.cooldavid.org Git - net-next-2.6.git/blame - sound/soc/omap/omap3evm.c
Merge branch 'for-2.6.37' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc...
[net-next-2.6.git] / sound / soc / omap / omap3evm.c
CommitLineData
14610ce7
AA
1/*
2 * omap3evm.c -- ALSA SoC support for OMAP3 EVM
3 *
4 * Author: Anuj Aggarwal <anuj.aggarwal@ti.com>
5 *
6 * Based on sound/soc/omap/beagle.c by Steve Sakoman
7 *
8 * Copyright (C) 2008 Texas Instruments, Incorporated
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation version 2.
13 *
14 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
15 * whether express or implied; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 */
19
20#include <linux/clk.h>
21#include <linux/platform_device.h>
22#include <sound/core.h>
23#include <sound/pcm.h>
24#include <sound/soc.h>
25#include <sound/soc-dapm.h>
26
27#include <asm/mach-types.h>
28#include <mach/hardware.h>
29#include <mach/gpio.h>
ce491cf8 30#include <plat/mcbsp.h>
14610ce7
AA
31
32#include "omap-mcbsp.h"
33#include "omap-pcm.h"
14610ce7
AA
34
35static int omap3evm_hw_params(struct snd_pcm_substream *substream,
36 struct snd_pcm_hw_params *params)
37{
38 struct snd_soc_pcm_runtime *rtd = substream->private_data;
f0fba2ad
LG
39 struct snd_soc_dai *codec_dai = rtd->codec_dai;
40 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
14610ce7
AA
41 int ret;
42
43 /* Set codec DAI configuration */
44 ret = snd_soc_dai_set_fmt(codec_dai,
45 SND_SOC_DAIFMT_I2S |
46 SND_SOC_DAIFMT_NB_NF |
47 SND_SOC_DAIFMT_CBM_CFM);
48 if (ret < 0) {
49 printk(KERN_ERR "Can't set codec DAI configuration\n");
50 return ret;
51 }
52
53 /* Set cpu DAI configuration */
54 ret = snd_soc_dai_set_fmt(cpu_dai,
55 SND_SOC_DAIFMT_I2S |
56 SND_SOC_DAIFMT_NB_NF |
57 SND_SOC_DAIFMT_CBM_CFM);
58 if (ret < 0) {
59 printk(KERN_ERR "Can't set cpu DAI configuration\n");
60 return ret;
61 }
62
63 /* Set the codec system clock for DAC and ADC */
64 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
65 SND_SOC_CLOCK_IN);
66 if (ret < 0) {
67 printk(KERN_ERR "Can't set codec system clock\n");
68 return ret;
69 }
70
71 return 0;
72}
73
74static struct snd_soc_ops omap3evm_ops = {
75 .hw_params = omap3evm_hw_params,
76};
77
78/* Digital audio interface glue - connects codec <--> CPU */
79static struct snd_soc_dai_link omap3evm_dai = {
80 .name = "TWL4030",
81 .stream_name = "TWL4030",
f0fba2ad
LG
82 .cpu_dai_name = "omap-mcbsp-dai.1",
83 .codec_dai_name = "twl4030-hifi",
84 .platform_name = "omap-pcm-audio",
85 .codec_name = "twl4030-codec",
14610ce7
AA
86 .ops = &omap3evm_ops,
87};
88
89/* Audio machine driver */
90static struct snd_soc_card snd_soc_omap3evm = {
91 .name = "omap3evm",
14610ce7
AA
92 .dai_link = &omap3evm_dai,
93 .num_links = 1,
94};
95
14610ce7
AA
96static struct platform_device *omap3evm_snd_device;
97
98static int __init omap3evm_soc_init(void)
99{
100 int ret;
101
ec588ae6 102 if (!machine_is_omap3evm())
14610ce7 103 return -ENODEV;
14610ce7
AA
104 pr_info("OMAP3 EVM SoC init\n");
105
106 omap3evm_snd_device = platform_device_alloc("soc-audio", -1);
107 if (!omap3evm_snd_device) {
108 printk(KERN_ERR "Platform device allocation failed\n");
109 return -ENOMEM;
110 }
111
f0fba2ad 112 platform_set_drvdata(omap3evm_snd_device, &snd_soc_omap3evm);
14610ce7
AA
113 ret = platform_device_add(omap3evm_snd_device);
114 if (ret)
115 goto err1;
116
117 return 0;
118
119err1:
120 printk(KERN_ERR "Unable to add platform device\n");
121 platform_device_put(omap3evm_snd_device);
122
123 return ret;
124}
125
126static void __exit omap3evm_soc_exit(void)
127{
128 platform_device_unregister(omap3evm_snd_device);
129}
130
131module_init(omap3evm_soc_init);
132module_exit(omap3evm_soc_exit);
133
134MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
135MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM");
bd6ddcb4 136MODULE_LICENSE("GPL v2");