From ac4d55c7741a13d4f209a63cce94a9acbbbf4f25 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Tue, 21 Sep 2021 10:31:27 +0200 Subject: [PATCH v2] ASoC: pcm512x: Mend accesses to the I2S_1 and I2S_2 registers Commit 25d27c4f68d2 ("ASoC: pcm512x: Add support for more data formats") breaks the TSE-850 device, which is using a pcm5142 in I2S and CBM_CFS mode (maybe not relevant). Without this fix, the result is: pcm512x 0-004c: Failed to set data format: -16 The root cause is that the chip is in Powerdown mode when pcm512x_set_fmt runs. So, bring the chip out of suspend for the update of the format. Fixes: 25d27c4f68d2 ("ASoC: pcm512x: Add support for more data formats") Signed-off-by: Peter Rosin --- sound/soc/codecs/pcm512x.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 4dc844f3c1fc..07cde6d45233 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -1339,6 +1339,7 @@ static int pcm512x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) int offset = 0; int clock_output; int master_mode; + int resuspend = 0; int ret; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1396,6 +1397,11 @@ static int pcm512x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } + if (pm_runtime_suspended(component->dev)) { + resuspend = 1; + pm_runtime_resume(component->dev); + } + ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, PCM512x_AFMT, afmt); if (ret != 0) { @@ -1410,6 +1416,9 @@ static int pcm512x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return ret; } + if (resuspend) + pm_runtime_suspend(component->dev); + pcm512x->fmt = fmt; return 0; -- 2.20.1