From: YLCHANG2 <neo.chang70@gmail.com>
To: Krzysztof Kozlowski <krzk@kernel.org>, Neo Chang <YLCHANG2@nuvoton.com>
Cc: broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz,
robh@kernel.org, krzk+dt@kernel.org, linux-sound@vger.kernel.org,
devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
kchsu0@nuvoton.com, sjlin0@nuvoton.com, lkp@intel.com
Subject: Re: [PATCH v2 2/2] ASoC: codecs: nau8310: Add support for NAU83G10 amplifier
Date: Tue, 17 Nov 2026 11:38:20 +0800 [thread overview]
Message-ID: <6d7f4ecd-bac0-44d6-a704-57cdd2877729@gmail.com> (raw)
In-Reply-To: <20261109-myna-of-noble-downpour-e09d3e@quoll>
On 11/9/26 21:15, Krzysztof Kozlowski wrote:
> On Mon, Nov 09, 2026 at 01:12:51PM +0800, Neo Chang wrote:
>> +static void nau8310_init_regs(struct nau8310 *nau8310)
>> +{
>> + struct regmap *regmap = nau8310->regmap;
>> + unsigned int clk_det = 0, ana_ctrl = 0;
>> +
>> + /* Latch IIC LSB value */
>> + regmap_write(regmap, NAU8310_R02_I2C_ADDR, 0x0001);
>> + /* Block MCLK */
>> + regmap_update_bits(regmap, NAU8310_R04_ENA_CTRL,
>> + NAU8310_MCLK_SEL_MASK, 0x7 << NAU8310_MCLK_SEL_SFT);
>> + /* stall DSP */
>> + regmap_update_bits(regmap, NAU8310_R1A_DSP_CORE_CTRL2,
>> + NAU8310_DSP_RUNSTALL, NAU8310_DSP_RUNSTALL);
>> + /* Default ADCI from slot1, ADCV from slot 0. */
>> + regmap_update_bits(regmap, NAU8310_R0C_TDM_CTRL,
>> + NAU8310_ADC_I_SEL_MASK | NAU8310_ADC_V_SEL_MASK,
>> + (0x4 << NAU8310_ADC_I_SEL_SFT) | 0x4);
>> + /* Set I-sense digital gain to +10.25dB */
>> + regmap_update_bits(regmap, NAU8310_R14_ADC_VOL_CTRL,
>> + NAU8310_ADC_GAIN_L_MASK | NAU8310_ADC_GAIN_R_MASK,
>> + (0x1 << NAU8310_ADC_GAIN_L_SFT) | 0x62);
>> + /* PGA in Class A Mode */
>> + regmap_update_bits(regmap, NAU8310_R76_BOOST,
>> + NAU8310_STG2_SEL_CLASSA, NAU8310_STG2_SEL_CLASSA);
>> + /* Set I-sense PGA Bias Current to minimum,
>> + * Disable PGA Common Mode Lock.
>> + */
> Even netdev does not use that format of comments anymore. And this is
> not netdev in the first place.
Got it. I will change the multi-line comment to the standard kernel format:
/*
* Set I-sense PGA Bias Current to minimum,
* Disable PGA Common Mode Lock.
*/
>
> ...
>
>> + nau8310 = devm_kzalloc(dev, sizeof(*nau8310), GFP_KERNEL);
>> + if (!nau8310)
>> + return -ENOMEM;
>> +
>> + i2c_set_clientdata(i2c, nau8310);
>> + mutex_init(&nau8310->lock);
>> + INIT_WORK(&nau8310->load_fw_work, nau8310_load_fw_work);
>> +
>> + nau8310->regmap = devm_regmap_init(dev, NULL, i2c, &nau8310_regmap_config);
>> + if (IS_ERR(nau8310->regmap))
>> + return PTR_ERR(nau8310->regmap);
>> +
>> + nau8310->dev = dev;
>> +
>> + nau8310_reset_chip(nau8310->regmap);
>> + ret = regmap_read(nau8310->regmap, NAU8310_R46_I2C_DEVICE_ID, &value);
>> + if (ret) {
>> + dev_err(dev, "Failed to read NAU8310/20 device id: %d", ret);
>> + return ret;
>> + }
>> +
>> + nau8310->silicon_id = value & NAU8310_REG_SI_REV_MASK;
>> + ret = nau8310_read_device_properties(nau8310);
>> + if (ret)
>> + return ret;
>> +
>> + nau8310_print_device_properties(nau8310);
>> + nau8310_init_regs(nau8310);
>> +
>> + return devm_snd_soc_register_component(dev, &soc_comp_dev_nau8310,
>> + &nau8310_dai, 1);
>> +}
>> +
>> +static void nau8310_i2c_remove(struct i2c_client *client)
>> +{
>> + struct nau8310 *nau8310 = i2c_get_clientdata(client);
>> +
>> + cancel_work_sync(&nau8310->load_fw_work);
> This looks safe, but still error-prone and discouraged. Use same order
> of cleanup as order of init/allocation in probe.
>
> See also include/linux/devm-helpers.h
Got it. I will use devm_work_autocancel() in probe instead of manual
cancellation in remove().
>
>> +}
>> +
>> +static const struct i2c_device_id nau8310_i2c_ids[] = {
>> + { .name = "nau8310" },
>> + { .name = "nau8320" },
>> + {}
>> +};
>> +MODULE_DEVICE_TABLE(i2c, nau8310_i2c_ids);
>> +
>> +static const struct of_device_id nau8310_of_ids[] = {
>> + { .compatible = "nuvoton,nau8310" },
>> + { .compatible = "nuvoton,nau8320" },
> This suggests devices are compatible, but was not expressed in the
> binding (and then second entry is redundant).
I will add the actual silicon ID into the .data field of both
i2c_device_id and of_device_id to validate it against the hardware ID in
the probe stage.
>
> Best regards,
> Krzysztof
>
next prev parent reply other threads:[~2026-11-17 3:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 5:12 [PATCH v2 0/2] ASoC: codecs: nau8310: Add NAU83G10 amplifier Neo Chang
2026-11-09 5:12 ` [PATCH v2 1/2] ASoC: dt-bindings: nuvoton,nau8310: Add NAU83G10 Neo Chang
2026-11-09 5:23 ` sashiko-bot
2026-11-09 13:11 ` Krzysztof Kozlowski
2026-11-17 3:38 ` YLCHANG2
2026-11-09 5:12 ` [PATCH v2 2/2] ASoC: codecs: nau8310: Add support for NAU83G10 amplifier Neo Chang
2026-11-09 5:44 ` sashiko-bot
2026-11-09 13:15 ` Krzysztof Kozlowski
2026-11-17 3:38 ` YLCHANG2 [this message]
2026-11-09 19:48 ` Mark Brown
2026-11-17 3:39 ` YLCHANG2
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=6d7f4ecd-bac0-44d6-a704-57cdd2877729@gmail.com \
--to=neo.chang70@gmail.com \
--cc=YLCHANG2@nuvoton.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kchsu0@nuvoton.com \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=lkp@intel.com \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=sjlin0@nuvoton.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