Skip to content

Commit 4167ac8

Browse files
rsglobaljernejsk
authored andcommitted
clk: sunxi-ng: sun50i: h6: Modify GPU clock configuration to support DFS
Using simple bash script it was discovered that not all CCU registers can be safely used for DFS, e.g.: while true do devmem 0x3001030 4 0xb0003e02 devmem 0x3001030 4 0xb0001e02 done Script above changes the GPU_PLL multiplier register value. While the script is running, the user should interact with the user interface. Using this method the following results were obtained: | Register | Name | Bits | Values | Result | | -- | -- | -- | -- | -- | | 0x3001030 | GPU_PLL.MULT | 15..8 | 20-62 | OK | | 0x3001030 | GPU_PLL.INDIV | 1 | 0-1 | OK | | 0x3001030 | GPU_PLL.OUTDIV | 0 | 0-1 | FAIL | | 0x3001670 | GPU_CLK.DIV | 3..0 | ANY | FAIL | DVFS started to work seamlessly once dividers which caused the glitches were set to fixed values. Signed-off-by: Roman Stratiienko <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Signed-off-by: Jernej Skrabec <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b17403a commit 4167ac8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ static struct ccu_nkmp pll_periph1_clk = {
9595
},
9696
};
9797

98+
/* For GPU PLL, using an output divider for DFS causes system to fail */
9899
#define SUN50I_H6_PLL_GPU_REG 0x030
99100
static struct ccu_nkmp pll_gpu_clk = {
100101
.enable = BIT(31),
101102
.lock = BIT(28),
102103
.n = _SUNXI_CCU_MULT_MIN(8, 8, 12),
103104
.m = _SUNXI_CCU_DIV(1, 1), /* input divider */
104-
.p = _SUNXI_CCU_DIV(0, 1), /* output divider */
105105
.common = {
106106
.reg = 0x030,
107107
.hw.init = CLK_HW_INIT("pll-gpu", "osc24M",
@@ -294,9 +294,9 @@ static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace",
294294
static SUNXI_CCU_GATE(bus_deinterlace_clk, "bus-deinterlace", "psi-ahb1-ahb2",
295295
0x62c, BIT(0), 0);
296296

297+
/* Keep GPU_CLK divider const to avoid DFS instability. */
297298
static const char * const gpu_parents[] = { "pll-gpu" };
298-
static SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
299-
0, 3, /* M */
299+
static SUNXI_CCU_MUX_WITH_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
300300
24, 1, /* mux */
301301
BIT(31), /* gate */
302302
CLK_SET_RATE_PARENT);
@@ -1191,6 +1191,16 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
11911191
if (IS_ERR(reg))
11921192
return PTR_ERR(reg);
11931193

1194+
/* Force PLL_GPU output divider bits to 0 */
1195+
val = readl(reg + SUN50I_H6_PLL_GPU_REG);
1196+
val &= ~BIT(0);
1197+
writel(val, reg + SUN50I_H6_PLL_GPU_REG);
1198+
1199+
/* Force GPU_CLK divider bits to 0 */
1200+
val = readl(reg + gpu_clk.common.reg);
1201+
val &= ~GENMASK(3, 0);
1202+
writel(val, reg + gpu_clk.common.reg);
1203+
11941204
/* Enable the lock bits on all PLLs */
11951205
for (i = 0; i < ARRAY_SIZE(pll_regs); i++) {
11961206
val = readl(reg + pll_regs[i]);

0 commit comments

Comments
 (0)