clk: tegra: Ensure that PLLU configuration is applied properly
authorDmitry Osipenko <digetx@gmail.com>
Sun, 16 May 2021 16:30:35 +0000 (19:30 +0300)
committerThierry Reding <treding@nvidia.com>
Mon, 31 May 2021 13:16:25 +0000 (15:16 +0200)
The PLLU (USB) consists of the PLL configuration itself and configuration
of the PLLU outputs. The PLLU programming is inconsistent on T30 vs T114,
where T114 immediately bails out if PLLU is enabled and T30 re-enables
a potentially already enabled PLL (left after bootloader) and then fully
reprograms it, which could be unsafe to do. The correct way should be to
skip enabling of the PLL if it's already enabled and then apply
configuration to the outputs. This patch doesn't fix any known problems,
it's a minor improvement.

Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/clk/tegra/clk-pll.c

index 0193ceb..823a567 100644 (file)
@@ -1131,7 +1131,8 @@ static int clk_pllu_enable(struct clk_hw *hw)
        if (pll->lock)
                spin_lock_irqsave(pll->lock, flags);
 
-       _clk_pll_enable(hw);
+       if (!clk_pll_is_enabled(hw))
+               _clk_pll_enable(hw);
 
        ret = clk_pll_wait_for_lock(pll);
        if (ret < 0)
@@ -1748,15 +1749,13 @@ static int clk_pllu_tegra114_enable(struct clk_hw *hw)
                return -EINVAL;
        }
 
-       if (clk_pll_is_enabled(hw))
-               return 0;
-
        input_rate = clk_hw_get_rate(__clk_get_hw(osc));
 
        if (pll->lock)
                spin_lock_irqsave(pll->lock, flags);
 
-       _clk_pll_enable(hw);
+       if (!clk_pll_is_enabled(hw))
+               _clk_pll_enable(hw);
 
        ret = clk_pll_wait_for_lock(pll);
        if (ret < 0)