Skip to content

Commit 46060be

Browse files
TobleMinermripard
authored andcommitted
clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll
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 <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a38fd87 commit 46060be

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

drivers/clk/sunxi-ng/ccu-sun8i-v3s.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,29 @@ static SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpu_clk, "pll-cpu",
4040
* the base (2x, 4x and 8x), and one variable divider (the one true
4141
* pll audio).
4242
*
43-
* We don't have any need for the variable divider for now, so we just
44-
* hardcode it to match with the clock names
43+
* With sigma-delta modulation for fractional-N on the audio PLL,
44+
* we have to use specific dividers. This means the variable divider
45+
* can no longer be used, as the audio codec requests the exact clock
46+
* rates we support through this mechanism. So we now hard code the
47+
* variable divider to 1. This means the clock rates will no longer
48+
* match the clock names.
4549
*/
4650
#define SUN8I_V3S_PLL_AUDIO_REG 0x008
4751

48-
static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
49-
"osc24M", 0x008,
50-
8, 7, /* N */
51-
0, 5, /* M */
52-
BIT(31), /* gate */
53-
BIT(28), /* lock */
54-
0);
52+
static struct ccu_sdm_setting pll_audio_sdm_table[] = {
53+
{ .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
54+
{ .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
55+
};
56+
57+
static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
58+
"osc24M", 0x008,
59+
8, 7, /* N */
60+
0, 5, /* M */
61+
pll_audio_sdm_table, BIT(24),
62+
0x284, BIT(31),
63+
BIT(31), /* gate */
64+
BIT(28), /* lock */
65+
CLK_SET_RATE_UNGATE);
5566

5667
static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video",
5768
"osc24M", 0x0010,
@@ -524,10 +535,10 @@ static struct ccu_common *sun8i_v3_ccu_clks[] = {
524535
&mipi_csi_clk.common,
525536
};
526537

527-
/* We hardcode the divider to 4 for now */
538+
/* We hardcode the divider to 1 for SDM support */
528539
static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
529540
clk_parent_pll_audio,
530-
4, 1, CLK_SET_RATE_PARENT);
541+
1, 1, CLK_SET_RATE_PARENT);
531542
static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
532543
clk_parent_pll_audio,
533544
2, 1, CLK_SET_RATE_PARENT);

0 commit comments

Comments
 (0)