linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll
@ 2021-02-18 11:20 Tobias Schramm
  2021-02-18 11:20 ` [PATCH v2 1/1] " Tobias Schramm
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Schramm @ 2021-02-18 11:20 UTC (permalink / raw)
  To: Icenowy Zheng, Maxime Ripard
  Cc: linux-clk, linux-arm-kernel, linux-kernel, Michael Turquette,
	Stephen Boyd, Chen-Yu Tsai, Jernej Skrabec, Tobias Schramm

Hi,

this patch extends the v3s audio-pll declaration to use sdm for supporting
24.576MHz and 22.5792MHz clock rates, required by the i2s peripheral driver.

This is v2 of the patch. The previous version used a flexible postdivider only.
However, that setup was unable to provide the 22.5792MHz clock rate.

Cheers,
Tobias

Changelog:
 v2:
  - use sdm instead of postdivider for audio-pll
  - change patch subject to reflect use of sdm

Tobias Schramm (1):
  clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll

 drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 33 ++++++++++++++++++----------
 1 file changed, 22 insertions(+), 11 deletions(-)

-- 
2.30.1


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

* [PATCH v2 1/1] clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll
  2021-02-18 11:20 [PATCH v2 0/1] clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll Tobias Schramm
@ 2021-02-18 11:20 ` Tobias Schramm
  2021-02-19 12:01   ` Maxime Ripard
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Schramm @ 2021-02-18 11:20 UTC (permalink / raw)
  To: Icenowy Zheng, Maxime Ripard
  Cc: linux-clk, linux-arm-kernel, linux-kernel, Michael Turquette,
	Stephen Boyd, Chen-Yu Tsai, Jernej Skrabec, Tobias Schramm

Previously it was not possible to achieve clock rates of 24.576MHz and
22.5792MHz, which are commonly required core clocks for the i2s
peripheral of v3s based SoCs.

Add support for those clock rates through the audio pll's sigma-delta
modulator.

Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
---
 drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 33 ++++++++++++++++++----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
index 0e36ca3bf3d5..a774942cb153 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
@@ -40,18 +40,29 @@ static SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpu_clk, "pll-cpu",
  * the base (2x, 4x and 8x), and one variable divider (the one true
  * pll audio).
  *
- * We don't have any need for the variable divider for now, so we just
- * hardcode it to match with the clock names
+ * With sigma-delta modulation for fractional-N on the audio PLL,
+ * we have to use specific dividers. This means the variable divider
+ * can no longer be used, as the audio codec requests the exact clock
+ * rates we support through this mechanism. So we now hard code the
+ * variable divider to 1. This means the clock rates will no longer
+ * match the clock names.
  */
 #define SUN8I_V3S_PLL_AUDIO_REG	0x008
 
-static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
-				   "osc24M", 0x008,
-				   8, 7,	/* N */
-				   0, 5,	/* M */
-				   BIT(31),	/* gate */
-				   BIT(28),	/* lock */
-				   0);
+static struct ccu_sdm_setting pll_audio_sdm_table[] = {
+	{ .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
+	{ .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
+};
+
+static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
+				       "osc24M", 0x008,
+				       8, 7,	/* N */
+				       0, 5,	/* M */
+				       pll_audio_sdm_table, BIT(24),
+				       0x284, BIT(31),
+				       BIT(31),	/* gate */
+				       BIT(28),	/* lock */
+				       CLK_SET_RATE_UNGATE);
 
 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video",
 					"osc24M", 0x0010,
@@ -524,10 +535,10 @@ static struct ccu_common *sun8i_v3_ccu_clks[] = {
 	&mipi_csi_clk.common,
 };
 
-/* We hardcode the divider to 4 for now */
+/* We hardcode the divider to 1 for SDM support */
 static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
 			    clk_parent_pll_audio,
-			    4, 1, CLK_SET_RATE_PARENT);
+			    1, 1, CLK_SET_RATE_PARENT);
 static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
 			    clk_parent_pll_audio,
 			    2, 1, CLK_SET_RATE_PARENT);
-- 
2.30.1


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

* Re: [PATCH v2 1/1] clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll
  2021-02-18 11:20 ` [PATCH v2 1/1] " Tobias Schramm
@ 2021-02-19 12:01   ` Maxime Ripard
  0 siblings, 0 replies; 3+ messages in thread
From: Maxime Ripard @ 2021-02-19 12:01 UTC (permalink / raw)
  To: Tobias Schramm
  Cc: Icenowy Zheng, linux-clk, linux-arm-kernel, linux-kernel,
	Michael Turquette, Stephen Boyd, Chen-Yu Tsai, Jernej Skrabec

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]

On Thu, Feb 18, 2021 at 12:20:01PM +0100, Tobias Schramm wrote:
> Previously it was not possible to achieve clock rates of 24.576MHz and
> 22.5792MHz, which are commonly required core clocks for the i2s
> peripheral of v3s based SoCs.
> 
> Add support for those clock rates through the audio pll's sigma-delta
> modulator.
> 
> Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>

Applied, thanks
Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2021-02-19 12:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18 11:20 [PATCH v2 0/1] clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll Tobias Schramm
2021-02-18 11:20 ` [PATCH v2 1/1] " Tobias Schramm
2021-02-19 12:01   ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).