Skip to content

Commit ac8616e

Browse files
wensmripard
authored andcommitted
clk: sunxi-ng: mp: Adjust parent rate for pre-dividers
The MP style clocks support an mux with pre-dividers. While the driver correctly accounted for them in the .determine_rate callback, it did not in the .recalc_rate and .set_rate callbacks. This means when calculating the factors in the .set_rate callback, they would be off by a factor of the active pre-divider. Same goes for reading back the clock rate after it is set. Cc: [email protected] Fixes: 2ab836d ("clk: sunxi-ng: Add M-P factor clock support") Signed-off-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Maxime Ripard <[email protected]>
1 parent c1ae3cf commit ac8616e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

0 commit comments

Comments
 (0)