timer: Reestablish init_timer(), consolidate timer initialization calls
We have known for a while that the old x86 model of calling init_timer() in ramstage doesn't make sense on other archs (and is questionable in general), and finally removed it with CL:219719. However, now timer initialization is completely buried in the platform code, and it's hard to ensure it is done in time to set up timestamps. For three out of four non-x86 SoC vendors we have brought up for now, the timers need some kind of SoC-specific initialization. This patch reintroduces init_timer() as a weak function that can be overridden by platform code. The call in ramstage is restricted to x86 (and should probably eventually be removed from there as well), and other archs should call them at the earliest reasonable point in their bootblock. (Only changing arm for now since arm64 and mips bootblocks are still in very early state and should sync up to features in arm once their requirements are better understood.) This allows us to move timestamp_init() into arch code, so that we can rely on timestamps being available at a well-defined point and initialize our base value as early as possible. (Platforms who know that their timers start at zero can still safely call timestamp_init(0) again from platform code.) BRANCH=None BUG=None TEST=Booted Pinky, Blaze and Storm, compiled Daisy and Pit. Change-Id: I1b064ba3831c0c5b7965b1d88a6f4a590789c891 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: ffaebcd3785c4ce998ac1536e9fdd46ce3f52bfa Original-Change-Id: Iece1614b7442d4fa9ca981010e1c8497bdea308d Original-Signed-off-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/234062 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/9606 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
efcee767de
commit
44cf870cb0
|
@ -24,7 +24,9 @@
|
||||||
#include <bootblock_common.h>
|
#include <bootblock_common.h>
|
||||||
#include <cbfs.h>
|
#include <cbfs.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
|
#include <delay.h>
|
||||||
#include <program_loading.h>
|
#include <program_loading.h>
|
||||||
|
#include <timestamp.h>
|
||||||
|
|
||||||
__attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ }
|
__attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ }
|
||||||
__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ }
|
__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ }
|
||||||
|
@ -32,6 +34,10 @@ __attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ }
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
init_timer();
|
||||||
|
if (IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION))
|
||||||
|
timestamp_init(timestamp_get());
|
||||||
|
|
||||||
bootblock_mainboard_early_init();
|
bootblock_mainboard_early_init();
|
||||||
|
|
||||||
if (CONFIG_BOOTBLOCK_CONSOLE) {
|
if (CONFIG_BOOTBLOCK_CONSOLE) {
|
||||||
|
|
|
@ -24,8 +24,10 @@
|
||||||
#include <bootblock_common.h>
|
#include <bootblock_common.h>
|
||||||
#include <cbfs.h>
|
#include <cbfs.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
|
#include <delay.h>
|
||||||
#include <program_loading.h>
|
#include <program_loading.h>
|
||||||
#include <smp/node.h>
|
#include <smp/node.h>
|
||||||
|
#include <timestamp.h>
|
||||||
|
|
||||||
__attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ }
|
__attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ }
|
||||||
__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ }
|
__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ }
|
||||||
|
@ -33,6 +35,10 @@ __attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ }
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
init_timer();
|
||||||
|
if (IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION))
|
||||||
|
timestamp_init(timestamp_get());
|
||||||
|
|
||||||
bootblock_mainboard_early_init();
|
bootblock_mainboard_early_init();
|
||||||
|
|
||||||
#if CONFIG_BOOTBLOCK_CONSOLE
|
#if CONFIG_BOOTBLOCK_CONSOLE
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#ifndef DELAY_H
|
#ifndef DELAY_H
|
||||||
#define DELAY_H
|
#define DELAY_H
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_GENERIC_UDELAY)
|
|
||||||
static inline void init_timer(void) {}
|
|
||||||
#else
|
|
||||||
void init_timer(void);
|
void init_timer(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
void udelay(unsigned usecs);
|
void udelay(unsigned usecs);
|
||||||
void mdelay(unsigned msecs);
|
void mdelay(unsigned msecs);
|
||||||
|
|
|
@ -464,8 +464,9 @@ void main(void)
|
||||||
/* Schedule the static boot state entries. */
|
/* Schedule the static boot state entries. */
|
||||||
boot_state_schedule_static_entries();
|
boot_state_schedule_static_entries();
|
||||||
|
|
||||||
/* FIXME: Is there a better way to handle this? */
|
/* TODO: Understand why this is here and move to arch/platform code. */
|
||||||
init_timer();
|
if (IS_ENABLED(CONFIG_ARCH_X86))
|
||||||
|
init_timer();
|
||||||
|
|
||||||
bs_walk_state_machine();
|
bs_walk_state_machine();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include <delay.h>
|
#include <delay.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
|
|
||||||
|
__attribute__((weak)) void init_timer() { /* do nothing */ }
|
||||||
|
|
||||||
void udelay(unsigned usec)
|
void udelay(unsigned usec)
|
||||||
{
|
{
|
||||||
struct stopwatch sw;
|
struct stopwatch sw;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
##
|
##
|
||||||
|
|
||||||
bootblock-y += bootblock.c
|
|
||||||
bootblock-y += cdp.c
|
bootblock-y += cdp.c
|
||||||
bootblock-y += reset.c
|
bootblock-y += reset.c
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the coreboot project.
|
|
||||||
*
|
|
||||||
* Copyright 2014 Google Inc.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <bootblock_common.h>
|
|
||||||
#include <delay.h>
|
|
||||||
|
|
||||||
void bootblock_mainboard_early_init(void)
|
|
||||||
{
|
|
||||||
init_timer();
|
|
||||||
}
|
|
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
static void bootblock_soc_init(void)
|
static void bootblock_soc_init(void)
|
||||||
{
|
{
|
||||||
rk3288_init_timer();
|
|
||||||
|
|
||||||
rkclk_init();
|
rkclk_init();
|
||||||
|
|
||||||
mmu_init();
|
mmu_init();
|
||||||
|
|
|
@ -40,6 +40,4 @@ static struct rk3288_timer * const timer7_ptr = (void *)TIMER7_BASE;
|
||||||
|
|
||||||
#define TIMER_LOAD_VAL 0xffffffff
|
#define TIMER_LOAD_VAL 0xffffffff
|
||||||
|
|
||||||
void rk3288_init_timer(void);
|
|
||||||
|
|
||||||
#endif /* __SOC_ROCKCHIP_RK3288_TIMER_H__ */
|
#endif /* __SOC_ROCKCHIP_RK3288_TIMER_H__ */
|
||||||
|
|
|
@ -39,7 +39,7 @@ void timer_monotonic_get(struct mono_time *mt)
|
||||||
mono_time_set_usecs(mt, timer_raw_value() / clocks_per_usec);
|
mono_time_set_usecs(mt, timer_raw_value() / clocks_per_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rk3288_init_timer(void)
|
void init_timer(void)
|
||||||
{
|
{
|
||||||
write32(TIMER_LOAD_VAL, &timer7_ptr->timer_load_count0);
|
write32(TIMER_LOAD_VAL, &timer7_ptr->timer_load_count0);
|
||||||
write32(TIMER_LOAD_VAL, &timer7_ptr->timer_load_count1);
|
write32(TIMER_LOAD_VAL, &timer7_ptr->timer_load_count1);
|
||||||
|
|
|
@ -23,11 +23,6 @@
|
||||||
|
|
||||||
void bootblock_soc_init(void)
|
void bootblock_soc_init(void)
|
||||||
{
|
{
|
||||||
/* kick off the multi-core timer.
|
|
||||||
* We want to do this as early as we can.
|
|
||||||
*/
|
|
||||||
mct_start();
|
|
||||||
|
|
||||||
if (get_wakeup_state() == WAKEUP_DIRECT) {
|
if (get_wakeup_state() == WAKEUP_DIRECT) {
|
||||||
wakeup();
|
wakeup();
|
||||||
/* Never returns. */
|
/* Never returns. */
|
||||||
|
|
|
@ -589,9 +589,6 @@ int clock_set_rate(enum periph_id periph_id, unsigned int rate);
|
||||||
/* Clock gate unused IP */
|
/* Clock gate unused IP */
|
||||||
void clock_gate(void);
|
void clock_gate(void);
|
||||||
|
|
||||||
void mct_start(void);
|
|
||||||
uint64_t mct_raw_value(void);
|
|
||||||
|
|
||||||
/* These are the ratio's for configuring ARM clock */
|
/* These are the ratio's for configuring ARM clock */
|
||||||
struct arm_clk_ratios {
|
struct arm_clk_ratios {
|
||||||
unsigned int arm_freq_mhz; /* Frequency of ARM core in MHz */
|
unsigned int arm_freq_mhz; /* Frequency of ARM core in MHz */
|
||||||
|
|
|
@ -18,13 +18,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
|
#include <delay.h>
|
||||||
#include <soc/clk.h>
|
#include <soc/clk.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
|
|
||||||
static const uint32_t clocks_per_usec = MCT_HZ/1000000;
|
static const uint32_t clocks_per_usec = MCT_HZ/1000000;
|
||||||
|
|
||||||
uint64_t mct_raw_value(void)
|
static uint64_t mct_raw_value(void)
|
||||||
{
|
{
|
||||||
uint64_t upper = readl(&exynos_mct->g_cnt_u);
|
uint64_t upper = readl(&exynos_mct->g_cnt_u);
|
||||||
uint64_t lower = readl(&exynos_mct->g_cnt_l);
|
uint64_t lower = readl(&exynos_mct->g_cnt_l);
|
||||||
|
@ -32,7 +33,7 @@ uint64_t mct_raw_value(void)
|
||||||
return (upper << 32) | lower;
|
return (upper << 32) | lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mct_start(void)
|
void init_timer(void)
|
||||||
{
|
{
|
||||||
writel(readl(&exynos_mct->g_tcon) | (0x1 << 8),
|
writel(readl(&exynos_mct->g_tcon) | (0x1 << 8),
|
||||||
&exynos_mct->g_tcon);
|
&exynos_mct->g_tcon);
|
||||||
|
|
|
@ -30,11 +30,6 @@
|
||||||
|
|
||||||
void bootblock_soc_init(void)
|
void bootblock_soc_init(void)
|
||||||
{
|
{
|
||||||
/* kick off the multi-core timer.
|
|
||||||
* We want to do this as early as we can.
|
|
||||||
*/
|
|
||||||
mct_start();
|
|
||||||
|
|
||||||
if (get_wakeup_state() == WAKEUP_DIRECT) {
|
if (get_wakeup_state() == WAKEUP_DIRECT) {
|
||||||
wakeup();
|
wakeup();
|
||||||
/* Never returns. */
|
/* Never returns. */
|
||||||
|
|
|
@ -725,9 +725,6 @@ int clock_set_rate(enum periph_id periph_id, unsigned int rate);
|
||||||
/* Clock gate unused IP */
|
/* Clock gate unused IP */
|
||||||
void clock_gate(void);
|
void clock_gate(void);
|
||||||
|
|
||||||
void mct_start(void);
|
|
||||||
uint64_t mct_raw_value(void);
|
|
||||||
|
|
||||||
/* These are the ratio's for configuring ARM clock */
|
/* These are the ratio's for configuring ARM clock */
|
||||||
struct arm_clk_ratios {
|
struct arm_clk_ratios {
|
||||||
unsigned int arm_freq_mhz; /* Frequency of ARM core in MHz */
|
unsigned int arm_freq_mhz; /* Frequency of ARM core in MHz */
|
||||||
|
|
|
@ -18,13 +18,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
|
#include <delay.h>
|
||||||
#include <soc/clk.h>
|
#include <soc/clk.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
|
|
||||||
static const uint32_t clocks_per_usec = MCT_HZ/1000000;
|
static const uint32_t clocks_per_usec = MCT_HZ/1000000;
|
||||||
|
|
||||||
uint64_t mct_raw_value(void)
|
static uint64_t mct_raw_value(void)
|
||||||
{
|
{
|
||||||
uint64_t upper = readl(&exynos_mct->g_cnt_u);
|
uint64_t upper = readl(&exynos_mct->g_cnt_u);
|
||||||
uint64_t lower = readl(&exynos_mct->g_cnt_l);
|
uint64_t lower = readl(&exynos_mct->g_cnt_l);
|
||||||
|
@ -32,7 +33,7 @@ uint64_t mct_raw_value(void)
|
||||||
return (upper << 32) | lower;
|
return (upper << 32) | lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mct_start(void)
|
void init_timer(void)
|
||||||
{
|
{
|
||||||
writel(readl(&exynos_mct->g_tcon) | (0x1 << 8),
|
writel(readl(&exynos_mct->g_tcon) | (0x1 << 8),
|
||||||
&exynos_mct->g_tcon);
|
&exynos_mct->g_tcon);
|
||||||
|
|
Loading…
Reference in New Issue