aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/zoom2.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/omap/zoom2.c')
-rw-r--r--sound/soc/omap/zoom2.c68
1 files changed, 24 insertions, 44 deletions
diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c
index 50a94ee76ecc..718031eeac34 100644
--- a/sound/soc/omap/zoom2.c
+++ b/sound/soc/omap/zoom2.c
@@ -29,21 +29,23 @@
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <mach/gpio.h> 31#include <mach/gpio.h>
32#include <mach/board-zoom.h>
32#include <plat/mcbsp.h> 33#include <plat/mcbsp.h>
33 34
35/* Register descriptions for twl4030 codec part */
36#include <linux/mfd/twl4030-codec.h>
37
34#include "omap-mcbsp.h" 38#include "omap-mcbsp.h"
35#include "omap-pcm.h" 39#include "omap-pcm.h"
36#include "../codecs/twl4030.h"
37 40
38#define ZOOM2_HEADSET_MUX_GPIO (OMAP_MAX_GPIO_LINES + 15) 41#define ZOOM2_HEADSET_MUX_GPIO (OMAP_MAX_GPIO_LINES + 15)
39#define ZOOM2_HEADSET_EXTMUTE_GPIO 153
40 42
41static int zoom2_hw_params(struct snd_pcm_substream *substream, 43static int zoom2_hw_params(struct snd_pcm_substream *substream,
42 struct snd_pcm_hw_params *params) 44 struct snd_pcm_hw_params *params)
43{ 45{
44 struct snd_soc_pcm_runtime *rtd = substream->private_data; 46 struct snd_soc_pcm_runtime *rtd = substream->private_data;
45 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 47 struct snd_soc_dai *codec_dai = rtd->codec_dai;
46 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 48 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
47 int ret; 49 int ret;
48 50
49 /* Set codec DAI configuration */ 51 /* Set codec DAI configuration */
@@ -85,8 +87,8 @@ static int zoom2_hw_voice_params(struct snd_pcm_substream *substream,
85 struct snd_pcm_hw_params *params) 87 struct snd_pcm_hw_params *params)
86{ 88{
87 struct snd_soc_pcm_runtime *rtd = substream->private_data; 89 struct snd_soc_pcm_runtime *rtd = substream->private_data;
88 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 90 struct snd_soc_dai *codec_dai = rtd->codec_dai;
89 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 91 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
90 int ret; 92 int ret;
91 93
92 /* Set codec DAI configuration */ 94 /* Set codec DAI configuration */
@@ -157,8 +159,9 @@ static const struct snd_soc_dapm_route audio_map[] = {
157 {"Aux In", NULL, "AUXR"}, 159 {"Aux In", NULL, "AUXR"},
158}; 160};
159 161
160static int zoom2_twl4030_init(struct snd_soc_codec *codec) 162static int zoom2_twl4030_init(struct snd_soc_pcm_runtime *rtd)
161{ 163{
164 struct snd_soc_codec *codec = rtd->codec;
162 int ret; 165 int ret;
163 166
164 /* Add Zoom2 specific widgets */ 167 /* Add Zoom2 specific widgets */
@@ -192,14 +195,15 @@ static int zoom2_twl4030_init(struct snd_soc_codec *codec)
192 return ret; 195 return ret;
193} 196}
194 197
195static int zoom2_twl4030_voice_init(struct snd_soc_codec *codec) 198static int zoom2_twl4030_voice_init(struct snd_soc_pcm_runtime *rtd)
196{ 199{
200 struct snd_soc_codec *codec = rtd->codec;
197 unsigned short reg; 201 unsigned short reg;
198 202
199 /* Enable voice interface */ 203 /* Enable voice interface */
200 reg = codec->read(codec, TWL4030_REG_VOICE_IF); 204 reg = codec->driver->read(codec, TWL4030_REG_VOICE_IF);
201 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN; 205 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN;
202 codec->write(codec, TWL4030_REG_VOICE_IF, reg); 206 codec->driver->write(codec, TWL4030_REG_VOICE_IF, reg);
203 207
204 return 0; 208 return 0;
205} 209}
@@ -209,16 +213,20 @@ static struct snd_soc_dai_link zoom2_dai[] = {
209 { 213 {
210 .name = "TWL4030 I2S", 214 .name = "TWL4030 I2S",
211 .stream_name = "TWL4030 Audio", 215 .stream_name = "TWL4030 Audio",
212 .cpu_dai = &omap_mcbsp_dai[0], 216 .cpu_dai_name = "omap-mcbsp-dai.1",
213 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 217 .codec_dai_name = "twl4030-hifi",
218 .platform_name = "omap-pcm-audio",
219 .codec_name = "twl4030-codec",
214 .init = zoom2_twl4030_init, 220 .init = zoom2_twl4030_init,
215 .ops = &zoom2_ops, 221 .ops = &zoom2_ops,
216 }, 222 },
217 { 223 {
218 .name = "TWL4030 PCM", 224 .name = "TWL4030 PCM",
219 .stream_name = "TWL4030 Voice", 225 .stream_name = "TWL4030 Voice",
220 .cpu_dai = &omap_mcbsp_dai[1], 226 .cpu_dai_name = "omap-mcbsp-dai.2",
221 .codec_dai = &twl4030_dai[TWL4030_DAI_VOICE], 227 .codec_dai_name = "twl4030-voice",
228 .platform_name = "omap-pcm-audio",
229 .codec_name = "twl4030-codec",
222 .init = zoom2_twl4030_voice_init, 230 .init = zoom2_twl4030_voice_init,
223 .ops = &zoom2_voice_ops, 231 .ops = &zoom2_voice_ops,
224 }, 232 },
@@ -227,42 +235,18 @@ static struct snd_soc_dai_link zoom2_dai[] = {
227/* Audio machine driver */ 235/* Audio machine driver */
228static struct snd_soc_card snd_soc_zoom2 = { 236static struct snd_soc_card snd_soc_zoom2 = {
229 .name = "Zoom2", 237 .name = "Zoom2",
230 .platform = &omap_soc_platform,
231 .dai_link = zoom2_dai, 238 .dai_link = zoom2_dai,
232 .num_links = ARRAY_SIZE(zoom2_dai), 239 .num_links = ARRAY_SIZE(zoom2_dai),
233}; 240};
234 241
235/* EXTMUTE callback function */
236void zoom2_set_hs_extmute(int mute)
237{
238 gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
239}
240
241/* twl4030 setup */
242static struct twl4030_setup_data twl4030_setup = {
243 .ramp_delay_value = 3, /* 161 ms */
244 .sysclk = 26000,
245 .hs_extmute = 1,
246 .set_hs_extmute = zoom2_set_hs_extmute,
247};
248
249/* Audio subsystem */
250static struct snd_soc_device zoom2_snd_devdata = {
251 .card = &snd_soc_zoom2,
252 .codec_dev = &soc_codec_dev_twl4030,
253 .codec_data = &twl4030_setup,
254};
255
256static struct platform_device *zoom2_snd_device; 242static struct platform_device *zoom2_snd_device;
257 243
258static int __init zoom2_soc_init(void) 244static int __init zoom2_soc_init(void)
259{ 245{
260 int ret; 246 int ret;
261 247
262 if (!machine_is_omap_zoom2()) { 248 if (!machine_is_omap_zoom2())
263 pr_debug("Not Zoom2!\n");
264 return -ENODEV; 249 return -ENODEV;
265 }
266 printk(KERN_INFO "Zoom2 SoC init\n"); 250 printk(KERN_INFO "Zoom2 SoC init\n");
267 251
268 zoom2_snd_device = platform_device_alloc("soc-audio", -1); 252 zoom2_snd_device = platform_device_alloc("soc-audio", -1);
@@ -271,11 +255,7 @@ static int __init zoom2_soc_init(void)
271 return -ENOMEM; 255 return -ENOMEM;
272 } 256 }
273 257
274 platform_set_drvdata(zoom2_snd_device, &zoom2_snd_devdata); 258 platform_set_drvdata(zoom2_snd_device, &snd_soc_zoom2);
275 zoom2_snd_devdata.dev = &zoom2_snd_device->dev;
276 *(unsigned int *)zoom2_dai[0].cpu_dai->private_data = 1; /* McBSP2 */
277 *(unsigned int *)zoom2_dai[1].cpu_dai->private_data = 2; /* McBSP3 */
278
279 ret = platform_device_add(zoom2_snd_device); 259 ret = platform_device_add(zoom2_snd_device);
280 if (ret) 260 if (ret)
281 goto err1; 261 goto err1;