Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Venkat Yadlapati" <venkat.yadlapati@yahoo.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/2] ASoC: codecs: Add NXP TFA9865 amplifier driver
Date: Mon, 16 Nov 2026 08:06:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-216504@kernel.org> (raw)
In-Reply-To: <20261116-vantage-tfa9865-v2-2-a93f976c9479@yahoo.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ASoC: tfa9865: tfa9865_b0_init re-asserts PWDN in
  tfa9865_init()
- [Low] ASoC: tfa9865: redundant volatile_reg callback with
  REGCACHE_NONE
--

commit 616efa16b28b605a452049773ef1a7ad03db31eb
Author: Venkat Yadlapati <venkat.yadlapati@yahoo.com>

ASoC: codecs: Add NXP TFA9865 amplifier driver

This commit adds an ASoC codec driver for the NXP/Goodix TFA9865 mono class-D
speaker amplifier.

> diff --git a/sound/soc/codecs/tfa9865.c b/sound/soc/codecs/tfa9865.c
> new file mode 100644
> index 0000000000000..8a34ede04d43e
> --- /dev/null
> +++ b/sound/soc/codecs/tfa9865.c
[ ... ]
> +static bool tfa9865_volatile_reg(struct device *dev, unsigned int reg)
> +{
> +	switch (reg) {
> +	case TFA9865_SYS_CTRL0 ... TFA9865_DEVICE_INFO:
> +	case 0x10 ... 0x15:	/* status and interrupt flags */
> +		return true;
> +	default:
> +		return false;
> +	}
> +}
> +
> +static const struct regmap_config tfa9865_regmap = {
> +	.reg_bits = 8,
> +	.val_bits = 16,
> +	.max_register = 0xff,
> +
> +	.volatile_reg = tfa9865_volatile_reg,
> +	.cache_type = REGCACHE_NONE,
> +};

[Severity: Low]
Is tfa9865_volatile_reg() needed when tfa9865_regmap uses REGCACHE_NONE?

With REGCACHE_NONE, register caching is disabled and all readable registers
already default to volatile.  Providing .volatile_reg here only causes
debugfs to report registers outside 0x00..0x06 and 0x10..0x15 as non-volatile
even though no cache is active, while marking static ID and control registers
in TFA9865_SYS_CTRL0 ... TFA9865_DEVICE_INFO as volatile.

[ ... ]

