The DAC clocks through an internal reset over the 65536 system clock
cycles that follow sck appearing, and its I2C control port does not
answer until that reset has completed. The driver waits out those cycles
right after enabling sck, in probe and in runtime resume, and syncs the
register cache once the wait is over.
That assumes sck is running by the time clk_prepare_enable() returns,
and not every provider works that way. On Qualcomm boards sck is an
LPASS clock exported by the q6prm clock controller, which turns the
enable into an APR command to the ADSP. The command succeeds, but the
pad is only driven while the audio interface the DAC hangs off is
active, and that interface is brought up from the machine driver's
hw_params, by snd_soc_dai_set_sysclk() on the CPU DAI. The machine
driver runs first and the codec DAI straight after it, so the DAC is
microseconds into a 5.3 ms reset when the first stream programs it:
pcm1681 0-004c: ASoC error (-6): at snd_soc_dai_hw_params()
pcm1681 0-004c: ASoC error (-6): at snd_soc_dai_digital_mute()
The second stream works, because by then sck has been running long
enough for the reset to complete, which makes the DAC look like it needs
a longer settle time than it does. The -6 is the i2c-qcom-geni mapping
of an address NACK, so the failure reads as a device that is not there
rather than one that is not ready yet.
Those failed writes also cost the register cache: regmap drops the cache
entry behind a write it could not complete, so the format and soft mute
writes of the failed stream take their registers out of the cache, and
reads of them go to a device that still is not answering.
Stop trying to pick the moment at which the device has to be reachable.
Keep the regmap in cache-only mode until the control port has answered
once, and do the waiting in pcm1681_ensure_ready(), called from
hw_params where the host interface is up and sck is known to be running.
Probe and runtime resume call it too, so a board whose sck runs
continuously is still set up as early as it was before, but neither
fails when the device stays quiet: failing probe would take the DAC away
for good over a clock that is simply not running yet, and while no
stream is running there is nothing that needs the device to be reachable
anyway. Resume only probes the control port, it leaves the reset to
hw_params rather than stalling a resume for a clock that may never
start.
A device that does answer is soft reset before the cache is replayed
onto it, so the cache describes the device instead of assuming the
registers still hold their power-on defaults.
Link: https://lore.kernel.org/all/20261204173012.3644350-1-mohammad.rafi.shaik@oss.qualcomm.com/
Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
Add Nord audio fixes for multi channel support and playback issue in Ride and RRD
FROMLIST: ASoC: pcm1681: Establish contact with the DAC lazily
FROMLIST: arm64: dts: qcom: nord-rrd: Add sound support
FROMLIST: arm64: dts: qcom: nord-ride-embedded: Add sound support
Revert "FROMLIST: ASoC: codec: pcm1681: Acquire sck when bound to a card"
Revert "PENDING: arm64: dts: qcom: nord-rrd: Add sound support"
Revert "PENDING: arm64: dts: qcom: nord-ride-embedded: Add sound support"