On 5/3/23 09:41, Krzysztof Kozlowski wrote:
The WCD938x comes with three devices on two Linux drivers:
- RX Soundwire device (wcd938x-sdw.c driver),
- TX Soundwire device, which is used to access devices via regmap (also wcd938x-sdw.c driver),
- 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:
- 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.
- 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
Cc: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Cc: Patrick Lai quic_plai@quicinc.com Cc: Srinivas Kandagatla srinivas.kandagatla@linaro.org
Changes since v1:
- Previous solution touched Soundwire. Rework it according to feedback. https://lore.kernel.org/all/20230420101617.142225-7-krzysztof.kozlowski@lina...
Thank you Mark and Pierre-Louis for great hints and valuable feedback!
LGTM, this was a very interesting thread to comment on.
Reviewed-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com