All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] arm64: dts: k3-am625-verdin: enable nau8822 pll
@ 2024-04-18 10:57 ` Andrejs Cainikovs
  0 siblings, 0 replies; 4+ messages in thread
From: Andrejs Cainikovs @ 2024-04-18 10:57 UTC (permalink / raw)
  To: Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Andrejs Cainikovs, linux-arm-kernel, devicetree, linux-kernel

From: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

In current configuration, nau8822 codec on development carrier board
provides distorted audio output. This happens due to reference clock
is fixed to 25MHz and no PLL is enabled. Following is the calculation
of deviation error for different frequencies:

44100Hz:

fs = 256 (fixed)
prescaler = 2
target frequency = 44100 * 256 * 2 = 22579200
deviation = 22579200 vs 25000000 = 9.6832%

48000Hz:

fs = 256 (fixed)
prescaler = 2
target frequency = 48000 * 256 * 2 = 24576000
deviation = 24576000 vs 25000000 = 1.696%

Enabling nau822 PLL via providing mclk-fs property to simple-audio-card
configures clocks properly, but also adjusts audio reference clock
(mclk), which in case of TI AM62 should be avoided, as it only
supports 25MHz output [1][2].

This change enables PLL on nau8822 by providing mclk-fs, and moves
away audio reference clock from DAI configuration, which prevents
simple-audio-card to adjust it before every playback [3].

[1]: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1175479/processor-sdk-am62x-output-audio_ext_refclk0-as-mclk-for-codec-and-mcbsp/4444986#4444986
[2]: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1188051/am625-audio_ext_refclk1-clock-output---dts-support/4476322#4476322
[3]: sound/soc/generic/simple-card-utils.c#L441

Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
---
This patch requires https://lore.kernel.org/all/20240409121719.337709-1-andrejs.cainikovs@gmail.com/ to be applied,
if not the audio will just stop working because no code will ever enable the required clock to the codec.
---
 arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi b/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
index 74eec1a1abca..5c1284b802ad 100644
--- a/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
@@ -14,6 +14,7 @@ sound {
 		simple-audio-card,bitclock-master = <&codec_dai>;
 		simple-audio-card,format = "i2s";
 		simple-audio-card,frame-master = <&codec_dai>;
+		simple-audio-card,mclk-fs = <256>;
 		simple-audio-card,name = "verdin-nau8822";
 		simple-audio-card,routing =
 			"Headphones", "LHP",
@@ -34,7 +35,6 @@ sound {
 			"Line", "Line In";
 
 		codec_dai: simple-audio-card,codec {
-			clocks = <&audio_refclk1>;
 			sound-dai = <&nau8822_1a>;
 		};
 
@@ -107,6 +107,8 @@ nau8822_1a: audio-codec@1a {
 		reg = <0x1a>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_i2s1_mclk>;
+		clock-names = "mclk";
+		clocks = <&audio_refclk1>;
 		#sound-dai-cells = <0>;
 	};
 
-- 
2.34.1


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

* [PATCH v1] arm64: dts: k3-am625-verdin: enable nau8822 pll
@ 2024-04-18 10:57 ` Andrejs Cainikovs
  0 siblings, 0 replies; 4+ messages in thread
From: Andrejs Cainikovs @ 2024-04-18 10:57 UTC (permalink / raw)
  To: Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Andrejs Cainikovs, linux-arm-kernel, devicetree, linux-kernel

From: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

In current configuration, nau8822 codec on development carrier board
provides distorted audio output. This happens due to reference clock
is fixed to 25MHz and no PLL is enabled. Following is the calculation
of deviation error for different frequencies:

44100Hz:

fs = 256 (fixed)
prescaler = 2
target frequency = 44100 * 256 * 2 = 22579200
deviation = 22579200 vs 25000000 = 9.6832%

48000Hz:

fs = 256 (fixed)
prescaler = 2
target frequency = 48000 * 256 * 2 = 24576000
deviation = 24576000 vs 25000000 = 1.696%

