From: "Wang, Sen" <sen@ti.com>
To: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>,
Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
Baojun Xu <baojun.xu@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>,
Shawn Guo <shengchao.guo@oss.qualcomm.com>
Cc: <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, 9 Oct 2026 22:07:51 -0500 [thread overview]
Message-ID: <24f08aa9-079a-42e1-80e6-3aa5e74e6e41@ti.com> (raw)
In-Reply-To: <20261009-nord-asoc-driver-support-v3-v3-2-0c1897f21ccf@oss.qualcomm.com>
On 10/9/2026 8:12 AM, 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>
Hi Mohammd, thanks for your patches.
> ---
> sound/soc/codecs/pcm1681.c | 137 +++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 131 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c
> index 60fdbe5c4..a1ccf1edf 100644
> --- a/sound/soc/codecs/pcm1681.c
> +++ b/sound/soc/codecs/pcm1681.c
>
>
> - return devm_snd_soc_register_component(&client->dev,
> - &soc_component_dev_pcm1681,
> - &pcm1681_dai, 1);
> + ret = clk_prepare_enable(priv->sck);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to enable sck\n");
> +
> + pcm1681_sck_settle(priv);
> +
> + /* The clock is on, so hand the now-active device over to runtime PM */
> + pm_runtime_set_autosuspend_delay(dev, 100);
> + pm_runtime_use_autosuspend(dev);
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> + pm_runtime_idle(dev);
For the sake of consistency let's add mark_last_busy first, so that
first suspend won't skip the delay.
> +static void pcm1681_i2c_remove(struct i2c_client *client)
> +{
> + struct pcm1681_private *priv = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + pm_runtime_dont_use_autosuspend(dev);
> + pm_runtime_disable(dev);
> + /* Runtime PM may already have gated the clock */
> + if (!pm_runtime_status_suspended(dev))
> + clk_disable_unprepare(priv->sck);
> + pm_runtime_set_suspended(dev);
> +}
> +
Sashiko reported something valid here so please take a look at this.
> +static int pcm1681_runtime_resume(struct device *dev)
> +{
> + struct pcm1681_private *priv = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = clk_prepare_enable(priv->sck);
> + if (ret) {
> + dev_err(dev, "Failed to enable sck: %d\n", ret);
> + return ret;
> + }
> +
> + pcm1681_sck_settle(priv);
> +
> + regcache_cache_only(priv->regmap, false);
> + ret = regcache_sync(priv->regmap);
I'm wondering if this would cause regression on existing boards without
SCK clock, since now regcache_sync writes from runtime resume at stream
open, before machine/CPU DAI startup or machine hw_params that may
enable SCK. Rather than writing in codec hw_params as before. Did/can
you try running your board with runtime PM but without the SCK and see
what it does?
The SCK dt might not be optional afterall with runtime PM
enabled.Overall I think it's a cramped patch with runtime PM, regcache
enable and SCK clock support which are all major features and shall be
bisected individually, therefore can you decouple and have separate
patches instead?
Best,
Sen Wang
next prev parent reply other threads:[~2026-10-10 3:09 UTC|newest]
Thread overview: 14+ 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-09 13:12 ` [PATCH v3 2/7] ASoC: codec: pcm1681: Add optional SCK clock and runtime PM support Mohammad Rafi Shaik
2026-10-09 13:23 ` sashiko-bot
2026-10-10 3:07 ` Wang, Sen [this message]
2026-10-09 13:12 ` [PATCH v3 3/7] ASoC: codec: pcm1681: Add TDM support Mohammad Rafi Shaik
2026-10-09 13:20 ` sashiko-bot
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-09 13:12 ` [PATCH v3 5/7] ASoC: codec: pcm1681: Enable " Mohammad Rafi Shaik
2026-10-09 13:21 ` sashiko-bot
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
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=24f08aa9-079a-42e1-80e6-3aa5e74e6e41@ti.com \
--to=sen@ti.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=shengchao.guo@oss.qualcomm.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