2 * (C) Copyright 2012-2014
3 * Texas Instruments Incorporated, <www.ti.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <bootstage.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 #ifndef CONFIG_SYS_HZ_CLOCK
16 static inline u32 read_cntfrq(void)
20 asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
30 #ifdef CONFIG_SYS_HZ_CLOCK
31 gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK;
33 gd->arch.timer_rate_hz = read_cntfrq();
38 unsigned long long get_ticks(void)
42 asm volatile("mrrc p15, 0, %0, %1, c14" : "=r" (nowl), "=r" (nowu));
47 return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
51 ulong timer_get_boot_us(void)
53 return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000);
58 return gd->arch.timer_rate_hz;