diff options
| author | Phani Kumar Uppalapati <phaniu@codeaurora.org> | 2017-01-30 18:12:59 -0800 |
|---|---|---|
| committer | Phani Kumar Uppalapati <phaniu@codeaurora.org> | 2017-02-08 12:57:31 -0800 |
| commit | f0864bd919a3799733a8427f1dd46767789ad9d9 (patch) | |
| tree | 714692b5e2ad9c4c169bb05eba3ce430921fcada | |
| parent | 24ff30a814dc44f3680697324dd9443863c7f323 (diff) | |
ASoC: wcd934x: Do not prevent the core entering power collapse
Do not prevent the core to enter into power collapse if it is
scheduled before ASoC probes the codec. Otherwise, digital core
will always be in ON state even after the device is booted up
and audio use cases are not running resulting in higher power
consumption.
Change-Id: Icea1b24e94f46f391aa2cc0cb01044cf8d60e394
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
| -rw-r--r-- | sound/soc/codecs/wcd934x/wcd934x.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/sound/soc/codecs/wcd934x/wcd934x.c b/sound/soc/codecs/wcd934x/wcd934x.c index fbd40fba8586..4c64fad9c20d 100644 --- a/sound/soc/codecs/wcd934x/wcd934x.c +++ b/sound/soc/codecs/wcd934x/wcd934x.c @@ -7807,13 +7807,8 @@ static struct snd_soc_dai_driver tavil_dai[] = { static void tavil_codec_power_gate_digital_core(struct tavil_priv *tavil) { - struct snd_soc_codec *codec = tavil->codec; - - if (!codec) - return; - mutex_lock(&tavil->power_lock); - dev_dbg(codec->dev, "%s: Entering power gating function, %d\n", + dev_dbg(tavil->dev, "%s: Entering power gating function, %d\n", __func__, tavil->power_active_ref); if (tavil->power_active_ref > 0) @@ -7822,16 +7817,16 @@ static void tavil_codec_power_gate_digital_core(struct tavil_priv *tavil) wcd9xxx_set_power_state(tavil->wcd9xxx, WCD_REGION_POWER_COLLAPSE_BEGIN, WCD9XXX_DIG_CORE_REGION_1); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, - 0x01, 0x00); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, - 0x02, 0x00); + regmap_update_bits(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x04, 0x04); + regmap_update_bits(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x01, 0x00); + regmap_update_bits(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x02, 0x00); wcd9xxx_set_power_state(tavil->wcd9xxx, WCD_REGION_POWER_DOWN, WCD9XXX_DIG_CORE_REGION_1); exit: - dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n", + dev_dbg(tavil->dev, "%s: Exiting power gating function, %d\n", __func__, tavil->power_active_ref); mutex_unlock(&tavil->power_lock); } @@ -7840,34 +7835,32 @@ static void tavil_codec_power_gate_work(struct work_struct *work) { struct tavil_priv *tavil; struct delayed_work *dwork; - struct snd_soc_codec *codec; dwork = to_delayed_work(work); tavil = container_of(dwork, struct tavil_priv, power_gate_work); - codec = tavil->codec; - - if (!codec) - return; tavil_codec_power_gate_digital_core(tavil); } /* called under power_lock acquisition */ -static int tavil_dig_core_remove_power_collapse(struct snd_soc_codec *codec) +static int tavil_dig_core_remove_power_collapse(struct tavil_priv *tavil) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); - - snd_soc_write(codec, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5); - snd_soc_write(codec, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_RST_CTL, 0x02, 0x00); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_RST_CTL, 0x02, 0x02); - snd_soc_write(codec, WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3); + regmap_write(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x05); + regmap_write(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x07); + regmap_update_bits(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_RST_CTL, 0x02, 0x00); + regmap_update_bits(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_RST_CTL, 0x02, 0x02); + regmap_write(tavil->wcd9xxx->regmap, + WCD934X_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x03); wcd9xxx_set_power_state(tavil->wcd9xxx, WCD_REGION_POWER_COLLAPSE_REMOVE, WCD9XXX_DIG_CORE_REGION_1); - regcache_mark_dirty(codec->component.regmap); - regcache_sync_region(codec->component.regmap, + regcache_mark_dirty(tavil->wcd9xxx->regmap); + regcache_sync_region(tavil->wcd9xxx->regmap, WCD934X_DIG_CORE_REG_MIN, WCD934X_DIG_CORE_REG_MAX); @@ -7877,7 +7870,6 @@ static int tavil_dig_core_remove_power_collapse(struct snd_soc_codec *codec) static int tavil_dig_core_power_collapse(struct tavil_priv *tavil, int req_state) { - struct snd_soc_codec *codec; int cur_state; /* Exit if feature is disabled */ @@ -7898,10 +7890,6 @@ static int tavil_dig_core_power_collapse(struct tavil_priv *tavil, goto unlock_mutex; } - codec = tavil->codec; - if (!codec) - goto unlock_mutex; - if (req_state == POWER_COLLAPSE) { if (tavil->power_active_ref == 0) { schedule_delayed_work(&tavil->power_gate_work, @@ -7919,7 +7907,7 @@ static int tavil_dig_core_power_collapse(struct tavil_priv *tavil, tavil->wcd9xxx, WCD9XXX_DIG_CORE_REGION_1); if (cur_state == WCD_REGION_POWER_DOWN) { - tavil_dig_core_remove_power_collapse(codec); + tavil_dig_core_remove_power_collapse(tavil); } else { mutex_unlock(&tavil->power_lock); cancel_delayed_work_sync( |
