Skip to content

Commit a3ba99a

Browse files
jernejskmripard
authored andcommitted
clk: sunxi-ng: sun8i: r40: Use sigma delta modulation for audio PLL
Audio cores need specific clock rates which can't be simply obtained by adjusting integer multipliers and dividers. HW for such cases supports delta-sigma modulation which enables fractional multipliers. Port H3 delta-sigma table to R40. They have identical audio PLLs. Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20200825131049.1277596-1-jernej.skrabec@siol.net
1 parent fb038ce commit a3ba99a

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

‎drivers/clk/sunxi-ng/ccu-sun8i-r40.c‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,29 @@ static struct ccu_nkmp pll_cpu_clk = {
4545
* the base (2x, 4x and 8x), and one variable divider (the one true
4646
* pll audio).
4747
*
48-
* We don't have any need for the variable divider for now, so we just
49-
* hardcode it to match with the clock names
48+
* With sigma-delta modulation for fractional-N on the audio PLL,
49+
* we have to use specific dividers. This means the variable divider
50+
* can no longer be used, as the audio codec requests the exact clock
51+
* rates we support through this mechanism. So we now hard code the
52+
* variable divider to 1. This means the clock rates will no longer
53+
* match the clock names.
5054
*/
5155
#define SUN8I_R40_PLL_AUDIO_REG 0x008
5256

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

6172
static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
6273
"osc24M", 0x0010,
@@ -952,10 +963,10 @@ static const struct clk_hw *clk_parent_pll_audio[] = {
952963
&pll_audio_base_clk.common.hw
953964
};
954965

955-
/* We hardcode the divider to 4 for now */
966+
/* We hardcode the divider to 1 for now */
956967
static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
957968
clk_parent_pll_audio,
958-
4, 1, CLK_SET_RATE_PARENT);
969+
1, 1, CLK_SET_RATE_PARENT);
959970
static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
960971
clk_parent_pll_audio,
961972
2, 1, CLK_SET_RATE_PARENT);
@@ -1307,10 +1318,10 @@ static int sun8i_r40_ccu_probe(struct platform_device *pdev)
13071318
if (IS_ERR(reg))
13081319
return PTR_ERR(reg);
13091320

1310-
/* Force the PLL-Audio-1x divider to 4 */
1321+
/* Force the PLL-Audio-1x divider to 1 */
13111322
val = readl(reg + SUN8I_R40_PLL_AUDIO_REG);
13121323
val &= ~GENMASK(19, 16);
1313-
writel(val | (3 << 16), reg + SUN8I_R40_PLL_AUDIO_REG);
1324+
writel(val | (0 << 16), reg + SUN8I_R40_PLL_AUDIO_REG);
13141325

13151326
/* Force PLL-MIPI to MIPI mode */
13161327
val = readl(reg + SUN8I_R40_PLL_MIPI_REG);

0 commit comments

Comments
 (0)