Skip to content

Commit 441f199

Browse files
author
Stephen Warren
committed
clk: tegra: defer application of init table
The Tegra clock driver is initialized during the ARM machine descriptor's .init_irq() hook. It can't be initialized earlier, since dynamic memory usage is required. It can't be initialized later, since the .init_timer() hook needs the clocks initialized. However, at this time, udelay() doesn't work. The Tegra clock initialization table may enable some PLLs. Enabling a PLL may require usage of udelay(). Hence, this can't happen right when the clock driver is initialized. To solve this, separate the clock driver initialization from the clock table processing, so they can execute at separate times. Signed-off-by: Stephen Warren <swarren@nvidia.com>
1 parent 82ce742 commit 441f199

6 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎arch/arm/mach-tegra/tegra.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/slab.h>
3737
#include <linux/sys_soc.h>
3838
#include <linux/usb/tegra_usb_phy.h>
39+
#include <linux/clk/tegra.h>
3940

4041
#include <asm/mach-types.h>
4142
#include <asm/mach/arch.h>
@@ -87,6 +88,8 @@ static void __init tegra_dt_init(void)
8788
struct soc_device *soc_dev;
8889
struct device *parent = NULL;
8990

91+
tegra_clocks_apply_init_table();
92+
9093
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
9194
if (!soc_dev_attr)
9295
goto out;

‎drivers/clk/tegra/clk-tegra20.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,11 @@ static __initdata struct tegra_clk_init_table init_table[] = {
12521252
{clk_max, clk_max, 0, 0}, /* This MUST be the last entry */
12531253
};
12541254

1255+
static void __init tegra20_clock_apply_init_table(void)
1256+
{
1257+
tegra_init_from_table(init_table, clks, clk_max);
1258+
}
1259+
12551260
/*
12561261
* Some clocks may be used by different drivers depending on the board
12571262
* configuration. List those here to register them twice in the clock lookup
@@ -1318,7 +1323,7 @@ void __init tegra20_clock_init(struct device_node *np)
13181323
clk_data.clk_num = ARRAY_SIZE(clks);
13191324
of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
13201325

1321-
tegra_init_from_table(init_table, clks, clk_max);
1326+
tegra_clk_apply_init_table = tegra20_clock_apply_init_table;
13221327

13231328
tegra_cpu_car_ops = &tegra20_cpu_car_ops;
13241329
}

‎drivers/clk/tegra/clk-tegra30.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,11 @@ static __initdata struct tegra_clk_init_table init_table[] = {
19161916
{clk_max, clk_max, 0, 0}, /* This MUST be the last entry. */
19171917
};
19181918

1919+
static void __init tegra30_clock_apply_init_table(void)
1920+
{
1921+
tegra_init_from_table(init_table, clks, clk_max);
1922+
}
1923+
19191924
/*
19201925
* Some clocks may be used by different drivers depending on the board
19211926
* configuration. List those here to register them twice in the clock lookup
@@ -1989,7 +1994,7 @@ void __init tegra30_clock_init(struct device_node *np)
19891994
clk_data.clk_num = ARRAY_SIZE(clks);
19901995
of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
19911996

1992-
tegra_init_from_table(init_table, clks, clk_max);
1997+
tegra_clk_apply_init_table = tegra30_clock_apply_init_table;
19931998

19941999
tegra_cpu_car_ops = &tegra30_cpu_car_ops;
19952000
}

‎drivers/clk/tegra/clk.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,13 @@ void __init tegra_clocks_init(void)
8383
{
8484
of_clk_init(tegra_dt_clk_match);
8585
}
86+
87+
tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
88+
89+
void __init tegra_clocks_apply_init_table(void)
90+
{
91+
if (!tegra_clk_apply_init_table)
92+
return;
93+
94+
tegra_clk_apply_init_table();
95+
}

‎drivers/clk/tegra/clk.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,7 @@ void tegra30_clock_init(struct device_node *np);
510510
static inline void tegra30_clock_init(struct device_node *np) {}
511511
#endif /* CONFIG_ARCH_TEGRA_3x_SOC */
512512

513+
typedef void (*tegra_clk_apply_init_table_func)(void);
514+
extern tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
515+
513516
#endif /* TEGRA_CLK_H */

‎include/linux/clk/tegra.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,6 @@ static inline void tegra_cpu_clock_resume(void)
123123
void tegra_periph_reset_deassert(struct clk *c);
124124
void tegra_periph_reset_assert(struct clk *c);
125125
void tegra_clocks_init(void);
126+
void tegra_clocks_apply_init_table(void);
126127

127128
#endif /* __LINUX_CLK_TEGRA_H_ */

0 commit comments

Comments
 (0)