diff options
author | Anuj Aggarwal <anuj.aggarwal@ti.com> | 2009-10-29 14:52:30 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-10-29 18:28:18 -0400 |
commit | 89e9abe78151de4d62fefe3976f6ef9f1f086e53 (patch) | |
tree | f18a8bcb51ad6d75a4568020eed8358226920eca | |
parent | ed146aeb68b6b240a015f3c24c9eea9266d845ec (diff) |
ASoC: Adding OMAP3517 / AM3517 EVM support in ASOC
Adding support for OMAP3517 / AM3517 EVM in Alsa SoC.
Signed-off-by: Anuj Aggarwal <anuj.aggarwal@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/omap/am3517evm.c | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c new file mode 100644 index 000000000000..135901b2ea11 --- /dev/null +++ b/sound/soc/omap/am3517evm.c | |||
@@ -0,0 +1,202 @@ | |||
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> | ||
25 | #include <sound/soc-dapm.h> | ||
26 | |||
27 | #include <asm/mach-types.h> | ||
28 | #include <mach/hardware.h> | ||
29 | #include <mach/gpio.h> | ||
30 | #include <plat/mcbsp.h> | ||
31 | |||
32 | #include "omap-mcbsp.h" | ||
33 | #include "omap-pcm.h" | ||
34 | |||
35 | #include "../codecs/tlv320aic23.h" | ||
36 | |||
37 | #define CODEC_CLOCK 12000000 | ||
38 | |||
39 | static int am3517evm_hw_params(struct snd_pcm_substream *substream, | ||
40 | struct snd_pcm_hw_params *params) | ||
41 | { | ||
42 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
43 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
44 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
45 | int ret; | ||
46 | |||
47 | /* Set codec DAI configuration */ | ||
48 | ret = snd_soc_dai_set_fmt(codec_dai, | ||
49 | SND_SOC_DAIFMT_DSP_B | | ||
50 | SND_SOC_DAIFMT_NB_NF | | ||
51 | SND_SOC_DAIFMT_CBM_CFM); | ||
52 | if (ret < 0) { | ||
53 | printk(KERN_ERR "can't set codec DAI configuration\n"); | ||
54 | return ret; | ||
55 | } | ||
56 | |||
57 | /* Set cpu DAI configuration */ | ||
58 | ret = snd_soc_dai_set_fmt(cpu_dai, | ||
59 | SND_SOC_DAIFMT_DSP_B | | ||
60 | SND_SOC_DAIFMT_NB_NF | | ||
61 | SND_SOC_DAIFMT_CBM_CFM); | ||
62 | if (ret < 0) { | ||
63 | printk(KERN_ERR "can't set cpu DAI configuration\n"); | ||
64 | return ret; | ||
65 | } | ||
66 | |||
67 | /* Set the codec system clock for DAC and ADC */ | ||
68 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, | ||
69 | CODEC_CLOCK, SND_SOC_CLOCK_IN); | ||
70 | if (ret < 0) { | ||
71 | printk(KERN_ERR "can't set codec system clock\n"); | ||
72 | return ret; | ||
73 | } | ||
74 | |||
75 | ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_CLKR_SRC_CLKX, 0, | ||
76 | SND_SOC_CLOCK_IN); | ||
77 | if (ret < 0) { | ||
78 | printk(KERN_ERR "can't set CPU system clock OMAP_MCBSP_CLKR_SRC_CLKX\n"); | ||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_FSR_SRC_FSX, 0, | ||
83 | SND_SOC_CLOCK_IN); | ||
84 | if (ret < 0) { | ||
85 | printk(KERN_ERR "can't set CPU system clock OMAP_MCBSP_FSR_SRC_FSX\n"); | ||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static struct snd_soc_ops am3517evm_ops = { | ||
93 | .hw_params = am3517evm_hw_params, | ||
94 | }; | ||
95 | |||
96 | /* am3517evm machine dapm widgets */ | ||
97 | static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = { | ||
98 | SND_SOC_DAPM_HP("Line Out", NULL), | ||
99 | SND_SOC_DAPM_LINE("Line In", NULL), | ||
100 | SND_SOC_DAPM_MIC("Mic In", NULL), | ||
101 | }; | ||
102 | |||
103 | static const struct snd_soc_dapm_route audio_map[] = { | ||
104 | /* Line Out connected to LLOUT, RLOUT */ | ||
105 | {"Line Out", NULL, "LOUT"}, | ||
106 | {"Line Out", NULL, "ROUT"}, | ||
107 | |||
108 | {"LLINEIN", NULL, "Line In"}, | ||
109 | {"RLINEIN", NULL, "Line In"}, | ||
110 | |||
111 | {"MICIN", NULL, "Mic In"}, | ||
112 | }; | ||
113 | |||
114 | static int am3517evm_aic23_init(struct snd_soc_codec *codec) | ||
115 | { | ||
116 | /* Add am3517-evm specific widgets */ | ||
117 | snd_soc_dapm_new_controls(codec, tlv320aic23_dapm_widgets, | ||
118 | ARRAY_SIZE(tlv320aic23_dapm_widgets)); | ||
119 | |||
120 | /* Set up davinci-evm specific audio path audio_map */ | ||
121 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
122 | |||
123 | /* always connected */ | ||
124 | snd_soc_dapm_enable_pin(codec, "Line Out"); | ||
125 | snd_soc_dapm_enable_pin(codec, "Line In"); | ||
126 | snd_soc_dapm_enable_pin(codec, "Mic In"); | ||
127 | |||
128 | snd_soc_dapm_sync(codec); | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
134 | static struct snd_soc_dai_link am3517evm_dai = { | ||
135 | .name = "TLV320AIC23", | ||
136 | .stream_name = "AIC23", | ||
137 | .cpu_dai = &omap_mcbsp_dai[0], | ||
138 | .codec_dai = &tlv320aic23_dai, | ||
139 | .init = am3517evm_aic23_init, | ||
140 | .ops = &am3517evm_ops, | ||
141 | }; | ||
142 | |||
143 | /* Audio machine driver */ | ||
144 | static struct snd_soc_card snd_soc_am3517evm = { | ||
145 | .name = "am3517evm", | ||
146 | .platform = &omap_soc_platform, | ||
147 | .dai_link = &am3517evm_dai, | ||
148 | .num_links = 1, | ||
149 | }; | ||
150 | |||
151 | /* Audio subsystem */ | ||
152 | static struct snd_soc_device am3517evm_snd_devdata = { | ||
153 | .card = &snd_soc_am3517evm, | ||
154 | .codec_dev = &soc_codec_dev_tlv320aic23, | ||
155 | }; | ||
156 | |||
157 | static struct platform_device *am3517evm_snd_device; | ||
158 | |||
159 | static int __init am3517evm_soc_init(void) | ||
160 | { | ||
161 | int ret; | ||
162 | |||
163 | if (!machine_is_omap3517evm()) { | ||
164 | pr_err("Not OMAP3517 / AM3517 EVM!\n"); | ||
165 | return -ENODEV; | ||
166 | } | ||
167 | pr_info("OMAP3517 / AM3517 EVM SoC init\n"); | ||
168 | |||
169 | am3517evm_snd_device = platform_device_alloc("soc-audio", -1); | ||
170 | if (!am3517evm_snd_device) { | ||
171 | printk(KERN_ERR "Platform device allocation failed\n"); | ||
172 | return -ENOMEM; | ||
173 | } | ||
174 | |||
175 | platform_set_drvdata(am3517evm_snd_device, &am3517evm_snd_devdata); | ||
176 | am3517evm_snd_devdata.dev = &am3517evm_snd_device->dev; | ||
177 | *(unsigned int *)am3517evm_dai.cpu_dai->private_data = 0; /* McBSP1 */ | ||
178 | |||
179 | ret = platform_device_add(am3517evm_snd_device); | ||
180 | if (ret) | ||
181 | goto err1; | ||
182 | |||
183 | return 0; | ||
184 | |||
185 | err1: | ||
186 | printk(KERN_ERR "Unable to add platform device\n"); | ||
187 | platform_device_put(am3517evm_snd_device); | ||
188 | |||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | static void __exit am3517evm_soc_exit(void) | ||
193 | { | ||
194 | platform_device_unregister(am3517evm_snd_device); | ||
195 | } | ||
196 | |||
197 | module_init(am3517evm_soc_init); | ||
198 | module_exit(am3517evm_soc_exit); | ||
199 | |||
200 | MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>"); | ||
201 | MODULE_DESCRIPTION("ALSA SoC OMAP3517 / AM3517 EVM"); | ||
202 | MODULE_LICENSE("GPL v2"); | ||