Skip to content

Commit fa29133

Browse files
oortcometbroonie
authored andcommitted
ASoC: rt5682: Enable Vref2 under using PLL2
Enable Vref2 under long term using PLL2 to avoid clock unstable. Signed-off-by: derek.fang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 12eb3ad commit fa29133

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

sound/soc/codecs/rt5682.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -967,13 +967,12 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
967967
rt5682_enable_push_button_irq(component, false);
968968
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
969969
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
970-
if (snd_soc_dapm_get_pin_status(dapm, "MICBIAS"))
970+
if (!snd_soc_dapm_get_pin_status(dapm, "MICBIAS"))
971971
snd_soc_component_update_bits(component,
972-
RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0);
973-
else
972+
RT5682_PWR_ANLG_1, RT5682_PWR_MB, 0);
973+
if (!snd_soc_dapm_get_pin_status(dapm, "Vref2"))
974974
snd_soc_component_update_bits(component,
975-
RT5682_PWR_ANLG_1,
976-
RT5682_PWR_VREF2 | RT5682_PWR_MB, 0);
975+
RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0);
977976
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
978977
RT5682_PWR_CBJ, 0);
979978

@@ -1609,8 +1608,7 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = {
16091608
0, set_filter_clk, SND_SOC_DAPM_PRE_PMU),
16101609
SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0,
16111610
rt5682_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1612-
SND_SOC_DAPM_SUPPLY("Vref2", RT5682_PWR_ANLG_1, RT5682_PWR_VREF2_BIT, 0,
1613-
NULL, 0),
1611+
SND_SOC_DAPM_SUPPLY("Vref2", SND_SOC_NOPM, 0, 0, NULL, 0),
16141612
SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, NULL, 0),
16151613

16161614
/* ASRC */
@@ -2493,6 +2491,15 @@ static int rt5682_wclk_prepare(struct clk_hw *hw)
24932491
snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS");
24942492
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
24952493
RT5682_PWR_MB, RT5682_PWR_MB);
2494+
2495+
snd_soc_dapm_force_enable_pin_unlocked(dapm, "Vref2");
2496+
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
2497+
RT5682_PWR_VREF2 | RT5682_PWR_FV2,
2498+
RT5682_PWR_VREF2);
2499+
usleep_range(55000, 60000);
2500+
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
2501+
RT5682_PWR_FV2, RT5682_PWR_FV2);
2502+
24962503
snd_soc_dapm_force_enable_pin_unlocked(dapm, "I2S1");
24972504
snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL2F");
24982505
snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL2B");
@@ -2518,9 +2525,12 @@ static void rt5682_wclk_unprepare(struct clk_hw *hw)
25182525
snd_soc_dapm_mutex_lock(dapm);
25192526

25202527
snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS");
2528+
snd_soc_dapm_disable_pin_unlocked(dapm, "Vref2");
25212529
if (!rt5682->jack_type)
25222530
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
2531+
RT5682_PWR_VREF2 | RT5682_PWR_FV2 |
25232532
RT5682_PWR_MB, 0);
2533+
25242534
snd_soc_dapm_disable_pin_unlocked(dapm, "I2S1");
25252535
snd_soc_dapm_disable_pin_unlocked(dapm, "PLL2F");
25262536
snd_soc_dapm_disable_pin_unlocked(dapm, "PLL2B");

0 commit comments

Comments
 (0)