1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2012-2014
4 * Texas Instruments Incorporated, <www.ti.com>
10 #include <bootstage.h>
12 DECLARE_GLOBAL_DATA_PTR;
14 #ifndef CONFIG_SYS_HZ_CLOCK
15 static inline u32 read_cntfrq(void)
19 asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
29 #ifdef CONFIG_SYS_HZ_CLOCK
30 gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK;
32 gd->arch.timer_rate_hz = read_cntfrq();
37 unsigned long long get_ticks(void)
41 asm volatile("mrrc p15, 0, %0, %1, c14" : "=r" (nowl), "=r" (nowu));
46 return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
50 ulong timer_get_boot_us(void)
52 if (!gd->arch.timer_rate_hz)
55 return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000);
60 return gd->arch.timer_rate_hz;