Skip to content

Commit 7f0b97d

Browse files
committed
Merge tag 'sunxi-clk-fixes-for-4.11' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux into clk-fixes
Pull Allwinner clock fixes from Maxime Ripard: A few fixes for a bunch of clocks on a few SoCs. The most important one is probably one that fixes the NKMP clock frequency calculation and could end up with clocking the CPU frequency to out of bounds rates. * tag 'sunxi-clk-fixes-for-4.11' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux: clk: sunxi-ng: fix recalc_rate formula of NKMP clocks clk: sunxi-ng: Fix div/mult settings for osc12M on A64 clk: sunxi-ng: sun6i: Fix enable bit offset for hdmi-ddc module clock clk: sunxi: ccu-sun5i needs nkmp clk: sunxi-ng: mp: Adjust parent rate for pre-dividers
2 parents f8ba2d6 + b467e08 commit 7f0b97d

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

drivers/clk/sunxi-ng/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ config SUN6I_A31_CCU
8080
select SUNXI_CCU_DIV
8181
select SUNXI_CCU_NK
8282
select SUNXI_CCU_NKM
83+
select SUNXI_CCU_NKMP
8384
select SUNXI_CCU_NM
8485
select SUNXI_CCU_MP
8586
select SUNXI_CCU_PHASE

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
566566
0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
567567

568568
/* Fixed Factor clocks */
569-
static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 1, 2, 0);
569+
static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 2, 1, 0);
570570

571571
/* We hardcode the divider to 4 for now */
572572
static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",

drivers/clk/sunxi-ng/ccu-sun6i-a31.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", lcd_ch1_parents,
608608
0x150, 0, 4, 24, 2, BIT(31),
609609
CLK_SET_RATE_PARENT);
610610

611-
static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M", 0x150, BIT(31), 0);
611+
static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M", 0x150, BIT(30), 0);
612612

613613
static SUNXI_CCU_GATE(ps_clk, "ps", "lcd1-ch1", 0x140, BIT(31), 0);
614614

drivers/clk/sunxi-ng/ccu_mp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw,
8585
unsigned int m, p;
8686
u32 reg;
8787

88+
/* Adjust parent_rate according to pre-dividers */
89+
ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux,
90+
-1, &parent_rate);
91+
8892
reg = readl(cmp->common.base + cmp->common.reg);
8993

9094
m = reg >> cmp->m.shift;
@@ -117,6 +121,10 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate,
117121
unsigned int m, p;
118122
u32 reg;
119123

124+
/* Adjust parent_rate according to pre-dividers */
125+
ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux,
126+
-1, &parent_rate);
127+
120128
max_m = cmp->m.max ?: 1 << cmp->m.width;
121129
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
122130

drivers/clk/sunxi-ng/ccu_nkmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static unsigned long ccu_nkmp_recalc_rate(struct clk_hw *hw,
107107
p = reg >> nkmp->p.shift;
108108
p &= (1 << nkmp->p.width) - 1;
109109

110-
return parent_rate * n * k >> p / m;
110+
return (parent_rate * n * k >> p) / m;
111111
}
112112

113113
static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,

0 commit comments

Comments
 (0)