diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-04-22 13:39:39 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-04-22 16:37:02 -0400 |
commit | 42768a12822c3a0a6d7db69445281db975938294 (patch) | |
tree | 8cc3955d8c9bc154f04caee941ef839bde56170c | |
parent | 246d0a17f5e09af0794960164269fc8988a8811c (diff) |
ASoC: Use DAPM supply widget for WM8903 charge pump
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/wm8903.c | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index c5391841d41f..a3a489da008f 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -217,7 +217,6 @@ struct wm8903_priv { | |||
217 | int sysclk; | 217 | int sysclk; |
218 | 218 | ||
219 | /* Reference counts */ | 219 | /* Reference counts */ |
220 | int charge_pump_users; | ||
221 | int class_w_users; | 220 | int class_w_users; |
222 | int playback_active; | 221 | int playback_active; |
223 | int capture_active; | 222 | int capture_active; |
@@ -373,6 +372,15 @@ static void wm8903_reset(struct snd_soc_codec *codec) | |||
373 | #define WM8903_OUTPUT_INT 0x2 | 372 | #define WM8903_OUTPUT_INT 0x2 |
374 | #define WM8903_OUTPUT_IN 0x1 | 373 | #define WM8903_OUTPUT_IN 0x1 |
375 | 374 | ||
375 | static int wm8903_cp_event(struct snd_soc_dapm_widget *w, | ||
376 | struct snd_kcontrol *kcontrol, int event) | ||
377 | { | ||
378 | WARN_ON(event != SND_SOC_DAPM_POST_PMU); | ||
379 | mdelay(4); | ||
380 | |||
381 | return 0; | ||
382 | } | ||
383 | |||
376 | /* | 384 | /* |
377 | * Event for headphone and line out amplifier power changes. Special | 385 | * Event for headphone and line out amplifier power changes. Special |
378 | * power up/down sequences are required in order to maximise pop/click | 386 | * power up/down sequences are required in order to maximise pop/click |
@@ -382,12 +390,9 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
382 | struct snd_kcontrol *kcontrol, int event) | 390 | struct snd_kcontrol *kcontrol, int event) |
383 | { | 391 | { |
384 | struct snd_soc_codec *codec = w->codec; | 392 | struct snd_soc_codec *codec = w->codec; |
385 | struct wm8903_priv *wm8903 = codec->private_data; | ||
386 | struct i2c_client *i2c = codec->control_data; | ||
387 | u16 val; | 393 | u16 val; |
388 | u16 reg; | 394 | u16 reg; |
389 | int shift; | 395 | int shift; |
390 | u16 cp_reg = wm8903_read(codec, WM8903_CHARGE_PUMP_0); | ||
391 | 396 | ||
392 | switch (w->reg) { | 397 | switch (w->reg) { |
393 | case WM8903_POWER_MANAGEMENT_2: | 398 | case WM8903_POWER_MANAGEMENT_2: |
@@ -419,18 +424,6 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
419 | /* Short the output */ | 424 | /* Short the output */ |
420 | val &= ~(WM8903_OUTPUT_SHORT << shift); | 425 | val &= ~(WM8903_OUTPUT_SHORT << shift); |
421 | wm8903_write(codec, reg, val); | 426 | wm8903_write(codec, reg, val); |
422 | |||
423 | wm8903->charge_pump_users++; | ||
424 | |||
425 | dev_dbg(&i2c->dev, "Charge pump use count now %d\n", | ||
426 | wm8903->charge_pump_users); | ||
427 | |||
428 | if (wm8903->charge_pump_users == 1) { | ||
429 | dev_dbg(&i2c->dev, "Enabling charge pump\n"); | ||
430 | wm8903_write(codec, WM8903_CHARGE_PUMP_0, | ||
431 | cp_reg | WM8903_CP_ENA); | ||
432 | mdelay(4); | ||
433 | } | ||
434 | } | 427 | } |
435 | 428 | ||
436 | if (event & SND_SOC_DAPM_POST_PMU) { | 429 | if (event & SND_SOC_DAPM_POST_PMU) { |
@@ -464,19 +457,6 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
464 | wm8903_write(codec, reg, val); | 457 | wm8903_write(codec, reg, val); |
465 | } | 458 | } |
466 | 459 | ||
467 | if (event & SND_SOC_DAPM_POST_PMD) { | ||
468 | wm8903->charge_pump_users--; | ||
469 | |||
470 | dev_dbg(&i2c->dev, "Charge pump use count now %d\n", | ||
471 | wm8903->charge_pump_users); | ||
472 | |||
473 | if (wm8903->charge_pump_users == 0) { | ||
474 | dev_dbg(&i2c->dev, "Disabling charge pump\n"); | ||
475 | wm8903_write(codec, WM8903_CHARGE_PUMP_0, | ||
476 | cp_reg & ~WM8903_CP_ENA); | ||
477 | } | ||
478 | } | ||
479 | |||
480 | return 0; | 460 | return 0; |
481 | } | 461 | } |
482 | 462 | ||
@@ -844,26 +824,28 @@ SND_SOC_DAPM_MIXER("Right Speaker Mixer", WM8903_POWER_MANAGEMENT_4, 0, 0, | |||
844 | SND_SOC_DAPM_PGA_E("Left Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, | 824 | SND_SOC_DAPM_PGA_E("Left Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, |
845 | 1, 0, NULL, 0, wm8903_output_event, | 825 | 1, 0, NULL, 0, wm8903_output_event, |
846 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 826 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
847 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 827 | SND_SOC_DAPM_PRE_PMD), |
848 | SND_SOC_DAPM_PGA_E("Right Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, | 828 | SND_SOC_DAPM_PGA_E("Right Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, |
849 | 0, 0, NULL, 0, wm8903_output_event, | 829 | 0, 0, NULL, 0, wm8903_output_event, |
850 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 830 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
851 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 831 | SND_SOC_DAPM_PRE_PMD), |
852 | 832 | ||
853 | SND_SOC_DAPM_PGA_E("Left Line Output PGA", WM8903_POWER_MANAGEMENT_3, 1, 0, | 833 | SND_SOC_DAPM_PGA_E("Left Line Output PGA", WM8903_POWER_MANAGEMENT_3, 1, 0, |
854 | NULL, 0, wm8903_output_event, | 834 | NULL, 0, wm8903_output_event, |
855 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 835 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
856 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 836 | SND_SOC_DAPM_PRE_PMD), |
857 | SND_SOC_DAPM_PGA_E("Right Line Output PGA", WM8903_POWER_MANAGEMENT_3, 0, 0, | 837 | SND_SOC_DAPM_PGA_E("Right Line Output PGA", WM8903_POWER_MANAGEMENT_3, 0, 0, |
858 | NULL, 0, wm8903_output_event, | 838 | NULL, 0, wm8903_output_event, |
859 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 839 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
860 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 840 | SND_SOC_DAPM_PRE_PMD), |
861 | 841 | ||
862 | SND_SOC_DAPM_PGA("Left Speaker PGA", WM8903_POWER_MANAGEMENT_5, 1, 0, | 842 | SND_SOC_DAPM_PGA("Left Speaker PGA", WM8903_POWER_MANAGEMENT_5, 1, 0, |
863 | NULL, 0), | 843 | NULL, 0), |
864 | SND_SOC_DAPM_PGA("Right Speaker PGA", WM8903_POWER_MANAGEMENT_5, 0, 0, | 844 | SND_SOC_DAPM_PGA("Right Speaker PGA", WM8903_POWER_MANAGEMENT_5, 0, 0, |
865 | NULL, 0), | 845 | NULL, 0), |
866 | 846 | ||
847 | SND_SOC_DAPM_SUPPLY("Charge Pump", WM8903_CHARGE_PUMP_0, 0, 0, | ||
848 | wm8903_cp_event, SND_SOC_DAPM_POST_PMU), | ||
867 | }; | 849 | }; |
868 | 850 | ||
869 | static const struct snd_soc_dapm_route intercon[] = { | 851 | static const struct snd_soc_dapm_route intercon[] = { |
@@ -951,6 +933,11 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
951 | 933 | ||
952 | { "ROP", NULL, "Right Speaker PGA" }, | 934 | { "ROP", NULL, "Right Speaker PGA" }, |
953 | { "RON", NULL, "Right Speaker PGA" }, | 935 | { "RON", NULL, "Right Speaker PGA" }, |
936 | |||
937 | { "Left Headphone Output PGA", NULL, "Charge Pump" }, | ||
938 | { "Right Headphone Output PGA", NULL, "Charge Pump" }, | ||
939 | { "Left Line Output PGA", NULL, "Charge Pump" }, | ||
940 | { "Right Line Output PGA", NULL, "Charge Pump" }, | ||
954 | }; | 941 | }; |
955 | 942 | ||
956 | static int wm8903_add_widgets(struct snd_soc_codec *codec) | 943 | static int wm8903_add_widgets(struct snd_soc_codec *codec) |