ASoC: AM3517: Update codec name after multi-component update
[deliverable/linux.git] / sound / soc / omap / am3517evm.c
CommitLineData
89e9abe7
AA
1/*
2 * am3517evm.c -- ALSA SoC support for OMAP3517 / AM3517 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) 2009 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>
89e9abe7
AA
25
26#include <asm/mach-types.h>
27#include <mach/hardware.h>
28#include <mach/gpio.h>
29#include <plat/mcbsp.h>
30
31#include "omap-mcbsp.h"
32#include "omap-pcm.h"
33
34#include "../codecs/tlv320aic23.h"
35
36#define CODEC_CLOCK 12000000
37
38static int am3517evm_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params)
40{
41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
f0fba2ad
LG
42 struct snd_soc_dai *codec_dai = rtd->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
89e9abe7
AA
44 int ret;
45
46 /* Set codec DAI configuration */
47 ret = snd_soc_dai_set_fmt(codec_dai,
48 SND_SOC_DAIFMT_DSP_B |
49 SND_SOC_DAIFMT_NB_NF |
50 SND_SOC_DAIFMT_CBM_CFM);
51 if (ret < 0) {
52 printk(KERN_ERR "can't set codec DAI configuration\n");
53 return ret;
54 }
55
56 /* Set cpu DAI configuration */
57 ret = snd_soc_dai_set_fmt(cpu_dai,
58 SND_SOC_DAIFMT_DSP_B |
59 SND_SOC_DAIFMT_NB_NF |
60 SND_SOC_DAIFMT_CBM_CFM);
61 if (ret < 0) {
62 printk(KERN_ERR "can't set cpu DAI configuration\n");
63 return ret;
64 }
65
66 /* Set the codec system clock for DAC and ADC */
67 ret = snd_soc_dai_set_sysclk(codec_dai, 0,
68 CODEC_CLOCK, SND_SOC_CLOCK_IN);
69 if (ret < 0) {
70 printk(KERN_ERR "can't set codec system clock\n");
71 return ret;
72 }
73
74 ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_CLKR_SRC_CLKX, 0,
75 SND_SOC_CLOCK_IN);
76 if (ret < 0) {
77 printk(KERN_ERR "can't set CPU system clock OMAP_MCBSP_CLKR_SRC_CLKX\n");
78 return ret;
79 }
80
81 snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_FSR_SRC_FSX, 0,
82 SND_SOC_CLOCK_IN);
83 if (ret < 0) {
84 printk(KERN_ERR "can't set CPU system clock OMAP_MCBSP_FSR_SRC_FSX\n");
85 return ret;
86 }
87
88 return 0;
89}
90
91static struct snd_soc_ops am3517evm_ops = {
92 .hw_params = am3517evm_hw_params,
93};
94
95/* am3517evm machine dapm widgets */
96static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
97 SND_SOC_DAPM_HP("Line Out", NULL),
98 SND_SOC_DAPM_LINE("Line In", NULL),
99 SND_SOC_DAPM_MIC("Mic In", NULL),
100};
101
102static const struct snd_soc_dapm_route audio_map[] = {
103 /* Line Out connected to LLOUT, RLOUT */
104 {"Line Out", NULL, "LOUT"},
105 {"Line Out", NULL, "ROUT"},
106
107 {"LLINEIN", NULL, "Line In"},
108 {"RLINEIN", NULL, "Line In"},
109
110 {"MICIN", NULL, "Mic In"},
111};
112
f0fba2ad 113static int am3517evm_aic23_init(struct snd_soc_pcm_runtime *rtd)
89e9abe7 114{
f0fba2ad 115 struct snd_soc_codec *codec = rtd->codec;
ce6120cc 116 struct snd_soc_dapm_context *dapm = &codec->dapm;
f0fba2ad 117
89e9abe7 118 /* Add am3517-evm specific widgets */
ce6120cc 119 snd_soc_dapm_new_controls(dapm, tlv320aic23_dapm_widgets,
89e9abe7
AA
120 ARRAY_SIZE(tlv320aic23_dapm_widgets));
121
122 /* Set up davinci-evm specific audio path audio_map */
ce6120cc 123 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
89e9abe7
AA
124
125 /* always connected */
ce6120cc
LG
126 snd_soc_dapm_enable_pin(dapm, "Line Out");
127 snd_soc_dapm_enable_pin(dapm, "Line In");
128 snd_soc_dapm_enable_pin(dapm, "Mic In");
89e9abe7 129
ce6120cc 130 snd_soc_dapm_sync(dapm);
89e9abe7
AA
131
132 return 0;
133}
134
135/* Digital audio interface glue - connects codec <--> CPU */
136static struct snd_soc_dai_link am3517evm_dai = {
137 .name = "TLV320AIC23",
138 .stream_name = "AIC23",
f0fba2ad
LG
139 .cpu_dai_name ="omap-mcbsp-dai.0",
140 .codec_dai_name = "tlv320aic23-hifi",
141 .platform_name = "omap-pcm-audio",
ffd6eae2 142 .codec_name = "tlv320aic23-codec.2-001a",
89e9abe7
AA
143 .init = am3517evm_aic23_init,
144 .ops = &am3517evm_ops,
145};
146
147/* Audio machine driver */
148static struct snd_soc_card snd_soc_am3517evm = {
149 .name = "am3517evm",
89e9abe7
AA
150 .dai_link = &am3517evm_dai,
151 .num_links = 1,
152};
153
89e9abe7
AA
154static struct platform_device *am3517evm_snd_device;
155
156static int __init am3517evm_soc_init(void)
157{
158 int ret;
159
ec588ae6 160 if (!machine_is_omap3517evm())
89e9abe7 161 return -ENODEV;
89e9abe7
AA
162 pr_info("OMAP3517 / AM3517 EVM SoC init\n");
163
164 am3517evm_snd_device = platform_device_alloc("soc-audio", -1);
165 if (!am3517evm_snd_device) {
166 printk(KERN_ERR "Platform device allocation failed\n");
167 return -ENOMEM;
168 }
169
f0fba2ad 170 platform_set_drvdata(am3517evm_snd_device, &snd_soc_am3517evm);
89e9abe7
AA
171
172 ret = platform_device_add(am3517evm_snd_device);
173 if (ret)
174 goto err1;
175
176 return 0;
177
178err1:
179 printk(KERN_ERR "Unable to add platform device\n");
180 platform_device_put(am3517evm_snd_device);
181
182 return ret;
183}
184
185static void __exit am3517evm_soc_exit(void)
186{
187 platform_device_unregister(am3517evm_snd_device);
188}
189
190module_init(am3517evm_soc_init);
191module_exit(am3517evm_soc_exit);
192
193MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
194MODULE_DESCRIPTION("ALSA SoC OMAP3517 / AM3517 EVM");
195MODULE_LICENSE("GPL v2");
This page took 0.080048 seconds and 5 git commands to generate.