Skip to content

Commit 0d8ae77

Browse files
committed
ASoC: cs42l84: Do not enable the PLL before the clocks are ready
Enabling the PLL with no valid input clock leads to PLL errors. Don't do that, always disable the PLL before reconfiguring it and let unmute take care of enabling the PLL. Also monitor the PLL error bit and complain if it's set. Signed-off-by: Hector Martin <[email protected]>
1 parent 3716791 commit 0d8ae77

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

sound/soc/codecs/cs42l84.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ static int cs42l84_pll_config(struct snd_soc_component *component)
433433
break;
434434
}
435435

436+
snd_soc_component_update_bits(component, CS42L84_PLL_CTL1, CS42L84_PLL_CTL1_EN, 0);
437+
436438
if (pll_ratio_table[i].mclk_src_sel) {
437439
/* Configure PLL */
438440
snd_soc_component_update_bits(component,
@@ -456,10 +458,6 @@ static int cs42l84_pll_config(struct snd_soc_component *component)
456458
snd_soc_component_write(component,
457459
CS42L84_PLL_DIVOUT,
458460
pll_ratio_table[i].pll_divout);
459-
460-
snd_soc_component_update_bits(component,
461-
CS42L84_PLL_CTL1, CS42L84_PLL_CTL1_EN,
462-
CS42L84_PLL_CTL1_EN);
463461
}
464462

465463
return 0;
@@ -633,6 +631,9 @@ static int cs42l84_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
633631
if (ret < 0)
634632
dev_warn(component->dev, "PLL failed to lock: %d\n", ret);
635633

634+
if (regval & CS42L84_PLL_LOCK_STATUS_ERROR)
635+
dev_warn(component->dev, "PLL lock error\n");
636+
636637
/* PLL must be running to drive glitchless switch logic */
637638
snd_soc_component_update_bits(component,
638639
CS42L84_CCM_CTL1,

sound/soc/codecs/cs42l84.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define CS42L84_TSRS_PLUG_VAL_MASK GENMASK(3, 0)
3232
#define CS42L84_PLL_LOCK_STATUS 0x040e // probably bit 0x10
3333
#define CS42L84_PLL_LOCK_STATUS_LOCKED BIT(4)
34+
#define CS42L84_PLL_LOCK_STATUS_ERROR BIT(5)
3435

3536
#define CS42L84_PLUG 3
3637
#define CS42L84_UNPLUG 0

0 commit comments

Comments
 (0)