From: Shawn Guo <shengchao.guo@oss.qualcomm.com>
To: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
Cc: "Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Nuno Sá" <nuno.sa@analog.com>,
"Shenghao Ding" <shenghao-ding@ti.com>,
"Kevin Lu" <kevin-lu@ti.com>, "Baojun Xu" <baojun.xu@ti.com>,
"Sen Wang" <sen@ti.com>, "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Srinivas Kandagatla" <srini@kernel.org>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v1 3/5] ASoC: codec: pcm1681: Enable system clock before regmap access
Date: Wed, 9 Sep 2026 22:59:19 +0800 [thread overview]
Message-ID: <aqF0R0FVrnC3hi6K@QCOM-aGQu4IUr3Y> (raw)
In-Reply-To: <20260907-nord-asoc-driver-support-v1-3-997d3b20cf43@oss.qualcomm.com>
On Mon, Sep 07, 2026 at 11:39:44PM +0530, Mohammad Rafi Shaik wrote:
> The PCM1681 DAC requires the SCK (system clock) input to be
> present for proper device operation. On platforms where SCK
> is provided by a controllable clock source, register accesses
> over I2C may fail when the clock is not enabled.
>
> Add optional clock support to the PCM1681 driver by acquiring
> the "sck" clock, enabling it during probe, and registering a
> managed cleanup action to disable it during device removal or
> probe failure.
>
> This allows platforms to model the PCM1681 system clock through
> the common clock framework and ensures the device is operational
> before regmap initialization and register accesses occur.
>
> Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
> ---
> sound/soc/codecs/pcm1681.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c
> index 60fdbe5c4e05..cfe549176d14 100644
> --- a/sound/soc/codecs/pcm1681.c
> +++ b/sound/soc/codecs/pcm1681.c
> @@ -12,6 +12,7 @@
> #include <linux/i2c.h>
> #include <linux/regmap.h>
> #include <linux/of.h>
> +#include <linux/clk.h>
> #include <sound/pcm.h>
> #include <sound/pcm_params.h>
> #include <sound/soc.h>
> @@ -74,6 +75,7 @@ struct pcm1681_private {
> unsigned int deemph;
> /* Current rate for deemphasis control */
> unsigned int rate;
> + struct clk *sclk;
> };
>
> static const int pcm1681_deemph[] = { 44100, 48000, 32000 };
> @@ -311,6 +313,22 @@ static int pcm1681_i2c_probe(struct i2c_client *client)
> if (!priv)
> return -ENOMEM;
>
> + priv->sclk = devm_clk_get_optional(&client->dev, "sck");
> + if (IS_ERR(priv->sclk))
> + return dev_err_probe(&client->dev, PTR_ERR(priv->sclk),
> + "Failed to get sck\n");
> +
> + ret = clk_prepare_enable(priv->sclk);
> + if (ret)
> + return dev_err_probe(&client->dev, ret,
> + "Failed to enable sck\n");
> +
> + ret = devm_add_action_or_reset(&client->dev,
> + (void (*)(void *))clk_disable_unprepare,
> + priv->sclk);
> + if (ret)
> + return ret;
> +
All three calls can collapse into one?
priv->sclk = devm_clk_get_optional_enabled(&client->dev, "sck");
if (IS_ERR(priv->sclk))
return dev_err_probe(&client->dev, PTR_ERR(priv->sclk), "Failed to get sck\n");
Also, priv->sclk is never used after probe, so drop the struct member
and use a local.
Shawn
> priv->regmap = devm_regmap_init_i2c(client, &pcm1681_regmap);
> if (IS_ERR(priv->regmap)) {
> ret = PTR_ERR(priv->regmap);
>
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2026-09-09 14:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 18:09 [PATCH 0/5] ASoC: qcom: Add Nord Ride audio support Mohammad Rafi Shaik
2026-09-07 18:09 ` [PATCH v1 1/5] ASoC: codec: adau1977-i2c: Add OF device match table Mohammad Rafi Shaik
2026-09-07 18:20 ` sashiko-bot
2026-09-09 14:44 ` Shawn Guo
2026-09-07 18:09 ` [PATCH v1 2/5] ASoC: dt-bindings: ti,pcm1681: Document the optional SCK clock Mohammad Rafi Shaik
2026-09-09 14:50 ` Shawn Guo
2026-09-07 18:09 ` [PATCH v1 3/5] ASoC: codec: pcm1681: Enable system clock before regmap access Mohammad Rafi Shaik
2026-09-07 18:17 ` sashiko-bot
2026-09-08 17:26 ` Mark Brown
2026-09-09 12:36 ` Mohammad Rafi Shaik
2026-09-09 12:39 ` Mark Brown
2026-09-09 12:45 ` Mohammad Rafi Shaik
2026-09-09 14:59 ` Shawn Guo [this message]
2026-09-07 18:09 ` [PATCH v1 4/5] ASoC: dt-bindings: qcom,sm8250: Add Nord Ride sound card Mohammad Rafi Shaik
2026-09-07 18:20 ` sashiko-bot
2026-09-09 14:54 ` Shawn Guo
2026-09-15 16:01 ` Mohammad Rafi Shaik
2026-09-07 18:09 ` [PATCH v1 5/5] ASoC: qcom: sc8280xp: Add Nord Ride sound card support Mohammad Rafi Shaik
2026-09-09 15:37 ` Shawn Guo
2026-09-15 16:32 ` Mohammad Rafi Shaik
2026-09-09 14:46 ` [PATCH 0/5] ASoC: qcom: Add Nord Ride audio support Shawn Guo
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=aqF0R0FVrnC3hi6K@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=lars@metafoo.de \
--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=nuno.sa@analog.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.