clk: k210: Fix PLL enable always getting taken
authorSean Anderson <seanga2@gmail.com>
Fri, 9 Apr 2021 02:13:05 +0000 (22:13 -0400)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Fri, 14 May 2021 08:20:47 +0000 (16:20 +0800)
This conditional always evaluated as false, regardless of the value of reg.
Fix it so that it properly tests the bits in the PLL register. Also test
PLL_EN, now that we set it.

Reported-by: Damien Le Moal <Damien.LeMoal@wdc.com>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
drivers/clk/kendryte/pll.c

index f198920..d46fd0e 100644 (file)
@@ -512,7 +512,8 @@ static int k210_pll_enable(struct clk *clk)
        struct k210_pll *pll = to_k210_pll(clk);
        u32 reg = readl(pll->reg);
 
-       if ((reg | K210_PLL_PWRD) && !(reg | K210_PLL_RESET))
+       if ((reg & K210_PLL_PWRD) && (reg & K210_PLL_EN) &&
+           !(reg & K210_PLL_RESET))
                return 0;
 
        reg |= K210_PLL_PWRD;