Skip to content

Commit 315a842

Browse files
pcercueibebarino
authored andcommitted
clk: ingenic: Read bypass register only when there is one
Rework the clock code so that the bypass register is only read when there is actually a bypass functionality. Signed-off-by: Paul Cercueil <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: 周琰杰 (Zhou Yanjie)<[email protected]> # on CU1830-neo/X1830 Signed-off-by: Stephen Boyd <[email protected]>
1 parent 249592b commit 315a842

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/clk/ingenic/cgu.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ ingenic_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
9999
od_enc = ctl >> pll_info->od_shift;
100100
od_enc &= GENMASK(pll_info->od_bits - 1, 0);
101101

102-
ctl = readl(cgu->base + pll_info->bypass_reg);
102+
if (!pll_info->no_bypass_bit) {
103+
ctl = readl(cgu->base + pll_info->bypass_reg);
103104

104-
bypass = !pll_info->no_bypass_bit &&
105-
!!(ctl & BIT(pll_info->bypass_bit));
105+
bypass = !!(ctl & BIT(pll_info->bypass_bit));
106106

107-
if (bypass)
108-
return parent_rate;
107+
if (bypass)
108+
return parent_rate;
109+
}
109110

110111
for (od = 0; od < pll_info->od_max; od++) {
111112
if (pll_info->od_encoding[od] == od_enc)
@@ -225,11 +226,13 @@ static int ingenic_pll_enable(struct clk_hw *hw)
225226
u32 ctl;
226227

227228
spin_lock_irqsave(&cgu->lock, flags);
228-
ctl = readl(cgu->base + pll_info->bypass_reg);
229+
if (!pll_info->no_bypass_bit) {
230+
ctl = readl(cgu->base + pll_info->bypass_reg);
229231

230-
ctl &= ~BIT(pll_info->bypass_bit);
232+
ctl &= ~BIT(pll_info->bypass_bit);
231233

232-
writel(ctl, cgu->base + pll_info->bypass_reg);
234+
writel(ctl, cgu->base + pll_info->bypass_reg);
235+
}
233236

234237
ctl = readl(cgu->base + pll_info->reg);
235238

0 commit comments

Comments
 (0)