* [PATCH 0/2] ASoC: nau8822: add support for supply regulators
@ 2026-05-13 13:39 Alexey Charkov
2026-05-13 13:39 ` [PATCH 1/2] ASoC: dt-bindings: nau8822: Add " Alexey Charkov
2026-05-13 13:39 ` [PATCH 2/2] ASoC: codecs: nau8822: add support for " Alexey Charkov
0 siblings, 2 replies; 5+ messages in thread
From: Alexey Charkov @ 2026-05-13 13:39 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, David Lin, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, devicetree, linux-kernel, Alexey Charkov
The Nuvoton NAU8822 codec has four power supply pins: VDDA, VDDB, VDDC
and VDDSPK, which must be online and stable before the device can be
accessed over I2C. On boards where these rails are software-controlled,
probing the codec before the regulators are up results in -ENXIO errors
during register access.
This short series adds optional regulator support to both the device
tree binding and the driver, so platforms that need explicit power
sequencing can describe and enforce it:
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
Alexey Charkov (2):
ASoC: dt-bindings: nau8822: Add supply regulators
ASoC: codecs: nau8822: add support for supply regulators
.../devicetree/bindings/sound/nuvoton,nau8822.yaml | 14 ++++++++++++++
sound/soc/codecs/nau8822.c | 11 ++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
---
base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260513-nau8822-reg-becf5b766d80
Best regards,
--
Alexey Charkov <alchark@flipper.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ASoC: dt-bindings: nau8822: Add supply regulators
2026-05-13 13:39 [PATCH 0/2] ASoC: nau8822: add support for supply regulators Alexey Charkov
@ 2026-05-13 13:39 ` Alexey Charkov
2026-05-13 13:39 ` [PATCH 2/2] ASoC: codecs: nau8822: add support for " Alexey Charkov
1 sibling, 0 replies; 5+ messages in thread
From: Alexey Charkov @ 2026-05-13 13:39 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, David Lin, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, devicetree, linux-kernel, Alexey Charkov
NAU8822 has 4 power supply pins: VDDA, VDDB, VDDC and VDDSPK, which need
to be online and stable before communication with the device is attempted.
List them (as optional) so that device tree users can ensure correct power
sequencing.
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
.../devicetree/bindings/sound/nuvoton,nau8822.yaml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/nuvoton,nau8822.yaml b/Documentation/devicetree/bindings/sound/nuvoton,nau8822.yaml
index cb8182bbc491..0a8e40a140c3 100644
--- a/Documentation/devicetree/bindings/sound/nuvoton,nau8822.yaml
+++ b/Documentation/devicetree/bindings/sound/nuvoton,nau8822.yaml
@@ -30,6 +30,20 @@ properties:
clock-names:
const: mclk
+ vdda-supply:
+ description: Analog power supply
+
+ vddb-supply:
+ description: Digital buffer (input/output) supply
+
+ vddc-supply:
+ description: Digital core supply
+
+ vddspk-supply:
+ description:
+ Speaker supply (power supply pin for RSPKOUT, LSPKOUT, AUXOUT2 and
+ AUXTOUT1 output drivers)
+
nuvoton,spk-btl:
description:
If set, configure the two loudspeaker outputs as a Bridge Tied Load output
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ASoC: codecs: nau8822: add support for supply regulators
2026-05-13 13:39 [PATCH 0/2] ASoC: nau8822: add support for supply regulators Alexey Charkov
2026-05-13 13:39 ` [PATCH 1/2] ASoC: dt-bindings: nau8822: Add " Alexey Charkov
@ 2026-05-13 13:39 ` Alexey Charkov
2026-05-14 1:43 ` Mark Brown
2026-05-14 5:39 ` sashiko-bot
1 sibling, 2 replies; 5+ messages in thread
From: Alexey Charkov @ 2026-05-13 13:39 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, David Lin, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, devicetree, linux-kernel, Alexey Charkov
NAU8822 has four power supply pins: VDDA, VDDB, VDDC, and VDDSPK, which
need to be online and stable before communication with the device is
attempted.
Request and enable these regulators at init time, if provided.
This helps avoid -ENXIO errors when the codec is probed before the
regulators are ready.
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
sound/soc/codecs/nau8822.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c
index a11759f85eac..c21a037e0f08 100644
--- a/sound/soc/codecs/nau8822.c
+++ b/sound/soc/codecs/nau8822.c
@@ -1153,7 +1153,8 @@ static int nau8822_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
struct nau8822 *nau8822 = dev_get_platdata(dev);
- int ret;
+ static const char * const regulators[] = { "vdda", "vddb", "vddc", "vddspk" };
+ int ret, i;
if (!nau8822) {
nau8822 = devm_kzalloc(dev, sizeof(*nau8822), GFP_KERNEL);
@@ -1167,6 +1168,14 @@ static int nau8822_i2c_probe(struct i2c_client *i2c)
return dev_err_probe(&i2c->dev, PTR_ERR(nau8822->mclk),
"Error getting mclk\n");
+ for (i = 0; i < ARRAY_SIZE(regulators); i++) {
+ ret = devm_regulator_get_enable_optional(dev, regulators[i]);
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret,
+ "Failed to get regulator %s\n",
+ regulators[i]);
+ }
+
nau8822->regmap = devm_regmap_init_i2c(i2c, &nau8822_regmap_config);
if (IS_ERR(nau8822->regmap)) {
ret = PTR_ERR(nau8822->regmap);
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ASoC: codecs: nau8822: add support for supply regulators
2026-05-13 13:39 ` [PATCH 2/2] ASoC: codecs: nau8822: add support for " Alexey Charkov
@ 2026-05-14 1:43 ` Mark Brown
2026-05-14 5:39 ` sashiko-bot
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-05-14 1:43 UTC (permalink / raw)
To: Alexey Charkov
Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
David Lin, Jaroslav Kysela, Takashi Iwai, linux-sound, devicetree,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 445 bytes --]
On Wed, May 13, 2026 at 05:39:11PM +0400, Alexey Charkov wrote:
> + for (i = 0; i < ARRAY_SIZE(regulators); i++) {
> + ret = devm_regulator_get_enable_optional(dev, regulators[i]);
> + if (ret && ret != -ENODEV)
> + return dev_err_probe(dev, ret,
> + "Failed to get regulator %s\n",
> + regulators[i]);
> + }
As ever unless the device can work with the supply being physically
absent regulators should never be optional.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ASoC: codecs: nau8822: add support for supply regulators
2026-05-13 13:39 ` [PATCH 2/2] ASoC: codecs: nau8822: add support for " Alexey Charkov
2026-05-14 1:43 ` Mark Brown
@ 2026-05-14 5:39 ` sashiko-bot
1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-05-14 5:39 UTC (permalink / raw)
To: Alexey Charkov; +Cc: robh, devicetree, conor+dt, krzk+dt
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Regulators are enabled permanently during probe and never disabled during PM or DAPM transitions.
- [Medium] Inefficient and semantically incorrect use of optional regulators in a loop instead of the bulk API.
- [Medium] Missing hardware stabilization delay after enabling power supplies before the first I2C access.
- [Low] Missing <linux/regulator/consumer.h> header inclusion.
--
commit d49855c46afc5aae191093735a6b46a1097ad452
Author: Alexey Charkov <alchark@flipper.net>
ASoC: codecs: nau8822: add support for supply regulators
This commit adds support for requesting and enabling four power supply
regulators (VDDA, VDDB, VDDC, VDDSPK) during the I2C probe of the NAU8822
codec to ensure they are online before communication.
> diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c
> index a11759f85eaca..c21a037e0f083 100644
> --- a/sound/soc/codecs/nau8822.c
> +++ b/sound/soc/codecs/nau8822.c
> @@ -1153,7 +1153,8 @@ static int nau8822_i2c_probe(struct i2c_client *i2c)
> {
> struct device *dev = &i2c->dev;
> struct nau8822 *nau8822 = dev_get_platdata(dev);
> - int ret;
> + static const char * const regulators[] = { "vdda", "vddb", "vddc", "vddspk" };
> + int ret, i;
Should <linux/regulator/consumer.h> be included in this file since it now
uses regulator APIs?
Relying on implicit inclusion might cause build failures if header
dependencies change in the future.
[ ... ]
> @@ -1167,6 +1168,14 @@ static int nau8822_i2c_probe(struct i2c_client *i2c)
> return dev_err_probe(&i2c->dev, PTR_ERR(nau8822->mclk),
> "Error getting mclk\n");
>
> + for (i = 0; i < ARRAY_SIZE(regulators); i++) {
> + ret = devm_regulator_get_enable_optional(dev, regulators[i]);
> + if (ret && ret != -ENODEV)
> + return dev_err_probe(dev, ret,
> + "Failed to get regulator %s\n",
> + regulators[i]);
> + }
> +
Does using devm_regulator_get_enable_optional() here prevent the driver
from managing power during suspend/resume or DAPM transitions?
Since this API discards the regulator handles, the driver cannot disable
the regulators when the system suspends or when the DAPM bias level drops
to SND_SOC_BIAS_OFF.
Also, since these supplies are required for communication, could
devm_regulator_bulk_get_enable() be used instead of a loop?
The bulk API automatically substitutes dummy regulators if properties are
missing in older Device Trees, avoiding the need for manual -ENODEV
filtering. It also processes ramp-up delays in parallel, whereas this loop
forces serial waits for each regulator.
Finally, is a hardware stabilization delay needed before the first I2C
access?
While the regulator framework handles the PMIC voltage ramp-up delay, it
doesn't account for the codec's internal Power-On-Reset stabilization time.
Without a post-power-on delay (like usleep_range()), can the subsequent I2C
reset race with the codec's internal reset state machine and intermittently
fail with -EREMOTEIO?
nau8822_i2c_probe() {
...
nau8822->regmap = devm_regmap_init_i2c(i2c, &nau8822_regmap_config);
...
/* Reset the codec */
ret = regmap_write(nau8822->regmap, NAU8822_REG_RESET, 0x00);
...
}
> nau8822->regmap = devm_regmap_init_i2c(i2c, &nau8822_regmap_config);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260513-nau8822-reg-v1-0-c532e18e92ad@flipper.net?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-14 5:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 13:39 [PATCH 0/2] ASoC: nau8822: add support for supply regulators Alexey Charkov
2026-05-13 13:39 ` [PATCH 1/2] ASoC: dt-bindings: nau8822: Add " Alexey Charkov
2026-05-13 13:39 ` [PATCH 2/2] ASoC: codecs: nau8822: add support for " Alexey Charkov
2026-05-14 1:43 ` Mark Brown
2026-05-14 5:39 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox