[PATCH 6/7] ASoC: nau8810: Don't reconfigure PLL to the same values

From: Mehmet Fide

Date: Thu Dec 03 2026 - 07:48:11 EST


From: Mehmet Fide <mehmet.fide@xxxxxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxx>
---
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