ASoC: wcd9310: Configure bandgap/clock block when needed.
The current code enables bandgap/clock block at boot but never
turns off these blocks when not in use. This results in higher
than expected power leakage in idle mode.
Disable bandgap and clock blocks when no audio is playing and
no headset is inserted.
CRs-Fixed: 330961
Change-Id: I1f51d99320ffe03ef1a569349405ad4cbaa9c868
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
diff --git a/sound/soc/codecs/wcd9310.c b/sound/soc/codecs/wcd9310.c
index 3d41abf..50dede5 100644
--- a/sound/soc/codecs/wcd9310.c
+++ b/sound/soc/codecs/wcd9310.c
@@ -2610,14 +2610,15 @@
if ((tabla->bandgap_type == TABLA_BANDGAP_OFF) &&
(choice == TABLA_BANDGAP_AUDIO_MODE)) {
tabla_codec_enable_audio_mode_bandgap(codec);
- } else if ((tabla->bandgap_type == TABLA_BANDGAP_AUDIO_MODE) &&
- (choice == TABLA_BANDGAP_MBHC_MODE)) {
+ } else if (choice == TABLA_BANDGAP_MBHC_MODE) {
snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x2,
0x2);
snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x80,
0x80);
snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x4,
0x4);
+ snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x01,
+ 0x01);
usleep_range(1000, 1000);
snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x80,
0x00);
@@ -2793,6 +2794,10 @@
tabla_codec_enable_clock_block(codec, 0);
tabla_codec_calibrate_hs_polling(codec);
tabla_codec_start_hs_polling(codec);
+ } else {
+ tabla_codec_enable_bandgap(codec,
+ TABLA_BANDGAP_AUDIO_MODE);
+ tabla_codec_enable_clock_block(codec, 0);
}
} else {
@@ -2814,6 +2819,10 @@
}
snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1,
0x05, 0x01);
+ } else {
+ tabla_codec_disable_clock_block(codec);
+ tabla_codec_enable_bandgap(codec,
+ TABLA_BANDGAP_OFF);
}
}
return 0;
@@ -3993,8 +4002,8 @@
if (!tabla->mclk_enabled) {
snd_soc_update_bits(codec, TABLA_A_TX_COM_BIAS, 0xE0, 0x00);
- tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_AUDIO_MODE);
- tabla_codec_enable_clock_block(codec, 0);
+ tabla_codec_disable_clock_block(codec);
+ tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_OFF);
}
tabla->mbhc_polling_active = false;
@@ -4646,10 +4655,6 @@
goto err_pdata;
}
- /* TODO only enable bandgap when necessary in order to save power */
- tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_AUDIO_MODE);
- tabla_codec_enable_clock_block(codec, 0);
-
snd_soc_add_controls(codec, tabla_snd_controls,
ARRAY_SIZE(tabla_snd_controls));
snd_soc_dapm_new_controls(dapm, tabla_dapm_widgets,