mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-25 04:23:46 +00:00
401d1c4f5d
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
64 lines
1.1 KiB
C
64 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2012-2014
|
|
* Texas Instruments Incorporated, <www.ti.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <init.h>
|
|
#include <time.h>
|
|
#include <asm/global_data.h>
|
|
#include <asm/io.h>
|
|
#include <div64.h>
|
|
#include <bootstage.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
#ifndef CONFIG_SYS_HZ_CLOCK
|
|
static inline u32 read_cntfrq(void)
|
|
{
|
|
u32 frq;
|
|
|
|
asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
|
|
return frq;
|
|
}
|
|
#endif
|
|
|
|
int timer_init(void)
|
|
{
|
|
gd->arch.tbl = 0;
|
|
gd->arch.tbu = 0;
|
|
|
|
#ifdef CONFIG_SYS_HZ_CLOCK
|
|
gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK;
|
|
#else
|
|
gd->arch.timer_rate_hz = read_cntfrq();
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
unsigned long long get_ticks(void)
|
|
{
|
|
ulong nowl, nowu;
|
|
|
|
asm volatile("mrrc p15, 0, %0, %1, c14" : "=r" (nowl), "=r" (nowu));
|
|
|
|
gd->arch.tbl = nowl;
|
|
gd->arch.tbu = nowu;
|
|
|
|
return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
|
|
}
|
|
|
|
|
|
ulong timer_get_boot_us(void)
|
|
{
|
|
if (!gd->arch.timer_rate_hz)
|
|
timer_init();
|
|
|
|
return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000);
|
|
}
|
|
|
|
ulong get_tbclk(void)
|
|
{
|
|
return gd->arch.timer_rate_hz;
|
|
}
|