Enabling nau822 PLL via providing mclk-fs property to simple-audio-card
configures clocks properly, but also adjusts audio reference clock
(mclk), which in case of TI AM62 should be avoided, as it only
supports 25MHz output [1][2].

This change enables PLL on nau8822 by providing mclk-fs, and moves
away audio reference clock from DAI configuration, which prevents
simple-audio-card to adjust it before every playback [3].

[1]: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1175479/processor-sdk-am62x-output-audio_ext_refclk0-as-mclk-for-codec-and-mcbsp/4444986#4444986
[2]: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1188051/am625-audio_ext_refclk1-clock-output---dts-support/4476322#4476322
[3]: sound/soc/generic/simple-card-utils.c#L441

Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
---
This patch requires https://lore.kernel.org/all/20240409121719.337709-1-andrejs.cainikovs@gmail.com/ to be applied,
if not the audio will just stop working because no code will ever enable the required clock to the codec.
---
 arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi b/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
index 74eec1a1abca..5c1284b802ad 100644
--- a/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
@@ -14,6 +14,7 @@ sound {
 		simple-audio-card,bitclock-master = <&codec_dai>;
 		simple-audio-card,format = "i2s";
 		simple-audio-card,frame-master = <&codec_dai>;
+		simple-audio-card,mclk-fs = <256>;
 		simple-audio-card,name = "verdin-nau8822";
 		simple-audio-card,routing =
 			"Headphones", "LHP",
@@ -34,7 +35,6 @@ sound {
 			"Line", "Line In";
 
 		codec_dai: simple-audio-card,codec {
-			clocks = <&audio_refclk1>;
 			sound-dai = <&nau8822_1a>;
 		};
 
@@ -107,6 +107,8 @@ nau8822_1a: audio-codec@1a {
 		reg = <0x1a>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_i2s1_mclk>;
+		clock-names = "mclk";
+		clocks = <&audio_refclk1>;
 		#sound-dai-cells = <0>;
 	};
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1] arm64: dts: k3-am625-verdin: enable nau8822 pll
  2024-04-18 10:57 ` Andrejs Cainikovs
@ 2024-04-25 13:56   ` Nishanth Menon
  -1 siblings, 0 replies; 4+ messages in thread
From: Nishanth Menon @ 2024-04-25 13:56 UTC (permalink / raw)
  To: Andrejs Cainikovs
  Cc: Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Andrejs Cainikovs,
	linux-arm-kernel, devicetree, linux-kernel

On 12:57-20240418, Andrejs Cainikovs wrote:
[...]

> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
> ---
> This patch requires https://lore.kernel.org/all/20240409121719.337709-1-andrejs.cainikovs@gmail.com/ to be applied,
> if not the audio will just stop working because no code will ever enable the required clock to the codec.

Thanks. lets wait for the dependency patch to be merged to master, and
once done, please resubmit this patch. I am going to guess for the next
cycle.
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

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

* Re: [PATCH v1] arm64: dts: k3-am625-verdin: enable nau8822 pll
@ 2024-04-25 13:56   ` Nishanth Menon
  0 siblings, 0 replies; 4+ messages in thread
From: Nishanth Menon @ 2024-04-25 13:56 UTC (permalink / raw)
  To: Andrejs Cainikovs
  Cc: Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Andrejs Cainikovs,
	linux-arm-kernel, devicetree, linux-kernel

On 12:57-20240418, Andrejs Cainikovs wrote:
[...]

> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
> ---
> This patch requires https://lore.kernel.org/all/20240409121719.337709-1-andrejs.cainikovs@gmail.com/ to be applied,
> if not the audio will just stop working because no code will ever enable the required clock to the codec.

Thanks. lets wait for the dependency patch to be merged to master, and
once done, please resubmit this patch. I am going to guess for the next
cycle.
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-04-25 13:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18 10:57 [PATCH v1] arm64: dts: k3-am625-verdin: enable nau8822 pll Andrejs Cainikovs
2024-04-18 10:57 ` Andrejs Cainikovs
2024-04-25 13:56 ` Nishanth Menon
2024-04-25 13:56   ` Nishanth Menon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.