• Cristian Ciocaltea's avatar
    ASoC: cs35l41: Fix broken shared boost activation · 77bf613f
    Cristian Ciocaltea authored
    Enabling the active/passive shared boosts requires setting SYNC_EN, but
    *not* before receiving the PLL Lock signal.
    
    Due to improper error handling, it was not obvious that waiting for the
    completion operation times out and, consequently, the shared boost is
    never activated.
    
    Further investigations revealed the signal is triggered while
    snd_pcm_start() is executed, right after receiving the
    SNDRV_PCM_TRIGGER_START command, which happens long after the
    SND_SOC_DAPM_PRE_PMU event handler is invoked as part of
    snd_pcm_prepare().  That is where cs35l41_global_enable() is called
    from.
    
    Increasing the wait duration doesn't help, as it only causes an
    unnecessary delay in the invocation of snd_pcm_start().  Moving the wait
    and the subsequent regmap operations to the SNDRV_PCM_TRIGGER_START
    callback is not a solution either, since they would be executed in an
    IRQ-off atomic context.
    
    Solve the issue by setting the SYNC_EN bit in PWR_CTRL3 register right
    after receiving the PLL Lock interrupt.
    
    Additionally, drop the unnecessary writes to PWR_CTRL1 register, part of
    the original mdsync_up_seq, which would have toggled GLOBAL_EN with
    unwanted consequences on PLL locking behavior.
    
    Fixes: f5030564 ("ALSA: cs35l41: Add shared boost feature")
    Signed-off-by: default avatarCristian Ciocaltea <cristian.ciocaltea@collabora.com>
    Reviewed-by: default avatarDavid Rhodes <david.rhodes@cirrus.com>
    Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/r/20230907171010.1447274-5-cristian.ciocaltea@collabora.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    77bf613f
cs35l41-lib.c 49 KB