> +static const struct reg_sequence tfa9865_b0_init[] = {
> +	/* "generated code" version 2 for TFA9865 B0 from the NXP driver */
> +	{ 0x00, 0xf241 },
> +	{ 0x02, 0x0c28 },
> +	{ 0x08, 0x009a },
> +	{ 0x50, 0xc000 },
> +	{ 0x54, 0x10e0 },
> +	{ 0x5a, 0x5f5e },
> +	{ 0x5b, 0x74e2 },
> +	{ 0x5c, 0xb02b },
> +	{ 0x5f, 0x00a0 },
[ ... ]
> +};
> +
> +static int tfa9865_init(struct tfa9865 *tfa9865)
> +{
> +	struct regmap *regmap = tfa9865->regmap;
> +	unsigned int seed;
> +	int ret;
> +
> +	/*
> +	 * Start from the register defaults, also when the device stayed
> +	 * powered (no reset GPIO, driver rebind). This clears MANSCONF, so
> +	 * the device manager waits in WAIT_SRC below.
> +	 */
> +	ret = regmap_write(regmap, TFA9865_SYS_CTRL0, TFA9865_SYS_CTRL0_I2CR);
> +	if (ret)
> +		return ret;
> +	usleep_range(1000, 2000);
> +
> +	/* Leave power down to make the protected registers accessible */
> +	regmap_clear_bits(regmap, TFA9865_SYS_CTRL0, BIT(TFA9865_SYS_CTRL0_PWDN));
> +	regmap_clear_bits(regmap, TFA9865_CLK_GATING_CTRL, TFA9865_CLK_GATING_CTRL_MANAOOSC);
> +	ret = tfa9865_wait_manstate(tfa9865, TFA9865_MANSTATE_WAIT_SRC);
> +	if (ret)
> +		return ret;
> +
> +	/* Unlock key 1 and key 2 */
> +	regmap_write(regmap, TFA9865_HIDE_UNHIDE_KEY, 0x5a6b);
> +	ret = regmap_read(regmap, TFA9865_KEY1_SEED, &seed);
> +	if (ret)
> +		return ret;
> +	regmap_write(regmap, TFA9865_KEY1, seed ^ 0x005a);
> +	regmap_write(regmap, TFA9865_KEY2, 0x005a);
> +
> +	ret = regmap_multi_reg_write(regmap, tfa9865_b0_init, ARRAY_SIZE(tfa9865_b0_init));
> +
> +	/* Lock the keys again */
> +	regmap_write(regmap, TFA9865_KEY2, 0);
> +	regmap_write(regmap, TFA9865_KEY1, 0);
> +	regmap_write(regmap, TFA9865_HIDE_UNHIDE_KEY, 0);
> +	if (ret)
> +		return ret;
> +
> +	/* Go back to power down with the oscillator off */
> +	regmap_set_bits(regmap, TFA9865_SYS_CTRL0, BIT(TFA9865_SYS_CTRL0_PWDN));
> +	ret = tfa9865_wait_manstate(tfa9865, TFA9865_MANSTATE_POWERDOWN);
> +	if (ret)
> +		return ret;
> +	regmap_set_bits(regmap, TFA9865_CLK_GATING_CTRL, TFA9865_CLK_GATING_CTRL_MANAOOSC);
> +
> +	/* Input attenuation used by the vendor configuration */
> +	regmap_update_bits(regmap, TFA9865_TDM_GAIN,
> +			   TFA9865_TDM_GAIN_TDMSPKG_MAX << TFA9865_TDM_GAIN_TDMSPKG,
> +			   5 << TFA9865_TDM_GAIN_TDMSPKG);

[Severity: Medium]
Does the first entry of tfa9865_b0_init ({ 0x00, 0xf241 }) re-assert
TFA9865_SYS_CTRL0_PWDN before the rest of the protected registers are
written?

tfa9865_init() clears BIT(TFA9865_SYS_CTRL0_PWDN) in TFA9865_SYS_CTRL0 and
waits for TFA9865_MANSTATE_WAIT_SRC so the protected registers can be
accessed, and then sets BIT(TFA9865_SYS_CTRL0_PWDN) again after locking the
keys.  Writing 0xf241 to 0x00 at the start of regmap_multi_reg_write() sets
bit 0 (PWDN) back to 1 before registers 0x02..0xdd are programmed and makes
the later regmap_set_bits() on TFA9865_SYS_CTRL0 a no-op.

Also, tfa9865_b0_init already writes { 0x5f, 0x00a0 } (5 <<
TFA9865_TDM_GAIN_TDMSPKG), so the regmap_update_bits() call on
TFA9865_TDM_GAIN at the end of tfa9865_init() is redundant.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-vantage-tfa9865-v2-0-a93f976c9479@yahoo.com?part=2

      reply	other threads:[~2026-11-16  8:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  7:39 [PATCH v2 0/2] ASoC: Add the NXP TFA9865 amplifier Venkat Yadlapati via B4 Relay
2026-11-16  7:39 ` [PATCH v2 1/2] ASoC: dt-bindings: Add " Venkat Yadlapati via B4 Relay
2026-11-16  7:39 ` [PATCH v2 2/2] ASoC: codecs: Add NXP TFA9865 amplifier driver Venkat Yadlapati via B4 Relay
2026-11-16  8:06   ` sashiko-bot [this message]

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=sashiko-outbox-216504@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=venkat.yadlapati@yahoo.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