From: Shawn Guo <shengchao.guo@oss.qualcomm.com>
To: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
Cc: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
Baojun Xu <baojun.xu@ti.com>, Sen Wang <sen@ti.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Srinivas Kandagatla <srini@kernel.org>,
linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v3 2/7] ASoC: codec: pcm1681: Add optional SCK clock and runtime PM support
Date: Fri, 16 Oct 2026 21:52:52 +0800 [thread overview]
Message-ID: <atIsNLNBT11XWtRV@QCOM-aGQu4IUr3Y> (raw)
In-Reply-To: <20261009-nord-asoc-driver-support-v3-v3-2-0c1897f21ccf@oss.qualcomm.com>
On Fri, Oct 09, 2026 at 06:42:48PM +0530, Mohammad Rafi Shaik wrote:
> The PCM1681 requires its SCK system clock to be running before register
> access. On platforms where SCK is provided by a gateable clock, register
> access may fail when the clock is disabled.
>
> Add support for an optional "sck" clock and enable it before accessing the
> device. After enabling SCK, wait for the required 65536 system clock cycles
> to allow the device to complete its internal reset sequence.
>
> Use runtime PM to manage SCK instead of keeping it enabled for the lifetime
> of the device. Disable the clock during runtime suspend and restore it on
> runtime resume. Use autosuspend to avoid unnecessary clock toggling between
> closely spaced accesses.
>
> Since the device register state may be lost when SCK is disabled, enable
> the regmap cache. Switch regmap to cache-only mode and mark the cache
> dirty on runtime suspend, then synchronize the cached register state after
> SCK is restored on runtime resume. Mark the zero-detect status register
> volatile since it is updated by hardware.
>
> Drop idle_bias_on so that the component can reach SND_SOC_BIAS_OFF and
> runtime suspend can gate SCK.
>
> Assisted-by: LLM
> Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
[...]
> @@ -304,34 +335,128 @@ MODULE_DEVICE_TABLE(i2c, pcm1681_i2c_id);
>
> static int pcm1681_i2c_probe(struct i2c_client *client)
> {
> + struct device *dev = &client->dev;
> int ret;
> struct pcm1681_private *priv;
>
> - priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> return -ENOMEM;
>
> + priv->sck = devm_clk_get_optional(dev, "sck");
> + if (IS_ERR(priv->sck))
> + return dev_err_probe(dev, PTR_ERR(priv->sck),
> + "Failed to get sck\n");
Holding sck from i2c probe for the lifetime of the device breaks audio
after an ADSP restart on Nord.
There sck is LPASS_CLK_ID_MCLK_1 from q6prmcc, a clock controller that
lives under the ADSP GPR service. Stopping the ADSP removes q6prm and
unregisters its clocks; starting it again registers new ones. pcm1681
is not unbound in between: fw_devlink can't link it to q6prmcc, since
that node has no device until the DSP is up, so the supplier link goes
to the remoteproc device, which stays bound across the restart.
pcm1681 is left with a handle to the orphaned clk, and the first runtime
resume after the restart fails:
pcm1681 0-004c: Failed to enable sck: -6
Reproduce with:
echo stop > /sys/class/remoteproc/remoteproc1/state
echo start > /sys/class/remoteproc/remoteproc1/state
speaker-test -D plughw:0,0 -t sine -l 1
Even with a fresh handle the DAC stays silent, because the
assigned-clock-rates (12.288 MHz) are applied by the i2c core only once,
before probe, and the re-registered provider comes back at its default
19.2 MHz.
The sound card, on the other hand, is torn down and re-created on an
ADSP restart. So what works for me is to move the clock handling into
the component .probe/.remove callbacks: clk_get_optional(), then
of_clk_set_defaults() to re-apply the assigned rate, enable, settle,
regcache_sync() and enable runtime PM in .probe; and the reverse plus
clk_put() in .remove. The i2c probe then only creates the regmap, in
cache-only mode until sck is running, and registers the component.
Shawn
next prev parent reply other threads:[~2026-10-16 13:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 13:12 [PATCH v3 0/7] ASoC: qcom: Add Nord audio support Mohammad Rafi Shaik
2026-10-09 13:12 ` [PATCH v3 1/7] ASoC: dt-bindings: ti,pcm1681: Document the optional SCK clock Mohammad Rafi Shaik
2026-10-13 7:01 ` Krzysztof Kozlowski
2026-10-14 17:16 ` Mohammad Rafi Shaik
2026-10-15 8:24 ` Krzysztof Kozlowski
2026-10-09 13:12 ` [PATCH v3 2/7] ASoC: codec: pcm1681: Add optional SCK clock and runtime PM support Mohammad Rafi Shaik
2026-10-10 3:07 ` Wang, Sen
2026-10-16 13:52 ` Shawn Guo [this message]
2026-10-09 13:12 ` [PATCH v3 3/7] ASoC: codec: pcm1681: Add TDM support Mohammad Rafi Shaik
2026-10-10 3:12 ` Wang, Sen
2026-10-09 13:12 ` [PATCH v3 4/7] ASoC: dt-bindings: ti,pcm1681: Document the PCM1681 supplies Mohammad Rafi Shaik
2026-10-12 6:25 ` Krzysztof Kozlowski
2026-10-14 17:18 ` Mohammad Rafi Shaik
2026-10-09 13:12 ` [PATCH v3 5/7] ASoC: codec: pcm1681: Enable " Mohammad Rafi Shaik
2026-10-10 3:13 ` Wang, Sen
2026-10-09 13:12 ` [PATCH v3 6/7] ASoC: dt-bindings: qcom,sm8250: Add Nord sound card Mohammad Rafi Shaik
2026-10-09 13:12 ` [PATCH v3 7/7] ASoC: qcom: sc8280xp: Add Nord sound card support Mohammad Rafi Shaik
2026-10-13 9:09 ` Ajay Kumar Nandam
2026-10-14 17:19 ` Mohammad Rafi Shaik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=atIsNLNBT11XWtRV@QCOM-aGQu4IUr3Y \
--to=shengchao.guo@oss.qualcomm.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kevin-lu@ti.com \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mohammad.rafi.shaik@oss.qualcomm.com \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=sen@ti.com \
--cc=shenghao-ding@ti.com \
--cc=srini@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®