ASoC: rt5682s: Reduce coupling of Micbias and Vref2 settings
Some parts of rt5682s CCF function are implemented by 'MICBIAS' and 'Vref2' dapm widgets. There is a risk of causing not expected behavior if we mix using dapm and CCF operations in machine specific code. This patch reduces the coupling. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20220913025658.5005-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
9fc2c8ed92
commit
bfc5e8b860
2 changed files with 28 additions and 28 deletions
|
@ -739,6 +739,7 @@ static void rt5682s_disable_push_button_irq(struct snd_soc_component *component)
|
||||||
*/
|
*/
|
||||||
static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_insert)
|
static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_insert)
|
||||||
{
|
{
|
||||||
|
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
|
||||||
unsigned int val, count;
|
unsigned int val, count;
|
||||||
int jack_type = 0;
|
int jack_type = 0;
|
||||||
|
|
||||||
|
@ -805,12 +806,10 @@ static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_
|
||||||
snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_1,
|
snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_1,
|
||||||
RT5682S_TRIG_JD_MASK, RT5682S_TRIG_JD_LOW);
|
RT5682S_TRIG_JD_MASK, RT5682S_TRIG_JD_LOW);
|
||||||
|
|
||||||
if (!snd_soc_dapm_get_pin_status(&component->dapm, "MICBIAS"))
|
if (!rt5682s->wclk_enabled) {
|
||||||
snd_soc_component_update_bits(component,
|
snd_soc_component_update_bits(component,
|
||||||
RT5682S_PWR_ANLG_1, RT5682S_PWR_MB, 0);
|
RT5682S_PWR_ANLG_1, RT5682S_PWR_VREF2 | RT5682S_PWR_MB, 0);
|
||||||
if (!snd_soc_dapm_get_pin_status(&component->dapm, "Vref2"))
|
}
|
||||||
snd_soc_component_update_bits(component,
|
|
||||||
RT5682S_PWR_ANLG_1, RT5682S_PWR_VREF2, 0);
|
|
||||||
|
|
||||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_3,
|
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_3,
|
||||||
RT5682S_PWR_CBJ, 0);
|
RT5682S_PWR_CBJ, 0);
|
||||||
|
@ -845,6 +844,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
|
||||||
|
|
||||||
snd_soc_dapm_mutex_lock(dapm);
|
snd_soc_dapm_mutex_lock(dapm);
|
||||||
mutex_lock(&rt5682s->calibrate_mutex);
|
mutex_lock(&rt5682s->calibrate_mutex);
|
||||||
|
mutex_lock(&rt5682s->wclk_mutex);
|
||||||
|
|
||||||
val = snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL)
|
val = snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL)
|
||||||
& RT5682S_JDH_RS_MASK;
|
& RT5682S_JDH_RS_MASK;
|
||||||
|
@ -900,6 +900,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
|
||||||
rt5682s->irq_work_delay_time = 50;
|
rt5682s->irq_work_delay_time = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&rt5682s->wclk_mutex);
|
||||||
mutex_unlock(&rt5682s->calibrate_mutex);
|
mutex_unlock(&rt5682s->calibrate_mutex);
|
||||||
snd_soc_dapm_mutex_unlock(dapm);
|
snd_soc_dapm_mutex_unlock(dapm);
|
||||||
|
|
||||||
|
@ -1218,13 +1219,9 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SND_SOC_DAPM_POST_PMD:
|
case SND_SOC_DAPM_POST_PMD:
|
||||||
if (!rt5682s->jack_type) {
|
if (!rt5682s->jack_type && !rt5682s->wclk_enabled) {
|
||||||
if (!snd_soc_dapm_get_pin_status(w->dapm, "MICBIAS"))
|
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
||||||
snd_soc_component_update_bits(component,
|
RT5682S_PWR_VREF2 | RT5682S_PWR_MB, 0);
|
||||||
RT5682S_PWR_ANLG_1, RT5682S_PWR_MB, 0);
|
|
||||||
if (!snd_soc_dapm_get_pin_status(w->dapm, "Vref2"))
|
|
||||||
snd_soc_component_update_bits(component,
|
|
||||||
RT5682S_PWR_ANLG_1, RT5682S_PWR_VREF2, 0);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1615,8 +1612,6 @@ static const struct snd_soc_dapm_widget rt5682s_dapm_widgets[] = {
|
||||||
RT5682S_PWR_LDO_MB2_BIT, 0, NULL, 0),
|
RT5682S_PWR_LDO_MB2_BIT, 0, NULL, 0),
|
||||||
SND_SOC_DAPM_SUPPLY("LDO", RT5682S_PWR_ANLG_3,
|
SND_SOC_DAPM_SUPPLY("LDO", RT5682S_PWR_ANLG_3,
|
||||||
RT5682S_PWR_LDO_BIT, 0, NULL, 0),
|
RT5682S_PWR_LDO_BIT, 0, NULL, 0),
|
||||||
SND_SOC_DAPM_SUPPLY("Vref2", SND_SOC_NOPM, 0, 0, NULL, 0),
|
|
||||||
SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, NULL, 0),
|
|
||||||
|
|
||||||
/* PLL Powers */
|
/* PLL Powers */
|
||||||
SND_SOC_DAPM_SUPPLY_S("PLLA_LDO", 0, RT5682S_PWR_ANLG_3,
|
SND_SOC_DAPM_SUPPLY_S("PLLA_LDO", 0, RT5682S_PWR_ANLG_3,
|
||||||
|
@ -2469,19 +2464,21 @@ static int rt5682s_wclk_prepare(struct clk_hw *hw)
|
||||||
if (!rt5682s_clk_check(rt5682s))
|
if (!rt5682s_clk_check(rt5682s))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
snd_soc_dapm_mutex_lock(dapm);
|
mutex_lock(&rt5682s->wclk_mutex);
|
||||||
|
|
||||||
snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS");
|
|
||||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
||||||
RT5682S_PWR_MB, RT5682S_PWR_MB);
|
RT5682S_PWR_VREF2 | RT5682S_PWR_FV2 | RT5682S_PWR_MB,
|
||||||
|
RT5682S_PWR_VREF2 | RT5682S_PWR_MB);
|
||||||
snd_soc_dapm_force_enable_pin_unlocked(dapm, "Vref2");
|
|
||||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
|
||||||
RT5682S_PWR_VREF2 | RT5682S_PWR_FV2, RT5682S_PWR_VREF2);
|
|
||||||
usleep_range(15000, 20000);
|
usleep_range(15000, 20000);
|
||||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
||||||
RT5682S_PWR_FV2, RT5682S_PWR_FV2);
|
RT5682S_PWR_FV2, RT5682S_PWR_FV2);
|
||||||
|
|
||||||
|
rt5682s->wclk_enabled = 1;
|
||||||
|
|
||||||
|
mutex_unlock(&rt5682s->wclk_mutex);
|
||||||
|
|
||||||
|
snd_soc_dapm_mutex_lock(dapm);
|
||||||
|
|
||||||
snd_soc_dapm_force_enable_pin_unlocked(dapm, "I2S1");
|
snd_soc_dapm_force_enable_pin_unlocked(dapm, "I2S1");
|
||||||
/* Only need to power PLLB due to the rate set restriction */
|
/* Only need to power PLLB due to the rate set restriction */
|
||||||
snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLLB");
|
snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLLB");
|
||||||
|
@ -2502,14 +2499,18 @@ static void rt5682s_wclk_unprepare(struct clk_hw *hw)
|
||||||
if (!rt5682s_clk_check(rt5682s))
|
if (!rt5682s_clk_check(rt5682s))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
snd_soc_dapm_mutex_lock(dapm);
|
mutex_lock(&rt5682s->wclk_mutex);
|
||||||
|
|
||||||
snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS");
|
|
||||||
snd_soc_dapm_disable_pin_unlocked(dapm, "Vref2");
|
|
||||||
if (!rt5682s->jack_type)
|
if (!rt5682s->jack_type)
|
||||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
||||||
RT5682S_PWR_VREF2 | RT5682S_PWR_FV2 | RT5682S_PWR_MB, 0);
|
RT5682S_PWR_VREF2 | RT5682S_PWR_FV2 | RT5682S_PWR_MB, 0);
|
||||||
|
|
||||||
|
rt5682s->wclk_enabled = 0;
|
||||||
|
|
||||||
|
mutex_unlock(&rt5682s->wclk_mutex);
|
||||||
|
|
||||||
|
snd_soc_dapm_mutex_lock(dapm);
|
||||||
|
|
||||||
snd_soc_dapm_disable_pin_unlocked(dapm, "I2S1");
|
snd_soc_dapm_disable_pin_unlocked(dapm, "I2S1");
|
||||||
snd_soc_dapm_disable_pin_unlocked(dapm, "PLLB");
|
snd_soc_dapm_disable_pin_unlocked(dapm, "PLLB");
|
||||||
snd_soc_dapm_sync_unlocked(dapm);
|
snd_soc_dapm_sync_unlocked(dapm);
|
||||||
|
@ -2805,7 +2806,6 @@ static inline int rt5682s_dai_probe_clks(struct snd_soc_component *component)
|
||||||
static int rt5682s_probe(struct snd_soc_component *component)
|
static int rt5682s_probe(struct snd_soc_component *component)
|
||||||
{
|
{
|
||||||
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
|
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
|
||||||
struct snd_soc_dapm_context *dapm = &component->dapm;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rt5682s->component = component;
|
rt5682s->component = component;
|
||||||
|
@ -2814,9 +2814,6 @@ static int rt5682s_probe(struct snd_soc_component *component)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
snd_soc_dapm_disable_pin(dapm, "MICBIAS");
|
|
||||||
snd_soc_dapm_disable_pin(dapm, "Vref2");
|
|
||||||
snd_soc_dapm_sync(dapm);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3113,6 +3110,7 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c)
|
||||||
|
|
||||||
mutex_init(&rt5682s->calibrate_mutex);
|
mutex_init(&rt5682s->calibrate_mutex);
|
||||||
mutex_init(&rt5682s->sar_mutex);
|
mutex_init(&rt5682s->sar_mutex);
|
||||||
|
mutex_init(&rt5682s->wclk_mutex);
|
||||||
rt5682s_calibrate(rt5682s);
|
rt5682s_calibrate(rt5682s);
|
||||||
|
|
||||||
regmap_update_bits(rt5682s->regmap, RT5682S_MICBIAS_2,
|
regmap_update_bits(rt5682s->regmap, RT5682S_MICBIAS_2,
|
||||||
|
|
|
@ -1450,6 +1450,7 @@ struct rt5682s_priv {
|
||||||
struct delayed_work jd_check_work;
|
struct delayed_work jd_check_work;
|
||||||
struct mutex calibrate_mutex;
|
struct mutex calibrate_mutex;
|
||||||
struct mutex sar_mutex;
|
struct mutex sar_mutex;
|
||||||
|
struct mutex wclk_mutex;
|
||||||
|
|
||||||
#ifdef CONFIG_COMMON_CLK
|
#ifdef CONFIG_COMMON_CLK
|
||||||
struct clk_hw dai_clks_hw[RT5682S_DAI_NUM_CLKS];
|
struct clk_hw dai_clks_hw[RT5682S_DAI_NUM_CLKS];
|
||||||
|
@ -1469,6 +1470,7 @@ struct rt5682s_priv {
|
||||||
|
|
||||||
int jack_type;
|
int jack_type;
|
||||||
int irq_work_delay_time;
|
int irq_work_delay_time;
|
||||||
|
int wclk_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
int rt5682s_sel_asrc_clk_src(struct snd_soc_component *component,
|
int rt5682s_sel_asrc_clk_src(struct snd_soc_component *component,
|
||||||
|
|
Loading…
Add table
Reference in a new issue