aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/sdp3430.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/omap/sdp3430.c')
-rw-r--r--sound/soc/omap/sdp3430.c104
1 files changed, 46 insertions, 58 deletions
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c
index 3c85c0f92823..3f72d17d1ef0 100644
--- a/sound/soc/omap/sdp3430.c
+++ b/sound/soc/omap/sdp3430.c
@@ -28,7 +28,6 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include <sound/pcm.h> 29#include <sound/pcm.h>
30#include <sound/soc.h> 30#include <sound/soc.h>
31#include <sound/soc-dapm.h>
32#include <sound/jack.h> 31#include <sound/jack.h>
33 32
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
@@ -36,9 +35,11 @@
36#include <mach/gpio.h> 35#include <mach/gpio.h>
37#include <plat/mcbsp.h> 36#include <plat/mcbsp.h>
38 37
38/* Register descriptions for twl4030 codec part */
39#include <linux/mfd/twl4030-codec.h>
40
39#include "omap-mcbsp.h" 41#include "omap-mcbsp.h"
40#include "omap-pcm.h" 42#include "omap-pcm.h"
41#include "../codecs/twl4030.h"
42 43
43/* TWL4030 PMBR1 Register */ 44/* TWL4030 PMBR1 Register */
44#define TWL4030_INTBR_PMBR1 0x0D 45#define TWL4030_INTBR_PMBR1 0x0D
@@ -51,8 +52,8 @@ static int sdp3430_hw_params(struct snd_pcm_substream *substream,
51 struct snd_pcm_hw_params *params) 52 struct snd_pcm_hw_params *params)
52{ 53{
53 struct snd_soc_pcm_runtime *rtd = substream->private_data; 54 struct snd_soc_pcm_runtime *rtd = substream->private_data;
54 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 55 struct snd_soc_dai *codec_dai = rtd->codec_dai;
55 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 56 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
56 int ret; 57 int ret;
57 58
58 /* Set codec DAI configuration */ 59 /* Set codec DAI configuration */
@@ -94,8 +95,8 @@ static int sdp3430_hw_voice_params(struct snd_pcm_substream *substream,
94 struct snd_pcm_hw_params *params) 95 struct snd_pcm_hw_params *params)
95{ 96{
96 struct snd_soc_pcm_runtime *rtd = substream->private_data; 97 struct snd_soc_pcm_runtime *rtd = substream->private_data;
97 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 98 struct snd_soc_dai *codec_dai = rtd->codec_dai;
98 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 99 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
99 int ret; 100 int ret;
100 101
101 /* Set codec DAI configuration */ 102 /* Set codec DAI configuration */
@@ -186,46 +187,48 @@ static const struct snd_soc_dapm_route audio_map[] = {
186 {"Headset Stereophone", NULL, "HSOR"}, 187 {"Headset Stereophone", NULL, "HSOR"},
187}; 188};
188 189
189static int sdp3430_twl4030_init(struct snd_soc_codec *codec) 190static int sdp3430_twl4030_init(struct snd_soc_pcm_runtime *rtd)
190{ 191{
192 struct snd_soc_codec *codec = rtd->codec;
193 struct snd_soc_dapm_context *dapm = &codec->dapm;
191 int ret; 194 int ret;
192 195
193 /* Add SDP3430 specific widgets */ 196 /* Add SDP3430 specific widgets */
194 ret = snd_soc_dapm_new_controls(codec, sdp3430_twl4030_dapm_widgets, 197 ret = snd_soc_dapm_new_controls(dapm, sdp3430_twl4030_dapm_widgets,
195 ARRAY_SIZE(sdp3430_twl4030_dapm_widgets)); 198 ARRAY_SIZE(sdp3430_twl4030_dapm_widgets));
196 if (ret) 199 if (ret)
197 return ret; 200 return ret;
198 201
199 /* Set up SDP3430 specific audio path audio_map */ 202 /* Set up SDP3430 specific audio path audio_map */
200 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 203 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
201 204
202 /* SDP3430 connected pins */ 205 /* SDP3430 connected pins */
203 snd_soc_dapm_enable_pin(codec, "Ext Mic"); 206 snd_soc_dapm_enable_pin(dapm, "Ext Mic");
204 snd_soc_dapm_enable_pin(codec, "Ext Spk"); 207 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
205 snd_soc_dapm_disable_pin(codec, "Headset Mic"); 208 snd_soc_dapm_disable_pin(dapm, "Headset Mic");
206 snd_soc_dapm_disable_pin(codec, "Headset Stereophone"); 209 snd_soc_dapm_disable_pin(dapm, "Headset Stereophone");
207 210
208 /* TWL4030 not connected pins */ 211 /* TWL4030 not connected pins */
209 snd_soc_dapm_nc_pin(codec, "AUXL"); 212 snd_soc_dapm_nc_pin(dapm, "AUXL");
210 snd_soc_dapm_nc_pin(codec, "AUXR"); 213 snd_soc_dapm_nc_pin(dapm, "AUXR");
211 snd_soc_dapm_nc_pin(codec, "CARKITMIC"); 214 snd_soc_dapm_nc_pin(dapm, "CARKITMIC");
212 snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); 215 snd_soc_dapm_nc_pin(dapm, "DIGIMIC0");
213 snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); 216 snd_soc_dapm_nc_pin(dapm, "DIGIMIC1");
214 217
215 snd_soc_dapm_nc_pin(codec, "OUTL"); 218 snd_soc_dapm_nc_pin(dapm, "OUTL");
216 snd_soc_dapm_nc_pin(codec, "OUTR"); 219 snd_soc_dapm_nc_pin(dapm, "OUTR");
217 snd_soc_dapm_nc_pin(codec, "EARPIECE"); 220 snd_soc_dapm_nc_pin(dapm, "EARPIECE");
218 snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); 221 snd_soc_dapm_nc_pin(dapm, "PREDRIVEL");
219 snd_soc_dapm_nc_pin(codec, "PREDRIVER"); 222 snd_soc_dapm_nc_pin(dapm, "PREDRIVER");
220 snd_soc_dapm_nc_pin(codec, "CARKITL"); 223 snd_soc_dapm_nc_pin(dapm, "CARKITL");
221 snd_soc_dapm_nc_pin(codec, "CARKITR"); 224 snd_soc_dapm_nc_pin(dapm, "CARKITR");
222 225
223 ret = snd_soc_dapm_sync(codec); 226 ret = snd_soc_dapm_sync(dapm);
224 if (ret) 227 if (ret)
225 return ret; 228 return ret;
226 229
227 /* Headset jack detection */ 230 /* Headset jack detection */
228 ret = snd_soc_jack_new(&snd_soc_sdp3430, "Headset Jack", 231 ret = snd_soc_jack_new(codec, "Headset Jack",
229 SND_JACK_HEADSET, &hs_jack); 232 SND_JACK_HEADSET, &hs_jack);
230 if (ret) 233 if (ret)
231 return ret; 234 return ret;
@@ -241,14 +244,15 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec)
241 return ret; 244 return ret;
242} 245}
243 246
244static int sdp3430_twl4030_voice_init(struct snd_soc_codec *codec) 247static int sdp3430_twl4030_voice_init(struct snd_soc_pcm_runtime *rtd)
245{ 248{
249 struct snd_soc_codec *codec = rtd->codec;
246 unsigned short reg; 250 unsigned short reg;
247 251
248 /* Enable voice interface */ 252 /* Enable voice interface */
249 reg = codec->read(codec, TWL4030_REG_VOICE_IF); 253 reg = codec->driver->read(codec, TWL4030_REG_VOICE_IF);
250 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN; 254 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN;
251 codec->write(codec, TWL4030_REG_VOICE_IF, reg); 255 codec->driver->write(codec, TWL4030_REG_VOICE_IF, reg);
252 256
253 return 0; 257 return 0;
254} 258}
@@ -259,16 +263,20 @@ static struct snd_soc_dai_link sdp3430_dai[] = {
259 { 263 {
260 .name = "TWL4030 I2S", 264 .name = "TWL4030 I2S",
261 .stream_name = "TWL4030 Audio", 265 .stream_name = "TWL4030 Audio",
262 .cpu_dai = &omap_mcbsp_dai[0], 266 .cpu_dai_name = "omap-mcbsp-dai.1",
263 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 267 .codec_dai_name = "twl4030-hifi",
268 .platform_name = "omap-pcm-audio",
269 .codec_name = "twl4030-codec",
264 .init = sdp3430_twl4030_init, 270 .init = sdp3430_twl4030_init,
265 .ops = &sdp3430_ops, 271 .ops = &sdp3430_ops,
266 }, 272 },
267 { 273 {
268 .name = "TWL4030 PCM", 274 .name = "TWL4030 PCM",
269 .stream_name = "TWL4030 Voice", 275 .stream_name = "TWL4030 Voice",
270 .cpu_dai = &omap_mcbsp_dai[1], 276 .cpu_dai_name = "omap-mcbsp-dai.2",
271 .codec_dai = &twl4030_dai[TWL4030_DAI_VOICE], 277 .codec_dai_name = "twl4030-voice",
278 .platform_name = "omap-pcm-audio",
279 .codec_name = "twl4030-codec",
272 .init = sdp3430_twl4030_voice_init, 280 .init = sdp3430_twl4030_voice_init,
273 .ops = &sdp3430_voice_ops, 281 .ops = &sdp3430_voice_ops,
274 }, 282 },
@@ -277,25 +285,10 @@ static struct snd_soc_dai_link sdp3430_dai[] = {
277/* Audio machine driver */ 285/* Audio machine driver */
278static struct snd_soc_card snd_soc_sdp3430 = { 286static struct snd_soc_card snd_soc_sdp3430 = {
279 .name = "SDP3430", 287 .name = "SDP3430",
280 .platform = &omap_soc_platform,
281 .dai_link = sdp3430_dai, 288 .dai_link = sdp3430_dai,
282 .num_links = ARRAY_SIZE(sdp3430_dai), 289 .num_links = ARRAY_SIZE(sdp3430_dai),
283}; 290};
284 291
285/* twl4030 setup */
286static struct twl4030_setup_data twl4030_setup = {
287 .ramp_delay_value = 3,
288 .sysclk = 26000,
289 .hs_extmute = 1,
290};
291
292/* Audio subsystem */
293static struct snd_soc_device sdp3430_snd_devdata = {
294 .card = &snd_soc_sdp3430,
295 .codec_dev = &soc_codec_dev_twl4030,
296 .codec_data = &twl4030_setup,
297};
298
299static struct platform_device *sdp3430_snd_device; 292static struct platform_device *sdp3430_snd_device;
300 293
301static int __init sdp3430_soc_init(void) 294static int __init sdp3430_soc_init(void)
@@ -303,10 +296,8 @@ static int __init sdp3430_soc_init(void)
303 int ret; 296 int ret;
304 u8 pin_mux; 297 u8 pin_mux;
305 298
306 if (!machine_is_omap_3430sdp()) { 299 if (!machine_is_omap_3430sdp())
307 pr_debug("Not SDP3430!\n");
308 return -ENODEV; 300 return -ENODEV;
309 }
310 printk(KERN_INFO "SDP3430 SoC init\n"); 301 printk(KERN_INFO "SDP3430 SoC init\n");
311 302
312 sdp3430_snd_device = platform_device_alloc("soc-audio", -1); 303 sdp3430_snd_device = platform_device_alloc("soc-audio", -1);
@@ -315,10 +306,7 @@ static int __init sdp3430_soc_init(void)
315 return -ENOMEM; 306 return -ENOMEM;
316 } 307 }
317 308
318 platform_set_drvdata(sdp3430_snd_device, &sdp3430_snd_devdata); 309 platform_set_drvdata(sdp3430_snd_device, &snd_soc_sdp3430);
319 sdp3430_snd_devdata.dev = &sdp3430_snd_device->dev;
320 *(unsigned int *)sdp3430_dai[0].cpu_dai->private_data = 1; /* McBSP2 */
321 *(unsigned int *)sdp3430_dai[1].cpu_dai->private_data = 2; /* McBSP3 */
322 310
323 /* Set TWL4030 GPIO6 as EXTMUTE signal */ 311 /* Set TWL4030 GPIO6 as EXTMUTE signal */
324 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux, 312 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,