]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
ASoC: codecs: wcd938x: fix accessing regmap on unattached devices
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 3 May 2023 14:41:02 +0000 (16:41 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 9 Aug 2023 09:37:37 +0000 (11:37 +0200)
commitd8b9b45020d4cfe6472b2a0f94e34fa435bfdf50
tree7a98ea5106f7f97270ce4358524c11eb1924fbbc
parent96cd9a1fcefa52a55a098dbd34a12d3379e4b126
ASoC: codecs: wcd938x: fix accessing regmap on unattached devices

BugLink: https://bugs.launchpad.net/bugs/2028580
[ Upstream commit 84822215acd15bd86a7759a835271e63bba83a7b ]

The WCD938x comes with three devices on two Linux drivers:
1. RX Soundwire device (wcd938x-sdw.c driver),
2. TX Soundwire device, which is used to access devices via regmap (also
   wcd938x-sdw.c driver),
3. platform device (wcd938x.c driver) - glue and component master,
   actually having most of the code using TX Soundwire device regmap.

When RX and TX Soundwire devices probe, the component master (platform
device) bind tries to write micbias configuration via TX Soundwire
regmap.  This might happen before TX Soundwire enumerates, so the regmap
access fails.  On Qualcomm SM8550 board with WCD9385:

  qcom-soundwire 6d30000.soundwire-controller: Qualcomm Soundwire controller v2.0.0 Registered
  wcd938x_codec audio-codec: bound sdw:0:0217:010d:00:4 (ops wcd938x_sdw_component_ops)
  wcd938x_codec audio-codec: bound sdw:0:0217:010d:00:3 (ops wcd938x_sdw_component_ops)
  qcom-soundwire 6ad0000.soundwire-controller: swrm_wait_for_wr_fifo_avail err write overflow

Fix the issue by:
1. Moving the regmap creation from platform device to TX Soundwire
   device.  The regmap settings are moved as-is with one difference:
   making the wcd938x_regmap_config const.
2. Using regmap in cache only mode till the actual TX Soundwire device
   enumerates and then sync the regmap cache.

Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Message-Id: <20230503144102.242240-1-krzysztof.kozlowski@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
sound/soc/codecs/wcd938x-sdw.c
sound/soc/codecs/wcd938x.c
sound/soc/codecs/wcd938x.h