]> www.infradead.org Git - users/dwmw2/linux.git/commit
ASoC: cs35l56: Prevent overwriting firmware ASP config
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Mon, 8 Apr 2024 10:18:03 +0000 (11:18 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 8 Apr 2024 13:10:01 +0000 (14:10 +0100)
commitdfd2ffb373999630a14d7ff614440f1c2fcc704c
tree23d62871a2f0546f7b9cbc041cd0ec1f3af6e34b
parentd4884fd48a44f3d7f0d4d7399b663b69c000233d
ASoC: cs35l56: Prevent overwriting firmware ASP config

Only populate the ASP1 config registers in the regmap cache if the
ASP DAI is used. This prevents regcache_sync() from overwriting
these registers with their defaults when the firmware owns
control of these registers.

On a SoundWire system the ASP could be owned by the firmware to
share reference audio with the firmware on other cs35l56. Or it
can be used as a normal codec-codec interface owned by the driver.
The driver must not overwrite the registers if the firmware has
control of them.

The original implementation for this in commit 07f7d6e7a124
("ASoC: cs35l56: Fix for initializing ASP1 mixer registers") was
to still provide defaults for these registers, assuming that if
they were never reconfigured from defaults then regcache_sync()
would not write them out because they are not dirty. Unfortunately
regcache_sync() is not that smart. If the chip has not reset (so
the driver has not called regcache_mark_dirty()) a regcache_sync()
could write out registers that are not dirty.

To avoid accidental overwriting of the ASP registers, they are
removed from the table of defaults and instead are populated with
defaults only if one of the ASP DAI configuration functions is
called. So if the DAI has never been configured, the firmware is
assumed to have ownership of these registers, and the regmap cache
will not contain any entries for them.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 07f7d6e7a124 ("ASoC: cs35l56: Fix for initializing ASP1 mixer registers")
Link: https://msgid.link/r/20240408101803.43183-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/cs35l56.h
sound/soc/codecs/cs35l56-shared.c
sound/soc/codecs/cs35l56.c