aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/s3c24xx/neo1973_wm8753.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-03-28 16:29:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-03-28 16:29:51 -0400
commited40d0c472b136682b2fcba05f89762859c7374f (patch)
tree076b83a26bcd63d6158463735dd34c10bbc591dc /sound/soc/s3c24xx/neo1973_wm8753.c
parent9e495834e59ca9b29f1a1f63b9f5533bb022ac49 (diff)
parent5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (diff)
Merge branch 'origin' into devel
Conflicts: sound/soc/pxa/pxa2xx-i2s.c
Diffstat (limited to 'sound/soc/s3c24xx/neo1973_wm8753.c')
-rw-r--r--sound/soc/s3c24xx/neo1973_wm8753.c67
1 files changed, 25 insertions, 42 deletions
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c
index 45bb12e8ea44..289fadf60b10 100644
--- a/sound/soc/s3c24xx/neo1973_wm8753.c
+++ b/sound/soc/s3c24xx/neo1973_wm8753.c
@@ -29,25 +29,17 @@
29#include <mach/regs-clock.h> 29#include <mach/regs-clock.h>
30#include <mach/regs-gpio.h> 30#include <mach/regs-gpio.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/audio.h> 32#include <plat/audio.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <mach/spi-gpio.h> 34#include <mach/spi-gpio.h>
35 35
36#include <asm/plat-s3c24xx/regs-iis.h> 36#include <plat/regs-iis.h>
37 37
38#include "../codecs/wm8753.h" 38#include "../codecs/wm8753.h"
39#include "lm4857.h" 39#include "lm4857.h"
40#include "s3c24xx-pcm.h" 40#include "s3c24xx-pcm.h"
41#include "s3c24xx-i2s.h" 41#include "s3c24xx-i2s.h"
42 42
43/* Debugging stuff */
44#define S3C24XX_SOC_NEO1973_WM8753_DEBUG 0
45#if S3C24XX_SOC_NEO1973_WM8753_DEBUG
46#define DBG(x...) printk(KERN_DEBUG "s3c24xx-soc-neo1973-wm8753: " x)
47#else
48#define DBG(x...)
49#endif
50
51/* define the scenarios */ 43/* define the scenarios */
52#define NEO_AUDIO_OFF 0 44#define NEO_AUDIO_OFF 0
53#define NEO_GSM_CALL_AUDIO_HANDSET 1 45#define NEO_GSM_CALL_AUDIO_HANDSET 1
@@ -72,7 +64,7 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream,
72 int ret = 0; 64 int ret = 0;
73 unsigned long iis_clkrate; 65 unsigned long iis_clkrate;
74 66
75 DBG("Entered %s\n", __func__); 67 pr_debug("Entered %s\n", __func__);
76 68
77 iis_clkrate = s3c24xx_i2s_get_clockrate(); 69 iis_clkrate = s3c24xx_i2s_get_clockrate();
78 70
@@ -158,7 +150,7 @@ static int neo1973_hifi_hw_free(struct snd_pcm_substream *substream)
158 struct snd_soc_pcm_runtime *rtd = substream->private_data; 150 struct snd_soc_pcm_runtime *rtd = substream->private_data;
159 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 151 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
160 152
161 DBG("Entered %s\n", __func__); 153 pr_debug("Entered %s\n", __func__);
162 154
163 /* disable the PLL */ 155 /* disable the PLL */
164 return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0); 156 return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0);
@@ -181,7 +173,7 @@ static int neo1973_voice_hw_params(struct snd_pcm_substream *substream,
181 int ret = 0; 173 int ret = 0;
182 unsigned long iis_clkrate; 174 unsigned long iis_clkrate;
183 175
184 DBG("Entered %s\n", __func__); 176 pr_debug("Entered %s\n", __func__);
185 177
186 iis_clkrate = s3c24xx_i2s_get_clockrate(); 178 iis_clkrate = s3c24xx_i2s_get_clockrate();
187 179
@@ -224,7 +216,7 @@ static int neo1973_voice_hw_free(struct snd_pcm_substream *substream)
224 struct snd_soc_pcm_runtime *rtd = substream->private_data; 216 struct snd_soc_pcm_runtime *rtd = substream->private_data;
225 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 217 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
226 218
227 DBG("Entered %s\n", __func__); 219 pr_debug("Entered %s\n", __func__);
228 220
229 /* disable the PLL */ 221 /* disable the PLL */
230 return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0); 222 return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0);
@@ -246,7 +238,7 @@ static int neo1973_get_scenario(struct snd_kcontrol *kcontrol,
246 238
247static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario) 239static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario)
248{ 240{
249 DBG("Entered %s\n", __func__); 241 pr_debug("Entered %s\n", __func__);
250 242
251 switch (neo1973_scenario) { 243 switch (neo1973_scenario) {
252 case NEO_AUDIO_OFF: 244 case NEO_AUDIO_OFF:
@@ -330,7 +322,7 @@ static int neo1973_set_scenario(struct snd_kcontrol *kcontrol,
330{ 322{
331 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 323 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
332 324
333 DBG("Entered %s\n", __func__); 325 pr_debug("Entered %s\n", __func__);
334 326
335 if (neo1973_scenario == ucontrol->value.integer.value[0]) 327 if (neo1973_scenario == ucontrol->value.integer.value[0])
336 return 0; 328 return 0;
@@ -344,7 +336,7 @@ static u8 lm4857_regs[4] = {0x00, 0x40, 0x80, 0xC0};
344 336
345static void lm4857_write_regs(void) 337static void lm4857_write_regs(void)
346{ 338{
347 DBG("Entered %s\n", __func__); 339 pr_debug("Entered %s\n", __func__);
348 340
349 if (i2c_master_send(i2c, lm4857_regs, 4) != 4) 341 if (i2c_master_send(i2c, lm4857_regs, 4) != 4)
350 printk(KERN_ERR "lm4857: i2c write failed\n"); 342 printk(KERN_ERR "lm4857: i2c write failed\n");
@@ -357,7 +349,7 @@ static int lm4857_get_reg(struct snd_kcontrol *kcontrol,
357 int shift = (kcontrol->private_value >> 8) & 0x0F; 349 int shift = (kcontrol->private_value >> 8) & 0x0F;
358 int mask = (kcontrol->private_value >> 16) & 0xFF; 350 int mask = (kcontrol->private_value >> 16) & 0xFF;
359 351
360 DBG("Entered %s\n", __func__); 352 pr_debug("Entered %s\n", __func__);
361 353
362 ucontrol->value.integer.value[0] = (lm4857_regs[reg] >> shift) & mask; 354 ucontrol->value.integer.value[0] = (lm4857_regs[reg] >> shift) & mask;
363 return 0; 355 return 0;
@@ -385,7 +377,7 @@ static int lm4857_get_mode(struct snd_kcontrol *kcontrol,
385{ 377{
386 u8 value = lm4857_regs[LM4857_CTRL] & 0x0F; 378 u8 value = lm4857_regs[LM4857_CTRL] & 0x0F;
387 379
388 DBG("Entered %s\n", __func__); 380 pr_debug("Entered %s\n", __func__);
389 381
390 if (value) 382 if (value)
391 value -= 5; 383 value -= 5;
@@ -399,7 +391,7 @@ static int lm4857_set_mode(struct snd_kcontrol *kcontrol,
399{ 391{
400 u8 value = ucontrol->value.integer.value[0]; 392 u8 value = ucontrol->value.integer.value[0];
401 393
402 DBG("Entered %s\n", __func__); 394 pr_debug("Entered %s\n", __func__);
403 395
404 if (value) 396 if (value)
405 value += 5; 397 value += 5;
@@ -506,9 +498,9 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = {
506 */ 498 */
507static int neo1973_wm8753_init(struct snd_soc_codec *codec) 499static int neo1973_wm8753_init(struct snd_soc_codec *codec)
508{ 500{
509 int i, err; 501 int err;
510 502
511 DBG("Entered %s\n", __func__); 503 pr_debug("Entered %s\n", __func__);
512 504
513 /* set up NC codec pins */ 505 /* set up NC codec pins */
514 snd_soc_dapm_nc_pin(codec, "LOUT2"); 506 snd_soc_dapm_nc_pin(codec, "LOUT2");
@@ -526,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
526 set_scenario_endpoints(codec, NEO_AUDIO_OFF); 518 set_scenario_endpoints(codec, NEO_AUDIO_OFF);
527 519
528 /* add neo1973 specific controls */ 520 /* add neo1973 specific controls */
529 for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) { 521 err = snd_soc_add_controls(codec, wm8753_neo1973_controls,
530 err = snd_ctl_add(codec->card, 522 ARRAY_SIZE(8753_neo1973_controls));
531 snd_soc_cnew(&wm8753_neo1973_controls[i], 523 if (err < 0)
532 codec, NULL)); 524 return err;
533 if (err < 0)
534 return err;
535 }
536 525
537 /* set up neo1973 specific audio routes */ 526 /* set up neo1973 specific audio routes */
538 err = snd_soc_dapm_add_routes(codec, dapm_routes, 527 err = snd_soc_dapm_add_routes(codec, dapm_routes,
@@ -585,21 +574,15 @@ static struct snd_soc_card neo1973 = {
585 .num_links = ARRAY_SIZE(neo1973_dai), 574 .num_links = ARRAY_SIZE(neo1973_dai),
586}; 575};
587 576
588static struct wm8753_setup_data neo1973_wm8753_setup = {
589 .i2c_bus = 0,
590 .i2c_address = 0x1a,
591};
592
593static struct snd_soc_device neo1973_snd_devdata = { 577static struct snd_soc_device neo1973_snd_devdata = {
594 .card = &neo1973, 578 .card = &neo1973,
595 .codec_dev = &soc_codec_dev_wm8753, 579 .codec_dev = &soc_codec_dev_wm8753,
596 .codec_data = &neo1973_wm8753_setup,
597}; 580};
598 581
599static int lm4857_i2c_probe(struct i2c_client *client, 582static int lm4857_i2c_probe(struct i2c_client *client,
600 const struct i2c_device_id *id) 583 const struct i2c_device_id *id)
601{ 584{
602 DBG("Entered %s\n", __func__); 585 pr_debug("Entered %s\n", __func__);
603 586
604 i2c = client; 587 i2c = client;
605 588
@@ -609,7 +592,7 @@ static int lm4857_i2c_probe(struct i2c_client *client,
609 592
610static int lm4857_i2c_remove(struct i2c_client *client) 593static int lm4857_i2c_remove(struct i2c_client *client)
611{ 594{
612 DBG("Entered %s\n", __func__); 595 pr_debug("Entered %s\n", __func__);
613 596
614 i2c = NULL; 597 i2c = NULL;
615 598
@@ -620,7 +603,7 @@ static u8 lm4857_state;
620 603
621static int lm4857_suspend(struct i2c_client *dev, pm_message_t state) 604static int lm4857_suspend(struct i2c_client *dev, pm_message_t state)
622{ 605{
623 DBG("Entered %s\n", __func__); 606 pr_debug("Entered %s\n", __func__);
624 607
625 dev_dbg(&dev->dev, "lm4857_suspend\n"); 608 dev_dbg(&dev->dev, "lm4857_suspend\n");
626 lm4857_state = lm4857_regs[LM4857_CTRL] & 0xf; 609 lm4857_state = lm4857_regs[LM4857_CTRL] & 0xf;
@@ -633,7 +616,7 @@ static int lm4857_suspend(struct i2c_client *dev, pm_message_t state)
633 616
634static int lm4857_resume(struct i2c_client *dev) 617static int lm4857_resume(struct i2c_client *dev)
635{ 618{
636 DBG("Entered %s\n", __func__); 619 pr_debug("Entered %s\n", __func__);
637 620
638 if (lm4857_state) { 621 if (lm4857_state) {
639 lm4857_regs[LM4857_CTRL] |= (lm4857_state & 0x0f); 622 lm4857_regs[LM4857_CTRL] |= (lm4857_state & 0x0f);
@@ -644,7 +627,7 @@ static int lm4857_resume(struct i2c_client *dev)
644 627
645static void lm4857_shutdown(struct i2c_client *dev) 628static void lm4857_shutdown(struct i2c_client *dev)
646{ 629{
647 DBG("Entered %s\n", __func__); 630 pr_debug("Entered %s\n", __func__);
648 631
649 dev_dbg(&dev->dev, "lm4857_shutdown\n"); 632 dev_dbg(&dev->dev, "lm4857_shutdown\n");
650 lm4857_regs[LM4857_CTRL] &= 0xf0; 633 lm4857_regs[LM4857_CTRL] &= 0xf0;
@@ -675,7 +658,7 @@ static int __init neo1973_init(void)
675{ 658{
676 int ret; 659 int ret;
677 660
678 DBG("Entered %s\n", __func__); 661 pr_debug("Entered %s\n", __func__);
679 662
680 if (!machine_is_neo1973_gta01()) { 663 if (!machine_is_neo1973_gta01()) {
681 printk(KERN_INFO 664 printk(KERN_INFO
@@ -706,7 +689,7 @@ static int __init neo1973_init(void)
706 689
707static void __exit neo1973_exit(void) 690static void __exit neo1973_exit(void)
708{ 691{
709 DBG("Entered %s\n", __func__); 692 pr_debug("Entered %s\n", __func__);
710 693
711 i2c_del_driver(&lm4857_i2c_driver); 694 i2c_del_driver(&lm4857_i2c_driver);
712 platform_device_unregister(neo1973_snd_device); 695 platform_device_unregister(neo1973_snd_device);