mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
	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 11/11] ASoC: codecs: add Qualcomm Tambora (WCD9378) SDCA codec
Date: Mon, 7 Sep 2026 14:03:00 +0100	[thread overview]
Message-ID: <7006ad74-334c-41cb-bcc8-9ef5e75dde7e@oss.qualcomm.com> (raw)
In-Reply-To: <525f887e-cb3b-4e74-8b93-30c3baeb8018@linux.dev>

Thanks Pierre for review,

On 9/7/26 12:32 PM, Pierre-Louis Bossart wrote:
> On 9/7/26 10:37, Srinivas Kandagatla wrote:
>> Add support for the Qualcomm Tambora (WCD9378) headset codec in SDCA
>> mode over SoundWire.  On ARM/DT platforms without ACPI/DisCo firmware
>> the SDCA topology and SoundWire port properties are supplied as static
>> data through the codec driver.
> 
> wow, I realize now I completely misunderstood what this whole endeavor
> was about. I *thought* the point was to read the information about all
> the functions from Device Tree tables. I now understand there are no
> such tables, all the information is encoded in C as part of the
> higher-level codec driver.
> 
> Is this really intended?
Unfortunately Yes.

> I mean, the whole ACPI set of definitions relied on the _DSD mechanism
> that mimics what DT provides. Do we really want all this information in
> C? Why not have a set of DT properties for each function?
> 

We discussed this topic at LPC 2025, Devicetree MC:
    "DeviceTrees - MIPI SoundWire Device Class for Audio (SDCA) and
     classic ACPI-DT problem"
    https://lpc.events/event/19/contributions/2024/

Among other options presented, representing them in a intermediate
format was something which was doable.

I have also proposed another follow up of this topic in this years LPC
Devicetree MC too

RFC of this patchset got some comments from DT maitainers.

DT maintainers are not happy with the idea of keeping this info in DT
while it can be derived from compatible string.

https://lkml.org/lkml/2026/7/29/1166

> I guess my main objection is for opaque initialization data aka blind
> writes or SWF table, this should really come from platform firmware, no?
This table is directly generated from ACPI tables both from Lenovo T14
and Reference platform.

on ARM platforms DT is is the only firmware entry for such things and
its not 1:1 with ACPI example, Somethings that can be derived can not be
in Device tree description so its bit of mix.

> With this approach you'd have an endless set of kernel quirks for each
> board variant using the same codec.

@Krzysztof Kozlowski <krzk+dt@kernel.org> that is a valid point.

Idea is to gate them using platform specific compatibles, so far we have
few laptops that are pretty much identical w.r.t the description, may be
we got lucky in this early stages.

In future if it turns out to need a quirks per platform or changes
needed in this table then we should be able to handle it with platform
specific device compatibles.



