From 46864cc8e82ade3523f4c474b7451bb960e4ad70 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 31 May 2017 17:57:16 -0600 Subject: [PATCH] tegra: Init clocks even when SPL did not run At present early clock init happens in SPL. If SPL did not run (because for example U-Boot is chain-loaded from another boot loader) then the clocks are not set as U-Boot expects. Add a function to detect this and call the early clock init in U-Boot proper. Signed-off-by: Simon Glass --- arch/arm/include/asm/arch-tegra/clock.h | 3 +++ arch/arm/mach-tegra/board2.c | 3 +++ arch/arm/mach-tegra/clock.c | 5 +++++ arch/arm/mach-tegra/tegra124/clock.c | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/arch/arm/include/asm/arch-tegra/clock.h b/arch/arm/include/asm/arch-tegra/clock.h index 388afcb723..f62b2a4378 100644 --- a/arch/arm/include/asm/arch-tegra/clock.h +++ b/arch/arm/include/asm/arch-tegra/clock.h @@ -288,6 +288,9 @@ void clock_init(void); /* Initialize the PLLs */ void clock_early_init(void); +/* @return true if hardware indicates that clock_early_init() was called */ +bool clock_early_init_done(void); + /* Returns a pointer to the clock source register for a peripheral */ u32 *get_periph_source_reg(enum periph_id periph_id); diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c index 84f1ee5035..1e627ba603 100644 --- a/arch/arm/mach-tegra/board2.c +++ b/arch/arm/mach-tegra/board2.c @@ -191,6 +191,9 @@ void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init"))); int board_early_init_f(void) { + if (!clock_early_init_done()) + clock_early_init(); + #if defined(CONFIG_TEGRA_DISCONNECT_UDC_ON_BOOT) #define USBCMD_FS2 (1 << 15) { diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c index 3bb72331a4..76436d8d91 100644 --- a/arch/arm/mach-tegra/clock.c +++ b/arch/arm/mach-tegra/clock.c @@ -825,3 +825,8 @@ int clock_external_output(int clk_id) return 0; } + +__weak bool clock_early_init_done(void) +{ + return true; +} diff --git a/arch/arm/mach-tegra/tegra124/clock.c b/arch/arm/mach-tegra/tegra124/clock.c index 5e4406102f..5ae718b342 100644 --- a/arch/arm/mach-tegra/tegra124/clock.c +++ b/arch/arm/mach-tegra/tegra124/clock.c @@ -891,6 +891,24 @@ void clock_early_init(void) udelay(2); } +/* + * clock_early_init_done - Check if clock_early_init() has been called + * + * Check a register that we set up to see if clock_early_init() has already + * been called. + * + * @return true if clock_early_init() was called, false if not + */ +bool clock_early_init_done(void) +{ + struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE; + u32 val; + + val = readl(&clkrst->crc_sclk_brst_pol); + + return val == 0x20002222; +} + void arch_timer_init(void) { struct sysctr_ctlr *sysctr = (struct sysctr_ctlr *)NV_PA_TSC_BASE;