devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Mark Brown <broonie@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Banajit Goswami <bgoswami@quicinc.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/5] ASoC: codecs: Add WCD939x Soundwire devices driver
Date: Fri, 15 Dec 2023 14:19:50 +0100	[thread overview]
Message-ID: <d41d4cc3-81eb-431c-b158-673b7ef92727@linaro.org> (raw)
In-Reply-To: <e8b5099c-ceb2-4605-94bc-efd09ad55cb7@sirena.org.uk>

On 13/12/2023 19:31, Mark Brown wrote:
> On Thu, Dec 07, 2023 at 11:28:07AM +0100, Neil Armstrong wrote:
>> Add Soundwire Slave driver for the WCD9390/WCD9395 Audio Codec.
>>
>> The WCD9390/WCD9395 Soundwire devices will be used by the
>> main WCD9390/WCD9395 Audio Codec driver to access registers
>> and configure Soundwire RX and TX ports.
> 
>> +static const struct reg_default wcd939x_defaults[] = {
> 
>> +	{ WCD939X_DIGITAL_MODE_STATUS_0, 0x00 },
>> +	{ WCD939X_DIGITAL_MODE_STATUS_1, 0x00 },
> 
> There's a bunch of registers like this which look like they should be
> volatile and are actually volatile which makes supplying defaults rather
> strange - in general volatile registers shouldn't have defaults.

Indeed I'll clean those up

> 
>> +	{ WCD939X_DIGITAL_EFUSE_REG_0, 0x00 },
>> +	{ WCD939X_DIGITAL_EFUSE_REG_1, 0xff },
>> +	{ WCD939X_DIGITAL_EFUSE_REG_2, 0xff },
> 
> With the fuse registers even though I'd expect them to be cachable the
> whole point is usually that these are programmable per device and
> therefore I'd not expect defaults, I'd expect them to be cached on first
> use.

Ack

> 
>> +static bool wcd939x_readonly_register(struct device *dev, unsigned int reg)
>> +{
> 
>> +	case WCD939X_DIGITAL_CHIP_ID0:
>> +	case WCD939X_DIGITAL_CHIP_ID1:
>> +	case WCD939X_DIGITAL_CHIP_ID2:
>> +	case WCD939X_DIGITAL_CHIP_ID3:
> 
>> +	case WCD939X_DIGITAL_EFUSE_REG_0:
>> +	case WCD939X_DIGITAL_EFUSE_REG_1:
>> +	case WCD939X_DIGITAL_EFUSE_REG_2:
> 
>> +	/* Consider all readonly registers as volatile */
>> +	.volatile_reg = wcd939x_readonly_register,
> 
> There's a bunch of the readonly registers that I'd expect to be cachable
> at runtime - I *hope* the chip ID doesn't change at runtime!  OTOH it
> likely doesn't matter so perhaps it's fine but the comment could use
> some improvement.


I'll improve this

> 
>> +static int wcd939x_sdw_component_bind(struct device *dev, struct device *master,
>> +				      void *data)
>> +{
>> +	/* Bind is required by component framework */
>> +	return 0;
>> +}
>> +
>> +static void wcd939x_sdw_component_unbind(struct device *dev,
>> +					 struct device *master, void *data)
>> +{
>> +	/* Unbind is required by component framework */
>> +}
>> +
>> +static const struct component_ops wcd939x_sdw_component_ops = {
>> +	.bind = wcd939x_sdw_component_bind,
>> +	.unbind = wcd939x_sdw_component_unbind,
>> +};
> 
> So what exactly is the component framework *doing* here then?  It really
> would be better to get this fixed in the component framework if this is
> a sensible usage.

So the component framework is here to synchronize probes of the main codec
and soundwire devices, because the main codec needs the soundwire devices
to access registers.
I assume this design was chosen to limit probe defer infinite loops waiting
for the soundwire devices to probe

I'll propose a change on the component framework, without any insurance it
would be accepted.

> 
>> +static int __maybe_unused wcd939x_sdw_runtime_resume(struct device *dev)
>> +{
>> +	struct wcd939x_sdw_priv *wcd = dev_get_drvdata(dev);
>> +
>> +	if (wcd->regmap) {
>> +		regcache_cache_only(wcd->regmap, false);
>> +		regcache_sync(wcd->regmap);
>> +	}
>> +
>> +	pm_runtime_mark_last_busy(dev);
> 
> The pm_runtime_mark_last_busy() in the resume function is a bit of a
> weird pattern - usually this is something that the user updates and more
> normally when releasing a runtime PM reference.

I took this from wcd938x_sd, I'll check the rationale of it in the resume function.

Thanks,
Neil

  reply	other threads:[~2023-12-15 13:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 10:28 [PATCH v3 0/5] ASoC: codecs: add support for WCD939x Codec Neil Armstrong
2023-12-07 10:28 ` [PATCH v3 1/5] ASoC: dt-bindings: qcom,wcd938x: move out common properties Neil Armstrong
2023-12-07 10:28 ` [PATCH v3 2/5] ASoC: dt-bindings: document WCD939x Audio Codec Neil Armstrong
2023-12-07 10:28 ` [PATCH v3 3/5] ASoC: codec: wcd-mbhc-v2: add support when connected behind an USB-C audio mux Neil Armstrong
2023-12-07 10:28 ` [PATCH v3 4/5] ASoC: codecs: Add WCD939x Soundwire devices driver Neil Armstrong
2023-12-13 18:31   ` Mark Brown
2023-12-15 13:19     ` Neil Armstrong [this message]
2023-12-07 10:28 ` [PATCH v3 5/5] ASoC: codecs: Add WCD939x Codec driver Neil Armstrong
2023-12-13 19:20   ` Mark Brown
2023-12-15 13:11     ` Neil Armstrong

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=d41d4cc3-81eb-431c-b158-673b7ef92727@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.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=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.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;
as well as URLs for NNTP newsgroup(s).