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 v3 2/2] ASoC: codecs: Add NXP TFA9865 amplifier driver
Date: Thu, 19 Nov 2026 08:41:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-222697@kernel.org> (raw)
In-Reply-To: <20261119-vantage-tfa9865-v3-2-5257fa45df57@yahoo.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: tfa9865: tfa9865_b0_init re-asserts PWDN in
tfa9865_init()
--
commit 22126aae516e932437c57483972adbeb537cf93f
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, supporting the B0 revision with 32-bit I2S
slots.
> diff --git a/sound/soc/codecs/tfa9865.c b/sound/soc/codecs/tfa9865.c
> new file mode 100644
> index 0000000000000..ca1a458e6f651
> --- /dev/null
> +++ b/sound/soc/codecs/tfa9865.c
[ ... ]
> +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 },
> + { 0x62, 0x06c4 },
> + { 0x63, 0x80d4 },
> + { 0x65, 0x0c58 },
> + { 0x67, 0x006e },
> + { 0x68, 0x0820 },
> + { 0x69, 0x0119 },
> + { 0x74, 0x6028 },
> + { 0x75, 0x1daa },
> + { 0x78, 0x0001 },
> + { 0x7c, 0x10f2 },
> + { 0xdd, 0x01b6 },
> +};
> +
> +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);
> +
> + /* The reset changed every register, forget what was read before */
> + regcache_drop_region(regmap, 0, tfa9865_regmap.max_register);
> +
> + /* 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 writing { 0x00, 0xf241 } at the start of tfa9865_b0_init[] put the
chip back into power down before the remaining protected registers in
tfa9865_b0_init[] are written?
tfa9865_init() clears BIT(TFA9865_SYS_CTRL0_PWDN) (bit 0 of register 0x00)
and waits for TFA9865_MANSTATE_WAIT_SRC so the protected registers are
accessible, then sets BIT(TFA9865_SYS_CTRL0_PWDN) again after locking the
keys. However, 0xf241 has bit 0 set, which immediately re-asserts PWDN on
the first write of regmap_multi_reg_write() and turns the later
regmap_set_bits() on TFA9865_SYS_CTRL0 into a no-op.
Also, tfa9865_b0_init[] already writes { 0x5f, 0x00a0 } (5 <<
TFA9865_TDM_GAIN_TDMSPKG) to TFA9865_TDM_GAIN, 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/20261119-vantage-tfa9865-v3-0-5257fa45df57@yahoo.com?part=2
prev parent reply other threads:[~2026-11-19 8:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:31 [PATCH v3 0/2] ASoC: Add the NXP TFA9865 amplifier Venkat Yadlapati via B4 Relay
2026-11-19 8:31 ` [PATCH v3 1/2] ASoC: dt-bindings: Add " Venkat Yadlapati via B4 Relay
2026-11-19 8:31 ` [PATCH v3 2/2] ASoC: codecs: Add NXP TFA9865 amplifier driver Venkat Yadlapati via B4 Relay
2026-11-19 8:41 ` 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-222697@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