1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2012-2014
4 * Texas Instruments Incorporated, <www.ti.com>
12 #include <bootstage.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 #ifndef CONFIG_SYS_HZ_CLOCK
17 static inline u32 read_cntfrq(void)
21 asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
31 #ifdef CONFIG_SYS_HZ_CLOCK
32 gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK;
34 gd->arch.timer_rate_hz = read_cntfrq();
39 unsigned long long get_ticks(void)
43 asm volatile("mrrc p15, 0, %0, %1, c14" : "=r" (nowl), "=r" (nowu));
48 return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
52 ulong timer_get_boot_us(void)
54 if (!gd->arch.timer_rate_hz)
57 return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000);
62 return gd->arch.timer_rate_hz;