From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Jaroslav Kysela <perex@perex.cz>,
Liam Girdwood <lgirdwood@gmail.com>,
Maciej Strozek <mstrozek@opensource.cirrus.com>,
Takashi Iwai <tiwai@suse.com>,
Faiz Nabi Kuchay <fkuchay@oss.qualcomm.com>,
Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>,
patches@opensource.cirrus.com, linux-sound@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 04/11] ASoC: SDCA: add hw_ops with hw_init hook
Date: Mon, 7 Sep 2026 13:29:18 +0200 [thread overview]
Message-ID: <603a67c1-dcc6-469f-9420-5ffbf55000bf@linux.dev> (raw)
In-Reply-To: <20260907083727.733705-5-srinivas.kandagatla@oss.qualcomm.com>
On 9/7/26 10:37, Srinivas Kandagatla wrote:
> Add struct sdca_class_hw_ops with a hw_init callback that runs from
> sdca_class_probe() before the class regmap is created. Codec drivers
> use it to enable supplies, toggle reset GPIOs and program initial
> vendor register state.
It'd be good to clarify when this hw_init() is supposed to run. Probe
and hardware being available are usually two different things. I think
this relies on a behavior at the device level where the function
subdevices are only created after SoundWire device enumeration.
Also the 'hw_init' naming could be confusing, this is used in many codec
drivers to track if the hardware has previously been initialized.
> sdca_class_probe() gains an optional const struct sdca_class_hw_ops *
> argument (NULL for pure-generic SDCA parts) and stashes it on
> sdca_class_drv for later use.
>
> No functional change for the built-in class_sdw_driver, which passes
> NULL.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> ---
> include/sound/sdca_class.h | 17 ++++++++++++++++-
> sound/soc/sdca/sdca_class.c | 15 +++++++++++++--
> 2 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/include/sound/sdca_class.h b/include/sound/sdca_class.h
> index c6063f22be7a..3342937d09fd 100644
> --- a/include/sound/sdca_class.h
> +++ b/include/sound/sdca_class.h
> @@ -20,6 +20,17 @@ struct regmap;
> struct sdw_slave;
> struct sdca_function_data;
>
> +/**
> + * struct sdca_class_hw_ops - optional codec hardware callbacks
> + * @hw_init: enable supplies, toggle reset, etc. Runs from sdca_class_probe()
> + * before the class regmap is created and before the slave is
> + * ATTACHED; callers needing bus I/O must sdw_slave_wait_for_init()
> + * first.
> + */
> +struct sdca_class_hw_ops {
> + int (*hw_init)(struct sdw_slave *slave);
> +};
> +
> struct sdca_class_drv {
> struct device *dev;
> struct regmap *dev_regmap;
> @@ -27,6 +38,8 @@ struct sdca_class_drv {
>
> struct sdca_interrupt_info *irq_info;
>
> + const struct sdca_class_hw_ops *hw_ops;
> +
> struct mutex regmap_lock;
> /* Serialise function initialisations */
> struct mutex init_lock;
> @@ -35,7 +48,9 @@ struct sdca_class_drv {
>
> /* Library helpers used by codec-specific SDCA SoundWire drivers. */
> int sdca_class_read_prop(struct sdw_slave *sdw);
> -int sdca_class_probe(struct sdw_slave *sdw, struct sdca_class_drv *drv);
> +int sdca_class_probe(struct sdw_slave *sdw,
> + struct sdca_class_drv *drv,
> + const struct sdca_class_hw_ops *hw_ops);
> void sdca_class_remove(struct sdca_class_drv *drv);
>
> /*
> diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c
> index b952fa6eb802..374de7d9e0b5 100644
> --- a/sound/soc/sdca/sdca_class.c
> +++ b/sound/soc/sdca/sdca_class.c
> @@ -153,6 +153,8 @@ static void class_boot_work(struct work_struct *work)
> * allocation and sets its own dev_set_drvdata() -- the framework
> * does not touch drvdata. Typically embedded in the codec's own
> * priv struct so codec drivers can keep per-slave state.
> + * @hw_ops: optional device-specific hw_ops (may be NULL for pure-generic
> + * SDCA parts that need no quirks)
> *
> * Codec-specific SoundWire drivers call this from their .probe after
> * allocating a struct sdca_class_drv (usually embedded in their own
> @@ -160,7 +162,9 @@ static void class_boot_work(struct work_struct *work)
> * sdca_class_drv fields, sets up the class regmap, and queues the
> * deferred boot work.
> */
> -int sdca_class_probe(struct sdw_slave *sdw, struct sdca_class_drv *drv)
> +int sdca_class_probe(struct sdw_slave *sdw,
> + struct sdca_class_drv *drv,
> + const struct sdca_class_hw_ops *hw_ops)
> {
> struct device *dev = &sdw->dev;
> struct regmap_config *dev_config;
> @@ -178,9 +182,16 @@ int sdca_class_probe(struct sdw_slave *sdw, struct sdca_class_drv *drv)
>
> drv->dev = dev;
> drv->sdw = sdw;
> + drv->hw_ops = hw_ops;
> mutex_init(&drv->regmap_lock);
> mutex_init(&drv->init_lock);
>
> + if (hw_ops && hw_ops->hw_init) {
> + ret = hw_ops->hw_init(sdw);
> + if (ret)
> + return dev_err_probe(dev, ret, "hw_init failed\n");
> + }
> +
nit-pick: should the INIT_WORK be moved higher before this hw_init()? It
has nothing to do with regmap and we'd lose the requirement that
hw_init() be run before regmap inits.
> INIT_WORK(&drv->boot_work, class_boot_work);
>
> dev_config->lock_arg = &drv->regmap_lock;
> @@ -222,7 +233,7 @@ static int class_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *id
>
> dev_set_drvdata(&sdw->dev, drv);
>
> - return sdca_class_probe(sdw, drv);
> + return sdca_class_probe(sdw, drv, NULL);
> }
>
> /**
next prev parent reply other threads:[~2026-09-07 11:32 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 8:37 [PATCH v2 00/11] ASoC: SDCA: enable on DT platforms and add Qualcomm WCD9378 (Tambora) codec Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 01/11] ASoC: SDCA: allow building without ACPI Srinivas Kandagatla
2026-09-07 8:54 ` Richard Fitzgerald
2026-09-07 9:09 ` Takashi Iwai
2026-09-07 8:37 ` [PATCH v2 02/11] ASoC: SDCA: export PM helpers keyed on sdca_class_drv Srinivas Kandagatla
2026-09-08 16:22 ` Charles Keepax
2026-09-08 17:49 ` Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 03/11] ASoC: SDCA: expose class SoundWire probe/remove/read_prop as library Srinivas Kandagatla
2026-09-07 11:31 ` Pierre-Louis Bossart
2026-09-07 13:29 ` Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 04/11] ASoC: SDCA: add hw_ops with hw_init hook Srinivas Kandagatla
2026-09-07 11:29 ` Pierre-Louis Bossart [this message]
2026-09-07 13:33 ` Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 05/11] ASoC: SDCA: add populate_function hw_op for DT function data Srinivas Kandagatla
2026-09-07 11:28 ` Pierre-Louis Bossart
2026-09-07 13:16 ` Charles Keepax
2026-09-08 16:25 ` Charles Keepax
2026-09-08 18:00 ` Srinivas Kandagatla
2026-09-09 8:34 ` Charles Keepax
2026-09-07 8:37 ` [PATCH v2 06/11] ASoC: SDCA: class_function: xlate sound-dai cell by entity index Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 07/11] ASoC: SDCA: register SDCA_FUNCTION_TYPE_SIMPLE_JACK in class function driver Srinivas Kandagatla
2026-09-07 11:32 ` Pierre-Louis Bossart
2026-09-07 8:37 ` [PATCH v2 08/11] ASoC: SDCA: make find_sdca_control_reset() return void Srinivas Kandagatla
2026-09-07 11:32 ` Pierre-Louis Bossart
2026-09-07 13:03 ` Charles Keepax
2026-09-07 13:16 ` Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 09/11] ASoC: SDCA: add sdca_apply_default_control_classifiers() helper Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 10/11] dt-bindings: sound: qcom: add Tambora WCD9378 SDCA codec Srinivas Kandagatla
2026-09-07 8:37 ` [PATCH v2 11/11] ASoC: codecs: add Qualcomm Tambora (WCD9378) " Srinivas Kandagatla
2026-09-07 11:32 ` Pierre-Louis Bossart
2026-09-07 13:03 ` Srinivas Kandagatla
2026-09-07 19:47 ` Pierre-Louis Bossart
2026-09-07 21:26 ` Mark Brown
2026-09-07 22:37 ` Srinivas Kandagatla
2026-09-08 8:49 ` Charles Keepax
2026-09-08 9:09 ` Srinivas Kandagatla
2026-09-08 10:37 ` Richard Fitzgerald
2026-09-08 12:31 ` Srinivas Kandagatla
2026-09-08 13:20 ` Charles Keepax
2026-09-08 13:34 ` Srinivas Kandagatla
2026-09-08 14:22 ` Pierre-Louis Bossart
2026-09-08 15:33 ` Charles Keepax
2026-09-08 15:34 ` Srinivas Kandagatla
2026-09-08 15:58 ` Uwe Kleine-König
2026-09-08 16:20 ` Charles Keepax
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=603a67c1-dcc6-469f-9420-5ffbf55000bf@linux.dev \
--to=pierre-louis.bossart@linux.dev \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fkuchay@oss.qualcomm.com \
--cc=jorijnvdgraaf@catcrafts.net \
--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=mstrozek@opensource.cirrus.com \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=srinivas.kandagatla@oss.qualcomm.com \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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®