* Re: [PATCH 7/7] ASoC: nau8810: add MCLK support [not found] <sashiko-outbox-247848@kernel.org> @ 2026-12-03 16:25 ` Mehmet Fide 0 siblings, 0 replies; 2+ messages in thread From: Mehmet Fide @ 2026-12-03 16:25 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 > Can switching from an MCLK-matched rate to a PLL-derived rate leave the > PLL powered off during pmdown_time? Yes. v2 handles PLL_EN as nau8822 does: the PLL is turned off and its frequencies are cleared when the system clock is set to 0 at the end of a stream, as in commit 390cdd61a947, and nau8810_set_pll() turns it on after programming it. > Should nau8810_set_pll() clear NAU8810_PLL_EN_SFT before updating the > PLL registers and restore it afterward if it was enabled? v2 turns the PLL off while the registers are written and on afterwards, as nau8822 does since commit aeca8a329502. Mehmet ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 0/7] ASoC: nau8810: add MCLK support
@ 2026-12-03 12:47 Mehmet Fide
2026-12-03 12:47 ` [PATCH 7/7] " Mehmet Fide
0 siblings, 1 reply; 2+ 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] 2+ messages in thread* [PATCH 7/7] ASoC: nau8810: add MCLK support 2026-12-03 12:47 [PATCH 0/7] " Mehmet Fide @ 2026-12-03 12:47 ` Mehmet Fide 0 siblings, 0 replies; 2+ 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 [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 16:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <sashiko-outbox-247848@kernel.org>
2026-12-03 16:25 ` [PATCH 7/7] ASoC: nau8810: add MCLK support Mehmet Fide
2026-12-03 12:47 [PATCH 0/7] " Mehmet Fide
2026-12-03 12:47 ` [PATCH 7/7] " Mehmet Fide
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®