Skip to content

Commit 3ee5f8a

Browse files
jernejskmripard
authored andcommitted
clk: sunxi-ng: h6: Use sigma-delta modulation for audio PLL
Audio devices needs exact clock rates in order to correctly reproduce the sound. Until now, only integer factors were used to configure H6 audio PLL which resulted in inexact rates. Fix that by adding support for fractional factors using sigma-delta modulation look-up table. It contains values for two most commonly used audio base frequencies. Signed-off-by: Jernej Skrabec <[email protected]> Acked-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Maxime Ripard <[email protected]>
1 parent 54ecb8f commit 3ee5f8a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/clk/sunxi-ng/ccu-sun50i-h6.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,21 @@ static struct ccu_nkmp pll_hsic_clk = {
203203
* hardcode it to match with the clock names.
204204
*/
205205
#define SUN50I_H6_PLL_AUDIO_REG 0x078
206+
207+
static struct ccu_sdm_setting pll_audio_sdm_table[] = {
208+
{ .rate = 541900800, .pattern = 0xc001288d, .m = 1, .n = 22 },
209+
{ .rate = 589824000, .pattern = 0xc00126e9, .m = 1, .n = 24 },
210+
};
211+
206212
static struct ccu_nm pll_audio_base_clk = {
207213
.enable = BIT(31),
208214
.lock = BIT(28),
209215
.n = _SUNXI_CCU_MULT_MIN(8, 8, 12),
210216
.m = _SUNXI_CCU_DIV(1, 1), /* input divider */
217+
.sdm = _SUNXI_CCU_SDM(pll_audio_sdm_table,
218+
BIT(24), 0x178, BIT(31)),
211219
.common = {
220+
.features = CCU_FEATURE_SIGMA_DELTA_MOD,
212221
.reg = 0x078,
213222
.hw.init = CLK_HW_INIT("pll-audio-base", "osc24M",
214223
&ccu_nm_ops,
@@ -753,12 +762,12 @@ static const struct clk_hw *clk_parent_pll_audio[] = {
753762
};
754763

755764
/*
756-
* The divider of pll-audio is fixed to 8 now, as pll-audio-4x has a
757-
* fixed post-divider 2.
765+
* The divider of pll-audio is fixed to 24 for now, so 24576000 and 22579200
766+
* rates can be set exactly in conjunction with sigma-delta modulation.
758767
*/
759768
static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
760769
clk_parent_pll_audio,
761-
8, 1, CLK_SET_RATE_PARENT);
770+
24, 1, CLK_SET_RATE_PARENT);
762771
static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
763772
clk_parent_pll_audio,
764773
4, 1, CLK_SET_RATE_PARENT);
@@ -1215,12 +1224,12 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
12151224
}
12161225

12171226
/*
1218-
* Force the post-divider of pll-audio to 8 and the output divider
1219-
* of it to 1, to make the clock name represents the real frequency.
1227+
* Force the post-divider of pll-audio to 12 and the output divider
1228+
* of it to 2, so 24576000 and 22579200 rates can be set exactly.
12201229
*/
12211230
val = readl(reg + SUN50I_H6_PLL_AUDIO_REG);
12221231
val &= ~(GENMASK(21, 16) | BIT(0));
1223-
writel(val | (7 << 16), reg + SUN50I_H6_PLL_AUDIO_REG);
1232+
writel(val | (11 << 16) | BIT(0), reg + SUN50I_H6_PLL_AUDIO_REG);
12241233

12251234
/*
12261235
* First clock parent (osc32K) is unusable for CEC. But since there

0 commit comments

Comments
 (0)