Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/7] ASoC: nau8810: add MCLK support
@ 2026-12-03 12:47 Mehmet Fide
  2026-12-03 12:47 ` [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock Mehmet Fide
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

The NAU8810 needs an internal master clock of 256 * fs, which the driver
can only divide from MCLK. With 25 MHz from the AM62 AUDIO_EXT_REFCLK1,
48 kHz and 44.1 kHz both play at 48.8 kHz.

This series lets the driver take MCLK and make the system clock with
its PLL, along the lines of the nau8822 changes, with two differences.
PLL_EN stays with the PLL supply widget, so the problem fixed for
nau8822 by commit 390cdd61a947 ("ASoC: nau8822: reprogram PLL after it
has been disabled") cannot occur. And the PLL is not switched off while
it is programmed, as in commit aeca8a329502 ("ASoC: nau8822: Add
operation for internal PLL off and on"): the NAU8810 datasheet does not
ask for it.

Tested on a Verdin AM62 with simple-audio-card and mclk-fs = <256>, on
6.12.120 with the series backported, also with lockdep: playback from
8 to 48 kHz and capture at 8, 44.1 and 48 kHz run within 0.2 % of the
rate, and a board without mclk-fs keeps the old behaviour.

Mehmet Fide (7):
  ASoC: dt-bindings: nau8810: Add MCLK clock
  ASoC: nau8810: move nau8810_set_sysclk()
  ASoC: nau8810: set NAU8810_REFIMP_80K only once
  ASoC: nau8810: Lower debug print priority
  ASoC: nau8810: Do not configure the PLL if freq_out is zero
  ASoC: nau8810: Don't reconfigure PLL to the same values
  ASoC: nau8810: add MCLK support

 .../bindings/sound/nuvoton,nau8810.yaml       | 51 +++++++++++
 .../bindings/sound/trivial-codec.yaml         |  3 -
 sound/soc/codecs/nau8810.c                    | 87 +++++++++++++++----
 sound/soc/codecs/nau8810.h                    |  3 +
 4 files changed, 126 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml


base-commit: b5b604242c1cc418d202d29d73fe8ec2db833a03
-- 
2.56.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 12:57   ` sashiko-bot
  2026-12-03 12:47 ` [PATCH 2/7] ASoC: nau8810: move nau8810_set_sysclk() Mehmet Fide
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

Add the master clock input. trivial-codec.yaml has no clocks, so move
the nau8810, nau8812 and nau8814 compatibles into a schema of their own.

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 .../bindings/sound/nuvoton,nau8810.yaml       | 51 +++++++++++++++++++
 .../bindings/sound/trivial-codec.yaml         |  3 --
 2 files changed, 51 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml

diff --git a/Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml b/Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml
new file mode 100644
index 000000000000..285dc08ab289
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nuvoton,nau8810.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NAU8810/NAU8812/NAU8814 audio CODEC
+
+maintainers:
+  - David Lin <CTLIN0@nuvoton.com>
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - nuvoton,nau8810
+      - nuvoton,nau8812
+      - nuvoton,nau8814
+
+  reg:
+    maxItems: 1
+
+  '#sound-dai-cells':
+    const: 0
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: mclk
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        codec@1a {
+            #sound-dai-cells = <0>;
+            compatible = "nuvoton,nau8810";
+            reg = <0x1a>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/sound/trivial-codec.yaml b/Documentation/devicetree/bindings/sound/trivial-codec.yaml
index 9a35dfb17349..9fd2802bf391 100644
--- a/Documentation/devicetree/bindings/sound/trivial-codec.yaml
+++ b/Documentation/devicetree/bindings/sound/trivial-codec.yaml
@@ -27,9 +27,6 @@ properties:
       - dlg,da9055-codec
       # Nuvoton Technology Corporation NAU85L40 Audio CODEC
       - nuvoton,nau8540
-      - nuvoton,nau8810
-      - nuvoton,nau8812
-      - nuvoton,nau8814
       # NXP TFA9879 class-D audio amplifier
       - nxp,tfa9879
       - nxp,uda1342
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/7] ASoC: nau8810: move nau8810_set_sysclk()
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
  2026-12-03 12:47 ` [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 12:47 ` [PATCH 3/7] ASoC: nau8810: set NAU8810_REFIMP_80K only once Mehmet Fide
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

The next change calls nau8810_set_pll() from nau8810_set_sysclk(). Move
nau8810_set_sysclk() below nau8810_set_pll() to avoid a forward
declaration.

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 sound/soc/codecs/nau8810.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index e18439c2b0e1..3ebef741f07a 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -512,20 +512,6 @@ static const struct snd_soc_dapm_route nau8810_dapm_routes[] = {
 	{"DAC", NULL, "Digital Loopback"},
 };
 
-static int nau8810_set_sysclk(struct snd_soc_dai *dai,
-				 int clk_id, unsigned int freq, int dir)
-{
-	struct snd_soc_component *component = dai->component;
-	struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
-
-	nau8810->clk_id = clk_id;
-	nau8810->sysclk = freq;
-	dev_dbg(nau8810->dev, "master sysclk %dHz, source %s\n",
-		freq, clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK");
-
-	return 0;
-}
-
 static int nau8810_calc_pll(unsigned int pll_in,
 	unsigned int fs, struct nau8810_pll *pll_param)
 {
@@ -605,6 +591,20 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
 	return 0;
 }
 
+static int nau8810_set_sysclk(struct snd_soc_dai *dai,
+				 int clk_id, unsigned int freq, int dir)
+{
+	struct snd_soc_component *component = dai->component;
+	struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
+
+	nau8810->clk_id = clk_id;
+	nau8810->sysclk = freq;
+	dev_dbg(nau8810->dev, "master sysclk %dHz, source %s\n",
+		freq, clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK");
+
+	return 0;
+}
+
 static int nau8810_set_dai_fmt(struct snd_soc_dai *codec_dai,
 		unsigned int fmt)
 {
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/7] ASoC: nau8810: set NAU8810_REFIMP_80K only once
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
  2026-12-03 12:47 ` [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock Mehmet Fide
  2026-12-03 12:47 ` [PATCH 2/7] ASoC: nau8810: move nau8810_set_sysclk() Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 12:47 ` [PATCH 4/7] ASoC: nau8810: Lower debug print priority Mehmet Fide
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

The bias level goes from STANDBY to PREPARE and then to ON before a
stream, and both PREPARE and ON set NAU8810_REFIMP_80K. Set it only in
PREPARE.

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 sound/soc/codecs/nau8810.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index 3ebef741f07a..de268eb68e53 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -781,6 +781,8 @@ static int nau8810_set_bias_level(struct snd_soc_component *component,
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
+		break;
+
 	case SND_SOC_BIAS_PREPARE:
 		regmap_update_bits(map, NAU8810_REG_POWER1,
 			NAU8810_REFIMP_MASK, NAU8810_REFIMP_80K);
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/7] ASoC: nau8810: Lower debug print priority
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
                   ` (2 preceding siblings ...)
  2026-12-03 12:47 ` [PATCH 3/7] ASoC: nau8810: set NAU8810_REFIMP_80K only once Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 12:47 ` [PATCH 5/7] ASoC: nau8810: Do not configure the PLL if freq_out is zero Mehmet Fide
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

The PLL parameters are of no interest to the general user. The message
is for debugging, print it with dev_dbg().

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 sound/soc/codecs/nau8810.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index de268eb68e53..b5b18994ebaa 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -567,7 +567,7 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
 		dev_err(nau8810->dev, "Unsupported input clock %d\n", freq_in);
 		return ret;
 	}
-	dev_info(nau8810->dev, "pll_int=%x pll_frac=%x mclk_scaler=%x pre_factor=%x\n",
+	dev_dbg(nau8810->dev, "pll_int=%x pll_frac=%x mclk_scaler=%x pre_factor=%x\n",
 		pll_param->pll_int, pll_param->pll_frac, pll_param->mclk_scaler,
 		pll_param->pre_factor);
 
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/7] ASoC: nau8810: Do not configure the PLL if freq_out is zero
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
                   ` (3 preceding siblings ...)
  2026-12-03 12:47 ` [PATCH 4/7] ASoC: nau8810: Lower debug print priority Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 12:47 ` [PATCH 6/7] ASoC: nau8810: Don't reconfigure PLL to the same values Mehmet Fide
  2026-12-03 12:47 ` [PATCH 7/7] ASoC: nau8810: add MCLK support Mehmet Fide
  6 siblings, 0 replies; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

When a stream ends, the PLL or, with a later change, the system clock
may be set to zero. nau8810_set_pll() then fails with "Unsupported input
clock". Return early, as nau8822 does, but leave the PLL power to its
supply widget, which already powers the PLL down.

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 sound/soc/codecs/nau8810.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index b5b18994ebaa..1a309d5c7454 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -561,6 +561,11 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
 	struct nau8810_pll *pll_param = &nau8810->pll;
 	int ret, fs;
 
+	if (freq_out == 0) {
+		dev_dbg(nau8810->dev, "PLL disabled\n");
+		return 0;
+	}
+
 	fs = freq_out / 256;
 	ret = nau8810_calc_pll(freq_in, fs, pll_param);
 	if (ret < 0) {
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/7] ASoC: nau8810: Don't reconfigure PLL to the same values
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
                   ` (4 preceding siblings ...)
  2026-12-03 12:47 ` [PATCH 5/7] ASoC: nau8810: Do not configure the PLL if freq_out is zero Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 12:47 ` [PATCH 7/7] ASoC: nau8810: add MCLK support Mehmet Fide
  6 siblings, 0 replies; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

Record the input and output frequency of the PLL and skip programming
it again when asked for the same values, as nau8822 does. As the PLL is
then not programmed on every stream, hw_params() selects the PLL and its
prescaler itself.

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 sound/soc/codecs/nau8810.c | 14 ++++++++++++++
 sound/soc/codecs/nau8810.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index 1a309d5c7454..a27fa63a2887 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -561,6 +561,10 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
 	struct nau8810_pll *pll_param = &nau8810->pll;
 	int ret, fs;
 
+	if (freq_in == pll_param->freq_in &&
+	    freq_out == pll_param->freq_out)
+		return 0;
+
 	if (freq_out == 0) {
 		dev_dbg(nau8810->dev, "PLL disabled\n");
 		return 0;
@@ -593,6 +597,9 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
 	regmap_update_bits(map, NAU8810_REG_CLOCK,
 		NAU8810_CLKM_MASK, NAU8810_CLKM_PLL);
 
+	pll_param->freq_in = freq_in;
+	pll_param->freq_out = freq_out;
+
 	return 0;
 }
 
@@ -772,6 +779,13 @@ static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream,
 		ret = nau8810_mclk_clkdiv(nau8810, params_rate(params));
 		if (ret < 0)
 			dev_err(nau8810->dev, "MCLK div configuration fail\n");
+	} else {
+		/* master clock from the PLL, through its prescaler */
+		int sel = nau8810->pll.mclk_scaler << NAU8810_MCLKSEL_SFT;
+
+		regmap_update_bits(nau8810->regmap, NAU8810_REG_CLOCK,
+				   NAU8810_MCLKSEL_MASK | NAU8810_CLKM_MASK,
+				   sel | NAU8810_CLKM_PLL);
 	}
 
 	return ret;
diff --git a/sound/soc/codecs/nau8810.h b/sound/soc/codecs/nau8810.h
index 6a7cacbe044a..33cf0d599c17 100644
--- a/sound/soc/codecs/nau8810.h
+++ b/sound/soc/codecs/nau8810.h
@@ -273,6 +273,8 @@ struct nau8810_pll {
 	int mclk_scaler;
 	int pll_frac;
 	int pll_int;
+	int freq_in;
+	int freq_out;
 };
 
 struct nau8810 {
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/7] ASoC: nau8810: add MCLK support
  2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
                   ` (5 preceding siblings ...)
  2026-12-03 12:47 ` [PATCH 6/7] ASoC: nau8810: Don't reconfigure PLL to the same values Mehmet Fide
@ 2026-12-03 12:47 ` Mehmet Fide
  2026-12-03 13:21   ` sashiko-bot
  6 siblings, 1 reply; 10+ messages in thread
From: Mehmet Fide @ 2026-12-03 12:47 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela,
	Takashi Iwai, David Lin, Lars-Peter Clausen, Nuno Sá,
	Peter Rosin, Martin Povišer, linux-sound, devicetree,
	patches, asahi, linux-kernel, mehmet.fide

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

The codec needs an internal clock of 256 * fs, which the prescalers can
only divide from MCLK. From 25 MHz, 48 kHz and 44.1 kHz both play at
48.8 kHz.

Handle MCLK in the driver as nau8822 does: when the system clock asked
for with mclk-fs differs from MCLK, make it with the PLL. MCLK is
enabled while the codec is out of standby.

Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
 sound/soc/codecs/nau8810.c | 38 +++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/nau8810.h |  1 +
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index a27fa63a2887..311dfa8eea74 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -13,6 +13,7 @@
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
@@ -608,11 +609,26 @@ static int nau8810_set_sysclk(struct snd_soc_dai *dai,
 {
 	struct snd_soc_component *component = dai->component;
 	struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
+	unsigned long mclk_freq;
 
 	nau8810->clk_id = clk_id;
 	nau8810->sysclk = freq;
+
+	if (nau8810->mclk) {
+		mclk_freq = clk_get_rate(nau8810->mclk);
+		if (mclk_freq != freq) {
+			int ret = nau8810_set_pll(dai, NAU8810_SCLK_MCLK,
+				NAU8810_SCLK_MCLK, mclk_freq, freq);
+			if (ret) {
+				dev_err(component->dev, "Failed to set PLL\n");
+				return ret;
+			}
+			nau8810->clk_id = NAU8810_SCLK_PLL;
+		}
+	}
+
 	dev_dbg(nau8810->dev, "master sysclk %dHz, source %s\n",
-		freq, clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK");
+		freq, nau8810->clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK");
 
 	return 0;
 }
@@ -803,11 +819,26 @@ static int nau8810_set_bias_level(struct snd_soc_component *component,
 		break;
 
 	case SND_SOC_BIAS_PREPARE:
+		if (nau8810->mclk &&
+		    snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON) {
+			int ret = clk_prepare_enable(nau8810->mclk);
+
+			if (ret) {
+				dev_err(nau8810->dev,
+					"Failed to enable MCLK: %d\n", ret);
+				return ret;
+			}
+		}
+
 		regmap_update_bits(map, NAU8810_REG_POWER1,
 			NAU8810_REFIMP_MASK, NAU8810_REFIMP_80K);
 		break;
 
 	case SND_SOC_BIAS_STANDBY:
+		if (nau8810->mclk &&
+		    snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_OFF)
+			clk_disable_unprepare(nau8810->mclk);
+
 		regmap_update_bits(map, NAU8810_REG_POWER1,
 			NAU8810_IOBUF_EN | NAU8810_ABIAS_EN,
 			NAU8810_IOBUF_EN | NAU8810_ABIAS_EN);
@@ -922,6 +953,11 @@ static int nau8810_i2c_probe(struct i2c_client *i2c)
 		return PTR_ERR(nau8810->regmap);
 	nau8810->dev = dev;
 
+	nau8810->mclk = devm_clk_get_optional(dev, "mclk");
+	if (IS_ERR(nau8810->mclk))
+		return dev_err_probe(dev, PTR_ERR(nau8810->mclk),
+				     "Error getting MCLK\n");
+
 	regmap_write(nau8810->regmap, NAU8810_REG_RESET, 0x00);
 
 	return devm_snd_soc_register_component(dev,
diff --git a/sound/soc/codecs/nau8810.h b/sound/soc/codecs/nau8810.h
index 33cf0d599c17..c0f81402f293 100644
--- a/sound/soc/codecs/nau8810.h
+++ b/sound/soc/codecs/nau8810.h
@@ -280,6 +280,7 @@ struct nau8810_pll {
 struct nau8810 {
 	struct device *dev;
 	struct regmap *regmap;
+	struct clk *mclk;
 	struct nau8810_pll pll;
 	int sysclk;
 	int clk_id;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock
  2026-12-03 12:47 ` [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock Mehmet Fide
@ 2026-12-03 12:57   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-12-03 12:57 UTC (permalink / raw)
  To: Mehmet Fide; +Cc: linux-sound, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: sound: nau8810 example lists #sound-dai-cells
  before compatible
--

commit bdcd7057136ec88d8022ec8581545b606b3ea3ac
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>

ASoC: dt-bindings: nau8810: Add MCLK clock

This commit moves the nuvoton,nau8810, nuvoton,nau8812, and nuvoton,nau8814
compatibles out of trivial-codec.yaml into a dedicated nuvoton,nau8810.yaml
binding and adds the master clock properties.

> diff --git a/Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml b/Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml
> new file mode 100644
> index 0000000000000..285dc08ab2891
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/nuvoton,nau8810.yaml

[ ... ]

> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        codec@1a {
> +            #sound-dai-cells = <0>;
> +            compatible = "nuvoton,nau8810";
> +            reg = <0x1a>;
> +        };
> +    };

[Severity: Low]
Should compatible and reg come before #sound-dai-cells in this example
node?  Documentation/devicetree/bindings/dts-coding-style.rst specifies
listing compatible and reg before standard properties like
#sound-dai-cells, which also matches the order used in this schema's
properties section.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203124733.2101884-1-mehmet.fide@gmail.com?part=1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 7/7] ASoC: nau8810: add MCLK support
  2026-12-03 12:47 ` [PATCH 7/7] ASoC: nau8810: add MCLK support Mehmet Fide
@ 2026-12-03 13:21   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-12-03 13:21 UTC (permalink / raw)
  To: Mehmet Fide; +Cc: linux-sound, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ASoC: nau8810: MCLK-to-PLL switch leaves PLL off during
  pmdown_time
- [Medium] ASoC: nau8810: nau8810_set_pll() reprograms PLL while PLL_EN
  is active
--

commit 6d8fbbb4bed0d01ffd7425872f563b6b8efcc0d3
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>

ASoC: nau8810: add MCLK support

This commit adds optional MCLK clock handling to the nau8810 driver,
enabling MCLK when the codec leaves standby and configuring the PLL in
nau8810_set_sysclk() whenever the requested sysclk differs from the MCLK
rate.

> diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
> index a27fa63a2887e..311dfa8eea74d 100644
> --- a/sound/soc/codecs/nau8810.c
> +++ b/sound/soc/codecs/nau8810.c

[ ... ]

> @@ -608,11 +609,26 @@ static int nau8810_set_sysclk(struct snd_soc_dai *dai,
>  {
>  	struct snd_soc_component *component = dai->component;
>  	struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
> +	unsigned long mclk_freq;
>  
>  	nau8810->clk_id = clk_id;
>  	nau8810->sysclk = freq;
> +
> +	if (nau8810->mclk) {
> +		mclk_freq = clk_get_rate(nau8810->mclk);
> +		if (mclk_freq != freq) {
> +			int ret = nau8810_set_pll(dai, NAU8810_SCLK_MCLK,
> +				NAU8810_SCLK_MCLK, mclk_freq, freq);
> +			if (ret) {
> +				dev_err(component->dev, "Failed to set PLL\n");
> +				return ret;
> +			}
> +			nau8810->clk_id = NAU8810_SCLK_PLL;
> +		}
> +	}
> +
>  	dev_dbg(nau8810->dev, "master sysclk %dHz, source %s\n",
> -		freq, clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK");
> +		freq, nau8810->clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK");
>  
>  	return 0;
>  }

[Severity: High]
Can switching from an MCLK-matched rate to a PLL-derived rate leave the
PLL powered off during pmdown_time?

Unlike nau8822_set_pll(), nau8810_set_pll() selects NAU8810_CLKM_PLL in
NAU8810_REG_CLOCK without setting NAU8810_PLL_EN_SFT in
NAU8810_REG_POWER1.  Instead, NAU8810_PLL_EN_SFT is only driven by the
"PLL" DAPM supply widget, gated on check_mclk_select_pll().

Because nau8810_component_driver sets .use_pmdown_time = 1, closing an
MCLK-matched stream leaves Playback and DAC powered on with PLL off.  If
a PLL-rate stream starts within pmdown_time, dapm_power_one_widget()
sees Playback already active and skips check_mclk_select_pll().

The codec master clock is then routed from a powered-off PLL, breaking
playback with silent output or PCM write timeouts when the codec is
clock provider.  In the reverse direction (PLL to MCLK), the PLL remains
powered on until pmdown_time expires.

[Severity: Medium]
Can nau8810_set_pll() reprogram the PLL registers while
NAU8810_PLL_EN_SFT is still active?

When back-to-back streams run at different PLL-derived rates within
pmdown_time (such as 48 kHz then 44.1 kHz from a 25 MHz MCLK), the DAPM
PLL widget keeps NAU8810_PLL_EN_SFT set.  nau8810_set_pll() then writes
NAU8810_REG_PLLN and NAU8810_REG_PLLK1..3 while the PLL is enabled.

On the sibling NAU8822 with the same fractional-N PLL registers, commit
aeca8a329502 ("ASoC: nau8822: Add operation for internal PLL off and
on") found that the PLL fails to lock unless PLL_EN is cleared before
programming the fractional parameters and re-enabled afterward.

Should nau8810_set_pll() clear NAU8810_PLL_EN_SFT before updating the
PLL registers and restore it afterward if it was enabled?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203124733.2101884-1-mehmet.fide@gmail.com?part=7

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-12-03 13:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 12:47 [PATCH 0/7] ASoC: nau8810: add MCLK support Mehmet Fide
2026-12-03 12:47 ` [PATCH 1/7] ASoC: dt-bindings: nau8810: Add MCLK clock Mehmet Fide
2026-12-03 12:57   ` sashiko-bot
2026-12-03 12:47 ` [PATCH 2/7] ASoC: nau8810: move nau8810_set_sysclk() Mehmet Fide
2026-12-03 12:47 ` [PATCH 3/7] ASoC: nau8810: set NAU8810_REFIMP_80K only once Mehmet Fide
2026-12-03 12:47 ` [PATCH 4/7] ASoC: nau8810: Lower debug print priority Mehmet Fide
2026-12-03 12:47 ` [PATCH 5/7] ASoC: nau8810: Do not configure the PLL if freq_out is zero Mehmet Fide
2026-12-03 12:47 ` [PATCH 6/7] ASoC: nau8810: Don't reconfigure PLL to the same values Mehmet Fide
2026-12-03 12:47 ` [PATCH 7/7] ASoC: nau8810: add MCLK support Mehmet Fide
2026-12-03 13:21   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox