Skip to content

Commit bff1cef

Browse files
digetxbebarino
authored andcommitted
clk: tegra: Don't enable already enabled PLLs
Initially Common Clock Framework isn't aware of the clock-enable status, this results in enabling of clocks that were enabled by bootloader. This is not a big deal for a regular clock-gates, but for PLL's it may have some unpleasant consequences. Thus re-enabling PLLX (the main CPU parent clock) may result in extra long period of PLL re-locking. Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 9e98c67 commit bff1cef

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

drivers/clk/tegra/clk-pll.c

+37-13
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ static int clk_pll_enable(struct clk_hw *hw)
444444
unsigned long flags = 0;
445445
int ret;
446446

447+
if (clk_pll_is_enabled(hw))
448+
return 0;
449+
447450
if (pll->lock)
448451
spin_lock_irqsave(pll->lock, flags);
449452

@@ -940,11 +943,16 @@ static int clk_plle_training(struct tegra_clk_pll *pll)
940943
static int clk_plle_enable(struct clk_hw *hw)
941944
{
942945
struct tegra_clk_pll *pll = to_clk_pll(hw);
943-
unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
944946
struct tegra_clk_pll_freq_table sel;
947+
unsigned long input_rate;
945948
u32 val;
946949
int err;
947950

951+
if (clk_pll_is_enabled(hw))
952+
return 0;
953+
954+
input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
955+
948956
if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
949957
return -EINVAL;
950958

@@ -1355,6 +1363,9 @@ static int clk_pllc_enable(struct clk_hw *hw)
13551363
int ret;
13561364
unsigned long flags = 0;
13571365

1366+
if (clk_pll_is_enabled(hw))
1367+
return 0;
1368+
13581369
if (pll->lock)
13591370
spin_lock_irqsave(pll->lock, flags);
13601371

@@ -1567,7 +1578,12 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw)
15671578
u32 val;
15681579
int ret;
15691580
unsigned long flags = 0;
1570-
unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
1581+
unsigned long input_rate;
1582+
1583+
if (clk_pll_is_enabled(hw))
1584+
return 0;
1585+
1586+
input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
15711587

15721588
if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
15731589
return -EINVAL;
@@ -1704,6 +1720,9 @@ static int clk_pllu_tegra114_enable(struct clk_hw *hw)
17041720
return -EINVAL;
17051721
}
17061722

1723+
if (clk_pll_is_enabled(hw))
1724+
return 0;
1725+
17071726
input_rate = clk_hw_get_rate(__clk_get_hw(osc));
17081727

17091728
if (pll->lock)
@@ -2379,14 +2398,29 @@ struct clk *tegra_clk_register_pllre_tegra210(const char *name,
23792398
return clk;
23802399
}
23812400

2401+
static int clk_plle_tegra210_is_enabled(struct clk_hw *hw)
2402+
{
2403+
struct tegra_clk_pll *pll = to_clk_pll(hw);
2404+
u32 val;
2405+
2406+
val = pll_readl_base(pll);
2407+
2408+
return val & PLLE_BASE_ENABLE ? 1 : 0;
2409+
}
2410+
23822411
static int clk_plle_tegra210_enable(struct clk_hw *hw)
23832412
{
23842413
struct tegra_clk_pll *pll = to_clk_pll(hw);
23852414
struct tegra_clk_pll_freq_table sel;
23862415
u32 val;
23872416
int ret = 0;
23882417
unsigned long flags = 0;
2389-
unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
2418+
unsigned long input_rate;
2419+
2420+
if (clk_plle_tegra210_is_enabled(hw))
2421+
return 0;
2422+
2423+
input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
23902424

23912425
if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
23922426
return -EINVAL;
@@ -2497,16 +2531,6 @@ static void clk_plle_tegra210_disable(struct clk_hw *hw)
24972531
spin_unlock_irqrestore(pll->lock, flags);
24982532
}
24992533

2500-
static int clk_plle_tegra210_is_enabled(struct clk_hw *hw)
2501-
{
2502-
struct tegra_clk_pll *pll = to_clk_pll(hw);
2503-
u32 val;
2504-
2505-
val = pll_readl_base(pll);
2506-
2507-
return val & PLLE_BASE_ENABLE ? 1 : 0;
2508-
}
2509-
25102534
static const struct clk_ops tegra_clk_plle_tegra210_ops = {
25112535
.is_enabled = clk_plle_tegra210_is_enabled,
25122536
.enable = clk_plle_tegra210_enable,

0 commit comments

Comments
 (0)