>> +static int wcd9378_sdca_hw_init(struct sdw_slave *slave)
>> +{
>> +	struct device *dev = &slave->dev;
>> +	struct gpio_desc *reset;
>> +	int ret;
>> +
>> +	/* No SPMI parent: supplies and reset live on the SoundWire DT node. */
>> +	ret = devm_regulator_bulk_get_enable(dev,
>> +					     ARRAY_SIZE(wcd9378_sdca_supplies),
>> +					     wcd9378_sdca_supplies);
>> +	if (ret)
>> +		return dev_err_probe(dev, ret, "failed to enable supplies\n");
>> +
>> +	reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
>> +	if (IS_ERR(reset))
>> +		return dev_err_probe(dev, PTR_ERR(reset),
>> +				     "failed to get reset GPIO\n");
>> +
>> +	if (reset) {
>> +		gpiod_set_value(reset, 1);
>> +		usleep_range(20, 30);
>> +		gpiod_set_value(reset, 0);
>> +		usleep_range(20, 30);
>> +	}
> 
> Could this be part of wcd9378_sdca_probe()

Good point, I have now moved this to probe and eliminates need of
hw_init callback all together, I can fold that in next version.


--srini
>> +
>> +	/* SCP writes below need the slave attached. */
>> +	ret = sdw_slave_wait_for_init(slave, 5000);
>> +	if (ret)
>> +		return dev_err_probe(dev, ret,
>> +				     "slave attach timeout: %d\n", ret);
> 
> That wait doesn't seem required, if you are using the existing class
> probe there's already a wait?
>> +
>> +	/*
>> +	 * TX PDM clock: bank-1 shadow + SCP_COMMIT. SCP survives PDE
>> +	 * cycles; one-shot at hw_init before any port is enabled.
>> +	 */
>> +	ret = sdw_write_no_pm(slave, WCD9378_SCP_HOST_CLK_DIV2_CTL_B1, 0x01);
>> +	if (ret)
>> +		return dev_err_probe(dev, ret,
>> +				     "HOST_CLK_DIV2_CTL_B1: %d\n", ret);
>> +
>> +	ret = sdw_write_no_pm(slave, SDW_SCP_COMMIT, 0x02);
>> +	if (ret)
>> +		return dev_err_probe(dev, ret,
>> +				     "SCP_COMMIT: %d\n", ret);
>> +
>> +	return 0;
> 
> and this could also be done in the existing .status callback upon
> enumeration.
> 
> In other words the need for this hw_init() isn't very clear to me...
> 
>> +}
>> +
>> +static int wcd9378_sdca_populate_function(struct sdw_slave *slave,
>> +					  struct sdca_function_data *function)
>> +{
>> +	/* @function->desc is already set by the framework; fill payload only. */
>> +	if (function->desc->type != wcd9378_sdca_desc.type)
>> +		return -EINVAL;
>> +
>> +	function->num_entities    = wcd9378_sdca_data.num_entities;
>> +	function->entities        = wcd9378_sdca_data.entities;
>> +	function->num_clusters    = wcd9378_sdca_data.num_clusters;
>> +	function->clusters        = wcd9378_sdca_data.clusters;
>> +	function->num_init_table  = wcd9378_sdca_data.num_init_table;
>> +	function->init_table      = wcd9378_sdca_data.init_table;
>> +	function->reset_max_delay = wcd9378_sdca_data.reset_max_delay;
>> +
>> +	/* Elevate is_volatile / has_reset to match the DisCo/ACPI path. */
>> +	sdca_apply_default_control_classifiers(function);
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct sdca_class_hw_ops wcd9378_sdca_hw_ops = {
>> +	.hw_init           = wcd9378_sdca_hw_init,
>> +	.populate_function = wcd9378_sdca_populate_function,
>> +};
>> +
>> +int wcd9378_sdca_probe(struct sdw_slave *slave,
>> +		       const struct sdw_device_id *id)
>> +{
>> +	struct device *dev = &slave->dev;
>> +	struct sdca_device_data *data = &slave->sdca_data;
>> +	struct wcd9378_priv *priv;
>> +
>> +	/*
>> +	 * 0x0217:0x0110 covers both mobile and compute modes; the
>> +	 * qcom,wcd9378c variant compatible identifies compute-mode
>> +	 * nodes only.  Mobile-mode nodes carry the plain class-ID
>> +	 * compatible and are picked up by the mobile driver.
>> +	 */
>> +	if (!device_is_compatible(dev, "qcom,wcd9378c"))
>> +		return -ENODEV;
>> +
>> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>> +	if (!priv)
>> +		return -ENOMEM;
>> +
>> +	dev_set_drvdata(dev, priv);
>> +
>> +	/* DT has no DisCo enumeration; seed the descriptor here. */
>> +	if (!data->num_functions) {
>> +		data->function[0].type = wcd9378_sdca_desc.type;
>> +		data->function[0].adr  = wcd9378_sdca_desc.adr;
>> +		data->function[0].name = wcd9378_sdca_desc.name;
>> +		data->num_functions    = 1;
>> +	}
>> +
>> +	return sdca_class_probe(slave, &priv->class, &wcd9378_sdca_hw_ops);
>> +}


  reply	other threads:[~2026-09-07 13:03 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
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 [this message]
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=7006ad74-334c-41cb-bcc8-9ef5e75dde7e@oss.qualcomm.com \
    --to=srinivas.kandagatla@oss.qualcomm.com \
    --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=pierre-louis.bossart@linux.dev \
    --cc=robh@kernel.org \
    --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®