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;
20 gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ;
24 unsigned long long get_ticks(void)
28 asm volatile("mrrc p15, 0, %0, %1, c14" : "=r" (nowl), "=r" (nowu));
33 return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
37 ulong get_timer(ulong base)
39 return lldiv(get_ticks(), gd->arch.timer_rate_hz) - base;
42 ulong timer_get_boot_us(void)
44 return lldiv(get_ticks(), CONFIG_SYS_HZ_CLOCK / (CONFIG_SYS_HZ * 1000));
47 void __udelay(unsigned long usec)
49 unsigned long long endtime;
51 endtime = lldiv((unsigned long long)usec * gd->arch.timer_rate_hz,
54 endtime += get_ticks();
56 while (get_ticks() < endtime)
62 return gd->arch.timer_rate_hz;