summaryrefslogtreecommitdiff
path: root/asoc
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2023-02-15 19:44:27 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2023-02-15 19:44:27 -0800
commitceb1665c03750165bf7dbd18e67f8a3d5ea48ebf (patch)
tree3156b23cc8f1326a9aba91bb45a9a2459cb50d50 /asoc
parenta6f733392cb4f855a9f8162b6052819b4d943a24 (diff)
parentf9fb310156b7da8263580cb8acf5f96deceea2e5 (diff)
downloadmsm-extra-ceb1665c03750165bf7dbd18e67f8a3d5ea48ebf.tar.gz
Merge "asoc: wcd937x: reset analog and digital path clk ctrl reg only when no active ADC"
Diffstat (limited to 'asoc')
-rw-r--r--asoc/codecs/wcd937x/internal.h1
-rw-r--r--asoc/codecs/wcd937x/wcd937x.c27
2 files changed, 20 insertions, 8 deletions
diff --git a/asoc/codecs/wcd937x/internal.h b/asoc/codecs/wcd937x/internal.h
index 128d3f77..a47dfeaa 100644
--- a/asoc/codecs/wcd937x/internal.h
+++ b/asoc/codecs/wcd937x/internal.h
@@ -95,6 +95,7 @@ struct wcd937x_priv {
struct snd_info_entry *variant_entry;
int ear_rx_path;
int ana_clk_count;
+ int adc_count;
struct mutex ana_tx_clk_lock;
u8 tx_master_ch_map[WCD937X_MAX_SLAVE_CH_TYPES];
bool usbc_hs_status;
diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c
index 8f42ea1b..51520716 100644
--- a/asoc/codecs/wcd937x/wcd937x.c
+++ b/asoc/codecs/wcd937x/wcd937x.c
@@ -1449,6 +1449,7 @@ static int wcd937x_codec_enable_adc(struct snd_soc_dapm_widget *w,
mutex_lock(&wcd937x->ana_tx_clk_lock);
wcd937x->ana_clk_count++;
mutex_unlock(&wcd937x->ana_tx_clk_lock);
+ wcd937x->adc_count++;
snd_soc_component_update_bits(component,
WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x80, 0x80);
snd_soc_component_update_bits(component,
@@ -1466,8 +1467,13 @@ static int wcd937x_codec_enable_adc(struct snd_soc_dapm_widget *w,
wcd937x_tx_connect_port(component, MBHC, false);
clear_bit(AMIC2_BCS_ENABLE, &wcd937x->status_mask);
}
- snd_soc_component_update_bits(component,
- WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x08, 0x00);
+
+ wcd937x->adc_count--;
+ if (wcd937x->adc_count <= 0) {
+ snd_soc_component_update_bits(component,
+ WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x08, 0x00);
+ wcd937x->adc_count = 0;
+ }
break;
};
@@ -1507,14 +1513,19 @@ static int wcd937x_enable_req(struct snd_soc_dapm_widget *w,
WCD937X_ANA_TX_CH3, 0x80, 0x80);
break;
case SND_SOC_DAPM_POST_PMD:
- snd_soc_component_update_bits(component,
+ if (wcd937x->adc_count == 0) {
+ snd_soc_component_update_bits(component,
WCD937X_ANA_TX_CH1, 0x80, 0x00);
- snd_soc_component_update_bits(component,
+ snd_soc_component_update_bits(component,
WCD937X_ANA_TX_CH2, 0x80, 0x00);
- snd_soc_component_update_bits(component,
+ snd_soc_component_update_bits(component,
WCD937X_ANA_TX_CH3, 0x80, 0x00);
- snd_soc_component_update_bits(component,
+ snd_soc_component_update_bits(component,
WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x10, 0x00);
+ snd_soc_component_update_bits(component,
+ WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x80, 0x00);
+ }
+
mutex_lock(&wcd937x->ana_tx_clk_lock);
wcd937x->ana_clk_count--;
if (wcd937x->ana_clk_count <= 0) {
@@ -1524,8 +1535,6 @@ static int wcd937x_enable_req(struct snd_soc_dapm_widget *w,
}
mutex_unlock(&wcd937x->ana_tx_clk_lock);
- snd_soc_component_update_bits(component,
- WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x80, 0x00);
break;
};
return 0;
@@ -2871,6 +2880,8 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component)
component, WCD937X_DIGITAL_EFUSE_REG_0) & 0x1E) >> 1;
wcd937x->variant = variant;
+ wcd937x->adc_count = 0;
+
wcd937x->fw_data = devm_kzalloc(component->dev,
sizeof(*(wcd937x->fw_data)),
GFP_KERNEL);