2 * (C) Copyright 2012-2014
3 * Texas Instruments Incorporated, <www.ti.com>
5 * SPDX-License-Identifier: GPL-2.0+
12 DECLARE_GLOBAL_DATA_PTR;
19 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 void __udelay(unsigned long usec)
44 unsigned long long endtime;
46 endtime = lldiv((unsigned long long)usec * gd->arch.timer_rate_hz,
49 endtime += get_ticks();
51 while (get_ticks() < endtime)
57 return gd->arch.timer_rate_hz;